frmAddMicroTemplateMessage.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Dynamic;
  6. namespace LYFZ.Software.MainBusiness.SMSManagement
  7. {
  8. public class frmAddMicroTemplateMessage : LYFZ.Software.UI.SMSManagement.frmAddMicroTemplateMessage
  9. {
  10. public frmAddMicroTemplateMessage()
  11. {
  12. this.Load += frmAddSMSTemplate_Load;
  13. this.btnSave.Click += btnSave_Click;
  14. this.Shown += frmAddSMSTemplate_Shown;
  15. this.cmbtemplate.SelectedIndexChanged += cmbtemplate_SelectedIndexChanged;
  16. }
  17. void cmbtemplate_SelectedIndexChanged(object sender, EventArgs e)
  18. {
  19. if (this.cmbtemplate.SelectedItem != null)
  20. {
  21. this.TemplateNo = (EnumPublic.MicroTemplate)Enum.Parse(typeof(EnumPublic.MicroTemplate), this.cmbtemplate.SelectedItem.ToString());
  22. this.lbContentExamples.Text = LYFZ.BLL.BLL_SMSTemplates.GetMicroTemplateExample(this.TemplateNo);
  23. this.TemplateIDModel = (LYFZ.Model.Model_SMSTemplates)smsDal.GetModelObject("ST_Category", (int)this.TemplateNo);
  24. }
  25. }
  26. /// <summary>
  27. /// 当前消息模板
  28. /// </summary>
  29. EnumPublic.MicroTemplate _TemplateNo = EnumPublic.MicroTemplate.新订单通知;
  30. /// <summary>
  31. /// 当前消息模板
  32. /// </summary>
  33. public EnumPublic.MicroTemplate TemplateNo
  34. {
  35. get { return _TemplateNo; }
  36. set { _TemplateNo = value; }
  37. }
  38. List<string> _Ord_Numberlist = new List<string>();
  39. /// <summary>
  40. /// 要发送消息的订单集合
  41. /// </summary>
  42. public List<string> Ord_Numberlist
  43. {
  44. get { return _Ord_Numberlist; }
  45. set { _Ord_Numberlist = value; }
  46. }
  47. void frmAddSMSTemplate_Shown(object sender, EventArgs e)
  48. {
  49. }
  50. LYFZ.DAL.DAL_SMSTemplates smsDal = new DAL.DAL_SMSTemplates();
  51. /* LYFZ.Model.Model_SMSTemplates smsModel = new Model.Model_SMSTemplates();
  52. /// <summary>
  53. /// 当前模板对象
  54. /// </summary>
  55. public LYFZ.Model.Model_SMSTemplates SmsModel
  56. {
  57. get { return smsModel; }
  58. set { smsModel = value; }
  59. }*/
  60. LYFZ.Model.Model_SMSTemplates _TemplateIDModel = new Model.Model_SMSTemplates();
  61. /// <summary>
  62. /// 当前模板ID对象
  63. /// </summary>
  64. public LYFZ.Model.Model_SMSTemplates TemplateIDModel
  65. {
  66. get { return _TemplateIDModel; }
  67. set { _TemplateIDModel = value; }
  68. }
  69. LYFZ.BLL.BLL_SMSRecord smsBll = new BLL.BLL_SMSRecord();
  70. void btnSave_Click(object sender, EventArgs e)
  71. {/*
  72. if (this.txtdescription.Text.Length <= 0)
  73. {
  74. MessageBoxCustom.Show("请输入消息描述");
  75. return;
  76. }
  77. if (this.txtRemark.Text.Length <= 0)
  78. {
  79. MessageBoxCustom.Show("请输入消息备注");
  80. return;
  81. }
  82. if (this.cmbtemplate.Text.Length <= 0)
  83. {
  84. MessageBoxCustom.Show("请选择消息模板,如果还没设置消息模板,请在“微信模板库管理”设置好微信消息模板后重试");
  85. return;
  86. }
  87. int sumSmsCount = 0;
  88. try
  89. {
  90. sumSmsCount = smsDal.GetRecordCount("ST_Type=" + (int)EnumPublic.SmsTemplateType.微信消息模板);
  91. }
  92. catch { }
  93. LYFZ.Model.Model_SMSRecord model = new Model.Model_SMSRecord();
  94. model.SR_Content = "";
  95. model.SR_CreateDatetime = SDateTime.Now;
  96. model.SR_RecipientNumber = "";
  97. model.SR_SendChannel = 1;
  98. model.SR_Type = 0;
  99. // model.SR_Status=()
  100. smsModel.ST_Type = (int)EnumPublic.SmsTemplateType.微信消息模板;
  101. smsModel.ST_Title = this.TemplateNo.ToString();
  102. // smsModel.ST_Category = (int)this.SCategory;
  103. smsModel.ST_SendChannel = 1;
  104. smsModel.ST_ReceiveObjects = this.txtURL.Text.Trim();
  105. smsModel.ST_SendEvent = (int)((EnumPublic.MicroSendEvent)Enum.Parse(typeof(EnumPublic.MicroSendEvent), ""));
  106. smsModel.ST_SMSContent = this.txtdescription.Text.Trim();
  107. smsModel.ST_Remark = this.txtRemark.Text.Trim();
  108. smsModel.ST_CreateDatetime = SDateTime.Now;
  109. smsModel.ST_UpdateDatetime = SDateTime.Now;
  110. bool ret = false;
  111. if (smsModel.ID > 0)
  112. {
  113. ret = smsDal.Update(smsModel);
  114. }
  115. else
  116. {
  117. if (sumSmsCount > 1000)
  118. {
  119. MessageBoxCustom.Show("对不起,微信模板设置多只能添加1000条记录,请删除无用微信模板设置记录后重试。");
  120. return;
  121. }
  122. ret = smsDal.Add(smsModel);
  123. }
  124. if (ret)
  125. {
  126. MessageBoxCustom.Show("保存成功");
  127. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  128. }
  129. else
  130. {
  131. MessageBoxCustom.Show("保存失败,请检查网络环境或关闭后重试。");
  132. }*/
  133. }
  134. /// <summary>
  135. /// 获取事件的说明属性信息
  136. /// </summary>
  137. /// <param name="sEvent"></param>
  138. /// <returns></returns>
  139. string GetControlPropertyAttribute(EnumPublic.MicroSendEvent sEvent)
  140. {
  141. return frmAddMicroTemplate.GetControlPropertyAttribute(sEvent, EnumPublic.SmsCategory.公共短信);
  142. }
  143. void frmAddSMSTemplate_Load(object sender, EventArgs e)
  144. {
  145. BindCmbtemplate();
  146. }
  147. /// <summary>
  148. /// 邦定消息模板
  149. /// </summary>
  150. void BindCmbtemplate()
  151. {
  152. this.cmbtemplate.Items.Clear();
  153. List<LYFZ.Model.Model_SMSTemplates> smsModelList = null;
  154. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
  155. {
  156. try
  157. {
  158. smsModelList = new LYFZ.BLL.BLL_SMSTemplates().GetModelList("ST_Type=" + ((int)EnumPublic.SmsTemplateType.微信模板ID).ToString());
  159. }
  160. catch
  161. {
  162. MessageBoxCustom.Show("模板加载失败!请检查网络环境或关闭系统后重试!", backgroundWorker: backgroundWorker);
  163. }
  164. });
  165. if (smsModelList != null && smsModelList.Count > 0)
  166. {
  167. List<string> elist = new List<string>();
  168. foreach (LYFZ.Model.Model_SMSTemplates tlModel in smsModelList)
  169. {
  170. elist.Add(((LYFZ.EnumPublic.MicroTemplate)tlModel.ST_Category).ToString());
  171. }
  172. this.cmbtemplate.DataSource = elist;
  173. cmbtemplate_SelectedIndexChanged(null, null);
  174. }
  175. }
  176. }
  177. }