1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace LYFZ.Software.MainBusiness.SMSManagement
- {
- public class frmAddCommonSMS:LYFZ.Software.UI.SMSManagement.frmAddCommonSMS
- {
- LYFZ.DAL.DAL_SMSTemplates smsDal = new DAL.DAL_SMSTemplates();
- LYFZ.Model.Model_SMSTemplates smsModel = new Model.Model_SMSTemplates();
- public frmAddCommonSMS() {
- this.Load += frmAddCommonSMS_Load;
- this.Shown += frmAddCommonSMS_Shown;
- this.btnSave.Click += btnSave_Click;
- }
- void frmAddCommonSMS_Shown(object sender, EventArgs e)
- {
- if (smsModel.ID > 0)
- {
- this.cboxSmsClass.Text = smsModel.ST_Title;
- this.txtSmsInfo.Text = smsModel.ST_SMSContent;
- }
- }
- /// <summary>
- /// 短信对象
- /// </summary>
- public LYFZ.Model.Model_SMSTemplates SmsModel
- {
- get { return smsModel; }
- set { smsModel = value; }
- }
- void btnSave_Click(object sender, EventArgs e)
- {
- if (this.cboxSmsClass.Text.Length <= 0)
- {
- MessageBoxCustom.Show("请输入或选择信息类别");
- return;
- }
- if (this.txtSmsInfo.Text.Length <= 0)
- {
- MessageBoxCustom.Show("请输入信息内容");
- return;
- }
- int sumSmsCount = 0;
- try
- {
- sumSmsCount = smsDal.GetRecordCount("ST_Type=0");
- }
- catch { }
- smsModel.ST_Type = (int)EnumPublic.SmsTemplateType.常用样板信息;
- smsModel.ST_Title = this.cboxSmsClass.Text;
- smsModel.ST_SMSContent = this.txtSmsInfo.Text;
- smsModel.ST_CreateDatetime = SDateTime.Now;
- smsModel.ST_UpdateDatetime = SDateTime.Now;
- smsModel.ST_DividedShop = "SSN001";
- 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("保存失败,请检查网络环境或关闭后重试。");
- }
- }
- void frmAddCommonSMS_Load(object sender, EventArgs e)
- {
- this.cboxSmsClass.DataSource = smsDal.GetCommonSMSClassList();
- }
- }
- }
|