IntentionRemind.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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.Customers
  10. {
  11. public partial class IntentionRemind : LYFZ.Software.UI.Customers.IntentionRemind
  12. {
  13. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  14. public IntentionRemind()
  15. {
  16. this.UcNavigationTool.LabTitle = "今日提醒";
  17. this.Load += IntentionRemind_Load;
  18. this.Shown += IntentionRemind_Shown;
  19. this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
  20. this.btnSelect.Click += btnSelect_Click;
  21. this.btnAll.Click += btnAll_Click;
  22. this.btnCancel.Click += btnCancel_Click;
  23. this.btnClose.Click += btnClose_Click;
  24. this.btnSMS.Click += btnSMS_Click;
  25. this.btnRemind.Click += btnRemind_Click;
  26. this.btnRemind.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TodayRemindedCustomerCompetence, LYFZ.CustomAttributes.OperatingAuthority.RemindedSet );
  27. this.btnCancel.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TodayRemindedCustomerCompetence, LYFZ.CustomAttributes.OperatingAuthority.CancelRemindedSet );
  28. this.btnSMS.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TodayRemindedCustomerCompetence, LYFZ.CustomAttributes.OperatingAuthority.SMSSend );
  29. this.dgvData.CellDoubleClick += dgvData_CellDoubleClick;
  30. }
  31. public IntentionRemind( string p )
  32. : this()
  33. {
  34. ShowType = p;
  35. }
  36. /// <summary>
  37. /// 是否弹屏提示:“AutoShow” 为判断
  38. /// </summary>
  39. string ShowType = "";
  40. /// <summary>
  41. /// 窗体加载事件
  42. /// </summary>
  43. /// <param name="sender"></param>
  44. /// <param name="e"></param>
  45. void IntentionRemind_Load( object sender, EventArgs e )
  46. {
  47. if ( ShowType == "AutoShow" )
  48. {
  49. if ( this.GetRemindCount() <= 0 )
  50. {
  51. this.IsShadow = false;
  52. this.Close();
  53. return;
  54. }
  55. this.IsShowUcNavigationTool = false;
  56. }
  57. }
  58. /// <summary>
  59. /// 窗体加载事件
  60. /// </summary>
  61. /// <param name="sender"></param>
  62. /// <param name="e"></param>
  63. void IntentionRemind_Shown( object sender, EventArgs e )
  64. {
  65. this.dateStart.DateValue = SDateTime.Now.ToString( "yyyy-MM-dd" );
  66. this.dateFinish.DateValue = this.dateStart.DateValue;
  67. this.ucPagerEx1.Bind();
  68. }
  69. /// <summary>
  70. /// 列表双击事件
  71. /// </summary>
  72. /// <param name="sender"></param>
  73. /// <param name="e"></param>
  74. void dgvData_CellDoubleClick( object sender, DataGridViewCellEventArgs e )
  75. {
  76. if ( e.RowIndex >= 0 && e.ColumnIndex >= 0 )
  77. {
  78. if ( this.dgvData.Rows.Count > 0 )
  79. {
  80. if ( this.dgvData.CurrentRow != null )
  81. {
  82. if ( this.dgvData.CurrentRow.Index >= 0 && this.dgvData.CurrentCell.RowIndex >= 0 )
  83. {
  84. bool bitemEnum = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(
  85. LYFZ.Software.MainBusiness.VersionControl.VersionFunctionEnum.客户管理沟通再次提醒
  86. , false );
  87. if ( bitemEnum )
  88. {
  89. LYFZ.Software.MainBusiness.Customers.OldCustomer.FrmAddInterestedBuyers frm = new OldCustomer.FrmAddInterestedBuyers();
  90. frm.GMID = this.dgvData.CurrentRow.Cells["客户组ID"].Value.ToString().Trim();
  91. if ( frm.ShowDialog() == DialogResult.OK )
  92. {
  93. this.Bind();
  94. }
  95. }
  96. }
  97. }
  98. }
  99. }
  100. }
  101. /// <summary>
  102. /// 提醒设置按钮
  103. /// </summary>
  104. /// <param name="sender"></param>
  105. /// <param name="e"></param>
  106. void btnRemind_Click( object sender, EventArgs e )
  107. {
  108. LYFZ.Software.MainBusiness.HospitalTrackingSystem.RemindSet frm = new HospitalTrackingSystem.RemindSet();
  109. frm.StrRemindSetLoadType = HospitalTrackingSystem.RemindSet.RemindSetLoadType.客户管理今日提醒;
  110. frm.ShowDialog();
  111. }
  112. /// <summary>
  113. /// 发信息按钮
  114. /// </summary>
  115. void btnSMS_Click( object sender, EventArgs e )
  116. {
  117. try
  118. {
  119. string Cus_Telephone = "";
  120. string Sj1 = "";
  121. LYFZ.Software.MainBusiness.SMSManagement.SmsSend.FrmSendSms set = new SMSManagement.SmsSend.FrmSendSms();
  122. if ( this.dgvData.SelectedRows.Count == 0 )
  123. {
  124. MessageBoxCustom.Show( "选择你要发送短信的客户!" ); return;
  125. }
  126. for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ )
  127. {
  128. Cus_Telephone = this.dgvData.SelectedRows[i].Cells["客户电话"].Value.ToString();
  129. //检查手机合法性
  130. if ( !string.IsNullOrEmpty( Cus_Telephone ) )
  131. {
  132. Sj1 += Cus_Telephone + ",";
  133. }
  134. }
  135. set.Phone = Sj1;
  136. set.ShowDialog();
  137. }
  138. catch ( Exception ex )
  139. {
  140. MessageBoxCustom.Show( ex.Message );
  141. }
  142. }
  143. /// <summary>
  144. /// 查看全部 判断使用
  145. /// </summary>
  146. bool selectAll = false;
  147. /// <summary>
  148. /// 关闭 按钮
  149. /// </summary>
  150. /// <param name="sender"></param>
  151. /// <param name="e"></param>
  152. void btnClose_Click( object sender, EventArgs e )
  153. {
  154. this.Close();
  155. }
  156. /// <summary>
  157. /// 取消提醒 按钮
  158. /// </summary>
  159. /// <param name="sender"></param>
  160. /// <param name="e"></param>
  161. void btnCancel_Click( object sender, EventArgs e )
  162. {
  163. if ( dgvData.SelectedRows.Count > 0 )
  164. {
  165. if ( MessageBoxCustom.Show( "确定取消?", "提示信息!", MessageBoxButtons.YesNo ) == DialogResult.Yes )
  166. {
  167. BLL.BLL_ErpCustomerGroup bll = new BLL.BLL_ErpCustomerGroup();
  168. Model.Model_ErpCustomerGroup model = bll.GetModel( "GP_CustomerGroupID", this.dgvData.CurrentRow.Cells["客户组ID"].Value.ToString() );
  169. model.GP_ReminderTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
  170. model.GP_RemindEvent = "";
  171. if ( bll.Update( model ) )
  172. {
  173. MessageBoxCustom.Show( "取消成功!" ); Bind();
  174. }
  175. else
  176. {
  177. MessageBoxCustom.Show( "取消失败!" );
  178. }
  179. }
  180. }
  181. else
  182. {
  183. MessageBoxCustom.Show( "请选中要取消提醒的行!" );
  184. }
  185. }
  186. /// <summary>
  187. /// 全部查看 按钮
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. void btnAll_Click( object sender, EventArgs e )
  192. {
  193. this.dateStart.DateValue = "";
  194. this.dateFinish.DateValue = "";
  195. this.selectAll = true;
  196. this.Bind();
  197. }
  198. /// <summary>
  199. /// 查询按钮
  200. /// </summary>
  201. /// <param name="sender"></param>
  202. /// <param name="e"></param>
  203. void btnSelect_Click( object sender, EventArgs e )
  204. {
  205. if ( this.dateFinish.DateValue != "" && this.dateStart.DateValue != "" && this.dateFinish.DateValue != this.dateStart.DateValue )
  206. {
  207. this.selectAll = false;
  208. if ( DateTime.Compare( this.dateFinish.Value, this.dateStart.Value ) > 0 )
  209. {
  210. this.Bind();
  211. }
  212. else
  213. {
  214. MessageBoxCustom.Show( "第二个时间比第一个小,不能查询!" );
  215. }
  216. }
  217. else
  218. {
  219. // 如果没有选择时间,默认查询全部;
  220. this.selectAll = true;
  221. this.Bind();
  222. }
  223. }
  224. /// <summary>
  225. /// 刷新事件
  226. /// </summary>
  227. public void Bind()
  228. {
  229. this.ucPagerEx1.PageCurrent = 1;
  230. this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
  231. this.ucPagerEx1.Bind();
  232. }
  233. /// <summary>
  234. /// 画分页
  235. /// </summary>
  236. /// <param name="e"></param>
  237. /// <returns></returns>
  238. int ucPagerEx1_EventPaging( UCPager.EventPagingArg e )
  239. {
  240. #region 获取条件
  241. string StrSQL = "";
  242. DataTable dthrs = orbll.GetView_Custom( "tb_ErpHospitalRemindSettings", StrWhere: "Hrs_RemindConditions in (0, 2, 3, 4) and Hrs_StartState='0'", ShowColumnName: "Hrs_RemindDays,Hrs_RemindConditions" ).Tables[0];
  243. if ( dthrs.Rows.Count > 0 )
  244. {
  245. string StrNewSQl = "";
  246. #region 新添加宝宝生日满x天的提醒;
  247. DataRow[] dtRow0 = dthrs.Select( "Hrs_RemindConditions = 0" );
  248. for ( int i = 0; i < dtRow0.Length; i++ )
  249. {
  250. StrNewSQl += dtRow0[i]["Hrs_RemindDays"].ToString() + ",";
  251. }
  252. if ( !string.IsNullOrEmpty( StrNewSQl ) )
  253. {
  254. StrSQL += "(距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '出生满天提醒')";
  255. }
  256. #endregion
  257. StrNewSQl = "";
  258. DataRow[] dtRow1 = dthrs.Select( "Hrs_RemindConditions = 2" );
  259. for ( int i = 0; i < dtRow1.Length; i++ )
  260. {
  261. StrNewSQl += dtRow1[i]["Hrs_RemindDays"].ToString() + ",";
  262. }
  263. if ( !string.IsNullOrEmpty( StrNewSQl ) )
  264. {
  265. if ( !string.IsNullOrEmpty( StrSQL ) )
  266. StrSQL += "or (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '生日提醒')";
  267. else
  268. StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '生日提醒')";
  269. }
  270. StrNewSQl = "";
  271. DataRow[] dtRow2 = dthrs.Select( "Hrs_RemindConditions = 3" );
  272. for ( int i = 0; i < dtRow2.Length; i++ )
  273. {
  274. StrNewSQl += dtRow2[i]["Hrs_RemindDays"].ToString() + ",";
  275. }
  276. if ( !string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
  277. {
  278. StrSQL += " or (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '婚庆提醒')";
  279. }
  280. else if ( string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
  281. {
  282. StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '婚庆提醒')";
  283. }
  284. StrNewSQl = "";
  285. DataRow[] dtRow3 = dthrs.Select( "Hrs_RemindConditions = 4" );
  286. for ( int i = 0; i < dtRow3.Length; i++ )
  287. {
  288. StrNewSQl += dtRow3[i]["Hrs_RemindDays"].ToString() + ",";
  289. }
  290. if ( !string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
  291. {
  292. StrSQL += " or (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '结婚纪念提醒')";
  293. }
  294. else if ( string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
  295. {
  296. StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '结婚纪念提醒')";
  297. }
  298. }
  299. if ( !selectAll )
  300. {
  301. if ( !string.IsNullOrEmpty( StrSQL ) )
  302. {
  303. StrSQL += " or ";
  304. }
  305. if ( this.dateStart.DateValue == null )
  306. StrSQL += "( And 提醒类别 = '指定提醒')";
  307. else
  308. StrSQL += " (" + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime( "convert(datetime,提醒时间,120)", this.dateStart.DateValue, this.dateFinish.DateValue, ConnectWord: "" ) + " And 提醒类别 = '指定提醒')";
  309. }
  310. #endregion
  311. DataTable dt = new DataTable();
  312. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  313. pageData.TableName = "view_OldRemind";
  314. pageData.PageIndex = this.ucPagerEx1.PageCurrent;
  315. pageData.PageSize = this.ucPagerEx1.PageSize;
  316. pageData.QueryCondition = StrSQL;
  317. pageData.QueryFieldName = "客户姓名,客户性别,客户生日,客户婚期,客户电话,客户QQ,所在区域,地址,工作单位,客户来源,提醒时间,提醒事项,客户组ID,距离提醒,提醒类别";
  318. pageData.OrderStr = "提醒时间";
  319. pageData.OrderType = 1;
  320. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
  321. {
  322. dt = pageData.QueryDataTable().Tables[0];
  323. } );
  324. try
  325. {
  326. this.dgvData.DataSource( dt, strHideField: "客户组ID,距离提醒" );
  327. }
  328. catch
  329. {
  330. }
  331. try
  332. {
  333. this.ucPagerEx1.TbDataSource = dt;
  334. this.dgvData.ClearSelection();
  335. //this.selectAll = false;
  336. }
  337. catch { }
  338. return pageData.TotalCount;
  339. }
  340. int GetRemindCount()
  341. {
  342. string StrSQL = "";
  343. DataTable dthrs = orbll.GetView_Custom( "tb_ErpHospitalRemindSettings", StrWhere: "Hrs_RemindConditions in (0, 2, 3, 4) and Hrs_StartState='0'", ShowColumnName: "Hrs_RemindDays,Hrs_RemindConditions" ).Tables[0];
  344. if ( dthrs.Rows.Count > 0 )
  345. {
  346. string StrNewSQl = "";
  347. #region 新添加宝宝生日满x天的提醒;
  348. DataRow[] dtRow0 = dthrs.Select( "Hrs_RemindConditions = 0" );
  349. for ( int i = 0; i < dtRow0.Length; i++ )
  350. {
  351. StrNewSQl += dtRow0[i]["Hrs_RemindDays"].ToString() + ",";
  352. }
  353. if ( !string.IsNullOrEmpty( StrNewSQl ) )
  354. {
  355. StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '出生满天提醒')";
  356. }
  357. #endregion
  358. StrNewSQl = "";
  359. DataRow[] dtRow1 = dthrs.Select( "Hrs_RemindConditions = 2" );
  360. for ( int i = 0; i < dtRow1.Length; i++ )
  361. {
  362. StrNewSQl += dtRow1[i]["Hrs_RemindDays"].ToString() + ",";
  363. }
  364. if ( !string.IsNullOrEmpty( StrNewSQl ) )
  365. {
  366. if(!string.IsNullOrEmpty(StrSQL))
  367. {
  368. StrSQL += " or ";
  369. }
  370. StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '生日提醒')";
  371. }
  372. StrNewSQl = "";
  373. DataRow[] dtRow2 = dthrs.Select( "Hrs_RemindConditions = 3" );
  374. for ( int i = 0; i < dtRow2.Length; i++ )
  375. {
  376. StrNewSQl += dtRow2[i]["Hrs_RemindDays"].ToString() + ",";
  377. }
  378. if ( !string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
  379. {
  380. StrSQL += " or (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '婚庆提醒')";
  381. }
  382. else if ( string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
  383. {
  384. StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '婚庆提醒')";
  385. }
  386. StrNewSQl = "";
  387. DataRow[] dtRow3 = dthrs.Select( "Hrs_RemindConditions = 4" );
  388. for ( int i = 0; i < dtRow3.Length; i++ )
  389. {
  390. StrNewSQl += dtRow3[i]["Hrs_RemindDays"].ToString() + ",";
  391. }
  392. if ( !string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
  393. {
  394. StrSQL += " or (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '结婚纪念提醒')";
  395. }
  396. else if ( string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
  397. {
  398. StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '结婚纪念提醒')";
  399. }
  400. }
  401. if ( !string.IsNullOrEmpty( StrSQL ) )
  402. {
  403. StrSQL += " or ";
  404. }
  405. StrSQL += " (" + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime( "convert(datetime,提醒时间,120)", SDateTime.Now.ToString( "yyyy-MM-dd" ), SDateTime.Now.ToString( "yyyy-MM-dd" ), ConnectWord: "" ) + " And 提醒类别 = '指定提醒')";
  406. DataTable dt = orbll.GetView_Custom( "view_OldRemind", StrWhere: StrSQL, ShowColumnName: "Count(*) AS CountID" ).Tables[0];
  407. return Convert.ToInt32( dt.Rows[0]["CountID"] );
  408. }
  409. }
  410. }