123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- 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);
- }
- }
- /// <summary>
- /// 当前消息模板
- /// </summary>
- EnumPublic.MicroTemplate _TemplateNo = EnumPublic.MicroTemplate.新订单通知;
- /// <summary>
- /// 当前消息模板
- /// </summary>
- public EnumPublic.MicroTemplate TemplateNo
- {
- get { return _TemplateNo; }
- set { _TemplateNo = value; }
- }
- List<string> _Ord_Numberlist = new List<string>();
- /// <summary>
- /// 要发送消息的订单集合
- /// </summary>
- public List<string> 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();
- /// <summary>
- /// 当前模板对象
- /// </summary>
- public LYFZ.Model.Model_SMSTemplates SmsModel
- {
- get { return smsModel; }
- set { smsModel = value; }
- }*/
- LYFZ.Model.Model_SMSTemplates _TemplateIDModel = new Model.Model_SMSTemplates();
- /// <summary>
- /// 当前模板ID对象
- /// </summary>
- 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("保存失败,请检查网络环境或关闭后重试。");
- }*/
- }
- /// <summary>
- /// 获取事件的说明属性信息
- /// </summary>
- /// <param name="sEvent"></param>
- /// <returns></returns>
- string GetControlPropertyAttribute(EnumPublic.MicroSendEvent sEvent)
- {
- return frmAddMicroTemplate.GetControlPropertyAttribute(sEvent, EnumPublic.SmsCategory.公共短信);
- }
- void frmAddSMSTemplate_Load(object sender, EventArgs e)
- {
- BindCmbtemplate();
- }
-
- /// <summary>
- /// 邦定消息模板
- /// </summary>
- void BindCmbtemplate()
- {
- this.cmbtemplate.Items.Clear();
- List<LYFZ.Model.Model_SMSTemplates> 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<string> elist = new List<string>();
- 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);
- }
- }
-
- }
- }
|