IntentionsSelect.cs 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  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. using System.Collections;
  10. using System.IO;
  11. using LYFZ.ComponentLibrary;
  12. using LYFZ.Helper;
  13. using System.Web.UI.WebControls;
  14. using Newtonsoft.Json;
  15. namespace LYFZ.Software.MainBusiness.HospitalTrackingSystem
  16. {
  17. public partial class IntentionsSelect : LYFZ.Software.UI.HospitalTrackingSystem.IntentionsSelect
  18. {
  19. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  20. LYFZ.BLL.BLL_ErpSystemLogs slogbll = new BLL.BLL_ErpSystemLogs();
  21. LYFZ.BLL.BLL_ErpHospitalClient ambll = new BLL.BLL_ErpHospitalClient();
  22. LYFZ.BLL.BLL_ErpHospitalDispatchDoor hddbll = new BLL.BLL_ErpHospitalDispatchDoor();
  23. public IntentionsSelect()
  24. {
  25. this.btnClose.Click += btnClose_Click;
  26. this.btnDelete.Click += btnDelete_Click;
  27. this.btnSelect.Click += btnSelect_Click;
  28. this.btnTexting.Click += btnTexting_Click;
  29. this.btnExport.Click += btnExport_Click;
  30. this.Shown += IntentionsSelect_Shown;
  31. this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
  32. this.dgvData.CellDoubleClick += dgvShow_CellDoubleClick;
  33. this.dgvData.ColumnHeaderMouseClick += DgvData_ColumnHeaderMouseClick;
  34. this.btnWhole.Click += btnWhole_Click;
  35. this.bntConditions.Click += bntConditions_Click;
  36. this.btnClientServiceAnPai.Click += btnClientServiceAnPai_Click;
  37. this.tabControlEx1.SelectedIndexChanged += tabControlEx1_SelectedIndexChanged;
  38. this.textBoxEx1.KeyPress += textBoxEx1_KeyPress;
  39. this.checkBoxEx1.CheckedChanged += checkBoxEx1_CheckedChanged;
  40. this.checkBoxEx2.CheckedChanged += checkBoxEx2_CheckedChanged;
  41. //this.dgvData.RowsAdded += dgvData_RowsAdded;
  42. this.Resize += IntentionsSelect_Resize;
  43. this.btnImport.Click += btnImport_Click;
  44. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.Delete);
  45. this.btnTexting.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.SMSSend);
  46. this.btnWhole.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.RemindedSet);
  47. this.btnExport.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.DataExport);
  48. LYFZ.BLL.BLL_ErpCompanyInfo bllCompany = new BLL.BLL_ErpCompanyInfo();
  49. DataTable dt = bllCompany.GetAllList().Tables[0];
  50. ComboBoxItem item = new ComboBoxItem()
  51. {
  52. Name = "全部",
  53. Value = ""
  54. };
  55. cbxCompanyList.Items.Add(item);
  56. foreach(DataRow dr in dt.Rows)
  57. {
  58. item = new ComboBoxItem() {
  59. Name = dr["Company_Name"].ToString(),
  60. Value = dr["Company_DividedShop"].ToString()
  61. };
  62. cbxCompanyList.Items.Add(item);
  63. }
  64. cbxCompanyList.SelectedIndex = 0;
  65. }
  66. // BMK ldkfad
  67. private void DgvData_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) // 右键列头;
  68. {
  69. if (e.Button == MouseButtons.Right)
  70. {
  71. this.dgvData.conMenu.Items.Clear();
  72. ToolStripMenuItem item = new ToolStripMenuItem();
  73. item.Text = "设置标题";
  74. item.Tag = "SetColumnShow";
  75. item.Name = "SetColumnShow";
  76. this.dgvData.conMenu.Items.Add(item);
  77. // this.dgvData.conMenu.Show(MousePosition.X, MousePosition.Y);//弹出操作菜单
  78. this.dgvData.conMenu.ItemClicked -= ConMenu_ItemClicked;
  79. this.dgvData.conMenu.ItemClicked += ConMenu_ItemClicked;
  80. // this.dgvData.conMenu.Show();
  81. if (!this.dgvData.conMenu.Visible)
  82. {
  83. this.dgvData.conMenu.Show(MousePosition.X, MousePosition.Y);//弹出操作菜单
  84. }
  85. }
  86. }
  87. private void ConMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  88. {
  89. ToolStripItem item = e.ClickedItem;
  90. if (item.Name.Trim() == "SetColumnShow")
  91. {
  92. string strEnabled = "";
  93. if (this.dgvData.Columns.Contains("拍摄状态"))
  94. {
  95. strEnabled = "拍摄状态";
  96. }
  97. if (LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ShowDataGridViewSetColumn(this.dgvData, StrEnabled: strEnabled))
  98. {
  99. this.PublicFunctionRows();
  100. }
  101. }
  102. }
  103. void IntentionsSelect_Resize(object sender, EventArgs e)
  104. {
  105. switch (this.panelEx14.Location.Y)
  106. {
  107. case 1: this.flowLayoutPanel1.Height = 36; break;
  108. case 33: this.flowLayoutPanel1.Height = 68; break;
  109. }
  110. }
  111. Dictionary<string, string> DictData = new Dictionary<string, string>();
  112. /// <summary>
  113. /// 窗体加载事件
  114. /// </summary>
  115. /// <param name="sender"></param>
  116. /// <param name="e"></param>
  117. void IntentionsSelect_Shown(object sender, EventArgs e)
  118. {
  119. bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(
  120. VersionControl.VersionFunctionEnum.医院跟踪系统意向单查询);
  121. if (!b)
  122. {
  123. this.Close();
  124. return;
  125. }
  126. //this.tabPage_ExpiredExpected.Parent = null;
  127. this.PublicFunctionRows();
  128. this.Settings();
  129. this.cbxusert.TextFindTag("不限条件");
  130. List<Control> hideControls=new List<Control>();
  131. hideControls.Add(btnTexting);
  132. LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(VersionControl.VersionFunctionEnum.短信管理医院跟踪短信, hideControls,null,null);
  133. }
  134. /// <summary>
  135. /// 导入按钮
  136. /// </summary>
  137. /// <param name="sender"></param>
  138. /// <param name="e"></param>
  139. void btnImport_Click(object sender, EventArgs e)
  140. {
  141. ImportExcel frm = new ImportExcel();
  142. frm.ShowDialog();
  143. this.PublicFunctionRows();
  144. }
  145. /// <summary>
  146. /// 预产期选中事件
  147. /// </summary>
  148. /// <param name="sender"></param>
  149. /// <param name="e"></param>
  150. void checkBoxEx2_CheckedChanged(object sender, EventArgs e)
  151. {
  152. if (this.checkBoxEx2.Checked == true)
  153. { this.checkBoxEx1.Checked = false; }
  154. this.PublicFunctionRows();
  155. }
  156. /// <summary>
  157. /// 宝宝生日选中事件
  158. /// </summary>
  159. /// <param name="sender"></param>
  160. /// <param name="e"></param>
  161. void checkBoxEx1_CheckedChanged(object sender, EventArgs e)
  162. {
  163. if (this.checkBoxEx1.Checked == true)
  164. { this.checkBoxEx2.Checked = false; }
  165. this.PublicFunctionRows();
  166. }
  167. /// <summary>
  168. /// 显示数字
  169. /// </summary>
  170. /// <param name="sender"></param>
  171. /// <param name="e"></param>
  172. void textBoxEx1_KeyPress(object sender, KeyPressEventArgs e)
  173. {
  174. if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar))
  175. { e.Handled = true; }
  176. }
  177. /// <summary>
  178. /// 导出按钮
  179. /// </summary>
  180. /// <param name="sender"></param>
  181. /// <param name="e"></param>
  182. void btnExport_Click(object sender, EventArgs e)
  183. {
  184. if (dgvData.Rows.Count > 0)
  185. {
  186. string StrWhere = GetWhereStr();
  187. SaveFileDialog saveFile = new SaveFileDialog();
  188. saveFile.FileName = "意向单查询";
  189. saveFile.Title = "导出数据报表文件";
  190. saveFile.Filter = "EXECL文件(*.xls) |*.xls |文本文件(*.txt) |*.txt |所有文件(*.*) |*.*";
  191. saveFile.FilterIndex = 1;
  192. DialogResult drst = saveFile.ShowDialog();
  193. if (drst == DialogResult.No || drst == DialogResult.Cancel || drst == DialogResult.No || drst == DialogResult.Abort)
  194. { return; }
  195. bool IsExport = false;
  196. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  197. {
  198. DataTable dt = orbll.GetView_Custom("View_HospitalContact", StrWhere: StrWhere, ShowColumnName: GetColumnFilde(), filedOrder: "来单批号").Tables[0];
  199. DataTable dtContact = orbll.GetView_Custom(" select Hcr_Number as 来单批号, dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Hcr_CallTime)) as 通话时间, Hcr_CallDuration as 通话时长, Hcr_Homeaddress as 具体事项, Hcr_CallStaff as 通话人员, Hcr_CallMode as 通话方式, dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Hcr_RemindTime)) as 下次提醒时间, Hcr_Remarks as 沟通备注 from tb_ErpHospitalContactRecord ").Tables[0];
  200. if (dt.Rows.Count > 0)
  201. {
  202. dt.Columns.Remove("ID");
  203. dt.Columns.Remove("录入时间查询");
  204. dt.Columns.Remove("订单客户");
  205. dt.Columns.Add("通话时间");
  206. dt.Columns.Add("通话时长");
  207. dt.Columns.Add("具体事项");
  208. dt.Columns.Add("通话人员");
  209. dt.Columns.Add("通话方式");
  210. dt.Columns.Add("下次提醒时间");
  211. dt.Columns.Add("沟通备注");
  212. List<dynamic> dtJson = JsonConvert.DeserializeObject<List<dynamic>>(JsonConvert.SerializeObject(dt));
  213. int intIndex = 0;
  214. for (int i = 0; i < dt.Rows.Count; i++)
  215. {
  216. DataRow[] drList = dtContact.Select(" 来单批号 = '" + dt.Rows[i]["来单批号"] + "' ");
  217. if(drList.Length>0)
  218. {
  219. for(int j=0;j< drList.Length;j++)
  220. {
  221. if(j==0)
  222. {
  223. ((dynamic)dtJson[i + intIndex]).通话时间 = drList[j]["通话时间"].ToString();
  224. ((dynamic)dtJson[i + intIndex]).通话时长 = drList[j]["通话时长"].ToString();
  225. ((dynamic)dtJson[i + intIndex]).具体事项 = drList[j]["具体事项"].ToString();
  226. ((dynamic)dtJson[i + intIndex]).通话人员 = drList[j]["通话人员"].ToString();
  227. ((dynamic)dtJson[i + intIndex]).通话方式 = drList[j]["通话方式"].ToString();
  228. ((dynamic)dtJson[i + intIndex]).下次提醒时间 = drList[j]["下次提醒时间"].ToString();
  229. ((dynamic)dtJson[i + intIndex]).沟通备注 = drList[j]["沟通备注"].ToString();
  230. }
  231. else
  232. {
  233. intIndex++;
  234. dynamic dyObj = new System.Dynamic.ExpandoObject();
  235. dyObj.通话时间 = drList[j]["通话时间"].ToString();
  236. dyObj.通话时长 = drList[j]["通话时长"].ToString();
  237. dyObj.具体事项 = drList[j]["具体事项"].ToString();
  238. dyObj.通话人员 = drList[j]["通话人员"].ToString();
  239. dyObj.通话方式 = drList[j]["通话方式"].ToString();
  240. dyObj.下次提醒时间 = drList[j]["下次提醒时间"].ToString();
  241. dyObj.沟通备注 = drList[j]["沟通备注"].ToString();
  242. dtJson.Insert(i + intIndex, dyObj);
  243. }
  244. }
  245. }
  246. }
  247. dt = Newtonsoft.Json.JsonConvert.DeserializeObject(Newtonsoft.Json.JsonConvert.SerializeObject(dtJson),
  248. typeof(DataTable)) as DataTable;
  249. try
  250. {
  251. //this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  252. //{
  253. // IsExport = LYFZ.Command.Command_ExportExcel.DataTable2Sheet(saveFile.FileName.Trim(), dt, "Sheet1", IsCoveredExistingFile: true);
  254. //}));
  255. IsExport = LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(saveFile.FileName.Trim(), dt, null, backgroundWorker);
  256. }
  257. catch
  258. { }
  259. if (IsExport)
  260. { MessageBoxCustom.Show("导出成功!"); }
  261. else
  262. { MessageBoxCustom.Show("导出失败!"); }
  263. }
  264. });
  265. }
  266. else
  267. { MessageBoxCustom.Show("没有数据可导出"); return; }
  268. }
  269. /// <summary>
  270. /// 多条件查询按钮
  271. /// </summary>
  272. /// <param name="sender"></param>
  273. /// <param name="e"></param>
  274. void bntConditions_Click(object sender, EventArgs e)
  275. {
  276. this.DictData.Clear();
  277. ConditionsInquiry frm = new ConditionsInquiry();
  278. frm.ShowDialog();
  279. if (frm.IsSaveed)
  280. {
  281. this.DictData = frm.DictDataArray;
  282. this.txtQuery.Text = "";
  283. this.PublicFunctionRows();
  284. }
  285. }
  286. /// <summary>
  287. /// 安排客服
  288. /// </summary>
  289. /// <param name="sender"></param>
  290. /// <param name="e"></param>
  291. void btnClientServiceAnPai_Click(object sender, EventArgs e)
  292. {
  293. if (this.dgvData.SelectedRows.Count > 0)
  294. {
  295. LYFZ.Software.MainBusiness.DoorCityProcess.SetSmallForm.ClientServiceTaskAnPaiSmallForm frm = new DoorCityProcess.SetSmallForm.ClientServiceTaskAnPaiSmallForm();
  296. frm.ShowDialog();
  297. if (frm.IsSaveed)
  298. {
  299. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ClientServiceAnPai(this.dgvData, LYFZ.EnumPublic.ClientServiceTaskType.意向跟踪, frm.model, LYFZ.EnumPublic.ClientServiceTaskItem.医院意向);
  300. }
  301. }
  302. }
  303. /// <summary>
  304. /// 选项卡事件
  305. /// </summary>
  306. /// <param name="sender"></param>
  307. /// <param name="e"></param>
  308. void tabControlEx1_SelectedIndexChanged(object sender, EventArgs e)
  309. {
  310. switch (this.tabControlEx1.SelectedTab.Name.Trim())
  311. {
  312. case "tabPage_All":
  313. this.txtStatistic.Visible = true;
  314. break;
  315. default:
  316. this.txtStatistic.Visible = false;
  317. break;
  318. }
  319. switch (this.tabControlEx1.SelectedTab.Name.Trim())
  320. {
  321. case "tabPage_NotComplete":
  322. this.btnClientServiceAnPai.Enabled = true;
  323. break;
  324. default:
  325. this.btnClientServiceAnPai.Enabled = false;
  326. break;
  327. }
  328. this.PublicFunctionRows();
  329. }
  330. /// <summary>
  331. /// 双击未完成事件
  332. /// </summary>
  333. /// <param name="e"></param>
  334. void dgvShow_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  335. {
  336. if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
  337. {
  338. if (this.dgvData.SelectedRows != null && this.dgvData.SelectedRows.Count > 0)
  339. {
  340. IntentionsEntered frm = new IntentionsEntered();
  341. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  342. frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  343. frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  344. frm.StrOrdNumber = this.dgvData.CurrentRow.Cells["来单批号"].Value.ToString();
  345. frm.Owner = this;
  346. frm.ShowDialog();
  347. if (frm.IsSaveed)
  348. { this.PublicFunctionRows(); }
  349. }
  350. }
  351. }
  352. /// <summary>
  353. /// 创建行
  354. /// </summary>
  355. /// <param name="sender"></param>
  356. /// <param name="e"></param>
  357. void dgvData_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
  358. {
  359. if (this.dgvData.Columns.Contains("生日类型"))
  360. {
  361. if (this.dgvData.Rows[e.RowIndex].Cells["生日类型"].Value.ToString().Trim() == "预产期")
  362. { this.dgvData.Rows[e.RowIndex].Cells["宝宝性别"].Value = ""; }
  363. }
  364. }
  365. /// <summary>
  366. /// 设置下拉框
  367. /// </summary>
  368. void Settings()
  369. {
  370. if (this.cbxusert.Nodes.Count > 0)
  371. { this.cbxusert.Nodes.Clear(); }
  372. System.Windows.Forms.TreeNode root = null;
  373. DataTable dt = orbll.GetView_Custom("tb_ErpHospitalRemindSettings", ShowColumnName: "ID,Hrs_RemindName,Hrs_RemindDays,Hrs_StartState").Tables[0];
  374. this.cbxusert.Nodes.Add("不限条件");
  375. for (int i = 0; i < dt.Rows.Count; i++)
  376. {
  377. if (dt.Rows[i]["Hrs_StartState"].ToString() == "0")
  378. {
  379. root = new System.Windows.Forms.TreeNode();
  380. root.Text = dt.Rows[i]["Hrs_RemindName"].ToString();
  381. root.Tag = dt.Rows[i]["ID"].ToString();
  382. this.cbxusert.Nodes.Add(root);
  383. }
  384. }
  385. }
  386. /// <summary>
  387. /// 提醒设置按钮
  388. /// </summary>
  389. /// <param name="sender"></param>
  390. /// <param name="e"></param>
  391. void btnWhole_Click(object sender, EventArgs e)
  392. {
  393. RemindSet frm = new RemindSet();
  394. frm.StrRemindSetLoadType = RemindSet.RemindSetLoadType.医院跟踪今日提醒;
  395. frm.ShowDialog();
  396. if (frm.ok)
  397. {
  398. string StrText = this.cbxusert.Text.Trim();
  399. this.Settings();
  400. this.cbxusert.TextFindTag(StrText);
  401. }
  402. }
  403. /// <summary>
  404. /// 发送短信按钮
  405. /// </summary>
  406. /// <param name="sender"></param>
  407. /// <param name="e"></param>
  408. void btnTexting_Click(object sender, EventArgs e)
  409. {
  410. LYFZ.Software.UI.SMSManagement.SmsSend.FrmSendSms frm = new UI.SMSManagement.SmsSend.FrmSendSms();
  411. if (dgvData.SelectedRows == null || dgvData.SelectedRows.Count == 0)
  412. { MessageBoxCustom.Show("请选择要发送短信的客人!"); return; }
  413. string Sj1 = "";
  414. string User_Telephone = "";
  415. LYFZ.Software.MainBusiness.SMSManagement.SmsSend.FrmSendSms sendSms = new SMSManagement.SmsSend.FrmSendSms();
  416. for (int i = 0; i < dgvData.SelectedRows.Count; i++)
  417. {
  418. User_Telephone = dgvData.SelectedRows[i].Cells["本人手机"].Value.ToString();
  419. //检查手机合法性
  420. if (!string.IsNullOrEmpty(User_Telephone))
  421. {
  422. string ret = LYFZ.WinAPI.CustomPublicMethod.ValidationPhones(User_Telephone);
  423. if (ret.Trim().Length <= 0)
  424. { Sj1 += User_Telephone + ","; }
  425. else if (dgvData.SelectedRows.Count == 1)
  426. { MessageBoxCustom.Show("手机号无效:" + ret); return; }
  427. }
  428. }
  429. sendSms.Phone = Sj1.Trim(',');
  430. sendSms.ShowDialog();
  431. }
  432. /// <summary>
  433. /// 查询按钮
  434. /// </summary>
  435. /// <param name="sender"></param>
  436. /// <param name="e"></param>
  437. void btnSelect_Click(object sender, EventArgs e)
  438. {
  439. this.DictData.Clear();
  440. this.PublicFunctionRows();
  441. }
  442. /// <summary>
  443. /// 删除按钮
  444. /// </summary>
  445. /// <param name="sender"></param>
  446. /// <param name="e"></param>
  447. void btnDelete_Click(object sender, EventArgs e)
  448. {
  449. if (this.dgvData.SelectedRows != null && this.dgvData.SelectedRows.Count > 0)
  450. {
  451. if (this.dgvData.CurrentRow != null)
  452. {
  453. if (this.dgvData.SelectedRows.Count > 0)
  454. {
  455. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  456. {
  457. LYFZ.Model.Model_ErpHospitalClient model = ambll.GetModel(Convert.ToInt32(dgvData.CurrentRow.Cells["ID"].Value));
  458. List<LYFZ.Helper.CommandInfo> clist = new List<CommandInfo>();
  459. clist.Add(ambll.GetDeleteCommandInfo("ID", "=", dgvData.CurrentRow.Cells["ID"].Value));
  460. DataTable dt = orbll.GetView_Custom("tb_ErpHospitalDispatchDoor", StrWhere: "Hdr_Number = '" + model.Hct_Oddnumber + "'", ShowColumnName: "ID").Tables[0];
  461. for (int i = 0; i < dt.Rows.Count; i++)
  462. {
  463. clist.Add(hddbll.GetDeleteCommandInfo("ID", "=", dt.Rows[i]["ID"]));
  464. }
  465. string strContent = "ID:" + model.ID + ",来单批号为:" + model.Hct_Oddnumber + ",客户姓名为:" + model.Hct_CustomerName + ",本人手机:" + model.Hct_MyselfMobile;
  466. if (!String.IsNullOrEmpty(model.Hct_HusbandMobile))
  467. {
  468. strContent += ",老公手机:" + model.Hct_HusbandMobile;
  469. }
  470. if (!String.IsNullOrEmpty(model.Hct_BabyName))
  471. {
  472. strContent += ",宝贝姓名:" + model.Hct_BabyName;
  473. }
  474. clist.Add(slogbll.GetAddCommandInfo(LYFZ.BLL.BLL_ErpSystemLogs.GetWriteLogModel(LYFZ.EnumPublic.SystemLogsType.删除医院跟踪客户, strContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name, StrInfoID: LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID())));
  475. //if (ambll.Delete())
  476. if (clist.Count > 0)
  477. {
  478. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  479. {
  480. MessageBoxCustom.Show("删除成功!");
  481. //LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除医院跟踪客户, "删除医院跟踪客户,ID为:" + dgvData.CurrentRow.Cells["ID"].Value + ",客户姓名为:" + dgvData.CurrentRow.Cells["客户姓名"].Value + "", LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  482. this.PublicFunctionRows();
  483. }
  484. else
  485. { MessageBoxCustom.Show("删除失败!"); }
  486. }
  487. }
  488. }
  489. }
  490. }
  491. else
  492. { MessageBoxCustom.Show("请选择你要删除的数据!"); }
  493. }
  494. /// <summary>
  495. /// 关闭窗体
  496. /// </summary>
  497. /// <param name="sender"></param>
  498. /// <param name="e"></param>
  499. void btnClose_Click(object sender, EventArgs e)
  500. {
  501. if (MessageBoxCustom.Show("你确定要关闭吗?", "关闭提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  502. { this.Close(); }
  503. }
  504. /// <summary>
  505. /// 创建行
  506. /// </summary>
  507. private void PublicFunctionRows()
  508. {
  509. this.UcPagerEx1.PageCurrent = 1;
  510. this.UcPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
  511. this.UcPagerEx1.Bind();
  512. if (this.tabControlEx1.SelectedTab.Name.Trim() == "tabPage_All")
  513. {
  514. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  515. DataTable dt = orbll.GetView_Custom("View_HospitalContact", StrWhere: GetWhereStr(), ShowColumnName: "订单客户").Tables[0];
  516. if (dt.Rows.Count > 0)
  517. {
  518. this.txtStatistic.Text = "总录入数量:" +
  519. dt.Rows.Count + " 成交数量:" +
  520. dt.Select("订单客户 = 1").Length + " 未成交数量:" +
  521. dt.Select("订单客户 = 0").Length + " 已流失:" +
  522. dt.Select("订单客户 = 2").Length + " 成交百分比:" +
  523. Convert.ToDouble(dt.Select("订单客户 = 1").Length) / Convert.ToDouble(dt.Rows.Count) + "%";
  524. }
  525. else
  526. {
  527. this.txtStatistic.Text = "总录入数量:0 成交数量:0 未成交数量:0 已流失:0 成交百分比:0%";
  528. }
  529. }
  530. }
  531. /// <summary>
  532. /// 未成交分页数据
  533. /// </summary>
  534. /// <param name="e"></param>
  535. /// <returns></returns>
  536. int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
  537. {
  538. DataTable dt = new DataTable();
  539. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  540. string tabName = "View_HospitalContact";
  541. if ((DictData.ContainsKey("StrGHUser") && DictData["StrGHUser"].Length > 0) || (DictData.ContainsKey("StrGHStartTime") && DictData["StrGHStartTime"].Length > 0) || (DictData.ContainsKey("StrGHEndTime") && DictData["StrGHEndTime"].Length > 0))
  542. {
  543. tabName += " inner join tb_ErpHospitalDispatchDoor on View_HospitalContact.来单批号 = tb_ErpHospitalDispatchDoor.Hdr_Number ";
  544. }
  545. pageData.TableName = tabName;
  546. pageData.PageIndex = this.UcPagerEx1.PageCurrent;
  547. pageData.PageSize = this.UcPagerEx1.PageSize;
  548. pageData.QueryCondition = GetWhereStr();
  549. pageData.QueryFieldName = this.GetColumnFilde();
  550. pageData.OrderStr = "来单批号";
  551. pageData.OrderType = 1;
  552. string strHideField = "ID,录入时间查询,订单客户";
  553. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  554. {
  555. dt = pageData.QueryDataTableByPage(this.UcPagerEx1.PageSize, this.UcPagerEx1.PageCurrent, this.GetColumnFilde(), tabName, GetWhereStr()).Tables[0];
  556. dt.Columns.Remove("RowNumber");
  557. });
  558. try
  559. {
  560. this.dgvData.DataSource(dt, strHideField: strHideField);
  561. }
  562. catch
  563. { }
  564. try
  565. {
  566. this.UcPagerEx1.TbDataSource = dt;
  567. }
  568. catch { }
  569. if (pageData.QueryFieldName.Contains("自家地址") )
  570. this.dgvData.Columns["自家地址"].Width = 200;
  571. if (pageData.QueryFieldName.Contains("婆家地址"))
  572. this.dgvData.Columns["婆家地址"].Width = 200;
  573. if (pageData.QueryFieldName.Contains("娘家地址"))
  574. this.dgvData.Columns["娘家地址"].Width = 200;
  575. this.dgvData.ClearSelection();
  576. return pageData.TotalCount;
  577. }
  578. /// <summary>
  579. /// 获取要查询的字段名
  580. /// </summary>
  581. /// <returns></returns>
  582. string GetColumnFilde()
  583. {
  584. #if IGNORE
  585. return "ID,来单批号,客户姓名,宝宝姓名,宝宝性别,生日类型,[宝宝生日/预产期],是否农历,宝宝年龄,宝宝天数,怀孕天数,本人手机,老公姓名,老公手机,发送来单短信,喂养方式,客户区域,客户类别,订单客户,业务种类,业务意向,来单医院,门市,发片状态,发片日期,发片人员,完成状态,完成日期,完成人员,取件状态,取件日期,取件人员,备注,录入时间,录入时间查询,录入者,自家地址,婆家地址,娘家地址";
  586. #else
  587. string strGuidName = LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0047.ToString().Trim();
  588. string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  589. string strDefaultColumn = "ID,来单批号,客户姓名,宝宝姓名,宝宝性别,生日类型,[宝宝生日/预产期],是否农历,宝宝年龄,宝宝天数,怀孕天数,本人手机,老公姓名,老公手机,发送来单短信,喂养方式,客户区域,客户类别,门市,订单客户,业务种类,业务意向,来单医院,发片状态,发片日期,发片人员,完成状态,完成日期,完成人员,取件状态,取件日期,取件人员,备注,录入时间,录入时间查询,录入者,自家地址,婆家地址,娘家地址";
  590. // 加载数据库中的记录;
  591. Dictionary<string, string> dictColumns =
  592. LYFZ.DAL.DAL_GridViewDisplayIndex.GetGridViewShowColumns(strUserID, strGuidName, strDefaultColumn);
  593. this.dgvData.dgvGuidName = strGuidName;
  594. this.dgvData.dgvCurrentColumnOriginalSet = strDefaultColumn;
  595. this.dgvData.dgvUserEmployeeID = strUserID;
  596. this.dgvData.AllowUserToOrderColumns = true;
  597. this.dgvData.dgvFixedHideColumn = "ID,录入时间查询,订单客户,来单批号,客户姓名,宝宝姓名,宝宝性别,本人手机,来单医院";
  598. this.dgvData.dictShowColumName = dictColumns;
  599. string strColumnShow = "";
  600. foreach (var key in dictColumns )
  601. {
  602. if (key.Key.Contains("宝宝生日/预产期"))
  603. {
  604. strColumnShow += "[宝宝生日/预产期],";
  605. }
  606. else if (key.Key.Contains("ID"))
  607. {
  608. strColumnShow += "View_HospitalContact.ID,";
  609. }
  610. else
  611. {
  612. strColumnShow += key.Key + ",";
  613. }
  614. }
  615. return strColumnShow.TrimEnd(',');
  616. #endif
  617. }
  618. /// <summary>
  619. /// 查询条件
  620. /// </summary>
  621. /// <returns></returns>
  622. private string GetWhereStr()
  623. {
  624. string StrWhere = " 1=1 ";
  625. switch (this.tabControlEx1.SelectedTab.Name.Trim())
  626. {
  627. case "tabPage_NotComplete": StrWhere += " and 订单客户 = '0' And ((Hct_BirthdayType = 1 And Hct_BabyBirthday >= '" + SDateTime.Now + "') or Hct_BirthdayType = 0)"; break;
  628. case "tabPage_OrderOK": StrWhere += " and 订单客户 = '1' "; break;
  629. case "tabPage_LostOK": StrWhere += " and 订单客户 = '2' "; break;
  630. case "tabPage_ExpiredExpected": StrWhere += " and 订单客户 = '0' And Hct_BirthdayType = 1 And Hct_BabyBirthday < '" + SDateTime.Now + "'"; break;
  631. }
  632. switch (this.tabControlEx1.SelectedTab.Name.Trim())
  633. {
  634. case "tabPage_OrderOK":
  635. case "tabPage_LostOK": break;
  636. default:
  637. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.Client_ShowAllIntentClient))
  638. { StrWhere += " And Hct_CreateName = '" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID + "'"; }
  639. break;
  640. }
  641. if (!string.IsNullOrEmpty(this.txtQuery.Text.Trim()))
  642. {
  643. StrWhere += "and (客户姓名 like'%" +
  644. this.txtQuery.Text.Trim() +
  645. "%' or 宝宝姓名 like'%" +
  646. this.txtQuery.Text.Trim() +
  647. "%' or dbo.fn_ChineseToSpell(客户姓名) like '%" +
  648. this.txtQuery.Text.Trim() +
  649. "%' or dbo.fn_ChineseToSpell(宝宝姓名) like '%" +
  650. this.txtQuery.Text.Trim() +
  651. "%' or 本人手机 like '%" +
  652. this.txtQuery.Text.Trim() +
  653. "%' or 老公手机 like '%" +
  654. this.txtQuery.Text.Trim() +
  655. "%' or 老公姓名 like '%" +
  656. this.txtQuery.Text.Trim() + "%')";
  657. }
  658. if (DictData.ContainsKey("StrClientClass") && DictData["StrClientClass"].Length > 0)
  659. { StrWhere += " and 客户类别 = '" + DictData["StrClientClass"].Trim() + "'"; }
  660. if (DictData.ContainsKey("StrIntent") && DictData["StrIntent"].Length > 0)
  661. { StrWhere += " and 业务意向 = '" + DictData["StrIntent"].Trim() + "'"; }
  662. if (DictData.ContainsKey("StrClientName") && DictData["StrClientName"].Length > 0)
  663. { StrWhere += " and 客户姓名 like '%" + DictData["StrClientName"].Trim() + "%'"; }
  664. if (DictData.ContainsKey("StrClientPhone") && DictData["StrClientPhone"].Length > 0)
  665. { StrWhere += " and 本人手机 like'%" + DictData["StrClientPhone"].ToString().Trim() + "%' or 老公手机 like '%" + DictData["StrClientPhone"].ToString().Trim() + "%'"; }
  666. if (DictData.ContainsKey("StrRegion") && DictData["StrRegion"].Length > 0)
  667. { StrWhere += " and 客户区域 = '" + DictData["StrRegion"].Trim() + "'"; }
  668. if (DictData.ContainsKey("StrRetail") && DictData["StrRetail"].Length > 0)
  669. { StrWhere += " and 门市 = '" + DictData["StrRetail"].Trim() + "'"; }
  670. if (DictData.ContainsKey("StrHospital") && DictData["StrHospital"].Length > 0)
  671. { StrWhere += " and 来单医院 = '" + DictData["StrHospital"].Trim() + "'"; }
  672. if (DictData.ContainsKey("StrSpecies") && DictData["StrSpecies"].Length > 0)
  673. { StrWhere += " and 业务种类 = '" + DictData["StrSpecies"].Trim() + "'"; }
  674. if (DictData.ContainsKey("StrOrderNumber") && DictData["StrOrderNumber"].Length > 0)
  675. { StrWhere += " and 来单批号 = '" + DictData["StrOrderNumber"].Trim() + "'"; }
  676. if (DictData.ContainsKey("StrSendStatus") && DictData["StrSendStatus"].Length > 0)
  677. { StrWhere += " and 发片状态 = '" + DictData["StrSendStatus"].Trim() + "'"; }
  678. if (DictData.ContainsKey("StrCompleteStatus") && DictData["StrCompleteStatus"].Length > 0)
  679. { StrWhere += " and 完成状态 = '" + DictData["StrCompleteStatus"].Trim() + "'"; }
  680. if (DictData.ContainsKey("StrPickupStatus") && DictData["StrPickupStatus"].Length > 0)
  681. { StrWhere += " and 取件状态 = '" + DictData["StrPickupStatus"].Trim() + "'"; }
  682. if (DictData.ContainsKey("StrAddress") && DictData["StrAddress"].Length > 0)
  683. { StrWhere += " and (自家地址 like '%" + DictData["StrAddress"].Trim() + "%' or 娘家地址 like '%" + DictData["StrAddress"].Trim() + "%' or 婆家地址 like '%" + DictData["StrAddress"].Trim() + "%')"; }
  684. if (DictData.ContainsKey("StrBornInStart") && DictData["StrBornInStart"].Length > 0 && DictData.ContainsKey("StrBornInEnd") && DictData["StrBornInEnd"].Length > 0)
  685. { StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("convert(datetime,[宝宝生日/预产期],120)", DictData["StrBornInStart"], DictData["StrBornInEnd"]); }
  686. if (DictData.ContainsKey("StrBirthdayStart") && DictData["StrBirthdayStart"].Length > 0 && DictData.ContainsKey("StrBirthdayEnd") && DictData["StrBirthdayEnd"].Length > 0)
  687. { StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("今年生日日期", DictData["StrBirthdayStart"], DictData["StrBirthdayEnd"]); }
  688. if (DictData.ContainsKey("StrCreateStart") && DictData["StrCreateStart"].Length > 0 && DictData.ContainsKey("StrCreateEnd") && DictData["StrCreateEnd"].Length > 0)
  689. { StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("录入时间查询", DictData["StrCreateStart"], DictData["StrCreateEnd"]); }
  690. #region 通话人员;
  691. if ( DictData.ContainsKey("strCommunicationPersonnel") && DictData["strCommunicationPersonnel"].Length > 0 )
  692. {
  693. StrWhere += " and [来单批号] in (select max([Hcr_Number]) FROM [tb_ErpHospitalContactRecord] where Hcr_CallStaff = '" + DictData["strCommunicationPersonnel"].ToString() + "' group by Hcr_Number)";
  694. }
  695. #endregion
  696. #region 上门时间 上门人员
  697. if (DictData.ContainsKey("StrGHStartTime") && DictData["StrGHStartTime"].Length > 0 && DictData.ContainsKey("StrGHEndTime") && DictData["StrGHEndTime"].Length > 0)
  698. { StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Hdr_DoorTime", DictData["StrGHStartTime"], DictData["StrGHEndTime"]); }
  699. if(DictData.ContainsKey("StrGHUser") && DictData["StrGHUser"].Length > 0)
  700. {
  701. StrWhere += " and ( Hdr_DoorPersonOne = '"+ DictData["StrGHUser"] + "' or Hdr_DoorPersonTwo = '" + DictData["StrGHUser"] + "' or Hdr_DoorPersonThree = '" + DictData["StrGHUser"] + "' or Hdr_DoorPersonFour = '" + DictData["StrGHUser"] + "' ) ";
  702. }
  703. if((DictData.ContainsKey("StrGHUser") && DictData["StrGHUser"].Length > 0) || (DictData.ContainsKey("StrGHStartTime") && DictData["StrGHStartTime"].Length > 0) || (DictData.ContainsKey("StrGHEndTime") && DictData["StrGHEndTime"].Length > 0))
  704. {
  705. StrWhere += " and Hdr_HomeState = 1 ";
  706. }
  707. #endregion
  708. if (this.checkBoxEx1.Checked == true)
  709. { StrWhere += " and 生日类型='宝宝生日'"; }
  710. else if (this.checkBoxEx2.Checked == true)
  711. { StrWhere += " and 生日类型='预产期'"; }
  712. if (textBoxEx1.Text.Trim() != "" && this.cbxusert.Text.Trim() != "" && this.cbxusert.Text.Trim() != "不限条件")
  713. {
  714. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  715. DataTable dt = orbll.GetView_Custom("tb_ErpHospitalRemindSettings", StrWhere: "ID ='" + cbxusert.Tag.ToString() + "'", ShowColumnName: "Hrs_RemindDays,Hrs_RemindConditions").Tables[0];
  716. int Strds = Convert.ToInt32(this.textBoxEx1.Text.Trim());//近x天
  717. //string Strrr = this.cbxusert.Text.Trim();
  718. int RemindDays = Convert.ToInt32(dt.Rows[0]["Hrs_RemindDays"].ToString());
  719. int Strde = RemindDays - Convert.ToInt32(Strds);
  720. if (dt.Rows[0]["Hrs_RemindConditions"].ToString() == "0")
  721. {
  722. StrWhere += " and 宝宝天数 <='" + dt.Rows[0]["Hrs_RemindDays"].ToString() + "' and 宝宝天数>= '" + Strde + "'";
  723. }
  724. else if (dt.Rows[0]["Hrs_RemindConditions"].ToString() == "1")
  725. {
  726. StrWhere += " and 怀孕天数 >=" + (280 - (Strds + RemindDays)).ToString() + " and 怀孕天数 <=" + (280 - RemindDays).ToString();
  727. }
  728. }
  729. if (!string.IsNullOrEmpty((cbxCompanyList.SelectedItem as ComboBoxItem).Value))
  730. {
  731. if(StrWhere!="")
  732. {
  733. StrWhere += " and ";
  734. }
  735. StrWhere += " Hct_DividedShop = '" + (cbxCompanyList.SelectedItem as ComboBoxItem).Value + "' ";
  736. }
  737. StrWhere = "(" + StrWhere + ") or (门市 = '') ";
  738. return StrWhere;
  739. }
  740. }
  741. class ComboBoxItem {
  742. public string Name { get; set; }
  743. public string Value { get; set; }
  744. public override string ToString()
  745. {
  746. return Name;
  747. }
  748. }
  749. }