using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Dynamic; namespace LYFZ.Software.MainBusiness.SMSManagement { public class frmAddMicroTemplateMessage : LYFZ.Software.UI.SMSManagement.frmAddMicroTemplateMessage { public frmAddMicroTemplateMessage() { this.Load += frmAddSMSTemplate_Load; this.btnSave.Click += btnSave_Click; this.Shown += frmAddSMSTemplate_Shown; this.cmbtemplate.SelectedIndexChanged += cmbtemplate_SelectedIndexChanged; } void cmbtemplate_SelectedIndexChanged(object sender, EventArgs e) { if (this.cmbtemplate.SelectedItem != null) { this.TemplateNo = (EnumPublic.MicroTemplate)Enum.Parse(typeof(EnumPublic.MicroTemplate), this.cmbtemplate.SelectedItem.ToString()); this.lbContentExamples.Text = LYFZ.BLL.BLL_SMSTemplates.GetMicroTemplateExample(this.TemplateNo); this.TemplateIDModel = (LYFZ.Model.Model_SMSTemplates)smsDal.GetModelObject("ST_Category", (int)this.TemplateNo); } } /// /// 当前消息模板 /// EnumPublic.MicroTemplate _TemplateNo = EnumPublic.MicroTemplate.新订单通知; /// /// 当前消息模板 /// public EnumPublic.MicroTemplate TemplateNo { get { return _TemplateNo; } set { _TemplateNo = value; } } List _Ord_Numberlist = new List(); /// /// 要发送消息的订单集合 /// public List Ord_Numberlist { get { return _Ord_Numberlist; } set { _Ord_Numberlist = value; } } void frmAddSMSTemplate_Shown(object sender, EventArgs e) { } LYFZ.DAL.DAL_SMSTemplates smsDal = new DAL.DAL_SMSTemplates(); /* LYFZ.Model.Model_SMSTemplates smsModel = new Model.Model_SMSTemplates(); /// /// 当前模板对象 /// public LYFZ.Model.Model_SMSTemplates SmsModel { get { return smsModel; } set { smsModel = value; } }*/ LYFZ.Model.Model_SMSTemplates _TemplateIDModel = new Model.Model_SMSTemplates(); /// /// 当前模板ID对象 /// public LYFZ.Model.Model_SMSTemplates TemplateIDModel { get { return _TemplateIDModel; } set { _TemplateIDModel = value; } } LYFZ.BLL.BLL_SMSRecord smsBll = new BLL.BLL_SMSRecord(); void btnSave_Click(object sender, EventArgs e) {/* if (this.txtdescription.Text.Length <= 0) { MessageBoxCustom.Show("请输入消息描述"); return; } if (this.txtRemark.Text.Length <= 0) { MessageBoxCustom.Show("请输入消息备注"); return; } if (this.cmbtemplate.Text.Length <= 0) { MessageBoxCustom.Show("请选择消息模板,如果还没设置消息模板,请在“微信模板库管理”设置好微信消息模板后重试"); return; } int sumSmsCount = 0; try { sumSmsCount = smsDal.GetRecordCount("ST_Type=" + (int)EnumPublic.SmsTemplateType.微信消息模板); } catch { } LYFZ.Model.Model_SMSRecord model = new Model.Model_SMSRecord(); model.SR_Content = ""; model.SR_CreateDatetime = SDateTime.Now; model.SR_RecipientNumber = ""; model.SR_SendChannel = 1; model.SR_Type = 0; // model.SR_Status=() smsModel.ST_Type = (int)EnumPublic.SmsTemplateType.微信消息模板; smsModel.ST_Title = this.TemplateNo.ToString(); // smsModel.ST_Category = (int)this.SCategory; smsModel.ST_SendChannel = 1; smsModel.ST_ReceiveObjects = this.txtURL.Text.Trim(); smsModel.ST_SendEvent = (int)((EnumPublic.MicroSendEvent)Enum.Parse(typeof(EnumPublic.MicroSendEvent), "")); smsModel.ST_SMSContent = this.txtdescription.Text.Trim(); smsModel.ST_Remark = this.txtRemark.Text.Trim(); smsModel.ST_CreateDatetime = SDateTime.Now; smsModel.ST_UpdateDatetime = SDateTime.Now; bool ret = false; if (smsModel.ID > 0) { ret = smsDal.Update(smsModel); } else { if (sumSmsCount > 1000) { MessageBoxCustom.Show("对不起,微信模板设置多只能添加1000条记录,请删除无用微信模板设置记录后重试。"); return; } ret = smsDal.Add(smsModel); } if (ret) { MessageBoxCustom.Show("保存成功"); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBoxCustom.Show("保存失败,请检查网络环境或关闭后重试。"); }*/ } /// /// 获取事件的说明属性信息 /// /// /// string GetControlPropertyAttribute(EnumPublic.MicroSendEvent sEvent) { return frmAddMicroTemplate.GetControlPropertyAttribute(sEvent, EnumPublic.SmsCategory.公共短信); } void frmAddSMSTemplate_Load(object sender, EventArgs e) { BindCmbtemplate(); } /// /// 邦定消息模板 /// void BindCmbtemplate() { this.cmbtemplate.Items.Clear(); List smsModelList = null; LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker) { try { smsModelList = new LYFZ.BLL.BLL_SMSTemplates().GetModelList("ST_Type=" + ((int)EnumPublic.SmsTemplateType.微信模板ID).ToString()); } catch { MessageBoxCustom.Show("模板加载失败!请检查网络环境或关闭系统后重试!", backgroundWorker: backgroundWorker); } }); if (smsModelList != null && smsModelList.Count > 0) { List elist = new List(); foreach (LYFZ.Model.Model_SMSTemplates tlModel in smsModelList) { elist.Add(((LYFZ.EnumPublic.MicroTemplate)tlModel.ST_Category).ToString()); } this.cmbtemplate.DataSource = elist; cmbtemplate_SelectedIndexChanged(null, null); } } } }