AddingTrackRecord.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.HospitalTrackingSystem
  10. {
  11. public partial class AddingTrackRecord : LYFZ.Software.UI.HospitalTrackingSystem.AddingTrackRecord
  12. {
  13. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  14. LYFZ.BLL.BLL_ErpClientServiceTask cstbll = new BLL.BLL_ErpClientServiceTask();
  15. LYFZ.BLL.BLL_ErpHospitalContactRecord ambll = new BLL.BLL_ErpHospitalContactRecord();
  16. public AddingTrackRecord()
  17. {
  18. this.bntClose.Click += bntClose_Click;
  19. this.bntSave.Click += bntSave_Click;
  20. this.txtCallTime.KeyPress += txtCallTime_KeyPress;
  21. this.Load += AddingTrackRecord_Load;
  22. this.btnDial.Click += btnDial_Click;
  23. this.buttonForm2.Click += buttonForm2_Click;
  24. this.cmbConcreteMatter.SelectedIndexChanged += cmbConcreteMatter_SelectedIndexChanged;
  25. #region 上传沟通记录相关相片;
  26. this.btn_AddFiles.Click += Btn_AddFiles_Click;
  27. this.listbox_files.DoubleClick += Listbox_files_DoubleClick;
  28. this.btn_Getfiles.Click += Btn_Getfiles_Click;
  29. #endregion
  30. }
  31. #region 上传沟通记录相关相片;
  32. private void GetFiles()
  33. {
  34. if (this.listbox_files.SelectedItem != null)
  35. {
  36. BLL.OssCloudDiskSDK.UploadOssCloudDisk uploadOss = new BLL.OssCloudDiskSDK.UploadOssCloudDisk();
  37. BLL.OssCloudDiskSDK.OSSUpdateReturnData retData = uploadOss.DownloadFile(this.listbox_files.SelectedItem.ToString());
  38. if (retData.State)
  39. {
  40. try
  41. {
  42. // 创建新的进程;
  43. System.Diagnostics.Process pro = new System.Diagnostics.Process();
  44. // 设置要打开的文件名;
  45. pro.StartInfo.FileName = retData.FileLocalFullPath;
  46. // 打开;
  47. pro.Start();
  48. }
  49. catch (Exception ex)
  50. {
  51. if (DialogResult.Yes == MessageBoxCustom.Show(ex.Message + "\n 文件是否另存为", "出错提示", MessageBoxButtons.YesNo))
  52. {
  53. SaveFileDialog savedlg = new SaveFileDialog();
  54. savedlg.Filter = "所有文件(*.*)|*.*";
  55. savedlg.Title = "另存为";
  56. savedlg.FileName = retData.FileLocalFullPath.Substring(retData.FileLocalFullPath.LastIndexOf('\\') + 1);
  57. if (savedlg.ShowDialog() == DialogResult.OK)
  58. {
  59. System.IO.File.Copy(retData.FileLocalFullPath, savedlg.FileName, true);
  60. }
  61. }
  62. }
  63. }
  64. else
  65. {
  66. MessageBoxCustom.Show("下载文件失败\n" + retData.Description);
  67. }
  68. }
  69. }
  70. /// <summary>
  71. /// 查看或下载相片;
  72. /// </summary>
  73. /// <param name="sender"></param>
  74. /// <param name="e"></param>
  75. private void Btn_Getfiles_Click(object sender, EventArgs e)
  76. {
  77. GetFiles();
  78. }
  79. /// <summary>
  80. /// 双击listbox时, 从中移除选中项;
  81. /// </summary>
  82. /// <param name="sender"></param>
  83. /// <param name="e"></param>
  84. private void Listbox_files_DoubleClick(object sender, EventArgs e)
  85. {
  86. if (!string.IsNullOrEmpty(StrOrderNumber))
  87. {
  88. GetFiles();
  89. return;
  90. }
  91. if ( this.listbox_files.SelectedItems.Count > 0 )
  92. {
  93. this.listbox_files.Items.Remove(this.listbox_files.SelectedItem.ToString());
  94. }
  95. }
  96. /// <summary>
  97. /// 添加文件按钮;
  98. /// </summary>
  99. /// <param name="sender"></param>
  100. /// <param name="e"></param>
  101. private void Btn_AddFiles_Click(object sender, EventArgs e)
  102. {
  103. OpenFileDialog dialog = new OpenFileDialog();
  104. dialog.Multiselect = true;//该值确定是否可以选择多个文件
  105. dialog.Title = "请选择文件夹";
  106. dialog.Filter = "所有文件(*.*)|*.*";
  107. if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  108. {
  109. foreach ( string file in dialog.FileNames )
  110. {
  111. if (this.listbox_files.Items.Contains(file))
  112. continue;
  113. this.listbox_files.Items.Add(file);
  114. }
  115. }
  116. }
  117. #endregion
  118. /// <summary>
  119. /// 是否保存
  120. /// </summary>
  121. public bool IsSaveed = false;
  122. /// <summary>
  123. /// 订单编号
  124. /// </summary>
  125. public string StrOrderNumber = "";
  126. /// <summary>
  127. /// 联系记录编号
  128. /// </summary>
  129. public string StrOrderRecordID = "";
  130. /// <summary>
  131. /// 订单派单ID
  132. /// </summary>
  133. public int intDispatchDoorID = 0;
  134. /// <summary>
  135. /// 是否显示下次提醒时间设置
  136. /// </summary>
  137. public bool IsShowDatimeRemind = true;
  138. /// <summary>
  139. /// 是否要打开选择派单界面
  140. /// </summary>
  141. public bool IsGoForm = true;
  142. /// <summary>
  143. /// 任务完成时间
  144. /// </summary>
  145. public string StrClientServiceDateTime = "";
  146. /// <summary>
  147. /// 任务完成说明
  148. /// </summary>
  149. public string StrCompletionRemark = "";
  150. string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  151. /// <summary>
  152. /// 窗体加载
  153. /// </summary>
  154. /// <param name="sender"></param>
  155. /// <param name="e"></param>
  156. void AddingTrackRecord_Load(object sender, EventArgs e)
  157. {
  158. // 查看时,不显示添加附件按钮;
  159. this.btn_AddFiles.Visible = string.IsNullOrEmpty(this.StrOrderRecordID);
  160. // 添加时,不显示查看附件按钮;
  161. this.btn_Getfiles.Visible = !string.IsNullOrEmpty(this.StrOrderRecordID);
  162. this.bntSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.AddCommunicateRecord);
  163. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtPhone);
  164. this.datimeCallDate.DateValue = SDateTime.Now.ToString("yyyy-MM-dd");
  165. if (!string.IsNullOrEmpty(this.StrOrderNumber))
  166. {
  167. DataTable dt = orbll.GetView_Custom("View_HospitalContact", StrWhere: "来单批号='" + this.StrOrderNumber + "'", ShowColumnName: "客户姓名,本人手机").Tables[0];
  168. this.txtName.Text = dt.Rows[0]["客户姓名"].ToString();
  169. this.txtPhone.Text = dt.Rows[0]["本人手机"].ToString();
  170. }
  171. if (!string.IsNullOrEmpty(this.StrOrderRecordID))
  172. {
  173. this.panelEx2.Visible = false;
  174. DataTable dts = orbll.GetView_Custom("tb_ErpHospitalContactRecord", StrWhere: "ID='" + this.StrOrderRecordID + "'", ShowColumnName: "Hcr_CallTime,Hcr_CallDuration,Hcr_CallType,Hcr_Homeaddress,Hcr_CallStaff,Hcr_CallCases,Hcr_CallMode,Hcr_RemindTime,Hcr_Remarks,Hcr_TrackImages").Tables[0];
  175. this.datimeCallDate.DateValue = dts.Rows[0]["Hcr_CallTime"].ToString().Trim();
  176. this.txtCallTime.Text = dts.Rows[0]["Hcr_CallDuration"].ToString().Trim();
  177. this.cmbCallType.Text = dts.Rows[0]["Hcr_CallType"].ToString().Trim();
  178. this.cmbConcreteMatter.Text = dts.Rows[0]["Hcr_Homeaddress"].ToString().Trim();
  179. this.cbxCallMode.Text = dts.Rows[0]["Hcr_CallMode"].ToString().Trim();
  180. this.txtRemark.Text = dts.Rows[0]["Hcr_Remarks"].ToString().Trim();
  181. this.datimeRemind.DateValue = dts.Rows[0]["Hcr_RemindTime"].ToString().Trim();
  182. if (dts.Rows[0]["Hcr_Homeaddress"].ToString().Trim() == "预约上门")
  183. {
  184. this.IsShowDatimeRemind = false;
  185. }
  186. // 在listbox中显示key值;
  187. string[] strKeys = dts.Rows[0]["Hcr_TrackImages"].ToString().Split('|');
  188. foreach ( string item in strKeys )
  189. {
  190. this.listbox_files.Items.Add(item);
  191. }
  192. }
  193. else
  194. {
  195. this.cmbCallType.SelectedIndex = 0;
  196. }
  197. if (intDispatchDoorID > 0)
  198. {
  199. this.cmbConcreteMatter.Text = "预约上门";
  200. this.cmbConcreteMatter.Enabled = false;
  201. }
  202. this.cmbCallType.Enabled = false;
  203. this.datimeRemind.Visible = this.IsShowDatimeRemind;
  204. this.labelEx11.Visible = this.IsShowDatimeRemind;
  205. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAE", this.cbxCallMode);
  206. }
  207. /// <summary>
  208. /// 通话时长只能为数字
  209. /// </summary>
  210. /// <param name="sender"></param>
  211. /// <param name="e"></param>
  212. void txtCallTime_KeyPress(object sender, KeyPressEventArgs e)
  213. {
  214. if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar))
  215. {
  216. e.Handled = true;
  217. }
  218. }
  219. /// <summary>
  220. /// 保存按钮
  221. /// </summary>
  222. /// <param name="sender"></param>
  223. /// <param name="e"></param>
  224. void bntSave_Click(object sender, EventArgs e)
  225. {
  226. DateTime strTime = SDateTime.Now;
  227. Model.Model_ErpHospitalContactRecord model = null;
  228. if (this.datimeCallDate.DateValue.Trim() == "")
  229. { MessageBoxCustom.Show("请选择通话时间!"); return; }
  230. if (this.cmbCallType.Text.Trim() == "")
  231. { MessageBoxCustom.Show("请选择通话类型!"); return; }
  232. if (this.cmbConcreteMatter.Text.Trim() == "")
  233. { MessageBoxCustom.Show("请选择具体事项"); return; }
  234. if (this.txtCallTime.Text.Trim() == "")
  235. { MessageBoxCustom.Show("通话时长只能为数字,如果是空可以输入0"); return; }
  236. string StrWhere = "";
  237. if (this.cmbConcreteMatter.Text.Trim().Equals("预约上门"))
  238. { StrWhere = "Cst_TaskModule = '" + LYFZ.EnumPublic.ClientServiceTaskType.摄控确认 + "' And Cst_TaskItem = '" + LYFZ.EnumPublic.ClientServiceTaskItem.摄控医院客人 + "'"; }
  239. else
  240. { StrWhere = "Cst_TaskModule = '" + LYFZ.EnumPublic.ClientServiceTaskType.意向跟踪 + "' And Cst_TaskItem = '" + LYFZ.EnumPublic.ClientServiceTaskItem.医院意向 + "'"; }
  241. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  242. string strTaskNumber = "";
  243. DataTable dt = orbll.GetView_Custom("tb_ErpClientServiceTask", StrWhere: StrWhere, ShowColumnName: "*", filedOrder: "Cst_TaskTermTime ASC", TopCount: 1).Tables[0];
  244. if (dt.Rows.Count > 0)
  245. {
  246. LYFZ.Model.Model_ErpClientServiceTask modelCstask = cstbll.DataRowToModel(dt.Rows[0]);
  247. modelCstask.Cst_CompletionIntStatus = 1;
  248. modelCstask.Cst_CompletionStatus = "OK";
  249. modelCstask.Cst_CompletionTime = strTime;
  250. modelCstask.Cst_CompletionPerson = this.strUserID;
  251. modelCstask.Cst_CompletionRemark = this.txtRemark.Text.Trim();
  252. modelCstask.Cst_UpdateDateTime = strTime;
  253. modelCstask.Cst_UpdateName = this.strUserID;
  254. clist.Add(cstbll.GetUpdateCommandInfo(modelCstask));
  255. strTaskNumber = modelCstask.Cst_Number;
  256. }
  257. model = new Model.Model_ErpHospitalContactRecord();
  258. model.Hcr_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  259. model.Hcr_Number = this.StrOrderNumber;
  260. model.Hcr_TaskNumber = strTaskNumber;
  261. model.Hcr_CallTime = Convert.ToDateTime(this.datimeCallDate.DateValue.Trim());
  262. model.Hcr_CallDuration = Convert.ToInt32(this.txtCallTime.Text.Trim());
  263. model.Hcr_CallType = this.cmbCallType.Text.Trim().ToString();
  264. model.Hcr_Homeaddress = this.cmbConcreteMatter.Text.Trim().ToString().Trim();
  265. model.Hcr_CallStaff = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
  266. model.Hcr_Remarks = this.txtRemark.Text.Trim().ToString().Trim();
  267. model.Hcr_CallMode = this.cbxCallMode.Text.Trim().ToString().Trim();
  268. model.Hcr_DispatchDoorID = this.intDispatchDoorID;
  269. model.Hcr_CreateDatetime = strTime;
  270. model.Hcr_CreateName = strUserID;
  271. if (string.IsNullOrEmpty(this.datimeRemind.DateValue.Trim()))
  272. {
  273. model.Hcr_RemindTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
  274. }
  275. else
  276. {
  277. model.Hcr_RemindTime = Convert.ToDateTime(this.datimeRemind.DateValue.Trim());
  278. }
  279. if (this.listbox_files.Items.Count > 0)
  280. {
  281. // 附件数理;
  282. int nAnnexCount = 0;
  283. string strResult = "";
  284. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  285. {
  286. backgroundWorker.ReportProgress(0, "正在上传......");
  287. foreach (string item in this.listbox_files.Items)
  288. {
  289. BLL.OssCloudDiskSDK.UploadOssCloudDisk uploadOss = new BLL.OssCloudDiskSDK.UploadOssCloudDisk();
  290. BLL.OssCloudDiskSDK.OSSUpdateReturnData retData = uploadOss.UpLoadFile(item);
  291. if (retData.State == true)
  292. {
  293. // 组串更新语句;
  294. nAnnexCount++;
  295. System.Diagnostics.Debug.Write("key=" + retData.OssFileKey + "\n");
  296. model.Hcr_TrackImages += retData.OssFileKey + "|";
  297. }
  298. else
  299. {
  300. strResult += item + " " + retData.Description + "\n";
  301. }
  302. }
  303. });
  304. if (nAnnexCount != this.listbox_files.Items.Count)
  305. {
  306. MessageBoxCustom.Show("文件上传失败!\n"+ strResult);
  307. return;
  308. }
  309. model.Hcr_TrackImages = model.Hcr_TrackImages.Trim('|');
  310. }
  311. clist.Add(ambll.GetAddCommandInfo(model));
  312. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  313. {
  314. this.IsSaveed = true;
  315. this.StrClientServiceDateTime = this.datimeCallDate.DateValue.Trim();
  316. this.StrCompletionRemark = this.txtRemark.Text.Trim();
  317. MessageBoxCustom.Show("保存成功");
  318. #if IGNORE
  319. if ( DialogResult.Yes == MessageBoxCustom.Show("保存成功,是否上传相片?", "提示消息!",MessageBoxButtons.YesNo) )
  320. {
  321. OpenFileDialog dialog = new OpenFileDialog();
  322. dialog.Multiselect = true;//该值确定是否可以选择多个文件
  323. dialog.Title = "请选择文件夹";
  324. dialog.Filter = "所有文件(*.*)|*.*";
  325. if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  326. {
  327. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  328. {
  329. backgroundWorker.ReportProgress(0, "正在上传......");
  330. string strKey = "";
  331. string strFile = "";
  332. foreach (string myfile in dialog.FileNames)
  333. {
  334. System.Diagnostics.Debug.Write("文件名:" + myfile + "\n");
  335. BLL.OssCloudDiskSDK.UploadOssCloudDisk uploadOss = new BLL.OssCloudDiskSDK.UploadOssCloudDisk();
  336. BLL.OssCloudDiskSDK.OSSUpdateReturnData retData = uploadOss.UpLoadFile(myfile);
  337. if ( retData.State == true )
  338. {
  339. // 组串更新语句;
  340. System.Diagnostics.Debug.Write("key=" + retData.OssFileKey + "\n");
  341. strKey += retData.OssFileKey + "|";
  342. }
  343. else
  344. {
  345. // 保存上传失败的文件, 结束后提示;
  346. strFile += myfile + "|";
  347. }
  348. }
  349. // 更新;
  350. model.Hcr_TrackImages = strKey.Trim('|');
  351. clist.Clear();
  352. clist.Add(ambll.GetAddCommandInfo(model));
  353. if ( LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  354. {
  355. MessageBoxCustom.Show("上传完成!");
  356. if (!string.IsNullOrEmpty(strFile))
  357. {
  358. strFile = strFile.Replace('|', '\n');
  359. MessageBoxCustom.Show("文件\n" + strFile + "上传失败,请重新上传");
  360. }
  361. }
  362. else
  363. {
  364. MessageBoxCustom.Show("上传失败!");
  365. }
  366. });
  367. }
  368. }
  369. #endif
  370. this.Close();
  371. }
  372. else
  373. { MessageBoxCustom.Show("保存失败!"); }
  374. }
  375. /// <summary>
  376. /// 关闭窗体
  377. /// </summary>
  378. /// <param name="sender"></param>
  379. /// <param name="e"></param>
  380. void bntClose_Click(object sender, EventArgs e)
  381. {
  382. this.Close();
  383. }
  384. /// <summary>
  385. /// 选择预约上门,弹出派单上门数据
  386. /// </summary>
  387. /// <param name="sender"></param>
  388. /// <param name="e"></param>
  389. void cmbConcreteMatter_SelectedIndexChanged(object sender, EventArgs e)
  390. {
  391. if (this.IsGoForm)
  392. {
  393. if (this.cmbConcreteMatter.Text.Trim() == "预约上门")
  394. {
  395. LYFZ.Software.MainBusiness.HospitalTrackingSystem.DispatchDoor frm = new DispatchDoor();
  396. frm.StrOrderNumber = this.StrOrderNumber;
  397. frm.ShowDialog();
  398. if (frm.IsSaveed)
  399. {
  400. intDispatchDoorID = frm.SelectID;
  401. this.datimeRemind.DateValue = "";
  402. this.datimeRemind.Visible = false;
  403. this.labelEx11.Visible = false;
  404. return;
  405. }
  406. }
  407. intDispatchDoorID = 0;
  408. this.datimeRemind.Visible = true;
  409. this.labelEx11.Visible = true;
  410. }
  411. }
  412. #region 设置按钮
  413. /// <summary>
  414. /// 通话方式设置按钮
  415. /// </summary>
  416. /// <param name="sender"></param>
  417. /// <param name="e"></param>
  418. void buttonForm2_Click(object sender, EventArgs e)
  419. {
  420. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet();
  421. frm.TypeName = "AAAAAAE";
  422. frm.Version = "Version";
  423. if (frm.ShowDialog() == DialogResult.OK)
  424. { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAE", this.cbxCallMode); }
  425. }
  426. /// <summary>
  427. /// 拨打电话按钮
  428. /// </summary>
  429. /// <param name="sender"></param>
  430. /// <param name="e"></param>
  431. void btnDial_Click(object sender, EventArgs e)
  432. {
  433. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.PhoneCall(this.txtPhone); //手机
  434. }
  435. #endregion
  436. }
  437. }