using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace LYFZ.Software.MainBusiness.SMSManagement { public class frmSMSTemplateSet:LYFZ.Software.UI.SMSManagement.frmSMSTemplateSet { LYFZ.DAL.DAL_SMSTemplates smsDal = new DAL.DAL_SMSTemplates(); LYFZ.BLL.BLL_SMSTemplates smsBLL = new BLL.BLL_SMSTemplates(); LYFZ.BLL.BLL_ErpSystemConfigure sysConfigBll = new BLL.BLL_ErpSystemConfigure(); Model.Model_ErpSystemConfigure SmsConfigureModel = new Model.Model_ErpSystemConfigure(); /// /// 当前软件业务类型 /// LYFZ.Software.MainBusiness.EnumPermissions.BusinessType CurrentBusinessType = EnumPermissions.BusinessType.旗舰版; public frmSMSTemplateSet() { CurrentBusinessType = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType(); this.btnSmsTImport.Click += btnSmsTImport_Click; this.btnSmsTExport.Click += btnSmsTExport_Click; this.btnCommonSMSAdd.Click += btnCommonSMSAdd_Click; this.tabControlEx1.SelectedIndexChanged += tabControlEx1_SelectedIndexChanged; this.Shown += frmSMSTemplateSet_Shown; this.dgvCommonSMS.CellDoubleClick += dgvCommonSMS_CellDoubleClick; this.dgvCommonSMS.CellContentClick += dgvCommonSMS_CellContentClick; this.btnSaveAccount.Click += btnSaveAccount_Click; this.btnCommonSMSAllDel.Click += btnCommonSMSAllDel_Click; this.btnSmsTAdd.Click += btnSmsTAdd_Click; this.dgvSmsT.CellDoubleClick += dgvSmsT_CellDoubleClick; this.dgvSmsT.CellContentClick += dgvSmsT_CellContentClick; this.dgvSmsT.RefreshTheme(); this.dgvCommonSMS.RefreshTheme(); this.rdoGonggong.Click += rdoGonggong_Click; this.rdohunsha.Click += rdohunsha_Click; this.rdoertong.Click += rdoertong_Click; this.rdoxiezheng.Click += rdoxiezheng_Click; this.tlsEnable.Click += tlsEnable_Click; this.tlsDisabled.Click += tlsDisabled_Click; this.rdoHTSms.Click += rdoHTSms_Click; this.rdoLFSMS.Click += rdoLFSMS_Click; this.contextMenuStrip1.Opening += contextMenuStrip1_Opening; this.cboxSmsClass.SelectedIndexChanged += cboxSmsClass_SelectedIndexChanged; SetShowSmsTpye(); if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update)) { this.btnSaveAccount.Enabled = true; } else { this.btnSaveAccount.Enabled = false; } if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Delete)) { this.btnSmsTImport.Enabled = true; this.btnCommonSMSAllDel.Enabled = true; this.btndelAllMicroTemplate.Enabled = true; this.btnDelallMicro.Enabled = true; } else { this.btnSmsTImport.Enabled = false; this.btnCommonSMSAllDel.Enabled = false; this.btndelAllMicroTemplate.Enabled = false; this.btnDelallMicro.Enabled = false; } if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Add)) { this.btnSmsTAdd.Enabled = true; this.btnCommonSMSAdd.Enabled = true; this.btnAddMicroT.Enabled = true; this.btnMicroTemplate.Enabled = true; this.btnSetIndustry.Enabled = true; this.btnSmsTExport.Enabled = true; this.btnSmsTImport.Enabled = true; } else { this.btnSmsTAdd.Enabled = false; this.btnCommonSMSAdd.Enabled = false; this.btnAddMicroT.Enabled = false; this.btnMicroTemplate.Enabled = false; this.btnSetIndustry.Enabled = false; this.btnSmsTExport.Enabled = false; this.btnSmsTImport.Enabled = false; } this.btnAccountQuery.Click += btnAccountQuery_Click; //微信模板消息管理 this.btnAddMicroT.Click += btnAddMicroT_Click; this.btnDelallMicro.Click += btnDelallMicro_Click; this.dgvMicroTemplate.CellDoubleClick += dgvMicroTemplate_CellDoubleClick; this.dgvMicroTemplate.CellContentClick += dgvMicroTemplate_CellContentClick; this.btnMicroTemplate.Click += btnMicroTemplate_Click; this.btndelAllMicroTemplate.Click += btndelAllMicroTemplate_Click; this.dgvMicroTemplateItem.CellContentClick += dgvMicroTemplateItem_CellContentClick; this.dgvMicroTemplateItem.CellDoubleClick += dgvMicroTemplateItem_CellDoubleClick; // this.Load += frmSMSTemplateSet_Load; this.rdoGonggongMicro.Click += rdoGonggongMicro_Click; this.rdohunshaMicro.Click += rdohunshaMicro_Click; this.rdoertongMicro.Click += rdoertongMicro_Click; this.rdoxiezhengMicro.Click += rdoxiezhengMicro_Click; this.rdoHTSmsMicro.Click += rdoHTSmsMicro_Click; this.btnSetIndustry.Click += btnSetIndustry_Click; this.rdoWeddingOrder.Click += rdoWeddingOrder_Click; this.rdoServiceOrder.Click += rdoServiceOrder_Click; this.rdoWeddingOrderMicro.Click += rdoWeddingOrderMicro_Click; this.rdoServiceOrderMicro.Click += rdoServiceOrderMicro_Click; } void rdoLFSMS_Click(object sender, EventArgs e) { BindSmsCategory(EnumPublic.SmsCategory.礼服管理短信); } /// /// 导出短信模板 /// /// /// void btnSmsTExport_Click(object sender, EventArgs e) { SaveFileDialog ExportRoleDlg = new SaveFileDialog(); ExportRoleDlg.Filter = "短信模板|*.STD"; ExportRoleDlg.FileName = this.sCategory.ToString()+"模板_" + SDateTime.Now.ToString("yyyy-MM-dd"); if (ExportRoleDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { string ImportRoleFileName = LYFZ.WinAPI.CustomPublicMethod.GetFullDirectoryPath(System.IO.Path.GetDirectoryName(ExportRoleDlg.FileName)) + System.IO.Path.GetFileNameWithoutExtension(ExportRoleDlg.FileName) + ".STD"; string ExportRoleData = ((int)this.sCategory).ToString() + "|" + ((int)EnumPublic.SmsTemplateType.事件短信).ToString()+"|"; foreach (DataGridViewRow row in this.dgvSmsT.Rows) { if (row.Tag != null) { LYFZ.Model.Model_SMSTemplates smsTlModel = (LYFZ.Model.Model_SMSTemplates)row.Tag; ExportRoleData +=LYFZ.WinAPI.SDKSecurity.Encode(smsTlModel.ST_ReceiveObjects) +"?" + LYFZ.WinAPI.SDKSecurity.Encode(smsTlModel.ST_SendEvent.ToString()) + "?" + LYFZ.WinAPI.SDKSecurity.Encode(smsTlModel.ST_SMSContent) + "?" + LYFZ.WinAPI.SDKSecurity.Encode(smsTlModel.ST_IsEnabled.ToString()) + "?" + LYFZ.WinAPI.SDKSecurity.Encode(smsTlModel.ST_SendEventValue.ToString()) + "|"; } } System.IO.File.WriteAllText(ImportRoleFileName, ExportRoleData.Trim('|'), Encoding.UTF8); MessageBoxCustom.Show("短信模板数据导出成功"); } catch (Exception ex) { MessageBoxCustom.Show("短信模板数据导出失败:" + ex.Message); } } } /// /// 导入短信模板 /// /// /// void btnSmsTImport_Click(object sender, EventArgs e) { OpenFileDialog ImportRoleDlg = new OpenFileDialog(); ImportRoleDlg.Filter = "短信模板|*.STD"; if (ImportRoleDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { string ImportRoleFileName = ImportRoleDlg.FileName; if (System.IO.File.Exists(ImportRoleFileName)) { string[] ImportDataList = System.IO.File.ReadAllText(ImportRoleFileName, Encoding.UTF8).Split('|'); if (ImportDataList.Length <= 1) { MessageBoxCustom.Show("选择的模板文件不正确"); return; } if ((EnumPublic.SmsCategory)Convert.ToInt32(ImportDataList[0]) != this.sCategory && (EnumPublic.SmsTemplateType)Convert.ToInt32(ImportDataList[0])!= EnumPublic.SmsTemplateType.事件短信) { MessageBoxCustom.Show("选择的短信模板不是当前类型的模板数据,请重新选择!"); return; } bool isSaveOk = false; int myCount = 1; LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { backgroundWorker.ReportProgress(0, "正在导入短信模板,请稍等..."); foreach (string iDatas in ImportDataList) { string[] iDataList = iDatas.Split('?'); if (iDataList.Length >= 4) { try { backgroundWorker.ReportProgress(0, "正在导入" + myCount.ToString() + "/" + ImportDataList.Length.ToString() + "条数据,请稍等..."); LYFZ.Model.Model_SMSTemplates smsTlModel = new Model.Model_SMSTemplates(); smsTlModel.ST_Type = (int)EnumPublic.SmsTemplateType.事件短信; smsTlModel.ST_Title = ""; smsTlModel.ST_Category = (int)this.sCategory; smsTlModel.ST_SendChannel = 0; smsTlModel.ST_ReceiveObjects = LYFZ.WinAPI.SDKSecurity.Decode(iDataList[0]); smsTlModel.ST_SendEvent = Convert.ToInt32(LYFZ.WinAPI.SDKSecurity.Decode(iDataList[1])); smsTlModel.ST_SMSContent = LYFZ.WinAPI.SDKSecurity.Decode(iDataList[2]); smsTlModel.ST_IsEnabled = Convert.ToBoolean(LYFZ.WinAPI.SDKSecurity.Decode(iDataList[3])); smsTlModel.ST_CreateDatetime = SDateTime.Now; smsTlModel.ST_UpdateDatetime = SDateTime.Now; smsTlModel.ST_DividedShop = LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID; smsTlModel.ST_SendEventValue = LYFZ.WinAPI.SDKSecurity.Decode(iDataList[4]); if (!ExistSMSTemplate(smsTlModel.ST_SendEvent, smsTlModel.ST_SendEventValue)) { isSaveOk = this.smsDal.Add(smsTlModel); if (!isSaveOk) { break; } } } catch (Exception ex) { isSaveOk = false; MessageBoxCustom.Show("短信模板导入失败:" + ex.Message); break; } } } }); if (isSaveOk || ImportDataList.Length==2) { // LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog("", LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name); MessageBoxCustom.Show("短信模板导入成功"); BindDgvSmsT(); } else { MessageBoxCustom.Show("短信模板导入失败,请重启软件后重试"); } } else { MessageBoxCustom.Show("选择的短信模板文件不存在"); } } catch (Exception ex) { MessageBoxCustom.Show("短信模板导入失败:" + ex.Message); } } } bool ExistSMSTemplate(int SendEvent, string SendEventValue) { foreach (DataGridViewRow row in this.dgvSmsT.Rows) { if (row.Tag != null) { LYFZ.Model.Model_SMSTemplates smsTlModel = (LYFZ.Model.Model_SMSTemplates)row.Tag; if (smsTlModel.ST_SendEvent == SendEvent && SendEventValue.Trim() == smsTlModel.ST_SendEventValue.Trim()) { return true; } } } return false; } void rdoServiceOrderMicro_Click(object sender, EventArgs e) { BindMicroCategory(EnumPublic.SmsCategory.服务订单短信); } void rdoWeddingOrderMicro_Click(object sender, EventArgs e) { BindMicroCategory(EnumPublic.SmsCategory.婚庆订单短信); } void rdoServiceOrder_Click(object sender, EventArgs e) { BindSmsCategory(EnumPublic.SmsCategory.服务订单短信); } void rdoWeddingOrder_Click(object sender, EventArgs e) { BindSmsCategory(EnumPublic.SmsCategory.婚庆订单短信); } void cboxSmsClass_SelectedIndexChanged(object sender, EventArgs e) { string cClass = this.cboxSmsClass.Text.Trim(); foreach (DataGridViewRow row in this.dgvCommonSMS.Rows) { if (cClass == "全部") { row.Visible = true; } else { if (row.Cells[0].Value.ToString().Trim() == cClass) { row.Visible = true; } else { row.Visible = false; } } } } void btnSetIndustry_Click(object sender, EventArgs e) { try { LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig(); int PortNumber = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.SoftwareInfo.WebServerPort; // int clearAccessToken = 1;//是否清容并刷新AccessToken string resultStr = ""; try { /* string url = LYFZ.BLL.BLL_MicroInterface.GetSetIndustryUrl(mConfig.ServerHostOrIP, PortNumber, "31", "41", clearAccessToken); System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); var result = client.GetAsync(url).Result; resultStr = result.Content.ReadAsStringAsync().Result; var retObj = Codeplex.Data.DynamicJson.Parse(resultStr); client.Dispose();*/ LYFZ.Model.Model_MicroInterface modelMIF = new BLL.BLL_MicroInterface().Model; string getSetIndustryUrl = "http://wx.lyfz.net/WeiXinAPP/WXServiceHandler.aspx?type=setindustry&appid=" + modelMIF.AppID.Trim(); string retTemplatesStr = LYFZ.WinAPI.CustomPublicMethod.HttpWebRequestGET(getSetIndustryUrl, Encoding.UTF8); if (retTemplatesStr.Contains("\"errcode\":")) { var retMsgObj = Codeplex.Data.DynamicJson.Parse(retTemplatesStr);//LYFZ.Weixin.SDK.TemplateMessageAPI.SetIndustry(LYFZ.Weixin.SDK.Helpers.TokenHelper.AccessToken, "31", "41"); if (retMsgObj.errmsg.ToString().ToLower() == "ok") { ExMessageBoxCustom.Show("设置行业成功。", backgroundWorker: backgroundWorker); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { if (retMsgObj.errmsg.ToString().ToLower() == "40001") { LYFZ.Weixin.SDK.Helpers.TokenHelper.ClearAccessToken(); } ExMessageBoxCustom.Show("设置行业失败,微信返回信息:" + retMsgObj.ToString(), backgroundWorker: backgroundWorker); } } else { ExMessageBoxCustom.Show("设置行业失败,原因:" + retTemplatesStr, backgroundWorker: backgroundWorker); } } catch (Exception ex) { ExMessageBoxCustom.Show("设置行业失败,错误代码:" + ex.Message + "\r\n" + resultStr, backgroundWorker: backgroundWorker); } }); } catch { MessageBoxCustom.Show("设置行业载失败!请检查网络环境或关闭系统后重试!"); } } void dgvMicroTemplate_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex == 9) { dgvMicroTemplate_CellDoubleClick(sender, e); } else if (e.RowIndex >= 0 && e.ColumnIndex == 10) { if (MessageBoxCustom.Show("您确定要删除当前微信模板设置记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { DataGridViewRow row = this.dgvMicroTemplate.Rows[e.RowIndex]; LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag; if (smsBLL.Delete(model)) { this.dgvMicroTemplate.Rows.RemoveAt(e.RowIndex); } else { MessageBoxCustom.Show("删除失败,请关闭后重试"); } } } else if (e.RowIndex >= 0 && e.ColumnIndex == 8) { if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update)) { MessageBoxCustom.Show("抱歉,你没有修改权限!"); return; } DataGridViewRow row = this.dgvMicroTemplate.Rows[e.RowIndex]; LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag; model = smsBLL.GetModel(model.ID); model.ST_IsEnabled = !model.ST_IsEnabled; if (smsBLL.Update(model)) { BindDgvMicroTemplate(); } else { MessageBoxCustom.Show("设置失败,请关闭后重试"); } } } void dgvMicroTemplate_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update)) { MessageBoxCustom.Show("抱歉,你没有修改权限!"); return; } if (e.RowIndex >= 0 && e.ColumnIndex >= 0 && (e.ColumnIndex <= 7 || e.ColumnIndex == 9)) { DataGridViewRow row = this.dgvMicroTemplate.Rows[e.RowIndex]; frmAddMicroTemplate frmAddST = new frmAddMicroTemplate(); frmAddST.SCategory = this.MicroCategory; frmAddST.ThisParentForm = this; try { frmAddST.SmsModel = (LYFZ.Model.Model_SMSTemplates)row.Tag; } catch { } if (frmAddST.ShowDialog() == System.Windows.Forms.DialogResult.OK) { BindDgvMicroTemplate(); } } } void frmSMSTemplateSet_Load(object sender, EventArgs e) { } void rdoGonggongMicro_Click(object sender, EventArgs e) { BindMicroCategory(EnumPublic.SmsCategory.公共短信); } void rdohunshaMicro_Click(object sender, EventArgs e) { BindMicroCategory(EnumPublic.SmsCategory.婚纱短信); } void rdoertongMicro_Click(object sender, EventArgs e) { BindMicroCategory(EnumPublic.SmsCategory.儿童短信); } void rdoxiezhengMicro_Click(object sender, EventArgs e) { BindMicroCategory(EnumPublic.SmsCategory.写真短信); } void rdoHTSmsMicro_Click(object sender, EventArgs e) { BindMicroCategory(EnumPublic.SmsCategory.医院跟踪短信); } /// /// /// /// void BindMicroCategory(EnumPublic.SmsCategory sCty) { if (sCty != this.MicroCategory) { this.MicroCategory = sCty; BindDgvMicroTemplate(); } } void BindDgvMicroTemplate() { this.dgvMicroTemplate.Rows.Clear(); try { List smsModelList = null; LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { smsModelList = smsBLL.GetModelList("ST_Type=" + ((int)EnumPublic.SmsTemplateType.微信消息模板).ToString() + " and ST_Category=" + ((int)this.MicroCategory).ToString() + " and ST_DividedShop='" + LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID.Trim() + "'"); }); if (smsModelList != null) { foreach (LYFZ.Model.Model_SMSTemplates model in smsModelList) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(this.dgvMicroTemplate); try { row.Cells[0].Value = ((LYFZ.EnumPublic.MicroSendEvent)model.ST_SendEvent).ToString(); } catch { row.Cells[0].Value = "未知事件"; } row.Cells[1].Value = GetTemplateMicroTitle(model); row.Cells[2].Value = model.ST_Title; try { row.Cells[3].Value = LYFZ.WinAPI.CustomPublicMethod.ConvertEnumToDescription((EnumPublic.MicroTemplate)Enum.Parse(typeof(EnumPublic.MicroTemplate), model.ST_Title));//model.ST_ReceiveObjects; }catch{ row.Cells[3].Value = "未知模板"; } row.Cells[4].Value = model.ST_SMSContent; row.Cells[5].Value = model.ST_Remark; row.Cells[6].Value = model.ST_ReceiveObjects; row.Cells[7].Value = model.ST_UpdateDatetime.ToString("yyyy-MM-dd HH:mm:ss"); if (model.ST_IsEnabled) { row.Cells[8].Value = "已启用"; row.Cells[8].Style.BackColor = Color.Green; } else { row.Cells[8].Value = "已禁用"; row.Cells[8].Style.BackColor = Color.Gray; } row.Cells[9].Value = "编缉"; row.Cells[10].Value = "删除"; row.Tag = model; this.dgvMicroTemplate.Rows.Add(row); } } if (this.dgvMicroTemplate.SortedColumn != null) { ListSortDirection Direction = ListSortDirection.Descending; switch (this.dgvMicroTemplate.SortOrder) { case SortOrder.Ascending: Direction = ListSortDirection.Ascending; break; case SortOrder.Descending: Direction = ListSortDirection.Descending; break; default: break; } this.dgvMicroTemplate.Sort(this.dgvSmsT.SortedColumn, Direction); } } catch { MessageBoxCustom.Show("微信消息模板记录加载失败!请检查网络环境或关闭系统后重试!"); } } /// /// 根据事件和事件值返回模板标题 /// /// /// string GetTemplateMicroTitle(LYFZ.Model.Model_SMSTemplates model) { string retTitle = "未知短信设置"; try { LYFZ.EnumPublic.MicroSendEvent smsEvent = (LYFZ.EnumPublic.MicroSendEvent)model.ST_SendEvent; retTitle = smsEvent.ToString().Replace("X", model.ST_SendEventValue); } catch { } return retTitle; } /// /// 当前微信模板类别 /// EnumPublic.SmsCategory MicroCategory = EnumPublic.SmsCategory.公共短信; void dgvMicroTemplateItem_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update)) { MessageBoxCustom.Show("抱歉,你没有修改权限!"); return; } if (e.RowIndex >= 0 && e.ColumnIndex >= 0 && e.ColumnIndex <= 4) { DataGridViewRow row = this.dgvMicroTemplateItem.Rows[e.RowIndex]; frmAddMicroTemplateItem frmAddSmsT = new frmAddMicroTemplateItem(); try { frmAddSmsT.SmsModel = (LYFZ.Model.Model_SMSTemplates)row.Tag; } catch { } if (frmAddSmsT.ShowDialog() == System.Windows.Forms.DialogResult.OK) { BindDgvMicroTemplateIDList(); } } } void dgvMicroTemplateItem_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex == 4) { dgvMicroTemplateItem_CellDoubleClick(sender, e); } else if (e.RowIndex >= 0 && e.ColumnIndex == 5) { if (MessageBoxCustom.Show("您确定要删除当前微信模板ID吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { DataGridViewRow row = this.dgvMicroTemplateItem.Rows[e.RowIndex]; LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag; if (smsBLL.Delete(model)) { this.dgvMicroTemplateItem.Rows.RemoveAt(e.RowIndex); } else { MessageBoxCustom.Show("删除失败,请关闭后重试"); } } } } /// /// 删除微信模板ID /// /// /// void btndelAllMicroTemplate_Click(object sender, EventArgs e) { if (this.dgvMicroTemplateItem.Rows.Count <= 0) { MessageBoxCustom.Show("没有要删除的记录!"); return; } if (MessageBoxCustom.Show("您确定要删除所有记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { if (smsBLL.Delete("ST_Type=" + ((int)EnumPublic.SmsTemplateType.微信模板ID).ToString())) { this.dgvMicroTemplateItem.Rows.Clear(); } else { MessageBoxCustom.Show("删除失败"); } } } /// /// 添加下载微信模板ID /// /// /// void btnMicroTemplate_Click(object sender, EventArgs e) { /* System.Web.Script.Serialization.JavaScriptSerializer Jss = new System.Web.Script.Serialization.JavaScriptSerializer(); dynamic data=new { first = LYFZ.BLL.BLL_SMSTemplates.GetColorAndValue("ipid"), keynote1 = LYFZ.BLL.BLL_SMSTemplates.GetColorAndValue("39.8元"), keynote2 = LYFZ.BLL.BLL_SMSTemplates.GetColorAndValue("2014年9月22日"), remark = LYFZ.BLL.BLL_SMSTemplates.GetColorAndValue("欢迎再次购买!"), }; dynamic obj = new { touser = "这是填入要发送到的用户的OpenID", template_id = "ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY", url = "http://weixin.qq.com/download", data = data }; string jsonstring = Jss.Serialize(obj); */ frmAddMicroTemplateItem frmAddSTItem = new frmAddMicroTemplateItem(); if (frmAddSTItem.ShowDialog() == System.Windows.Forms.DialogResult.OK) { BindDgvMicroTemplateIDList(); } } /// /// 删除微信模板 /// /// /// void btnDelallMicro_Click(object sender, EventArgs e) { if (this.dgvMicroTemplate.Rows.Count <= 0) { MessageBoxCustom.Show("没有要删除的记录!"); return; } if (MessageBoxCustom.Show("您确定要删除所有记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { if (smsBLL.Delete("ST_Type=" + ((int)EnumPublic.SmsTemplateType.微信消息模板).ToString()+" and ST_Category=" + ((int)this.MicroCategory).ToString())) { this.dgvMicroTemplate.Rows.Clear(); } else { MessageBoxCustom.Show("删除失败"); } } } /// /// 添加微信模板 /// /// /// void btnAddMicroT_Click(object sender, EventArgs e) { frmAddMicroTemplate frmAddST = new frmAddMicroTemplate(); frmAddST.SCategory = this.MicroCategory; frmAddST.ThisParentForm = this; if (frmAddST.ShowDialog() == System.Windows.Forms.DialogResult.OK) { BindDgvMicroTemplate(); } } void rdoHTSms_Click(object sender, EventArgs e) { BindSmsCategory(EnumPublic.SmsCategory.医院跟踪短信); } void btnAccountQuery_Click(object sender, EventArgs e) { try { if (CurrentSmsAccount != null && CurrentSmsAccount.ID > 0) { CurrentSmsAccount.Smsa_AccountNumber = this.txtSmsa_AccountNumber.Text.Trim() ; CurrentSmsAccount.Smsa_Password = this.txtSmsa_Password.Text.Trim(); if (CurrentSmsAccount.Smsa_AccountNumber.Trim().Length <= 0) { MessageBoxCustom.Show("请输入短信帐号"); return; } if (CurrentSmsAccount.Smsa_Password.Trim().Length <= 0) { MessageBoxCustom.Show("请输入帐号密码"); return; } LYFZ.WcfServiceSharedLibraries.Wcf_SmsUserInfo uIfo = null; bool isAccountQueryOK = false; LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { backgroundWorker.ReportProgress(0, "正在查询,请稍等..."); uIfo = LYFZ.WindowsServiceHandling.SmsSendHandling.GetSMSAccountInfo(CurrentSmsAccount.Smsa_AccountNumber, CurrentSmsAccount.Smsa_Password); if (uIfo != null && uIfo.ReturnCode.Trim() == "0") { CurrentSmsAccount.Smsa_AccountName = uIfo.Signatures; CurrentSmsAccount.Smsa_MoneyBalances = uIfo.Balance; CurrentSmsAccount.Smsa_SumSendCount = uIfo.BeenSentCount; if (SmsAccountInfobll.Update(CurrentSmsAccount)) { isAccountQueryOK = true; MessageBoxCustom.Show("当前帐号余额(条数):" + CurrentSmsAccount.Smsa_MoneyBalances.ToString() + "\r\n已发送(条数):" + CurrentSmsAccount.Smsa_SumSendCount.ToString() + "\r\n签名为:" + CurrentSmsAccount.Smsa_AccountName); } else { MessageBoxCustom.Show("更新帐号信息时失败,请关闭后重试.", backgroundWorker: backgroundWorker); } } else { if (uIfo == null) { MessageBoxCustom.Show("短信帐号信息查询失败,请检查网络环境是否正常.", backgroundWorker: backgroundWorker); } else { MessageBoxCustom.Show("短信帐号信息查询失败,失败原因:" + getSendReport(uIfo.ReturnCode), backgroundWorker: backgroundWorker); } } backgroundWorker.ReportProgress(0, "查询完成"); }); if (isAccountQueryOK) { GetCurrentSmsAccount(); } } else { MessageBoxCustom.Show("请设置帐号密码后重试"); } } catch (Exception ex) { MessageBoxCustom.Show("获取当前短信帖号信息失败,失败原因:" + ex.Message); } } string getSendReport(string returnCode) { LYFZ.WcfServiceSharedLibraries.SmsReturnCode retCode = WcfServiceSharedLibraries.SmsReturnCode.提交异常_请联系服务商解决; try { retCode = (LYFZ.WcfServiceSharedLibraries.SmsReturnCode)Convert.ToInt32(returnCode); } catch { } return retCode.ToString(); } void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update)) { e.Cancel = true; } } /// /// 启用/禁用短信模版 /// /// void SetSMSTemplatesEnabled(bool enabled) { if (this.dgvSmsT.SelectedRows != null && this.dgvSmsT.SelectedRows.Count>0) { bool updateOK = false; string idList = ""; foreach (DataGridViewRow row in this.dgvSmsT.SelectedRows) { LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag; idList += model.ID.ToString()+","; } idList = idList.Trim(','); updateOK= this.smsBLL.UpdateIsEnabled(idList,enabled); if (updateOK) { BindDgvSmsT(); } } else { MessageBoxCustom.Show("请选择要设置的短信模板记录"); } } void tlsDisabled_Click(object sender, EventArgs e) { SetSMSTemplatesEnabled(false); } void tlsEnable_Click(object sender, EventArgs e) { SetSMSTemplatesEnabled(true); } /// /// 根据软件业务版本设置显示短信设置类型 /// void SetShowSmsTpye() { switch (CurrentBusinessType) { case EnumPermissions.BusinessType.婚纱版: this.rdoertong.Visible = false; this.rdoHTSms.Visible = false; break; case EnumPermissions.BusinessType.儿童版: this.rdohunsha.Visible = false; break; } } void rdoxiezheng_Click(object sender, EventArgs e) { BindSmsCategory(EnumPublic.SmsCategory.写真短信); } void rdoertong_Click(object sender, EventArgs e) { BindSmsCategory(EnumPublic.SmsCategory.儿童短信); } void rdohunsha_Click(object sender, EventArgs e) { BindSmsCategory(EnumPublic.SmsCategory.婚纱短信); } void rdoGonggong_Click(object sender, EventArgs e) { BindSmsCategory(EnumPublic.SmsCategory.公共短信); } /// /// /// /// void BindSmsCategory(EnumPublic.SmsCategory sCty) { // EnumPublic.SmsCategory sCty = (EnumPublic.SmsCategory)Convert.ToInt32(i); if (sCty != this.sCategory) { this.sCategory = sCty; BindDgvSmsT(); } } /// /// 当前短信类别 /// EnumPublic.SmsCategory sCategory = EnumPublic.SmsCategory.公共短信; void dgvSmsT_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex == 6) { dgvSmsT_CellDoubleClick(sender, e); } else if (e.RowIndex >= 0 && e.ColumnIndex == 7) { if (MessageBoxCustom.Show("您确定要删除当前短信设置记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { DataGridViewRow row = this.dgvSmsT.Rows[e.RowIndex]; LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag; if (smsBLL.Delete(model)) { this.dgvSmsT.Rows.RemoveAt(e.RowIndex); } else { MessageBoxCustom.Show("删除失败,请关闭后重试"); } } } else if (e.RowIndex >= 0 && e.ColumnIndex == 5) { if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update)) { MessageBoxCustom.Show("抱歉,你没有修改权限!"); return; } DataGridViewRow row = this.dgvSmsT.Rows[e.RowIndex]; LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag; model = smsBLL.GetModel(model.ID); model.ST_IsEnabled = !model.ST_IsEnabled; if (smsBLL.Update(model)) { BindDgvSmsT(); } else { MessageBoxCustom.Show("设置失败,请关闭后重试"); } } } void dgvSmsT_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update)) { MessageBoxCustom.Show("抱歉,你没有修改权限!"); return; } if (e.RowIndex >= 0 && e.ColumnIndex >= 0 && (e.ColumnIndex <= 4 || e.ColumnIndex == 6)) { DataGridViewRow row = this.dgvSmsT.Rows[e.RowIndex]; frmAddSMSTemplate frmAddSmsT = new frmAddSMSTemplate(); frmAddSmsT.SCategory = this.sCategory; try { frmAddSmsT.SmsModel = (LYFZ.Model.Model_SMSTemplates)row.Tag; } catch { } if (frmAddSmsT.ShowDialog() == System.Windows.Forms.DialogResult.OK) { BindDgvSmsT(); } } } void btnSmsTAdd_Click(object sender, EventArgs e) { frmAddSMSTemplate frmAddST = new frmAddSMSTemplate(); frmAddST.SCategory = this.sCategory; if (frmAddST.ShowDialog() == System.Windows.Forms.DialogResult.OK) { BindDgvSmsT(); } } void btnCommonSMSAllDel_Click(object sender, EventArgs e) { if (this.dgvCommonSMS.Rows.Count <= 0) { MessageBoxCustom.Show("没有要删除的记录!"); return; } if (MessageBoxCustom.Show("您确定要删除所有记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { if (smsBLL.Delete("ST_Type=" + ((int)EnumPublic.SmsTemplateType.常用样板信息).ToString())) { this.dgvCommonSMS.Rows.Clear(); } else { MessageBoxCustom.Show("删除失败"); } } } void btnSmsTAlldel_Click(object sender, EventArgs e) { // FrmSMSSettings frm = new FrmSMSSettings(); // frm.Show(); // return; //以上为测试用 if (this.dgvSmsT.Rows.Count <= 0) { MessageBoxCustom.Show("没有要删除的记录!"); return; } if (MessageBoxCustom.Show("您确定要删除所有记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { if (smsBLL.Delete("ST_Type="+((int)EnumPublic.SmsTemplateType.事件短信).ToString()+" and ST_Category=" + ((int)sCategory).ToString())) { this.dgvSmsT.Rows.Clear(); } else { MessageBoxCustom.Show("删除失败"); } } } void btnSaveAccount_Click(object sender, EventArgs e) { if (this.txtSmsa_AccountNumber.Text.Trim().Length <= 0) { MessageBoxCustom.Show("请输入短信帐号!"); return; } if (this.txtSmsa_Password.Text.Trim().Length <= 0) { MessageBoxCustom.Show("请输入短信帐号密码!"); return; } SaveSmsBalanceToRemind(this.chkbalanceRemind.Checked, Convert.ToInt32(this.nubalanceRemind.Value)); if (CurrentSmsAccount == null) { _CurrentSmsAccount = new Model.Model_ErpSmsAccountInfo(); CurrentSmsAccount.Smsa_SendTypes = "0"; CurrentSmsAccount.Smsa_AccountNumber = this.txtSmsa_AccountNumber.Text.Trim(); CurrentSmsAccount.Smsa_Password = this.txtSmsa_Password.Text.Trim(); CurrentSmsAccount.Smsa_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID(); if (SmsAccountInfobll.Add(CurrentSmsAccount)) { LoadCurrentSmsAccount(); GetCurrentSmsAccount(); MessageBoxCustom.Show("短信帐号添加成功!"); } else { MessageBoxCustom.Show("短信帐号添加失败!"); } } else { CurrentSmsAccount.Smsa_AccountNumber = this.txtSmsa_AccountNumber.Text.Trim(); CurrentSmsAccount.Smsa_Password = this.txtSmsa_Password.Text.Trim(); if (SmsAccountInfobll.Update(CurrentSmsAccount)) { MessageBoxCustom.Show("短信帐号修改成功!"); } else { MessageBoxCustom.Show("短信帐号修改失败!"); } } } void dgvCommonSMS_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex == 3) { dgvCommonSMS_CellDoubleClick(sender, e); } else if (e.RowIndex >= 0 && e.ColumnIndex == 4) { if (MessageBoxCustom.Show("您确定要删除当前短信记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { DataGridViewRow row = this.dgvCommonSMS.Rows[e.RowIndex]; LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag; if (smsBLL.Delete(model)) { this.dgvCommonSMS.Rows.RemoveAt(e.RowIndex); } else { MessageBoxCustom.Show("删除失败,请关闭后重试"); } } } } void dgvCommonSMS_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update)) { MessageBoxCustom.Show("抱歉,你没有修改权限!"); return; } if (e.RowIndex >= 0 && e.ColumnIndex >= 0 && e.ColumnIndex<=3) { DataGridViewRow row = this.dgvCommonSMS.Rows[e.RowIndex]; frmAddCommonSMS frmAddSms = new frmAddCommonSMS(); try { frmAddSms.SmsModel = (LYFZ.Model.Model_SMSTemplates)row.Tag; } catch { } if (frmAddSms.ShowDialog() == System.Windows.Forms.DialogResult.OK) { frmSelectSmsInfo.BindSmsClass(this.cboxSmsClass); BindDgvCommonSMS(); } } } LYFZ.BLL.BLL_ErpSmsAccountInfo SmsAccountInfobll = new BLL.BLL_ErpSmsAccountInfo(); /// /// 当前短信帐号 /// static LYFZ.Model.Model_ErpSmsAccountInfo _CurrentSmsAccount = null; public static LYFZ.Model.Model_ErpSmsAccountInfo CurrentSmsAccount { get { if (frmSMSTemplateSet._CurrentSmsAccount == null) { LoadCurrentSmsAccount(); /* List smsAccountList = new BLL.BLL_ErpSmsAccountInfo().GetModelObject("Smsa_DividedShop=''");//.GetModelList("[Smsa_SendTypes]='0'"); if (smsAccountList.Count > 0) { frmSMSTemplateSet._CurrentSmsAccount = smsAccountList[0]; }*/ } return frmSMSTemplateSet._CurrentSmsAccount; } } public static void LoadCurrentSmsAccount() { frmSMSTemplateSet._CurrentSmsAccount = (LYFZ.Model.Model_ErpSmsAccountInfo)(new BLL.BLL_ErpSmsAccountInfo().GetModelObject("Smsa_DividedShop", LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID())); if (frmSMSTemplateSet._CurrentSmsAccount.ID <= 0) { frmSMSTemplateSet._CurrentSmsAccount = null; } } /// /// 获取当前短信帖号 /// void GetCurrentSmsAccount() { if (frmSMSTemplateSet.CurrentSmsAccount != null) { this.txtSmsa_AccountNumber.Text = CurrentSmsAccount.Smsa_AccountNumber; this.txtSmsa_Password.Text = CurrentSmsAccount.Smsa_Password; this.txtSmsa_MoneyBalances.Text = CurrentSmsAccount.Smsa_MoneyBalances.ToString("n0"); this.txtUsed.Text = CurrentSmsAccount.Smsa_SumSendCount.ToString(); } } void frmSMSTemplateSet_Shown(object sender, EventArgs e) { // LYFZ.WindowsServiceHandling.MessageService.WeixinConfigRegister(); List hideControl = new List(); //LYFZSS.SystemSpecterPossessed.ISystemSpecterPossessed.GetMySystemSpecter = LYFZSS.SystemSpecterType.SST_D; hideControl.Add(this.rdoHTSms); LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl( VersionControl.VersionFunctionEnum.短信管理医院跟踪短信, hideControl, null, null); hideControl = new List(); //LYFZSS.SystemSpecterPossessed.ISystemSpecterPossessed.GetMySystemSpecter = LYFZSS.SystemSpecterType.SST_D; bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl( VersionControl.VersionFunctionEnum.短信管理微信短信推送, hideControl, null, null); if(!b) { if (tabControlEx1.TabPages.Count > 2) { tabControlEx1.TabPages.Remove(tabControlEx1.TabPages[2]); tabControlEx1.TabPages.Remove(tabControlEx1.TabPages[2]); } } this.rdoLFSMS.Visible= LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl( VersionControl.VersionFunctionEnum.礼服管理, hideControl, null, null); BindDgvSmsT(); GetCurrentSmsAccount(); SmsConfigureModel = sysConfigBll.GetConfigureInfo(Model.ConfigItemType.SmsBalanceToRemind); SetSmsBalanceToRemind(SmsConfigureModel); } void SetSmsBalanceToRemind(Model.Model_ErpSystemConfigure SmsConfigureModelInfo) { if (SmsConfigureModelInfo.ID > 0 && SmsConfigureModelInfo.Sconfig_Value.Length > 3) { dynamic RemindObj = Newtonsoft.Json.JsonConvert.DeserializeObject(SmsConfigureModelInfo.Sconfig_Value); this.nubalanceRemind.Value =Convert.ToDecimal(RemindObj["balanceNumber"]); if (RemindObj["Open"] == 1) { this.chkbalanceRemind.Checked = true; } } } void SaveSmsBalanceToRemind(bool open, int balanceNumber) { string valueString = Newtonsoft.Json.JsonConvert.SerializeObject( new { Open = open ? 1 : 0, balanceNumber = balanceNumber } ); sysConfigBll.SaveConfigureInfo(Model.ConfigItemType.SmsBalanceToRemind, valueString); } void BindDgvSmsT() { this.dgvSmsT.Rows.Clear(); try { List smsModelList = null; LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { smsModelList = smsBLL.GetModelList("ST_Type=" + ((int)EnumPublic.SmsTemplateType.事件短信).ToString() + " and ST_Category=" + ((int)sCategory).ToString() + " and ST_DividedShop='" + LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID.Trim() + "'"); }); if (smsModelList != null) { foreach (LYFZ.Model.Model_SMSTemplates model in smsModelList) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(this.dgvSmsT); try { row.Cells[0].Value = ((LYFZ.EnumPublic.SmsSendEvent)model.ST_SendEvent).ToString(); } catch { row.Cells[0].Value = "未知事件"; } row.Cells[1].Value = GetTemplateSmsTitle(model); row.Cells[2].Value = model.ST_SMSContent; row.Cells[3].Value = model.ST_ReceiveObjects; row.Cells[4].Value = model.ST_UpdateDatetime.ToString("yyyy-MM-dd HH:mm:ss"); if (model.ST_IsEnabled) { row.Cells[5].Value = "已启用"; row.Cells[5].Style.BackColor = Color.Green; } else { row.Cells[5].Value = "已禁用"; row.Cells[5].Style.BackColor = Color.Gray; } row.Cells[6].Value = "编缉"; row.Cells[7].Value = "删除"; row.Tag = model; this.dgvSmsT.Rows.Add(row); } } if (this.dgvSmsT.SortedColumn != null) { ListSortDirection Direction = ListSortDirection.Descending; switch (this.dgvSmsT.SortOrder) { case SortOrder.Ascending: Direction = ListSortDirection.Ascending; break; case SortOrder.Descending: Direction = ListSortDirection.Descending; break; default: break; } this.dgvSmsT.Sort(this.dgvSmsT.SortedColumn, Direction); } } catch { MessageBoxCustom.Show("短信设置记录加载失败!请检查网络环境或关闭系统后重试!"); } } /* 积分兑换后X分钟发提醒短信: 男宾生日前X天发短信给女宾: 女宾生日前X天发短信给男宾: 员工生日前X天发送短信给X手机号: 会员积分变动后X分钟: 删除会员后X分钟: 注消会员后X分钟: 修改会员支付密码后X分钟: 会员服务卡使用后X分钟: 会员积分有效期到期前X天: 会员储值有效期到期前X天: 会员服务套餐有效期到期前X天: 会员新摄会有效期到期前X天: 会员返现卡有效期到期前X天: 会员返现卡提现后X分钟: 会员返现卡获得返现金后X分钟: */ /// /// 根据事件和事件值返回模板标题 /// /// /// string GetTemplateSmsTitle(LYFZ.Model.Model_SMSTemplates model) { string retTitle = "未知短信设置"; try { LYFZ.EnumPublic.SmsSendEvent smsEvent = (LYFZ.EnumPublic.SmsSendEvent)model.ST_SendEvent; retTitle = smsEvent.ToString(); switch (smsEvent) { case EnumPublic.SmsSendEvent.客人订单后X分钟: case EnumPublic.SmsSendEvent.订单件齐后X分钟发送取件通知: case EnumPublic.SmsSendEvent.拍照预约后X分钟: case EnumPublic.SmsSendEvent.拍照完成后X分钟: case EnumPublic.SmsSendEvent.客人选片完成后X分钟: case EnumPublic.SmsSendEvent.客人看样后X分钟: case EnumPublic.SmsSendEvent.客人取件后X分钟: case EnumPublic.SmsSendEvent.当积分接近X的百分之80时: case EnumPublic.SmsSendEvent.当积分达到或超过X分时: case EnumPublic.SmsSendEvent.转介绍后X分钟发送短信给介绍人: case EnumPublic.SmsSendEvent.发放会员卡后X分钟发会员短信: case EnumPublic.SmsSendEvent.现金卡消费后X分钟后发提醒短信: case EnumPublic.SmsSendEvent.现金卡充值后X分钟后发提醒短信: case EnumPublic.SmsSendEvent.客人生日前X天: case EnumPublic.SmsSendEvent.客人婚礼前X天: case EnumPublic.SmsSendEvent.结婚纪念日前X天: case EnumPublic.SmsSendEvent.宝宝生日前X天: case EnumPublic.SmsSendEvent.宝宝X天成长跟踪短信: case EnumPublic.SmsSendEvent.家长生日前X天: case EnumPublic.SmsSendEvent.员工生日前X天: case EnumPublic.SmsSendEvent.客户来电挂机后X分钟: case EnumPublic.SmsSendEvent.未知来电挂机后X分钟: case EnumPublic.SmsSendEvent.员工来电挂机后X分钟: case EnumPublic.SmsSendEvent.怀孕X天周期跟踪短信: case EnumPublic.SmsSendEvent.来单录入后X分钟: case EnumPublic.SmsSendEvent.礼服出租还衣前X天: case EnumPublic.SmsSendEvent.礼服出租取衣前X天: case EnumPublic.SmsSendEvent.礼服出售取衣前X天: case EnumPublic.SmsSendEvent.礼服出租订单后X分钟: case EnumPublic.SmsSendEvent.礼服出租还衣后X分钟: case EnumPublic.SmsSendEvent.礼服出售订单后X分钟: case EnumPublic.SmsSendEvent.客人预约选片后X分钟: case EnumPublic.SmsSendEvent.拍照预约后拍照前X天: case EnumPublic.SmsSendEvent.服务预约后服务前X天: case EnumPublic.SmsSendEvent.选片预约后选片前X天: case EnumPublic.SmsSendEvent.看样预约后看样前X天: case EnumPublic.SmsSendEvent.客人预约看样后X分钟: case EnumPublic.SmsSendEvent.服务预约后X分钟: case EnumPublic.SmsSendEvent.服务完成后X分钟: case EnumPublic.SmsSendEvent.积分兑换后X分钟发提醒短信: case EnumPublic.SmsSendEvent.男宾生日前X天发短信给女宾: case EnumPublic.SmsSendEvent.女宾生日前X天发短信给男宾: case EnumPublic.SmsSendEvent.员工生日前X天发送短信给X手机号: case EnumPublic.SmsSendEvent.会员积分变动后X分钟: case EnumPublic.SmsSendEvent.删除会员后X分钟: case EnumPublic.SmsSendEvent.注消会员后X分钟: case EnumPublic.SmsSendEvent.修改会员支付密码后X分钟: case EnumPublic.SmsSendEvent.会员服务卡使用后X分钟: case EnumPublic.SmsSendEvent.会员积分有效期到期前X天: case EnumPublic.SmsSendEvent.会员储值有效期到期前X天: case EnumPublic.SmsSendEvent.会员服务套餐有效期到期前X天: case EnumPublic.SmsSendEvent.会员新摄会有效期到期前X天: case EnumPublic.SmsSendEvent.会员返现卡有效期到期前X天: case EnumPublic.SmsSendEvent.会员返现卡提现后X分钟: case EnumPublic.SmsSendEvent.会员返现卡获得返现金后X分钟: case EnumPublic.SmsSendEvent.支付成功后X分钟发提醒消息: case EnumPublic.SmsSendEvent.客片上传完成后X分钟发通知短信: retTitle = smsEvent.ToString().Replace("X", model.ST_SendEventValue); break; case EnumPublic.SmsSendEvent.宝宝生日前X天且X岁以下: if (model.ST_SendEventValue.Trim().Contains(":")) { string[] tempValues = model.ST_SendEventValue.Trim().Split(':'); if (tempValues.Length == 2) { retTitle = smsEvent.ToString().Replace("X天", tempValues[0] + "天").Replace("X岁", tempValues[1] + "岁"); } } break; case EnumPublic.SmsSendEvent.宝宝X岁前X天成长跟踪短信: if (model.ST_SendEventValue.Trim().Contains(":")) { string[] tempValues = model.ST_SendEventValue.Trim().Split(':'); if (tempValues.Length == 2) { retTitle = smsEvent.ToString().Replace("X岁", tempValues[0] + "岁").Replace("X天", tempValues[1] + "天"); } } else { retTitle = smsEvent.ToString().Replace("X岁", model.ST_SendEventValue + "岁").Replace("X天", "0天"); } break; case EnumPublic.SmsSendEvent.每天X时X分发送财务短信到X手机: if (model.ST_SendEventValue.Trim().Contains(":")) { string[] tempValues = model.ST_SendEventValue.Trim().Split(':'); if (tempValues.Length == 2) { retTitle = smsEvent.ToString().Replace("X时", tempValues[0] + "时").Replace("X分", tempValues[1] + "分").Replace("X手机", model.ST_ReceiveObjects + "手机"); } } break; } } catch { } return retTitle; } void tabControlEx1_SelectedIndexChanged(object sender, EventArgs e) { switch (this.tabControlEx1.SelectedIndex) { case 1: if (this.dgvCommonSMS.Rows.Count <= 0) { frmSelectSmsInfo.BindSmsClass(this.cboxSmsClass); BindDgvCommonSMS(); } break; case 2: if (this.dgvMicroTemplate.Rows.Count <= 0) { BindDgvMicroTemplate(); } break; case 3: if (this.dgvMicroTemplateItem.Rows.Count <= 0) { BindDgvMicroTemplateIDList(); } break; } } /// /// 邦定微信模板ID配置列表 /// public void BindDgvMicroTemplateIDList() { this.dgvMicroTemplateItem.Rows.Clear(); try { List smsModelList = null; LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { try { smsModelList = smsBLL.GetModelList("ST_Type=" + ((int)EnumPublic.SmsTemplateType.微信模板ID).ToString() + " and ST_DividedShop='" + LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID.Trim() + "'"); } catch { MessageBoxCustom.Show("加载失败!请检查网络环境或关闭系统后重试!", backgroundWorker: backgroundWorker); } }); if (smsModelList != null) { foreach (LYFZ.Model.Model_SMSTemplates model in smsModelList) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(this.dgvMicroTemplateItem); row.Cells[0].Value = model.ST_Title; row.Cells[1].Value = model.ST_SMSContent; row.Cells[2].Value = model.ST_Remark; row.Cells[3].Value = model.ST_UpdateDatetime.ToString("yyyy-MM-dd HH:mm:ss"); row.Cells[4].Value = "编缉"; row.Cells[5].Value = "删除"; row.Tag = model; this.dgvMicroTemplateItem.Rows.Add(row); } if (this.dgvMicroTemplateItem.SortedColumn != null) { ListSortDirection Direction = ListSortDirection.Descending; switch (this.dgvMicroTemplateItem.SortOrder) { case SortOrder.Ascending: Direction = ListSortDirection.Ascending; break; case SortOrder.Descending: Direction = ListSortDirection.Descending; break; default: break; } this.dgvMicroTemplateItem.Sort(this.dgvCommonSMS.SortedColumn, Direction); } } } catch { MessageBoxCustom.Show("常用短信记录加载失败!请检查网络环境或关闭系统后重试!"); } } /// /// 邦定常用短信 /// void BindDgvCommonSMS() { this.dgvCommonSMS.Rows.Clear(); try { List smsModelList = null; LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { try { smsModelList = smsBLL.GetModelList("ST_Type=" + ((int)EnumPublic.SmsTemplateType.常用样板信息).ToString()); } catch { MessageBoxCustom.Show("常用短信加载失败!请检查网络环境或关闭系统后重试!", backgroundWorker: backgroundWorker); } }); if (smsModelList != null) { foreach (LYFZ.Model.Model_SMSTemplates model in smsModelList) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(this.dgvCommonSMS); row.Cells[0].Value = model.ST_Title; row.Cells[1].Value = model.ST_SMSContent; row.Cells[2].Value = model.ST_UpdateDatetime.ToString("yyyy-MM-dd HH:mm:ss"); row.Cells[3].Value = "编缉"; row.Cells[4].Value = "删除"; row.Tag = model; this.dgvCommonSMS.Rows.Add(row); } if (this.dgvCommonSMS.SortedColumn != null) { ListSortDirection Direction = ListSortDirection.Descending; switch (this.dgvCommonSMS.SortOrder) { case SortOrder.Ascending: Direction = ListSortDirection.Ascending; break; case SortOrder.Descending: Direction = ListSortDirection.Descending; break; default: break; } this.dgvCommonSMS.Sort(this.dgvCommonSMS.SortedColumn, Direction); } } } catch { MessageBoxCustom.Show("常用短信记录加载失败!请检查网络环境或关闭系统后重试!"); } } void btnCommonSMSAdd_Click(object sender, EventArgs e) { frmAddCommonSMS frmAddSms = new frmAddCommonSMS(); if (frmAddSms.ShowDialog() == System.Windows.Forms.DialogResult.OK) { frmSelectSmsInfo.BindSmsClass(this.cboxSmsClass); BindDgvCommonSMS(); } } } }