TodayReminded.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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 TodayReminded : LYFZ.Software.UI.HospitalTrackingSystem.TodayReminded
  12. {
  13. string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  14. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  15. LYFZ.BLL.BLL_ErpHospitalContactRecord ambll = new BLL.BLL_ErpHospitalContactRecord();
  16. public TodayReminded()
  17. {
  18. this.Load += TodayReminded_Load;
  19. this.Shown += TodayReminded_Shown;
  20. this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
  21. this.btnselect.Click += btnselect_Click;
  22. this.btnRemind.Click += btnRemind_Click;
  23. this.btnTexting.Click += btnTexting_Click;
  24. this.btnExport.Click += btnExport_Click;
  25. this.btnClose.Click += btnClose_Click;
  26. this.btnWhole.Click += btnWhole_Click;
  27. this.dgvRemind.CellDoubleClick += dgvRemind_CellDoubleClick;
  28. this.btnRemind.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.CancelRemindedSet);
  29. this.btnTexting.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.SMSSend);
  30. this.btnExport.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.HospitalTrackingSystem, CustomAttributes.OperatingAuthority.DataExport);
  31. }
  32. void TodayReminded_Shown(object sender, EventArgs e)
  33. {
  34. bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(
  35. VersionControl.VersionFunctionEnum.医院跟踪系统今日提醒);
  36. if (!b)
  37. {
  38. this.Close();
  39. }
  40. List<Control> hideControls = new List<Control>();
  41. hideControls.Add(btnTexting);
  42. LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(VersionControl.VersionFunctionEnum.短信管理医院跟踪短信, hideControls, null, null);
  43. }
  44. public TodayReminded(string p)
  45. : this()
  46. {
  47. ShowType = p;
  48. }
  49. /// <summary>
  50. /// 是否弹屏提示:“AutoShow” 为判断
  51. /// </summary>
  52. string ShowType = "";
  53. DataTable dt_RemindSet = new DataTable();
  54. /// <summary>
  55. /// 窗体加载时
  56. /// </summary>
  57. /// <param name="sender"></param>
  58. /// <param name="e"></param>
  59. void TodayReminded_Load(object sender, EventArgs e)
  60. {
  61. if (ShowType == "AutoShow")
  62. {
  63. if (this.GetRemindCount() <= 0)
  64. {
  65. this.IsShadow = false;
  66. this.Close();
  67. return;
  68. }
  69. this.IsShowUcNavigationTool = false;
  70. }
  71. dt_RemindSet = orbll.GetView_Custom("tb_ErpHospitalRemindSettings", StrWhere: "", ShowColumnName: "Hrs_RemindName,Hrs_RemindDays,Hrs_RemindConditions,Hrs_StartState").Tables[0];
  72. this.datebing.DateValue = SDateTime.Now.ToString("yyyy-MM-dd");
  73. this.dateEnd.DateValue = SDateTime.Now.ToString("yyyy-MM-dd");
  74. this.PublicFunctionRows_Show();
  75. }
  76. /// <summary>
  77. /// 双击事件
  78. /// </summary>
  79. /// <param name="sender"></param>
  80. /// <param name="e"></param>
  81. void dgvRemind_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  82. {
  83. if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
  84. {
  85. if (this.dgvRemind.Rows.Count > 0)
  86. {
  87. if (this.dgvRemind.CurrentRow != null)
  88. {
  89. if (this.dgvRemind.CurrentRow.Index >= 0 && this.dgvRemind.CurrentCell.ColumnIndex >= 0)
  90. {
  91. IntentionsEntered frm = new IntentionsEntered();
  92. if (this.dgvRemind.SelectedRows != null && this.dgvRemind.SelectedRows.Count > 0)
  93. {
  94. frm.StrOrdNumber = this.dgvRemind.CurrentRow.Cells["来单批号"].Value.ToString();
  95. frm.Owner = this;
  96. frm.ShowDialog();
  97. }
  98. }
  99. }
  100. }
  101. }
  102. }
  103. /// <summary>
  104. /// 查看全部按钮
  105. /// </summary>
  106. /// <param name="sender"></param>
  107. /// <param name="e"></param>
  108. void btnWhole_Click(object sender, EventArgs e)
  109. {
  110. this.ucPagerEx1.Visible = false;
  111. this.PublicFunctionRows_Show();
  112. }
  113. /// <summary>
  114. /// 关闭
  115. /// </summary>
  116. /// <param name="sender"></param>
  117. /// <param name="e"></param>
  118. void btnClose_Click(object sender, EventArgs e)
  119. {
  120. if (MessageBoxCustom.Show("你确定要关闭吗?", "关闭提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  121. { this.Close(); }
  122. }
  123. /// <summary>
  124. /// 导出按钮
  125. /// </summary>
  126. /// <param name="sender"></param>
  127. /// <param name="e"></param>
  128. void btnExport_Click(object sender, EventArgs e)
  129. {
  130. if (this.dgvRemind.Rows.Count > 0)
  131. { this.dgvRemind.ExportDataTable(); }
  132. else
  133. {
  134. MessageBoxCustom.Show("没有数据可导出");
  135. return;
  136. }
  137. }
  138. /// <summary>
  139. /// 发短信按钮
  140. /// </summary>
  141. /// <param name="sender"></param>
  142. /// <param name="e"></param>
  143. void btnTexting_Click(object sender, EventArgs e)
  144. {
  145. LYFZ.Software.UI.SMSManagement.SmsSend.FrmSendSms frm = new UI.SMSManagement.SmsSend.FrmSendSms();
  146. if (dgvRemind.SelectedRows == null || dgvRemind.SelectedRows.Count == 0)
  147. { MessageBoxCustom.Show("请选择要发送短信的客人!"); return; }
  148. string Sj1 = "";
  149. string User_Telephone = "";
  150. LYFZ.Software.MainBusiness.SMSManagement.SmsSend.FrmSendSms sendSms = new SMSManagement.SmsSend.FrmSendSms();
  151. for (int i = 0; i < dgvRemind.SelectedRows.Count; i++)
  152. {
  153. User_Telephone = dgvRemind.SelectedRows[i].Cells["本人手机"].Value.ToString();
  154. //检查手机合法性
  155. if (!string.IsNullOrEmpty(User_Telephone))
  156. {
  157. string ret = LYFZ.WinAPI.CustomPublicMethod.ValidationPhones(User_Telephone);
  158. if (ret.Trim().Length <= 0)
  159. { Sj1 += User_Telephone + ","; }
  160. else if (dgvRemind.SelectedRows.Count == 1)
  161. { MessageBoxCustom.Show("手机号无效:" + ret); return; }
  162. }
  163. }
  164. sendSms.Phone = Sj1.Trim(',');
  165. sendSms.ShowDialog();
  166. }
  167. /// <summary>
  168. /// 取消提醒按钮
  169. /// </summary>
  170. /// <param name="sender"></param>
  171. /// <param name="e"></param>
  172. void btnRemind_Click(object sender, EventArgs e)
  173. {
  174. DateTime strTime = SDateTime.Now;
  175. if (dgvRemind.SelectedRows == null || dgvRemind.SelectedRows.Count == 0)
  176. { MessageBoxCustom.Show("请选择要取消提醒的数据!"); }
  177. else
  178. {
  179. if(string.IsNullOrEmpty(dgvRemind.CurrentRow.Cells["ID"].Value.ToString()))
  180. {
  181. MessageBoxCustom.Show("未添加跟踪记录,请添加跟踪记录并设置下次提醒时间");
  182. return;
  183. }
  184. LYFZ.Model.Model_ErpHospitalContactRecord model = ambll.GetModel(Convert.ToInt32(dgvRemind.CurrentRow.Cells["ID"].Value.ToString()));
  185. model.Hcr_RemindTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
  186. model.Hcr_UpdateName = strUserID;
  187. model.Hcr_UpdateDatetime = strTime;
  188. if (ambll.Update(model))
  189. {
  190. MessageBoxCustom.Show("取消提醒成功");
  191. this.PublicFunctionRows_Show();
  192. }
  193. else
  194. { MessageBoxCustom.Show("取消提醒失败"); }
  195. }
  196. }
  197. /// <summary>
  198. /// 查询按钮
  199. /// </summary>
  200. /// <param name="sender"></param>
  201. /// <param name="e"></param>
  202. void btnselect_Click(object sender, EventArgs e)
  203. {
  204. this.ucPagerEx1.Visible = true;
  205. this.PublicFunctionRows_Show();
  206. }
  207. /// <summary>
  208. /// 创建行
  209. /// </summary>
  210. private void PublicFunctionRows_Show()
  211. {
  212. this.ucPagerEx1.PageCurrent = 1;
  213. this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
  214. this.ucPagerEx1.Bind();
  215. }
  216. /// <summary>
  217. /// 分页数据
  218. /// </summary>
  219. /// <param name="e"></param>
  220. /// <returns></returns>
  221. int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
  222. {
  223. #region 获取查询条件
  224. //string StrWhere = "";
  225. //StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("提醒时间查询", this.datebing.DateValue.Trim(), this.dateEnd.DateValue.Trim(), ConnectWord: "");
  226. //if (this.dt_RemindSet.Rows.Count > 0)
  227. //{
  228. // string StrSQL = "";
  229. // DataRow[] dtRow1 = dt_RemindSet.Select("(Hrs_RemindConditions = '0' or Hrs_RemindConditions = '1') And Hrs_StartState = '0' ");
  230. // for (int i = 0; i < dtRow1.Length; i++)
  231. // { StrSQL += dtRow1[i]["Hrs_RemindDays"] + ","; }
  232. // if (!string.IsNullOrEmpty(StrSQL.TrimEnd(',')))
  233. // { StrWhere += " or 宝宝天数 in (" + StrSQL.TrimEnd(',') + ")"; }
  234. //}
  235. //StrWhere = "(" + StrWhere + ")";
  236. #endregion
  237. DataTable dt = new DataTable();
  238. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  239. pageData.TableName = "View_HospitalRemindedToday";
  240. pageData.PageIndex = this.ucPagerEx1.PageCurrent;
  241. pageData.PageSize = this.ucPagerEx1.PageSize;
  242. pageData.QueryCondition = GetWhere(this.datebing.DateValue.Trim(), this.dateEnd.DateValue.Trim());
  243. pageData.QueryFieldName = "ID,来单批号,客户姓名,宝宝姓名,宝宝性别,生日类型,[宝宝生日/预产期],宝宝年龄,宝宝天数,是否农历,怀孕天数,本人手机,老公姓名,老公手机,发送来单短信,喂养方式,客户区域,客户类别,订单客户,业务种类,业务意向,来单医院,门市,备注,录入员,通话时间,通话时长,通话类型,具体事项,通话人员,通话详情,通话方式,提醒时间,提醒时间查询,沟通备注";
  244. pageData.OrderStr = "ID";
  245. pageData.OrderType = 1;
  246. string strHideField = "ID,提醒时间查询";
  247. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  248. {
  249. dt = pageData.QueryDataTable().Tables[0];
  250. });
  251. try
  252. { this.dgvRemind.DataSource(dt, strHideField: strHideField); }
  253. catch
  254. { }
  255. try
  256. {
  257. this.ucPagerEx1.TbDataSource = dt;
  258. }
  259. catch { }
  260. this.dgvRemind.ClearSelection();
  261. return pageData.TotalCount;
  262. }
  263. string GetWhere(string datebing, string dateEnd)
  264. {
  265. string StrWhere = "";
  266. StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("提醒时间查询", datebing, dateEnd, ConnectWord: "");
  267. //StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("提醒时间查询", SDateTime.Now.ToString("yyyy-MM-dd"), SDateTime.Now.ToString("yyyy-MM-dd"), ConnectWord: "");
  268. if (this.dt_RemindSet.Rows.Count > 0)
  269. {
  270. string StrSQL = "";
  271. DataRow[] dtRow1 = dt_RemindSet.Select("(Hrs_RemindConditions = '0' or Hrs_RemindConditions = '1') And Hrs_StartState = '0' ");
  272. for (int i = 0; i < dtRow1.Length; i++)
  273. { StrSQL += dtRow1[i]["Hrs_RemindDays"] + ","; }
  274. if (!string.IsNullOrEmpty(StrSQL.TrimEnd(',')))
  275. { StrWhere += " or 宝宝天数 in (" + StrSQL.TrimEnd(',') + ")"; }
  276. }
  277. StrWhere = "(" + StrWhere + ")";
  278. return StrWhere;
  279. }
  280. int GetRemindCount()
  281. {
  282. //string StrWhere = "";
  283. //StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("提醒时间查询", SDateTime.Now.ToString("yyyy-MM-dd"), SDateTime.Now.ToString("yyyy-MM-dd"), ConnectWord: "");
  284. //if (this.dt_RemindSet.Rows.Count > 0)
  285. //{
  286. // string StrSQL = "";
  287. // DataRow[] dtRow1 = dt_RemindSet.Select("(Hrs_RemindConditions = '0' or Hrs_RemindConditions = '1') And Hrs_StartState = '0' ");
  288. // for (int i = 0; i < dtRow1.Length; i++)
  289. // { StrSQL += dtRow1[i]["Hrs_RemindDays"] + ","; }
  290. // if (!string.IsNullOrEmpty(StrSQL.TrimEnd(',')))
  291. // { StrWhere += " or 宝宝天数 in (" + StrSQL.TrimEnd(',') + ")"; }
  292. //}
  293. //StrWhere = "(" + StrWhere + ")";
  294. DataTable dt = orbll.GetView_Custom("View_HospitalRemindedToday", StrWhere: GetWhere(SDateTime.Now.ToString("yyyy-MM-dd"), SDateTime.Now.ToString("yyyy-MM-dd")), ShowColumnName: "Count(*) AS CountID").Tables[0];
  295. return Convert.ToInt32(dt.Rows[0]["CountID"]);
  296. }
  297. }
  298. }