123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584 |
- 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();
- /// <summary>
- /// 当前软件业务类型
- /// </summary>
- 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.礼服管理短信);
-
- }
- /// <summary>
- /// 导出短信模板
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
-
-
- }
- /// <summary>
- /// 导入短信模板
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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.医院跟踪短信);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sCty"></param>
- void BindMicroCategory(EnumPublic.SmsCategory sCty)
- {
- if (sCty != this.MicroCategory)
- {
- this.MicroCategory = sCty;
- BindDgvMicroTemplate();
- }
- }
- void BindDgvMicroTemplate()
- {
- this.dgvMicroTemplate.Rows.Clear();
- try
- {
- List<LYFZ.Model.Model_SMSTemplates> 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("微信消息模板记录加载失败!请检查网络环境或关闭系统后重试!");
- }
- }
- /// <summary>
- /// 根据事件和事件值返回模板标题
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 当前微信模板类别
- /// </summary>
- 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("删除失败,请关闭后重试");
- }
- }
- }
-
- }
- /// <summary>
- /// 删除微信模板ID
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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("删除失败");
- }
- }
- }
- /// <summary>
- /// 添加下载微信模板ID
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- }
- /// <summary>
- /// 删除微信模板
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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("删除失败");
- }
- }
- }
- /// <summary>
- /// 添加微信模板
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
- /// <summary>
- /// 启用/禁用短信模版
- /// </summary>
- /// <param name="enabled"></param>
- 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);
- }
- /// <summary>
- /// 根据软件业务版本设置显示短信设置类型
- /// </summary>
- 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.公共短信);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="i"></param>
- void BindSmsCategory(EnumPublic.SmsCategory sCty)
- {
- // EnumPublic.SmsCategory sCty = (EnumPublic.SmsCategory)Convert.ToInt32(i);
- if (sCty != this.sCategory)
- {
- this.sCategory = sCty;
- BindDgvSmsT();
- }
- }
- /// <summary>
- /// 当前短信类别
- /// </summary>
- 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();
- /// <summary>
- /// 当前短信帐号
- /// </summary>
- static LYFZ.Model.Model_ErpSmsAccountInfo _CurrentSmsAccount = null;
- public static LYFZ.Model.Model_ErpSmsAccountInfo CurrentSmsAccount
- {
- get {
- if (frmSMSTemplateSet._CurrentSmsAccount == null)
- {
- LoadCurrentSmsAccount();
- /* List<LYFZ.Model.Model_ErpSmsAccountInfo> 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;
- }
- }
- /// <summary>
- /// 获取当前短信帖号
- /// </summary>
- 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<Control> hideControl = new List<Control>();
- //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<Control>();
- //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<LYFZ.Model.Model_SMSTemplates> 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分钟:
-
- */
- /// <summary>
- /// 根据事件和事件值返回模板标题
- /// </summary>
- /// <param name="model"></param>
- /// <returns></returns>
- 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;
- }
-
- }
- /// <summary>
- /// 邦定微信模板ID配置列表
- /// </summary>
- public void BindDgvMicroTemplateIDList()
- {
- this.dgvMicroTemplateItem.Rows.Clear();
- try
- {
- List<LYFZ.Model.Model_SMSTemplates> 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("常用短信记录加载失败!请检查网络环境或关闭系统后重试!");
- }
- }
- /// <summary>
- /// 邦定常用短信
- /// </summary>
- void BindDgvCommonSMS()
- {
- this.dgvCommonSMS.Rows.Clear();
- try
- {
- List<LYFZ.Model.Model_SMSTemplates> 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();
- }
- }
-
- }
- }
|