frmAddCommonSMS.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace LYFZ.Software.MainBusiness.SMSManagement
  6. {
  7. public class frmAddCommonSMS:LYFZ.Software.UI.SMSManagement.frmAddCommonSMS
  8. {
  9. LYFZ.DAL.DAL_SMSTemplates smsDal = new DAL.DAL_SMSTemplates();
  10. LYFZ.Model.Model_SMSTemplates smsModel = new Model.Model_SMSTemplates();
  11. public frmAddCommonSMS() {
  12. this.Load += frmAddCommonSMS_Load;
  13. this.Shown += frmAddCommonSMS_Shown;
  14. this.btnSave.Click += btnSave_Click;
  15. }
  16. void frmAddCommonSMS_Shown(object sender, EventArgs e)
  17. {
  18. if (smsModel.ID > 0)
  19. {
  20. this.cboxSmsClass.Text = smsModel.ST_Title;
  21. this.txtSmsInfo.Text = smsModel.ST_SMSContent;
  22. }
  23. }
  24. /// <summary>
  25. /// 短信对象
  26. /// </summary>
  27. public LYFZ.Model.Model_SMSTemplates SmsModel
  28. {
  29. get { return smsModel; }
  30. set { smsModel = value; }
  31. }
  32. void btnSave_Click(object sender, EventArgs e)
  33. {
  34. if (this.cboxSmsClass.Text.Length <= 0)
  35. {
  36. MessageBoxCustom.Show("请输入或选择信息类别");
  37. return;
  38. }
  39. if (this.txtSmsInfo.Text.Length <= 0)
  40. {
  41. MessageBoxCustom.Show("请输入信息内容");
  42. return;
  43. }
  44. int sumSmsCount = 0;
  45. try
  46. {
  47. sumSmsCount = smsDal.GetRecordCount("ST_Type=0");
  48. }
  49. catch { }
  50. smsModel.ST_Type = (int)EnumPublic.SmsTemplateType.常用样板信息;
  51. smsModel.ST_Title = this.cboxSmsClass.Text;
  52. smsModel.ST_SMSContent = this.txtSmsInfo.Text;
  53. smsModel.ST_CreateDatetime = SDateTime.Now;
  54. smsModel.ST_UpdateDatetime = SDateTime.Now;
  55. smsModel.ST_DividedShop = "SSN001";
  56. bool ret = false;
  57. if (smsModel.ID > 0)
  58. {
  59. ret = smsDal.Update(smsModel);
  60. }
  61. else {
  62. if (sumSmsCount > 1000)
  63. {
  64. MessageBoxCustom.Show("对不起,常用信息库最多只能添加1000条记录,请删除无用短信记录后重试。");
  65. return;
  66. }
  67. ret = smsDal.Add(smsModel);
  68. }
  69. if (ret)
  70. {
  71. MessageBoxCustom.Show("保存成功");
  72. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  73. }
  74. else {
  75. MessageBoxCustom.Show("保存失败,请检查网络环境或关闭后重试。");
  76. }
  77. }
  78. void frmAddCommonSMS_Load(object sender, EventArgs e)
  79. {
  80. this.cboxSmsClass.DataSource = smsDal.GetCommonSMSClassList();
  81. }
  82. }
  83. }