FrmSendRecords.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. using LYFZ.ComponentLibrary;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. namespace LYFZ.Software.MainBusiness.SMSManagement
  11. {
  12. public partial class FrmSendRecords : LYFZ.Software.UI.SMSManagement.FrmSendRecords
  13. {
  14. private delegate void UpdateControl();
  15. public FrmSendRecords()
  16. {
  17. this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
  18. this.Shown+=FrmSendRecords_Shown;
  19. this.btnClose.Click+=btnClose_Click;
  20. this.btnRefresh.Click+=btnRefresh_Click;
  21. this.btnDelete.Click+=btnDelete_Click;
  22. this.btnExport.Click+=btnExport_Click;
  23. this.btnNewSend.Click += btnNewSend_Click;
  24. this.dgv.CellDoubleClick += dgv_CellDoubleClick;
  25. this.tabControlEx1.SelectedIndexChanged += tabControlEx1_SelectedIndexChanged;
  26. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SendRecordsCompetence, CustomAttributes.OperatingAuthority.SMSResendSend))
  27. {
  28. this.btnNewSend.Enabled = true;
  29. this.btnResendMicro.Enabled = true;
  30. }
  31. else
  32. {
  33. this.btnNewSend.Enabled = false;
  34. this.btnResendMicro.Enabled = false;
  35. }
  36. #region 删除
  37. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SendRecordsCompetence, CustomAttributes.OperatingAuthority.Delete))
  38. {
  39. btnDelete.Enabled = true;
  40. this.btnDeleteMicro.Enabled = true;
  41. }
  42. else
  43. {
  44. btnDelete.Enabled = false;
  45. this.btnDeleteMicro.Enabled = false;
  46. }
  47. #endregion
  48. #region 导出
  49. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SendRecordsCompetence, CustomAttributes.OperatingAuthority.DataExport))
  50. {
  51. btnExport.Enabled = true;
  52. this.btnExpordMicro.Enabled = true;
  53. }
  54. else
  55. {
  56. btnExport.Enabled = false;
  57. this.btnExpordMicro.Enabled = true;
  58. }
  59. #endregion
  60. this.ucPagerEx2.EventPaging += ucPagerEx2_EventPaging;
  61. this.btnQueryMicro.Click += btnQueryMicro_Click;
  62. this.btnExpordMicro.Click += btnExpordMicro_Click;
  63. this.btnCloseMicro.Click += btnCloseMicro_Click;
  64. this.btnDeleteMicro.Click += btnDeleteMicro_Click;
  65. this.btnResendMicro.Click += btnResendMicro_Click;
  66. this.dgvMicroletter.CellDoubleClick += dgvMicroletter_CellDoubleClick;
  67. }
  68. void dgvMicroletter_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  69. {
  70. if (dgvMicroletter.Rows.Count > 0 && dgvMicroletter.CurrentRow != null && e.ColumnIndex >= 0 && e.RowIndex >= 0)
  71. {
  72. LYFZ.Software.MainBusiness.SMSManagement.SendRecords.FrmSMSContent set = new SendRecords.FrmSMSContent();
  73. LYFZ.Model.Model_SMSRecord model = (LYFZ.Model.Model_SMSRecord)dgvMicroletter.CurrentRow.Tag;
  74. if (e.ColumnIndex == 6)
  75. {
  76. set.Text = "模板消息发送日志";
  77. set.Content = model.SR_SendReport + "\r\n" + model.SR_SendLogs;
  78. }
  79. else
  80. {
  81. // string Smsr_Content = dgv.CurrentRow.Cells["Smsr_Content"].Value.ToString();
  82. set.Text = "推送消息内容预览";
  83. set.Content = MessageContentPreview(model);
  84. }
  85. set.ShowDialog();
  86. }
  87. }
  88. /// <summary>
  89. /// 获取推送消息预览内容
  90. /// </summary>
  91. /// <param name="model"></param>
  92. /// <returns></returns>
  93. string MessageContentPreview(LYFZ.Model.Model_SMSRecord model)
  94. {
  95. string retInfo = "";
  96. retInfo = model.SR_Content;
  97. return retInfo;
  98. }
  99. void btnResendMicro_Click(object sender, EventArgs e)
  100. {
  101. try
  102. {
  103. if (this.dgvMicroletter.SelectedRows.Count <= 0)
  104. {
  105. MessageBoxCustom.Show("请选中你要重发的消息记录!");
  106. return;
  107. }
  108. if (MessageBoxCustom.Show("你确定要重发选中的消息记录吗?", "重发提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  109. {
  110. List<LYFZ.Model.Model_SMSRecord> modelList = new List<Model.Model_SMSRecord>();
  111. foreach (DataGridViewRow row in this.dgvMicroletter.SelectedRows)
  112. {
  113. if (row.Tag != null)
  114. {
  115. LYFZ.Model.Model_SMSRecord model = (LYFZ.Model.Model_SMSRecord)row.Tag;
  116. if (model.SR_Status != 100 && model.SR_Status != 0)
  117. {
  118. modelList.Add(model);
  119. }
  120. }
  121. }
  122. bool sendOK = true;
  123. if (modelList.Count <= 0)
  124. {
  125. MessageBoxCustom.Show("您选中的消息记录没有需要重新发送的记录!发送中 和 等待发送的消息不需要重新发送");
  126. return;
  127. }
  128. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  129. {
  130. foreach (LYFZ.Model.Model_SMSRecord model in modelList)
  131. {
  132. model.SR_Status = (int)EnumPublic.SmsSendStatus.等待发送;
  133. model.SR_SendReport = "手动重发中...";
  134. model.SR_SendLogs = "手动重发/" + model.SR_SendLogs;
  135. model.SR_StartSendDatetime = SDateTime.Now;
  136. if (!this.bllSR.Update(model))
  137. {
  138. sendOK = false;
  139. return;
  140. }
  141. }
  142. });
  143. if (sendOK)
  144. {
  145. MessageBoxCustom.Show("已标记为重发,稍后系统将重新发送消息");
  146. this.Invoke(new UpdateControl(delegate()
  147. {
  148. bindMicro();
  149. }));
  150. }
  151. else
  152. {
  153. MessageBoxCustom.Show("标记为重发失败,请重启软件后重试。");
  154. }
  155. }
  156. }
  157. catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
  158. }
  159. void btnDeleteMicro_Click(object sender, EventArgs e)
  160. {
  161. try
  162. {
  163. if (this.dgvMicroletter.SelectedRows.Count <= 0)
  164. {
  165. MessageBoxCustom.Show("请选中你要删除的数据!");
  166. return;
  167. }
  168. if (MessageBoxCustom.Show("你确定要删除选择的消息记录吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  169. {
  170. string delSmsIDStr = "";
  171. foreach (DataGridViewRow row in this.dgvMicroletter.SelectedRows)
  172. {
  173. if (row.Tag != null)
  174. {
  175. LYFZ.Model.Model_SMSRecord model = (LYFZ.Model.Model_SMSRecord)row.Tag;
  176. if (model.SR_Status != 100)
  177. {
  178. delSmsIDStr += model.ID.ToString() + ",";
  179. }
  180. else
  181. {
  182. MessageBoxCustom.Show(EnumPublic.SmsSendStatus.发送中.ToString() + "的消息不能删除!");
  183. return;
  184. }
  185. }
  186. }
  187. int delCount = this.dgvMicroletter.SelectedRows.Count;
  188. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  189. {
  190. if (bllSR.DeleteList(delSmsIDStr.Trim().Trim(',')))
  191. {
  192. #region 写入操作日志
  193. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除模板消息记录, "删除" + delCount.ToString() + "条模板消息记录 ", LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  194. #endregion
  195. MessageBoxCustom.Show("删除成功!");
  196. this.Invoke(new UpdateControl(delegate()
  197. {
  198. bindMicro();
  199. }));
  200. }
  201. else { MessageBoxCustom.Show("删除失败!"); }
  202. });
  203. }
  204. }
  205. catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
  206. }
  207. void btnCloseMicro_Click(object sender, EventArgs e)
  208. {
  209. this.Close();
  210. }
  211. void btnExpordMicro_Click(object sender, EventArgs e)
  212. {
  213. this.dgvMicroletter.ExportDataTable();
  214. }
  215. void btnQueryMicro_Click(object sender, EventArgs e)
  216. {
  217. try
  218. {
  219. bindMicro();
  220. }
  221. catch (Exception ex)
  222. {
  223. MessageBoxCustom.Show(ex.Message);
  224. }
  225. }
  226. void tabControlEx1_SelectedIndexChanged(object sender, EventArgs e)
  227. {
  228. if (this.tabControlEx1.SelectedIndex == 1)
  229. {
  230. if (this.dgvMicroletter.Rows.Count <= 0)
  231. {
  232. bindMicro();
  233. }
  234. }
  235. }
  236. int ucPagerEx2_EventPaging(UCPager.EventPagingArg e)
  237. {
  238. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  239. dgvMicroletter.DataSource = null;
  240. DataTable dt = new DataTable();
  241. string whereStr = " [SR_SendChannel]=1 ";
  242. if (txtKeyWordMicro.Text.Trim().Length > 0)
  243. {
  244. whereStr = " [SR_SendChannel]=1 and ([SR_RecipientNumber] like '%" + txtKeyWordMicro.Text.Trim() + "%' or [SR_Content] like '%" + txtKeyWordMicro.Text.Trim() + "%') ";
  245. }
  246. this.dgvMicroletter.Rows.Clear();
  247. List<LYFZ.Model.Model_SMSRecord> modelList = new List<LYFZ.Model.Model_SMSRecord>();
  248. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  249. {
  250. pageData.TableName = "tb_SMSRecords";
  251. pageData.PageIndex = this.ucPagerEx2.PageCurrent;
  252. pageData.PageSize = this.ucPagerEx2.PageSize;
  253. pageData.QueryCondition = whereStr + " and SR_DividedShop='" + LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID.Trim() + "'";
  254. pageData.QueryFieldName = "[id]"
  255. + " ,[SR_SendChannel]"
  256. + " ,[SR_Type]"
  257. + " ,[SR_SendEvent]"
  258. + " ,[SR_SMSGenerateIdentity]"
  259. + " ,[SR_SMSSendIdentity]"
  260. + " ,[SR_RecipientNumber]"
  261. + " ,[SR_Content]"
  262. + " ,[SR_StartSendDatetime]"
  263. + " ,[SR_SendSumCount]"
  264. + " ,[SR_Status]"
  265. + " ,[SR_SendLogs]"
  266. + " ,[SR_SendReport]"
  267. + " ,[SR_CreateDatetime]"
  268. + " ,[SR_SendDatetime]"
  269. + " ,[SR_SMSSendSender]";
  270. pageData.OrderStr = " ID desc ";
  271. DataSet da = pageData.QueryDataTable();
  272. dt = da.Tables[0];
  273. if (dt.Rows.Count > 0)
  274. {
  275. for (int t = 0; t < dt.Rows.Count; t++)
  276. {
  277. modelList.Add(bllSR.DataRowToModel(dt.Rows[t]));
  278. }
  279. }
  280. });
  281. if (dt.Rows.Count > 0)
  282. {
  283. foreach (LYFZ.Model.Model_SMSRecord model in modelList)
  284. {
  285. DataGridViewRow row = new DataGridViewRow();
  286. row.CreateCells(this.dgvMicroletter);
  287. row.Cells[0].Value = model.SR_RecipientNumber;//客户名字
  288. try
  289. {
  290. row.Cells[1].Value = ((LYFZ.EnumPublic.MicroTemplate)model.SR_SendSumCount).ToString();//模板标识
  291. }
  292. catch
  293. {
  294. row.Cells[1].Value = "未知模板";
  295. }
  296. row.Cells[2].Value = MessageContentPreview(model); //model.SR_Content;//发送消息预览
  297. row.Cells[3].Value = model.SR_StartSendDatetime.ToString("yyyy-MM-dd HH:mm");
  298. if (model.SR_SendDatetime > LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime())
  299. {
  300. row.Cells[4].Value = model.SR_SendDatetime.ToString("yyyy-MM-dd HH:mm");
  301. }
  302. row.Cells[5].Value = ((EnumPublic.SmsSendStatus)model.SR_Status).ToString();
  303. if (model.SR_Status == 3)
  304. {
  305. row.Cells[5].Value = (EnumPublic.SmsSendStatus.忽略发送).ToString();
  306. }
  307. row.Cells[6].Value = model.SR_SendReport;
  308. row.Cells[7].Value = model.SR_SMSSendSender;
  309. row.Cells[8].Value = model.SR_CreateDatetime.ToString("yyyy-MM-dd HH:mm:ss");
  310. row.Tag = model;
  311. this.dgvMicroletter.Rows.Add(row);
  312. }
  313. dgvMicroletter.ClearSelection();
  314. }
  315. try
  316. {
  317. this.ucPagerEx2.TbDataSource = dt;
  318. }
  319. catch { }
  320. return pageData.TotalCount;
  321. }
  322. /// <summary>
  323. /// 邦定微信模板消息发送记录
  324. /// </summary>
  325. public void bindMicro()
  326. {
  327. this.ucPagerEx2.PageCurrent = 1;
  328. this.ucPagerEx2.PageSize = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ReportFormPageSize; //3;分页条数
  329. this.ucPagerEx2.Bind();
  330. }
  331. void dgv_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  332. {
  333. if (dgv.Rows.Count > 0 && dgv.CurrentRow != null && e.ColumnIndex>=0&&e.RowIndex>=0)
  334. {
  335. LYFZ.Software.MainBusiness.SMSManagement.SendRecords.FrmSMSContent set = new SendRecords.FrmSMSContent();
  336. if (e.ColumnIndex == 6)
  337. {
  338. LYFZ.Model.Model_SMSRecord model = (LYFZ.Model.Model_SMSRecord)dgv.CurrentRow.Tag;
  339. set.Text = "短信发送日志";
  340. set.Content =model.SR_SendReport+"\r\n" +model.SR_SendLogs;
  341. }
  342. else {
  343. string Smsr_Content = dgv.CurrentRow.Cells["Smsr_Content"].Value.ToString();
  344. set.Text = "短信内容";
  345. set.Content = Smsr_Content;
  346. }
  347. set.ShowDialog();
  348. }
  349. }
  350. void btnNewSend_Click(object sender, EventArgs e)
  351. {
  352. try
  353. {
  354. if (this.dgv.SelectedRows.Count <= 0)
  355. {
  356. MessageBoxCustom.Show("请选中你要重发的短信记录!");
  357. return;
  358. }
  359. if (MessageBoxCustom.Show("你确定要重发选中的短信记录吗?", "重发提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  360. {
  361. List<LYFZ.Model.Model_SMSRecord> modelList = new List<Model.Model_SMSRecord>();
  362. foreach (DataGridViewRow row in this.dgv.SelectedRows)
  363. {
  364. if (row.Tag != null)
  365. {
  366. LYFZ.Model.Model_SMSRecord model = (LYFZ.Model.Model_SMSRecord)row.Tag;
  367. if (model.SR_Status != 100 && model.SR_Status != 0)
  368. {
  369. modelList.Add(model);
  370. }
  371. }
  372. }
  373. bool sendOK = true;
  374. if (modelList.Count <= 0)
  375. {
  376. MessageBoxCustom.Show("您选中的短信记录没有需要重新发送的记录!发送中 和 等待发送的短信不需要重新发送");
  377. return;
  378. }
  379. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  380. {
  381. foreach (LYFZ.Model.Model_SMSRecord model in modelList)
  382. {
  383. model.SR_Status = (int)EnumPublic.SmsSendStatus.等待发送;
  384. model.SR_SendReport = "手动重发中...";
  385. model.SR_SendLogs = "手动重发/" + model.SR_SendLogs;
  386. model.SR_StartSendDatetime = SDateTime.Now;
  387. if (!this.bllSR.Update(model)) {
  388. sendOK = false;
  389. return;
  390. }
  391. }
  392. });
  393. if (sendOK)
  394. {
  395. MessageBoxCustom.Show("已标记为重发,稍后系统将重新发送短信");
  396. this.Invoke(new UpdateControl(delegate()
  397. {
  398. bind();
  399. }));
  400. }
  401. else {
  402. MessageBoxCustom.Show("标记为重发失败,请重启软件后重试。");
  403. }
  404. }
  405. }
  406. catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
  407. }
  408. #region 加载
  409. protected void FrmSendRecords_Shown(object sender, EventArgs e)
  410. {
  411. List<Control> hideControl = new List<Control>();
  412. //LYFZSS.SystemSpecterPossessed.ISystemSpecterPossessed.GetMySystemSpecter = LYFZSS.SystemSpecterType.SST_D;
  413. bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(
  414. VersionControl.VersionFunctionEnum.短信管理微信短信推送, hideControl, null, null);
  415. if (!b)
  416. {
  417. if (tabControlEx1.TabPages.Count > 1)
  418. {
  419. tabControlEx1.TabPages.Remove(tabControlEx1.TabPages[1]);
  420. }
  421. }
  422. try
  423. {
  424. bind();
  425. }
  426. catch (Exception ex)
  427. {
  428. MessageBoxCustom.Show(ex.Message);
  429. }
  430. }
  431. public void bind()
  432. {
  433. this.ucPagerEx1.PageCurrent = 1;
  434. this.ucPagerEx1.PageSize = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ReportFormPageSize; //3;分页条数
  435. this.ucPagerEx1.Bind();
  436. }
  437. #endregion
  438. #region 刷新
  439. protected void btnRefresh_Click(object sender, EventArgs e)
  440. {
  441. try
  442. {
  443. bind();
  444. }
  445. catch (Exception ex)
  446. {
  447. MessageBoxCustom.Show(ex.Message);
  448. }
  449. }
  450. #endregion
  451. #region 关闭
  452. protected void btnClose_Click(object sender, EventArgs e)
  453. {
  454. this.Close();
  455. }
  456. #endregion
  457. LYFZ.BLL.BLL_SMSRecord bllSR = new BLL.BLL_SMSRecord();
  458. #region 删除
  459. protected void btnDelete_Click(object sender, EventArgs e)
  460. {
  461. try
  462. {
  463. if (this.dgv.SelectedRows.Count <= 0)
  464. {
  465. MessageBoxCustom.Show("请选中你要删除的数据!");
  466. return;
  467. }
  468. if (MessageBoxCustom.Show("你确定要删除选择的短信记录吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  469. {
  470. string delSmsIDStr = "";
  471. foreach (DataGridViewRow row in this.dgv.SelectedRows)
  472. {
  473. if (row.Tag != null)
  474. {
  475. LYFZ.Model.Model_SMSRecord model = (LYFZ.Model.Model_SMSRecord)row.Tag;
  476. if (model.SR_Status != 100)
  477. {
  478. delSmsIDStr += model.ID.ToString() + ",";
  479. }
  480. else {
  481. MessageBoxCustom.Show(EnumPublic.SmsSendStatus.发送中.ToString()+"的短信不能删除!");
  482. return;
  483. }
  484. }
  485. }
  486. int delCount = this.dgv.SelectedRows.Count;
  487. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  488. {
  489. if (bllSR.DeleteList(delSmsIDStr.Trim().Trim(',')))
  490. {
  491. #region 写入操作日志
  492. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除短信记录, "删除" + delCount.ToString() + "条短信记录 ", LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  493. #endregion
  494. MessageBoxCustom.Show("删除成功!");
  495. bind();
  496. }
  497. else { MessageBoxCustom.Show("删除失败!"); }
  498. });
  499. }
  500. }
  501. catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
  502. }
  503. #endregion
  504. #region 导出
  505. protected void btnExport_Click(object sender, EventArgs e)
  506. {
  507. this.dgv.ExportDataTable();
  508. }
  509. #endregion
  510. #region 画分页
  511. /// <summary>
  512. /// 画分页
  513. /// </summary>
  514. /// <param name="e"></param>
  515. /// <returns></returns>
  516. private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
  517. {
  518. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  519. dgv.DataSource = null;
  520. DataTable dt = new DataTable();
  521. string whereStr = " [SR_SendChannel]=0 ";
  522. if (txtKeyword.Text.Trim().Length > 0) {
  523. whereStr = " [SR_SendChannel]=0 and ([SR_RecipientNumber] like '%" + txtKeyword.Text.Trim() + "%' or [SR_Content] like '%" + txtKeyword.Text.Trim() + "%') ";
  524. }
  525. this.dgv.Rows.Clear();
  526. List<LYFZ.Model.Model_SMSRecord> modelList=new List<LYFZ.Model.Model_SMSRecord>();
  527. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  528. {
  529. pageData.TableName = "tb_SMSRecords";
  530. pageData.PageIndex = this.ucPagerEx1.PageCurrent;
  531. pageData.PageSize = this.ucPagerEx1.PageSize;
  532. pageData.QueryCondition = whereStr + " and SR_DividedShop='" + LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID.Trim() + "'";
  533. pageData.QueryFieldName = "[id]"
  534. +" ,[SR_SendChannel]"
  535. +" ,[SR_Type]"
  536. +" ,[SR_SendEvent]"
  537. +" ,[SR_SMSGenerateIdentity]"
  538. +" ,[SR_SMSSendIdentity]"
  539. +" ,[SR_RecipientNumber]"
  540. +" ,[SR_Content]"
  541. +" ,[SR_StartSendDatetime]"
  542. +" ,[SR_SendSumCount]"
  543. +" ,[SR_Status]"
  544. +" ,[SR_SendLogs]"
  545. +" ,[SR_SendReport]"
  546. +" ,[SR_CreateDatetime]"
  547. +" ,[SR_SendDatetime]"
  548. +" ,[SR_SMSSendSender]";
  549. pageData.OrderStr = " ID desc ";
  550. DataSet da = pageData.QueryDataTable();
  551. dt = da.Tables[0];
  552. if (dt.Rows.Count > 0)
  553. {
  554. for (int t = 0; t < dt.Rows.Count; t++)
  555. {
  556. modelList.Add(bllSR.DataRowToModel(dt.Rows[t]));
  557. }
  558. }
  559. });
  560. if (dt.Rows.Count > 0)
  561. {
  562. foreach (LYFZ.Model.Model_SMSRecord model in modelList)
  563. {
  564. DataGridViewRow row = new DataGridViewRow();
  565. row.CreateCells(this.dgv);
  566. row.Cells[0].Value = model.SR_RecipientNumber;
  567. row.Cells[1].Value = model.SR_Content;
  568. row.Cells[2].Value = model.SR_StartSendDatetime.ToString("yyyy-MM-dd HH:mm");
  569. if (model.SR_SendDatetime > LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime())
  570. {
  571. row.Cells[3].Value = model.SR_SendDatetime.ToString("yyyy-MM-dd HH:mm");
  572. }
  573. row.Cells[4].Value = model.SR_SendSumCount.ToString();
  574. row.Cells[5].Value = ((EnumPublic.SmsSendStatus)model.SR_Status).ToString();
  575. row.Cells[6].Value = model.SR_SendReport;
  576. row.Cells[7].Value = model.SR_SMSSendSender;
  577. row.Cells[8].Value = model.SR_CreateDatetime.ToString("yyyy-MM-dd HH:mm:ss");
  578. this.dgv.Rows.Add(row);
  579. row.Tag = model;
  580. }
  581. dgv.ClearSelection();
  582. }
  583. try
  584. {
  585. this.ucPagerEx1.TbDataSource = dt;
  586. }
  587. catch { }
  588. return pageData.TotalCount;
  589. }
  590. #endregion
  591. }
  592. }