frmSMSTemplateSet.cs 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.SMSManagement
  10. {
  11. public class frmSMSTemplateSet:LYFZ.Software.UI.SMSManagement.frmSMSTemplateSet
  12. {
  13. LYFZ.DAL.DAL_SMSTemplates smsDal = new DAL.DAL_SMSTemplates();
  14. LYFZ.BLL.BLL_SMSTemplates smsBLL = new BLL.BLL_SMSTemplates();
  15. LYFZ.BLL.BLL_ErpSystemConfigure sysConfigBll = new BLL.BLL_ErpSystemConfigure();
  16. Model.Model_ErpSystemConfigure SmsConfigureModel = new Model.Model_ErpSystemConfigure();
  17. /// <summary>
  18. /// 当前软件业务类型
  19. /// </summary>
  20. LYFZ.Software.MainBusiness.EnumPermissions.BusinessType CurrentBusinessType = EnumPermissions.BusinessType.旗舰版;
  21. public frmSMSTemplateSet() {
  22. CurrentBusinessType = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType();
  23. this.btnSmsTImport.Click += btnSmsTImport_Click;
  24. this.btnSmsTExport.Click += btnSmsTExport_Click;
  25. this.btnCommonSMSAdd.Click += btnCommonSMSAdd_Click;
  26. this.tabControlEx1.SelectedIndexChanged += tabControlEx1_SelectedIndexChanged;
  27. this.Shown += frmSMSTemplateSet_Shown;
  28. this.dgvCommonSMS.CellDoubleClick += dgvCommonSMS_CellDoubleClick;
  29. this.dgvCommonSMS.CellContentClick += dgvCommonSMS_CellContentClick;
  30. this.btnSaveAccount.Click += btnSaveAccount_Click;
  31. this.btnCommonSMSAllDel.Click += btnCommonSMSAllDel_Click;
  32. this.btnSmsTAdd.Click += btnSmsTAdd_Click;
  33. this.dgvSmsT.CellDoubleClick += dgvSmsT_CellDoubleClick;
  34. this.dgvSmsT.CellContentClick += dgvSmsT_CellContentClick;
  35. this.dgvSmsT.RefreshTheme();
  36. this.dgvCommonSMS.RefreshTheme();
  37. this.rdoGonggong.Click += rdoGonggong_Click;
  38. this.rdohunsha.Click += rdohunsha_Click;
  39. this.rdoertong.Click += rdoertong_Click;
  40. this.rdoxiezheng.Click += rdoxiezheng_Click;
  41. this.tlsEnable.Click += tlsEnable_Click;
  42. this.tlsDisabled.Click += tlsDisabled_Click;
  43. this.rdoHTSms.Click += rdoHTSms_Click;
  44. this.rdoLFSMS.Click += rdoLFSMS_Click;
  45. this.contextMenuStrip1.Opening += contextMenuStrip1_Opening;
  46. this.cboxSmsClass.SelectedIndexChanged += cboxSmsClass_SelectedIndexChanged;
  47. SetShowSmsTpye();
  48. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update))
  49. {
  50. this.btnSaveAccount.Enabled = true;
  51. }
  52. else {
  53. this.btnSaveAccount.Enabled = false;
  54. }
  55. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Delete))
  56. {
  57. this.btnSmsTImport.Enabled = true;
  58. this.btnCommonSMSAllDel.Enabled = true;
  59. this.btndelAllMicroTemplate.Enabled = true;
  60. this.btnDelallMicro.Enabled = true;
  61. }
  62. else
  63. {
  64. this.btnSmsTImport.Enabled = false;
  65. this.btnCommonSMSAllDel.Enabled = false;
  66. this.btndelAllMicroTemplate.Enabled = false;
  67. this.btnDelallMicro.Enabled = false;
  68. }
  69. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Add))
  70. {
  71. this.btnSmsTAdd.Enabled = true;
  72. this.btnCommonSMSAdd.Enabled = true;
  73. this.btnAddMicroT.Enabled = true;
  74. this.btnMicroTemplate.Enabled = true;
  75. this.btnSetIndustry.Enabled = true;
  76. this.btnSmsTExport.Enabled = true;
  77. this.btnSmsTImport.Enabled = true;
  78. }
  79. else
  80. {
  81. this.btnSmsTAdd.Enabled = false;
  82. this.btnCommonSMSAdd.Enabled = false;
  83. this.btnAddMicroT.Enabled = false;
  84. this.btnMicroTemplate.Enabled = false;
  85. this.btnSetIndustry.Enabled = false;
  86. this.btnSmsTExport.Enabled = false;
  87. this.btnSmsTImport.Enabled = false;
  88. }
  89. this.btnAccountQuery.Click += btnAccountQuery_Click;
  90. //微信模板消息管理
  91. this.btnAddMicroT.Click += btnAddMicroT_Click;
  92. this.btnDelallMicro.Click += btnDelallMicro_Click;
  93. this.dgvMicroTemplate.CellDoubleClick += dgvMicroTemplate_CellDoubleClick;
  94. this.dgvMicroTemplate.CellContentClick += dgvMicroTemplate_CellContentClick;
  95. this.btnMicroTemplate.Click += btnMicroTemplate_Click;
  96. this.btndelAllMicroTemplate.Click += btndelAllMicroTemplate_Click;
  97. this.dgvMicroTemplateItem.CellContentClick += dgvMicroTemplateItem_CellContentClick;
  98. this.dgvMicroTemplateItem.CellDoubleClick += dgvMicroTemplateItem_CellDoubleClick;
  99. // this.Load += frmSMSTemplateSet_Load;
  100. this.rdoGonggongMicro.Click += rdoGonggongMicro_Click;
  101. this.rdohunshaMicro.Click += rdohunshaMicro_Click;
  102. this.rdoertongMicro.Click += rdoertongMicro_Click;
  103. this.rdoxiezhengMicro.Click += rdoxiezhengMicro_Click;
  104. this.rdoHTSmsMicro.Click += rdoHTSmsMicro_Click;
  105. this.btnSetIndustry.Click += btnSetIndustry_Click;
  106. this.rdoWeddingOrder.Click += rdoWeddingOrder_Click;
  107. this.rdoServiceOrder.Click += rdoServiceOrder_Click;
  108. this.rdoWeddingOrderMicro.Click += rdoWeddingOrderMicro_Click;
  109. this.rdoServiceOrderMicro.Click += rdoServiceOrderMicro_Click;
  110. }
  111. void rdoLFSMS_Click(object sender, EventArgs e)
  112. {
  113. BindSmsCategory(EnumPublic.SmsCategory.礼服管理短信);
  114. }
  115. /// <summary>
  116. /// 导出短信模板
  117. /// </summary>
  118. /// <param name="sender"></param>
  119. /// <param name="e"></param>
  120. void btnSmsTExport_Click(object sender, EventArgs e)
  121. {
  122. SaveFileDialog ExportRoleDlg = new SaveFileDialog();
  123. ExportRoleDlg.Filter = "短信模板|*.STD";
  124. ExportRoleDlg.FileName = this.sCategory.ToString()+"模板_" + SDateTime.Now.ToString("yyyy-MM-dd");
  125. if (ExportRoleDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  126. {
  127. try
  128. {
  129. string ImportRoleFileName = LYFZ.WinAPI.CustomPublicMethod.GetFullDirectoryPath(System.IO.Path.GetDirectoryName(ExportRoleDlg.FileName))
  130. + System.IO.Path.GetFileNameWithoutExtension(ExportRoleDlg.FileName) + ".STD";
  131. string ExportRoleData = ((int)this.sCategory).ToString() + "|" + ((int)EnumPublic.SmsTemplateType.事件短信).ToString()+"|";
  132. foreach (DataGridViewRow row in this.dgvSmsT.Rows)
  133. {
  134. if (row.Tag != null)
  135. {
  136. LYFZ.Model.Model_SMSTemplates smsTlModel = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  137. ExportRoleData +=LYFZ.WinAPI.SDKSecurity.Encode(smsTlModel.ST_ReceiveObjects) +"?"
  138. + LYFZ.WinAPI.SDKSecurity.Encode(smsTlModel.ST_SendEvent.ToString()) + "?"
  139. + LYFZ.WinAPI.SDKSecurity.Encode(smsTlModel.ST_SMSContent) + "?"
  140. + LYFZ.WinAPI.SDKSecurity.Encode(smsTlModel.ST_IsEnabled.ToString()) + "?"
  141. + LYFZ.WinAPI.SDKSecurity.Encode(smsTlModel.ST_SendEventValue.ToString()) + "|";
  142. }
  143. }
  144. System.IO.File.WriteAllText(ImportRoleFileName, ExportRoleData.Trim('|'), Encoding.UTF8);
  145. MessageBoxCustom.Show("短信模板数据导出成功");
  146. }
  147. catch (Exception ex)
  148. {
  149. MessageBoxCustom.Show("短信模板数据导出失败:" + ex.Message);
  150. }
  151. }
  152. }
  153. /// <summary>
  154. /// 导入短信模板
  155. /// </summary>
  156. /// <param name="sender"></param>
  157. /// <param name="e"></param>
  158. void btnSmsTImport_Click(object sender, EventArgs e)
  159. {
  160. OpenFileDialog ImportRoleDlg = new OpenFileDialog();
  161. ImportRoleDlg.Filter = "短信模板|*.STD";
  162. if (ImportRoleDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  163. {
  164. try
  165. {
  166. string ImportRoleFileName = ImportRoleDlg.FileName;
  167. if (System.IO.File.Exists(ImportRoleFileName))
  168. {
  169. string[] ImportDataList = System.IO.File.ReadAllText(ImportRoleFileName, Encoding.UTF8).Split('|');
  170. if (ImportDataList.Length <= 1)
  171. {
  172. MessageBoxCustom.Show("选择的模板文件不正确");
  173. return;
  174. }
  175. if ((EnumPublic.SmsCategory)Convert.ToInt32(ImportDataList[0]) != this.sCategory && (EnumPublic.SmsTemplateType)Convert.ToInt32(ImportDataList[0])!= EnumPublic.SmsTemplateType.事件短信)
  176. {
  177. MessageBoxCustom.Show("选择的短信模板不是当前类型的模板数据,请重新选择!");
  178. return;
  179. }
  180. bool isSaveOk = false;
  181. int myCount = 1;
  182. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  183. {
  184. backgroundWorker.ReportProgress(0, "正在导入短信模板,请稍等...");
  185. foreach (string iDatas in ImportDataList)
  186. {
  187. string[] iDataList = iDatas.Split('?');
  188. if (iDataList.Length >= 4)
  189. {
  190. try
  191. {
  192. backgroundWorker.ReportProgress(0, "正在导入" + myCount.ToString() + "/" + ImportDataList.Length.ToString() + "条数据,请稍等...");
  193. LYFZ.Model.Model_SMSTemplates smsTlModel = new Model.Model_SMSTemplates();
  194. smsTlModel.ST_Type = (int)EnumPublic.SmsTemplateType.事件短信;
  195. smsTlModel.ST_Title = "";
  196. smsTlModel.ST_Category = (int)this.sCategory;
  197. smsTlModel.ST_SendChannel = 0;
  198. smsTlModel.ST_ReceiveObjects = LYFZ.WinAPI.SDKSecurity.Decode(iDataList[0]);
  199. smsTlModel.ST_SendEvent = Convert.ToInt32(LYFZ.WinAPI.SDKSecurity.Decode(iDataList[1]));
  200. smsTlModel.ST_SMSContent = LYFZ.WinAPI.SDKSecurity.Decode(iDataList[2]);
  201. smsTlModel.ST_IsEnabled = Convert.ToBoolean(LYFZ.WinAPI.SDKSecurity.Decode(iDataList[3]));
  202. smsTlModel.ST_CreateDatetime = SDateTime.Now;
  203. smsTlModel.ST_UpdateDatetime = SDateTime.Now;
  204. smsTlModel.ST_DividedShop = LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID;
  205. smsTlModel.ST_SendEventValue = LYFZ.WinAPI.SDKSecurity.Decode(iDataList[4]);
  206. if (!ExistSMSTemplate(smsTlModel.ST_SendEvent, smsTlModel.ST_SendEventValue))
  207. {
  208. isSaveOk = this.smsDal.Add(smsTlModel);
  209. if (!isSaveOk)
  210. {
  211. break;
  212. }
  213. }
  214. }
  215. catch (Exception ex)
  216. {
  217. isSaveOk = false;
  218. MessageBoxCustom.Show("短信模板导入失败:" + ex.Message);
  219. break;
  220. }
  221. }
  222. }
  223. });
  224. if (isSaveOk || ImportDataList.Length==2)
  225. {
  226. // LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog("", LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  227. MessageBoxCustom.Show("短信模板导入成功");
  228. BindDgvSmsT();
  229. }
  230. else
  231. {
  232. MessageBoxCustom.Show("短信模板导入失败,请重启软件后重试");
  233. }
  234. }
  235. else
  236. {
  237. MessageBoxCustom.Show("选择的短信模板文件不存在");
  238. }
  239. }
  240. catch (Exception ex)
  241. {
  242. MessageBoxCustom.Show("短信模板导入失败:" + ex.Message);
  243. }
  244. }
  245. }
  246. bool ExistSMSTemplate(int SendEvent, string SendEventValue)
  247. {
  248. foreach (DataGridViewRow row in this.dgvSmsT.Rows)
  249. {
  250. if (row.Tag != null)
  251. {
  252. LYFZ.Model.Model_SMSTemplates smsTlModel = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  253. if (smsTlModel.ST_SendEvent == SendEvent && SendEventValue.Trim() == smsTlModel.ST_SendEventValue.Trim())
  254. {
  255. return true;
  256. }
  257. }
  258. }
  259. return false;
  260. }
  261. void rdoServiceOrderMicro_Click(object sender, EventArgs e)
  262. {
  263. BindMicroCategory(EnumPublic.SmsCategory.服务订单短信);
  264. }
  265. void rdoWeddingOrderMicro_Click(object sender, EventArgs e)
  266. {
  267. BindMicroCategory(EnumPublic.SmsCategory.婚庆订单短信);
  268. }
  269. void rdoServiceOrder_Click(object sender, EventArgs e)
  270. {
  271. BindSmsCategory(EnumPublic.SmsCategory.服务订单短信);
  272. }
  273. void rdoWeddingOrder_Click(object sender, EventArgs e)
  274. {
  275. BindSmsCategory(EnumPublic.SmsCategory.婚庆订单短信);
  276. }
  277. void cboxSmsClass_SelectedIndexChanged(object sender, EventArgs e)
  278. {
  279. string cClass = this.cboxSmsClass.Text.Trim();
  280. foreach (DataGridViewRow row in this.dgvCommonSMS.Rows)
  281. {
  282. if (cClass == "全部")
  283. {
  284. row.Visible = true;
  285. }
  286. else
  287. {
  288. if (row.Cells[0].Value.ToString().Trim() == cClass)
  289. {
  290. row.Visible = true;
  291. }
  292. else
  293. {
  294. row.Visible = false;
  295. }
  296. }
  297. }
  298. }
  299. void btnSetIndustry_Click(object sender, EventArgs e)
  300. {
  301. try
  302. {
  303. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  304. {
  305. LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig();
  306. int PortNumber = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.SoftwareInfo.WebServerPort;
  307. // int clearAccessToken = 1;//是否清容并刷新AccessToken
  308. string resultStr = "";
  309. try
  310. {
  311. /* string url = LYFZ.BLL.BLL_MicroInterface.GetSetIndustryUrl(mConfig.ServerHostOrIP, PortNumber, "31", "41", clearAccessToken);
  312. System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
  313. var result = client.GetAsync(url).Result;
  314. resultStr = result.Content.ReadAsStringAsync().Result;
  315. var retObj = Codeplex.Data.DynamicJson.Parse(resultStr);
  316. client.Dispose();*/
  317. LYFZ.Model.Model_MicroInterface modelMIF = new BLL.BLL_MicroInterface().Model;
  318. string getSetIndustryUrl = "http://wx.lyfz.net/WeiXinAPP/WXServiceHandler.aspx?type=setindustry&appid=" + modelMIF.AppID.Trim();
  319. string retTemplatesStr = LYFZ.WinAPI.CustomPublicMethod.HttpWebRequestGET(getSetIndustryUrl, Encoding.UTF8);
  320. if (retTemplatesStr.Contains("\"errcode\":"))
  321. {
  322. var retMsgObj = Codeplex.Data.DynamicJson.Parse(retTemplatesStr);//LYFZ.Weixin.SDK.TemplateMessageAPI.SetIndustry(LYFZ.Weixin.SDK.Helpers.TokenHelper.AccessToken, "31", "41");
  323. if (retMsgObj.errmsg.ToString().ToLower() == "ok")
  324. {
  325. ExMessageBoxCustom.Show("设置行业成功。", backgroundWorker: backgroundWorker);
  326. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  327. }
  328. else
  329. {
  330. if (retMsgObj.errmsg.ToString().ToLower() == "40001")
  331. {
  332. LYFZ.Weixin.SDK.Helpers.TokenHelper.ClearAccessToken();
  333. }
  334. ExMessageBoxCustom.Show("设置行业失败,微信返回信息:" + retMsgObj.ToString(), backgroundWorker: backgroundWorker);
  335. }
  336. }
  337. else {
  338. ExMessageBoxCustom.Show("设置行业失败,原因:" + retTemplatesStr, backgroundWorker: backgroundWorker);
  339. }
  340. }
  341. catch (Exception ex)
  342. {
  343. ExMessageBoxCustom.Show("设置行业失败,错误代码:" + ex.Message + "\r\n" + resultStr, backgroundWorker: backgroundWorker);
  344. }
  345. });
  346. }
  347. catch
  348. {
  349. MessageBoxCustom.Show("设置行业载失败!请检查网络环境或关闭系统后重试!");
  350. }
  351. }
  352. void dgvMicroTemplate_CellContentClick(object sender, DataGridViewCellEventArgs e)
  353. {
  354. if (e.RowIndex >= 0 && e.ColumnIndex == 9)
  355. {
  356. dgvMicroTemplate_CellDoubleClick(sender, e);
  357. }
  358. else if (e.RowIndex >= 0 && e.ColumnIndex == 10)
  359. {
  360. if (MessageBoxCustom.Show("您确定要删除当前微信模板设置记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  361. {
  362. DataGridViewRow row = this.dgvMicroTemplate.Rows[e.RowIndex];
  363. LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  364. if (smsBLL.Delete(model))
  365. {
  366. this.dgvMicroTemplate.Rows.RemoveAt(e.RowIndex);
  367. }
  368. else
  369. {
  370. MessageBoxCustom.Show("删除失败,请关闭后重试");
  371. }
  372. }
  373. }
  374. else if (e.RowIndex >= 0 && e.ColumnIndex == 8)
  375. {
  376. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update))
  377. {
  378. MessageBoxCustom.Show("抱歉,你没有修改权限!");
  379. return;
  380. }
  381. DataGridViewRow row = this.dgvMicroTemplate.Rows[e.RowIndex];
  382. LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  383. model = smsBLL.GetModel(model.ID);
  384. model.ST_IsEnabled = !model.ST_IsEnabled;
  385. if (smsBLL.Update(model))
  386. {
  387. BindDgvMicroTemplate();
  388. }
  389. else
  390. {
  391. MessageBoxCustom.Show("设置失败,请关闭后重试");
  392. }
  393. }
  394. }
  395. void dgvMicroTemplate_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  396. {
  397. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update))
  398. {
  399. MessageBoxCustom.Show("抱歉,你没有修改权限!");
  400. return;
  401. }
  402. if (e.RowIndex >= 0 && e.ColumnIndex >= 0 && (e.ColumnIndex <= 7 || e.ColumnIndex == 9))
  403. {
  404. DataGridViewRow row = this.dgvMicroTemplate.Rows[e.RowIndex];
  405. frmAddMicroTemplate frmAddST = new frmAddMicroTemplate();
  406. frmAddST.SCategory = this.MicroCategory;
  407. frmAddST.ThisParentForm = this;
  408. try
  409. {
  410. frmAddST.SmsModel = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  411. }
  412. catch { }
  413. if (frmAddST.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  414. {
  415. BindDgvMicroTemplate();
  416. }
  417. }
  418. }
  419. void frmSMSTemplateSet_Load(object sender, EventArgs e)
  420. {
  421. }
  422. void rdoGonggongMicro_Click(object sender, EventArgs e)
  423. {
  424. BindMicroCategory(EnumPublic.SmsCategory.公共短信);
  425. }
  426. void rdohunshaMicro_Click(object sender, EventArgs e)
  427. {
  428. BindMicroCategory(EnumPublic.SmsCategory.婚纱短信);
  429. }
  430. void rdoertongMicro_Click(object sender, EventArgs e)
  431. {
  432. BindMicroCategory(EnumPublic.SmsCategory.儿童短信);
  433. }
  434. void rdoxiezhengMicro_Click(object sender, EventArgs e)
  435. {
  436. BindMicroCategory(EnumPublic.SmsCategory.写真短信);
  437. }
  438. void rdoHTSmsMicro_Click(object sender, EventArgs e)
  439. {
  440. BindMicroCategory(EnumPublic.SmsCategory.医院跟踪短信);
  441. }
  442. /// <summary>
  443. ///
  444. /// </summary>
  445. /// <param name="sCty"></param>
  446. void BindMicroCategory(EnumPublic.SmsCategory sCty)
  447. {
  448. if (sCty != this.MicroCategory)
  449. {
  450. this.MicroCategory = sCty;
  451. BindDgvMicroTemplate();
  452. }
  453. }
  454. void BindDgvMicroTemplate()
  455. {
  456. this.dgvMicroTemplate.Rows.Clear();
  457. try
  458. {
  459. List<LYFZ.Model.Model_SMSTemplates> smsModelList = null;
  460. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  461. {
  462. 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() + "'");
  463. });
  464. if (smsModelList != null)
  465. {
  466. foreach (LYFZ.Model.Model_SMSTemplates model in smsModelList)
  467. {
  468. DataGridViewRow row = new DataGridViewRow();
  469. row.CreateCells(this.dgvMicroTemplate);
  470. try
  471. {
  472. row.Cells[0].Value = ((LYFZ.EnumPublic.MicroSendEvent)model.ST_SendEvent).ToString();
  473. }
  474. catch
  475. {
  476. row.Cells[0].Value = "未知事件";
  477. }
  478. row.Cells[1].Value = GetTemplateMicroTitle(model);
  479. row.Cells[2].Value = model.ST_Title;
  480. try
  481. {
  482. row.Cells[3].Value = LYFZ.WinAPI.CustomPublicMethod.ConvertEnumToDescription((EnumPublic.MicroTemplate)Enum.Parse(typeof(EnumPublic.MicroTemplate), model.ST_Title));//model.ST_ReceiveObjects;
  483. }catch{
  484. row.Cells[3].Value = "未知模板";
  485. }
  486. row.Cells[4].Value = model.ST_SMSContent;
  487. row.Cells[5].Value = model.ST_Remark;
  488. row.Cells[6].Value = model.ST_ReceiveObjects;
  489. row.Cells[7].Value = model.ST_UpdateDatetime.ToString("yyyy-MM-dd HH:mm:ss");
  490. if (model.ST_IsEnabled)
  491. {
  492. row.Cells[8].Value = "已启用";
  493. row.Cells[8].Style.BackColor = Color.Green;
  494. }
  495. else
  496. {
  497. row.Cells[8].Value = "已禁用";
  498. row.Cells[8].Style.BackColor = Color.Gray;
  499. }
  500. row.Cells[9].Value = "编缉";
  501. row.Cells[10].Value = "删除";
  502. row.Tag = model;
  503. this.dgvMicroTemplate.Rows.Add(row);
  504. }
  505. }
  506. if (this.dgvMicroTemplate.SortedColumn != null)
  507. {
  508. ListSortDirection Direction = ListSortDirection.Descending;
  509. switch (this.dgvMicroTemplate.SortOrder)
  510. {
  511. case SortOrder.Ascending:
  512. Direction = ListSortDirection.Ascending;
  513. break;
  514. case SortOrder.Descending:
  515. Direction = ListSortDirection.Descending;
  516. break;
  517. default: break;
  518. }
  519. this.dgvMicroTemplate.Sort(this.dgvSmsT.SortedColumn, Direction);
  520. }
  521. }
  522. catch
  523. {
  524. MessageBoxCustom.Show("微信消息模板记录加载失败!请检查网络环境或关闭系统后重试!");
  525. }
  526. }
  527. /// <summary>
  528. /// 根据事件和事件值返回模板标题
  529. /// </summary>
  530. /// <param name="model"></param>
  531. /// <returns></returns>
  532. string GetTemplateMicroTitle(LYFZ.Model.Model_SMSTemplates model)
  533. {
  534. string retTitle = "未知短信设置";
  535. try
  536. {
  537. LYFZ.EnumPublic.MicroSendEvent smsEvent = (LYFZ.EnumPublic.MicroSendEvent)model.ST_SendEvent;
  538. retTitle = smsEvent.ToString().Replace("X", model.ST_SendEventValue);
  539. }
  540. catch { }
  541. return retTitle;
  542. }
  543. /// <summary>
  544. /// 当前微信模板类别
  545. /// </summary>
  546. EnumPublic.SmsCategory MicroCategory = EnumPublic.SmsCategory.公共短信;
  547. void dgvMicroTemplateItem_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  548. {
  549. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update))
  550. {
  551. MessageBoxCustom.Show("抱歉,你没有修改权限!");
  552. return;
  553. }
  554. if (e.RowIndex >= 0 && e.ColumnIndex >= 0 && e.ColumnIndex <= 4)
  555. {
  556. DataGridViewRow row = this.dgvMicroTemplateItem.Rows[e.RowIndex];
  557. frmAddMicroTemplateItem frmAddSmsT = new frmAddMicroTemplateItem();
  558. try
  559. {
  560. frmAddSmsT.SmsModel = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  561. }
  562. catch { }
  563. if (frmAddSmsT.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  564. {
  565. BindDgvMicroTemplateIDList();
  566. }
  567. }
  568. }
  569. void dgvMicroTemplateItem_CellContentClick(object sender, DataGridViewCellEventArgs e)
  570. {
  571. if (e.RowIndex >= 0 && e.ColumnIndex == 4)
  572. {
  573. dgvMicroTemplateItem_CellDoubleClick(sender, e);
  574. }
  575. else if (e.RowIndex >= 0 && e.ColumnIndex == 5)
  576. {
  577. if (MessageBoxCustom.Show("您确定要删除当前微信模板ID吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  578. {
  579. DataGridViewRow row = this.dgvMicroTemplateItem.Rows[e.RowIndex];
  580. LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  581. if (smsBLL.Delete(model))
  582. {
  583. this.dgvMicroTemplateItem.Rows.RemoveAt(e.RowIndex);
  584. }
  585. else
  586. {
  587. MessageBoxCustom.Show("删除失败,请关闭后重试");
  588. }
  589. }
  590. }
  591. }
  592. /// <summary>
  593. /// 删除微信模板ID
  594. /// </summary>
  595. /// <param name="sender"></param>
  596. /// <param name="e"></param>
  597. void btndelAllMicroTemplate_Click(object sender, EventArgs e)
  598. {
  599. if (this.dgvMicroTemplateItem.Rows.Count <= 0)
  600. {
  601. MessageBoxCustom.Show("没有要删除的记录!");
  602. return;
  603. }
  604. if (MessageBoxCustom.Show("您确定要删除所有记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  605. {
  606. if (smsBLL.Delete("ST_Type=" + ((int)EnumPublic.SmsTemplateType.微信模板ID).ToString()))
  607. {
  608. this.dgvMicroTemplateItem.Rows.Clear();
  609. }
  610. else
  611. {
  612. MessageBoxCustom.Show("删除失败");
  613. }
  614. }
  615. }
  616. /// <summary>
  617. /// 添加下载微信模板ID
  618. /// </summary>
  619. /// <param name="sender"></param>
  620. /// <param name="e"></param>
  621. void btnMicroTemplate_Click(object sender, EventArgs e)
  622. {
  623. /* System.Web.Script.Serialization.JavaScriptSerializer Jss = new System.Web.Script.Serialization.JavaScriptSerializer();
  624. dynamic data=new
  625. {
  626. first = LYFZ.BLL.BLL_SMSTemplates.GetColorAndValue("ipid"),
  627. keynote1 = LYFZ.BLL.BLL_SMSTemplates.GetColorAndValue("39.8元"),
  628. keynote2 = LYFZ.BLL.BLL_SMSTemplates.GetColorAndValue("2014年9月22日"),
  629. remark = LYFZ.BLL.BLL_SMSTemplates.GetColorAndValue("欢迎再次购买!"),
  630. };
  631. dynamic obj = new
  632. {
  633. touser = "这是填入要发送到的用户的OpenID",
  634. template_id = "ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY",
  635. url = "http://weixin.qq.com/download",
  636. data = data
  637. };
  638. string jsonstring = Jss.Serialize(obj);
  639. */
  640. frmAddMicroTemplateItem frmAddSTItem = new frmAddMicroTemplateItem();
  641. if (frmAddSTItem.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  642. {
  643. BindDgvMicroTemplateIDList();
  644. }
  645. }
  646. /// <summary>
  647. /// 删除微信模板
  648. /// </summary>
  649. /// <param name="sender"></param>
  650. /// <param name="e"></param>
  651. void btnDelallMicro_Click(object sender, EventArgs e)
  652. {
  653. if (this.dgvMicroTemplate.Rows.Count <= 0)
  654. {
  655. MessageBoxCustom.Show("没有要删除的记录!");
  656. return;
  657. }
  658. if (MessageBoxCustom.Show("您确定要删除所有记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  659. {
  660. if (smsBLL.Delete("ST_Type=" + ((int)EnumPublic.SmsTemplateType.微信消息模板).ToString()+" and ST_Category=" + ((int)this.MicroCategory).ToString()))
  661. {
  662. this.dgvMicroTemplate.Rows.Clear();
  663. }
  664. else
  665. {
  666. MessageBoxCustom.Show("删除失败");
  667. }
  668. }
  669. }
  670. /// <summary>
  671. /// 添加微信模板
  672. /// </summary>
  673. /// <param name="sender"></param>
  674. /// <param name="e"></param>
  675. void btnAddMicroT_Click(object sender, EventArgs e)
  676. {
  677. frmAddMicroTemplate frmAddST = new frmAddMicroTemplate();
  678. frmAddST.SCategory = this.MicroCategory;
  679. frmAddST.ThisParentForm = this;
  680. if (frmAddST.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  681. {
  682. BindDgvMicroTemplate();
  683. }
  684. }
  685. void rdoHTSms_Click(object sender, EventArgs e)
  686. {
  687. BindSmsCategory(EnumPublic.SmsCategory.医院跟踪短信);
  688. }
  689. void btnAccountQuery_Click(object sender, EventArgs e)
  690. {
  691. try
  692. {
  693. if (CurrentSmsAccount != null && CurrentSmsAccount.ID > 0)
  694. {
  695. CurrentSmsAccount.Smsa_AccountNumber = this.txtSmsa_AccountNumber.Text.Trim() ;
  696. CurrentSmsAccount.Smsa_Password = this.txtSmsa_Password.Text.Trim();
  697. if (CurrentSmsAccount.Smsa_AccountNumber.Trim().Length <= 0)
  698. {
  699. MessageBoxCustom.Show("请输入短信帐号");
  700. return;
  701. }
  702. if (CurrentSmsAccount.Smsa_Password.Trim().Length <= 0)
  703. {
  704. MessageBoxCustom.Show("请输入帐号密码");
  705. return;
  706. }
  707. LYFZ.WcfServiceSharedLibraries.Wcf_SmsUserInfo uIfo = null;
  708. bool isAccountQueryOK = false;
  709. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  710. {
  711. backgroundWorker.ReportProgress(0, "正在查询,请稍等...");
  712. uIfo = LYFZ.WindowsServiceHandling.SmsSendHandling.GetSMSAccountInfo(CurrentSmsAccount.Smsa_AccountNumber, CurrentSmsAccount.Smsa_Password);
  713. if (uIfo != null && uIfo.ReturnCode.Trim() == "0")
  714. {
  715. CurrentSmsAccount.Smsa_AccountName = uIfo.Signatures;
  716. CurrentSmsAccount.Smsa_MoneyBalances = uIfo.Balance;
  717. CurrentSmsAccount.Smsa_SumSendCount = uIfo.BeenSentCount;
  718. if (SmsAccountInfobll.Update(CurrentSmsAccount))
  719. {
  720. isAccountQueryOK = true;
  721. MessageBoxCustom.Show("当前帐号余额(条数):" + CurrentSmsAccount.Smsa_MoneyBalances.ToString() + "\r\n已发送(条数):" + CurrentSmsAccount.Smsa_SumSendCount.ToString() + "\r\n签名为:" + CurrentSmsAccount.Smsa_AccountName);
  722. }
  723. else
  724. {
  725. MessageBoxCustom.Show("更新帐号信息时失败,请关闭后重试.", backgroundWorker: backgroundWorker);
  726. }
  727. }
  728. else
  729. {
  730. if (uIfo == null)
  731. {
  732. MessageBoxCustom.Show("短信帐号信息查询失败,请检查网络环境是否正常.", backgroundWorker: backgroundWorker);
  733. }
  734. else
  735. {
  736. MessageBoxCustom.Show("短信帐号信息查询失败,失败原因:" + getSendReport(uIfo.ReturnCode), backgroundWorker: backgroundWorker);
  737. }
  738. }
  739. backgroundWorker.ReportProgress(0, "查询完成");
  740. });
  741. if (isAccountQueryOK)
  742. {
  743. GetCurrentSmsAccount();
  744. }
  745. }
  746. else {
  747. MessageBoxCustom.Show("请设置帐号密码后重试");
  748. }
  749. }
  750. catch (Exception ex)
  751. {
  752. MessageBoxCustom.Show("获取当前短信帖号信息失败,失败原因:" + ex.Message);
  753. }
  754. }
  755. string getSendReport(string returnCode)
  756. {
  757. LYFZ.WcfServiceSharedLibraries.SmsReturnCode retCode = WcfServiceSharedLibraries.SmsReturnCode.提交异常_请联系服务商解决;
  758. try
  759. {
  760. retCode = (LYFZ.WcfServiceSharedLibraries.SmsReturnCode)Convert.ToInt32(returnCode);
  761. }
  762. catch { }
  763. return retCode.ToString();
  764. }
  765. void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
  766. {
  767. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update))
  768. {
  769. e.Cancel = true;
  770. }
  771. }
  772. /// <summary>
  773. /// 启用/禁用短信模版
  774. /// </summary>
  775. /// <param name="enabled"></param>
  776. void SetSMSTemplatesEnabled(bool enabled)
  777. {
  778. if (this.dgvSmsT.SelectedRows != null && this.dgvSmsT.SelectedRows.Count>0)
  779. {
  780. bool updateOK = false;
  781. string idList = "";
  782. foreach (DataGridViewRow row in this.dgvSmsT.SelectedRows)
  783. {
  784. LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  785. idList += model.ID.ToString()+",";
  786. }
  787. idList = idList.Trim(',');
  788. updateOK= this.smsBLL.UpdateIsEnabled(idList,enabled);
  789. if (updateOK)
  790. {
  791. BindDgvSmsT();
  792. }
  793. }
  794. else {
  795. MessageBoxCustom.Show("请选择要设置的短信模板记录");
  796. }
  797. }
  798. void tlsDisabled_Click(object sender, EventArgs e)
  799. {
  800. SetSMSTemplatesEnabled(false);
  801. }
  802. void tlsEnable_Click(object sender, EventArgs e)
  803. {
  804. SetSMSTemplatesEnabled(true);
  805. }
  806. /// <summary>
  807. /// 根据软件业务版本设置显示短信设置类型
  808. /// </summary>
  809. void SetShowSmsTpye() {
  810. switch (CurrentBusinessType)
  811. {
  812. case EnumPermissions.BusinessType.婚纱版:
  813. this.rdoertong.Visible = false;
  814. this.rdoHTSms.Visible = false;
  815. break;
  816. case EnumPermissions.BusinessType.儿童版:
  817. this.rdohunsha.Visible = false;
  818. break;
  819. }
  820. }
  821. void rdoxiezheng_Click(object sender, EventArgs e)
  822. {
  823. BindSmsCategory(EnumPublic.SmsCategory.写真短信);
  824. }
  825. void rdoertong_Click(object sender, EventArgs e)
  826. {
  827. BindSmsCategory(EnumPublic.SmsCategory.儿童短信);
  828. }
  829. void rdohunsha_Click(object sender, EventArgs e)
  830. {
  831. BindSmsCategory(EnumPublic.SmsCategory.婚纱短信);
  832. }
  833. void rdoGonggong_Click(object sender, EventArgs e)
  834. {
  835. BindSmsCategory(EnumPublic.SmsCategory.公共短信);
  836. }
  837. /// <summary>
  838. ///
  839. /// </summary>
  840. /// <param name="i"></param>
  841. void BindSmsCategory(EnumPublic.SmsCategory sCty)
  842. {
  843. // EnumPublic.SmsCategory sCty = (EnumPublic.SmsCategory)Convert.ToInt32(i);
  844. if (sCty != this.sCategory)
  845. {
  846. this.sCategory = sCty;
  847. BindDgvSmsT();
  848. }
  849. }
  850. /// <summary>
  851. /// 当前短信类别
  852. /// </summary>
  853. EnumPublic.SmsCategory sCategory = EnumPublic.SmsCategory.公共短信;
  854. void dgvSmsT_CellContentClick(object sender, DataGridViewCellEventArgs e)
  855. {
  856. if (e.RowIndex >= 0 && e.ColumnIndex == 6)
  857. {
  858. dgvSmsT_CellDoubleClick(sender, e);
  859. }
  860. else if (e.RowIndex >= 0 && e.ColumnIndex == 7)
  861. {
  862. if (MessageBoxCustom.Show("您确定要删除当前短信设置记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  863. {
  864. DataGridViewRow row = this.dgvSmsT.Rows[e.RowIndex];
  865. LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  866. if (smsBLL.Delete(model))
  867. {
  868. this.dgvSmsT.Rows.RemoveAt(e.RowIndex);
  869. }
  870. else
  871. {
  872. MessageBoxCustom.Show("删除失败,请关闭后重试");
  873. }
  874. }
  875. }
  876. else if (e.RowIndex >= 0 && e.ColumnIndex == 5)
  877. {
  878. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update))
  879. {
  880. MessageBoxCustom.Show("抱歉,你没有修改权限!");
  881. return;
  882. }
  883. DataGridViewRow row = this.dgvSmsT.Rows[e.RowIndex];
  884. LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  885. model = smsBLL.GetModel(model.ID);
  886. model.ST_IsEnabled = !model.ST_IsEnabled;
  887. if (smsBLL.Update(model))
  888. {
  889. BindDgvSmsT();
  890. }
  891. else
  892. {
  893. MessageBoxCustom.Show("设置失败,请关闭后重试");
  894. }
  895. }
  896. }
  897. void dgvSmsT_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  898. {
  899. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update))
  900. {
  901. MessageBoxCustom.Show("抱歉,你没有修改权限!");
  902. return;
  903. }
  904. if (e.RowIndex >= 0 && e.ColumnIndex >= 0 && (e.ColumnIndex <= 4 || e.ColumnIndex == 6))
  905. {
  906. DataGridViewRow row = this.dgvSmsT.Rows[e.RowIndex];
  907. frmAddSMSTemplate frmAddSmsT = new frmAddSMSTemplate();
  908. frmAddSmsT.SCategory = this.sCategory;
  909. try
  910. {
  911. frmAddSmsT.SmsModel = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  912. }
  913. catch { }
  914. if (frmAddSmsT.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  915. {
  916. BindDgvSmsT();
  917. }
  918. }
  919. }
  920. void btnSmsTAdd_Click(object sender, EventArgs e)
  921. {
  922. frmAddSMSTemplate frmAddST = new frmAddSMSTemplate();
  923. frmAddST.SCategory = this.sCategory;
  924. if (frmAddST.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
  925. BindDgvSmsT();
  926. }
  927. }
  928. void btnCommonSMSAllDel_Click(object sender, EventArgs e)
  929. {
  930. if (this.dgvCommonSMS.Rows.Count <= 0)
  931. {
  932. MessageBoxCustom.Show("没有要删除的记录!");
  933. return;
  934. }
  935. if (MessageBoxCustom.Show("您确定要删除所有记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  936. {
  937. if (smsBLL.Delete("ST_Type=" + ((int)EnumPublic.SmsTemplateType.常用样板信息).ToString()))
  938. {
  939. this.dgvCommonSMS.Rows.Clear();
  940. }
  941. else {
  942. MessageBoxCustom.Show("删除失败");
  943. }
  944. }
  945. }
  946. void btnSmsTAlldel_Click(object sender, EventArgs e)
  947. {
  948. // FrmSMSSettings frm = new FrmSMSSettings();
  949. // frm.Show();
  950. // return;
  951. //以上为测试用
  952. if (this.dgvSmsT.Rows.Count <= 0) {
  953. MessageBoxCustom.Show("没有要删除的记录!");
  954. return;
  955. }
  956. if (MessageBoxCustom.Show("您确定要删除所有记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  957. {
  958. if (smsBLL.Delete("ST_Type="+((int)EnumPublic.SmsTemplateType.事件短信).ToString()+" and ST_Category=" + ((int)sCategory).ToString()))
  959. {
  960. this.dgvSmsT.Rows.Clear();
  961. }
  962. else
  963. {
  964. MessageBoxCustom.Show("删除失败");
  965. }
  966. }
  967. }
  968. void btnSaveAccount_Click(object sender, EventArgs e)
  969. {
  970. if (this.txtSmsa_AccountNumber.Text.Trim().Length <= 0)
  971. {
  972. MessageBoxCustom.Show("请输入短信帐号!");
  973. return;
  974. }
  975. if (this.txtSmsa_Password.Text.Trim().Length <= 0)
  976. {
  977. MessageBoxCustom.Show("请输入短信帐号密码!");
  978. return;
  979. }
  980. SaveSmsBalanceToRemind(this.chkbalanceRemind.Checked, Convert.ToInt32(this.nubalanceRemind.Value));
  981. if (CurrentSmsAccount == null)
  982. {
  983. _CurrentSmsAccount = new Model.Model_ErpSmsAccountInfo();
  984. CurrentSmsAccount.Smsa_SendTypes = "0";
  985. CurrentSmsAccount.Smsa_AccountNumber = this.txtSmsa_AccountNumber.Text.Trim();
  986. CurrentSmsAccount.Smsa_Password = this.txtSmsa_Password.Text.Trim();
  987. CurrentSmsAccount.Smsa_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID();
  988. if (SmsAccountInfobll.Add(CurrentSmsAccount))
  989. {
  990. LoadCurrentSmsAccount();
  991. GetCurrentSmsAccount();
  992. MessageBoxCustom.Show("短信帐号添加成功!");
  993. }
  994. else
  995. {
  996. MessageBoxCustom.Show("短信帐号添加失败!");
  997. }
  998. }
  999. else
  1000. {
  1001. CurrentSmsAccount.Smsa_AccountNumber = this.txtSmsa_AccountNumber.Text.Trim();
  1002. CurrentSmsAccount.Smsa_Password = this.txtSmsa_Password.Text.Trim();
  1003. if (SmsAccountInfobll.Update(CurrentSmsAccount))
  1004. {
  1005. MessageBoxCustom.Show("短信帐号修改成功!");
  1006. }
  1007. else
  1008. {
  1009. MessageBoxCustom.Show("短信帐号修改失败!");
  1010. }
  1011. }
  1012. }
  1013. void dgvCommonSMS_CellContentClick(object sender, DataGridViewCellEventArgs e)
  1014. {
  1015. if (e.RowIndex >= 0 && e.ColumnIndex == 3)
  1016. {
  1017. dgvCommonSMS_CellDoubleClick(sender, e);
  1018. }
  1019. else if (e.RowIndex >= 0 && e.ColumnIndex == 4)
  1020. {
  1021. if (MessageBoxCustom.Show("您确定要删除当前短信记录吗?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  1022. {
  1023. DataGridViewRow row = this.dgvCommonSMS.Rows[e.RowIndex];
  1024. LYFZ.Model.Model_SMSTemplates model = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  1025. if (smsBLL.Delete(model))
  1026. {
  1027. this.dgvCommonSMS.Rows.RemoveAt(e.RowIndex);
  1028. }
  1029. else {
  1030. MessageBoxCustom.Show("删除失败,请关闭后重试");
  1031. }
  1032. }
  1033. }
  1034. }
  1035. void dgvCommonSMS_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  1036. {
  1037. if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSSettingsCompetence, CustomAttributes.OperatingAuthority.Update))
  1038. {
  1039. MessageBoxCustom.Show("抱歉,你没有修改权限!");
  1040. return;
  1041. }
  1042. if (e.RowIndex >= 0 && e.ColumnIndex >= 0 && e.ColumnIndex<=3)
  1043. {
  1044. DataGridViewRow row = this.dgvCommonSMS.Rows[e.RowIndex];
  1045. frmAddCommonSMS frmAddSms = new frmAddCommonSMS();
  1046. try
  1047. {
  1048. frmAddSms.SmsModel = (LYFZ.Model.Model_SMSTemplates)row.Tag;
  1049. }
  1050. catch { }
  1051. if (frmAddSms.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1052. {
  1053. frmSelectSmsInfo.BindSmsClass(this.cboxSmsClass);
  1054. BindDgvCommonSMS();
  1055. }
  1056. }
  1057. }
  1058. LYFZ.BLL.BLL_ErpSmsAccountInfo SmsAccountInfobll = new BLL.BLL_ErpSmsAccountInfo();
  1059. /// <summary>
  1060. /// 当前短信帐号
  1061. /// </summary>
  1062. static LYFZ.Model.Model_ErpSmsAccountInfo _CurrentSmsAccount = null;
  1063. public static LYFZ.Model.Model_ErpSmsAccountInfo CurrentSmsAccount
  1064. {
  1065. get {
  1066. if (frmSMSTemplateSet._CurrentSmsAccount == null)
  1067. {
  1068. LoadCurrentSmsAccount();
  1069. /* List<LYFZ.Model.Model_ErpSmsAccountInfo> smsAccountList = new BLL.BLL_ErpSmsAccountInfo().GetModelObject("Smsa_DividedShop=''");//.GetModelList("[Smsa_SendTypes]='0'");
  1070. if (smsAccountList.Count > 0) {
  1071. frmSMSTemplateSet._CurrentSmsAccount = smsAccountList[0];
  1072. }*/
  1073. }
  1074. return frmSMSTemplateSet._CurrentSmsAccount; }
  1075. }
  1076. public static void LoadCurrentSmsAccount()
  1077. {
  1078. frmSMSTemplateSet._CurrentSmsAccount = (LYFZ.Model.Model_ErpSmsAccountInfo)(new BLL.BLL_ErpSmsAccountInfo().GetModelObject("Smsa_DividedShop", LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID()));
  1079. if (frmSMSTemplateSet._CurrentSmsAccount.ID <= 0)
  1080. {
  1081. frmSMSTemplateSet._CurrentSmsAccount = null;
  1082. }
  1083. }
  1084. /// <summary>
  1085. /// 获取当前短信帖号
  1086. /// </summary>
  1087. void GetCurrentSmsAccount()
  1088. {
  1089. if (frmSMSTemplateSet.CurrentSmsAccount != null)
  1090. {
  1091. this.txtSmsa_AccountNumber.Text = CurrentSmsAccount.Smsa_AccountNumber;
  1092. this.txtSmsa_Password.Text = CurrentSmsAccount.Smsa_Password;
  1093. this.txtSmsa_MoneyBalances.Text = CurrentSmsAccount.Smsa_MoneyBalances.ToString("n0");
  1094. this.txtUsed.Text = CurrentSmsAccount.Smsa_SumSendCount.ToString();
  1095. }
  1096. }
  1097. void frmSMSTemplateSet_Shown(object sender, EventArgs e)
  1098. {
  1099. // LYFZ.WindowsServiceHandling.MessageService.WeixinConfigRegister();
  1100. List<Control> hideControl = new List<Control>();
  1101. //LYFZSS.SystemSpecterPossessed.ISystemSpecterPossessed.GetMySystemSpecter = LYFZSS.SystemSpecterType.SST_D;
  1102. hideControl.Add(this.rdoHTSms);
  1103. LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(
  1104. VersionControl.VersionFunctionEnum.短信管理医院跟踪短信, hideControl, null, null);
  1105. hideControl = new List<Control>();
  1106. //LYFZSS.SystemSpecterPossessed.ISystemSpecterPossessed.GetMySystemSpecter = LYFZSS.SystemSpecterType.SST_D;
  1107. bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(
  1108. VersionControl.VersionFunctionEnum.短信管理微信短信推送, hideControl, null, null);
  1109. if(!b)
  1110. {
  1111. if (tabControlEx1.TabPages.Count > 2)
  1112. {
  1113. tabControlEx1.TabPages.Remove(tabControlEx1.TabPages[2]);
  1114. tabControlEx1.TabPages.Remove(tabControlEx1.TabPages[2]);
  1115. }
  1116. }
  1117. this.rdoLFSMS.Visible= LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(
  1118. VersionControl.VersionFunctionEnum.礼服管理, hideControl, null, null);
  1119. BindDgvSmsT();
  1120. GetCurrentSmsAccount();
  1121. SmsConfigureModel = sysConfigBll.GetConfigureInfo(Model.ConfigItemType.SmsBalanceToRemind);
  1122. SetSmsBalanceToRemind(SmsConfigureModel);
  1123. }
  1124. void SetSmsBalanceToRemind(Model.Model_ErpSystemConfigure SmsConfigureModelInfo)
  1125. {
  1126. if (SmsConfigureModelInfo.ID > 0 && SmsConfigureModelInfo.Sconfig_Value.Length > 3)
  1127. {
  1128. dynamic RemindObj = Newtonsoft.Json.JsonConvert.DeserializeObject(SmsConfigureModelInfo.Sconfig_Value);
  1129. this.nubalanceRemind.Value =Convert.ToDecimal(RemindObj["balanceNumber"]);
  1130. if (RemindObj["Open"] == 1)
  1131. {
  1132. this.chkbalanceRemind.Checked = true;
  1133. }
  1134. }
  1135. }
  1136. void SaveSmsBalanceToRemind(bool open, int balanceNumber)
  1137. {
  1138. string valueString = Newtonsoft.Json.JsonConvert.SerializeObject(
  1139. new
  1140. {
  1141. Open = open ? 1 : 0,
  1142. balanceNumber = balanceNumber
  1143. }
  1144. );
  1145. sysConfigBll.SaveConfigureInfo(Model.ConfigItemType.SmsBalanceToRemind, valueString);
  1146. }
  1147. void BindDgvSmsT()
  1148. {
  1149. this.dgvSmsT.Rows.Clear();
  1150. try
  1151. {
  1152. List<LYFZ.Model.Model_SMSTemplates> smsModelList = null;
  1153. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  1154. {
  1155. smsModelList = smsBLL.GetModelList("ST_Type=" + ((int)EnumPublic.SmsTemplateType.事件短信).ToString() + " and ST_Category=" + ((int)sCategory).ToString() + " and ST_DividedShop='" + LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID.Trim() + "'");
  1156. });
  1157. if (smsModelList != null)
  1158. {
  1159. foreach (LYFZ.Model.Model_SMSTemplates model in smsModelList)
  1160. {
  1161. DataGridViewRow row = new DataGridViewRow();
  1162. row.CreateCells(this.dgvSmsT);
  1163. try
  1164. {
  1165. row.Cells[0].Value = ((LYFZ.EnumPublic.SmsSendEvent)model.ST_SendEvent).ToString();
  1166. }
  1167. catch {
  1168. row.Cells[0].Value = "未知事件";
  1169. }
  1170. row.Cells[1].Value = GetTemplateSmsTitle(model);
  1171. row.Cells[2].Value = model.ST_SMSContent;
  1172. row.Cells[3].Value = model.ST_ReceiveObjects;
  1173. row.Cells[4].Value = model.ST_UpdateDatetime.ToString("yyyy-MM-dd HH:mm:ss");
  1174. if (model.ST_IsEnabled)
  1175. {
  1176. row.Cells[5].Value = "已启用";
  1177. row.Cells[5].Style.BackColor = Color.Green;
  1178. }
  1179. else {
  1180. row.Cells[5].Value = "已禁用";
  1181. row.Cells[5].Style.BackColor = Color.Gray;
  1182. }
  1183. row.Cells[6].Value = "编缉";
  1184. row.Cells[7].Value = "删除";
  1185. row.Tag = model;
  1186. this.dgvSmsT.Rows.Add(row);
  1187. }
  1188. }
  1189. if (this.dgvSmsT.SortedColumn != null)
  1190. {
  1191. ListSortDirection Direction = ListSortDirection.Descending;
  1192. switch (this.dgvSmsT.SortOrder)
  1193. {
  1194. case SortOrder.Ascending:
  1195. Direction = ListSortDirection.Ascending;
  1196. break;
  1197. case SortOrder.Descending:
  1198. Direction = ListSortDirection.Descending;
  1199. break;
  1200. default: break;
  1201. }
  1202. this.dgvSmsT.Sort(this.dgvSmsT.SortedColumn, Direction);
  1203. }
  1204. }
  1205. catch
  1206. {
  1207. MessageBoxCustom.Show("短信设置记录加载失败!请检查网络环境或关闭系统后重试!");
  1208. }
  1209. }
  1210. /*
  1211. 积分兑换后X分钟发提醒短信:
  1212. 男宾生日前X天发短信给女宾:
  1213. 女宾生日前X天发短信给男宾:
  1214. 员工生日前X天发送短信给X手机号:
  1215. 会员积分变动后X分钟:
  1216. 删除会员后X分钟:
  1217. 注消会员后X分钟:
  1218. 修改会员支付密码后X分钟:
  1219. 会员服务卡使用后X分钟:
  1220. 会员积分有效期到期前X天:
  1221. 会员储值有效期到期前X天:
  1222. 会员服务套餐有效期到期前X天:
  1223. 会员新摄会有效期到期前X天:
  1224. 会员返现卡有效期到期前X天:
  1225. 会员返现卡提现后X分钟:
  1226. 会员返现卡获得返现金后X分钟:
  1227. */
  1228. /// <summary>
  1229. /// 根据事件和事件值返回模板标题
  1230. /// </summary>
  1231. /// <param name="model"></param>
  1232. /// <returns></returns>
  1233. string GetTemplateSmsTitle(LYFZ.Model.Model_SMSTemplates model)
  1234. {
  1235. string retTitle = "未知短信设置";
  1236. try
  1237. {
  1238. LYFZ.EnumPublic.SmsSendEvent smsEvent = (LYFZ.EnumPublic.SmsSendEvent)model.ST_SendEvent;
  1239. retTitle = smsEvent.ToString();
  1240. switch (smsEvent)
  1241. {
  1242. case EnumPublic.SmsSendEvent.客人订单后X分钟:
  1243. case EnumPublic.SmsSendEvent.订单件齐后X分钟发送取件通知:
  1244. case EnumPublic.SmsSendEvent.拍照预约后X分钟:
  1245. case EnumPublic.SmsSendEvent.拍照完成后X分钟:
  1246. case EnumPublic.SmsSendEvent.客人选片完成后X分钟:
  1247. case EnumPublic.SmsSendEvent.客人看样后X分钟:
  1248. case EnumPublic.SmsSendEvent.客人取件后X分钟:
  1249. case EnumPublic.SmsSendEvent.当积分接近X的百分之80时:
  1250. case EnumPublic.SmsSendEvent.当积分达到或超过X分时:
  1251. case EnumPublic.SmsSendEvent.转介绍后X分钟发送短信给介绍人:
  1252. case EnumPublic.SmsSendEvent.发放会员卡后X分钟发会员短信:
  1253. case EnumPublic.SmsSendEvent.现金卡消费后X分钟后发提醒短信:
  1254. case EnumPublic.SmsSendEvent.现金卡充值后X分钟后发提醒短信:
  1255. case EnumPublic.SmsSendEvent.客人生日前X天:
  1256. case EnumPublic.SmsSendEvent.客人婚礼前X天:
  1257. case EnumPublic.SmsSendEvent.结婚纪念日前X天:
  1258. case EnumPublic.SmsSendEvent.宝宝生日前X天:
  1259. case EnumPublic.SmsSendEvent.宝宝X天成长跟踪短信:
  1260. case EnumPublic.SmsSendEvent.家长生日前X天:
  1261. case EnumPublic.SmsSendEvent.员工生日前X天:
  1262. case EnumPublic.SmsSendEvent.客户来电挂机后X分钟:
  1263. case EnumPublic.SmsSendEvent.未知来电挂机后X分钟:
  1264. case EnumPublic.SmsSendEvent.员工来电挂机后X分钟:
  1265. case EnumPublic.SmsSendEvent.怀孕X天周期跟踪短信:
  1266. case EnumPublic.SmsSendEvent.来单录入后X分钟:
  1267. case EnumPublic.SmsSendEvent.礼服出租还衣前X天:
  1268. case EnumPublic.SmsSendEvent.礼服出租取衣前X天:
  1269. case EnumPublic.SmsSendEvent.礼服出售取衣前X天:
  1270. case EnumPublic.SmsSendEvent.礼服出租订单后X分钟:
  1271. case EnumPublic.SmsSendEvent.礼服出租还衣后X分钟:
  1272. case EnumPublic.SmsSendEvent.礼服出售订单后X分钟:
  1273. case EnumPublic.SmsSendEvent.客人预约选片后X分钟:
  1274. case EnumPublic.SmsSendEvent.拍照预约后拍照前X天:
  1275. case EnumPublic.SmsSendEvent.服务预约后服务前X天:
  1276. case EnumPublic.SmsSendEvent.选片预约后选片前X天:
  1277. case EnumPublic.SmsSendEvent.看样预约后看样前X天:
  1278. case EnumPublic.SmsSendEvent.客人预约看样后X分钟:
  1279. case EnumPublic.SmsSendEvent.服务预约后X分钟:
  1280. case EnumPublic.SmsSendEvent.服务完成后X分钟:
  1281. case EnumPublic.SmsSendEvent.积分兑换后X分钟发提醒短信:
  1282. case EnumPublic.SmsSendEvent.男宾生日前X天发短信给女宾:
  1283. case EnumPublic.SmsSendEvent.女宾生日前X天发短信给男宾:
  1284. case EnumPublic.SmsSendEvent.员工生日前X天发送短信给X手机号:
  1285. case EnumPublic.SmsSendEvent.会员积分变动后X分钟:
  1286. case EnumPublic.SmsSendEvent.删除会员后X分钟:
  1287. case EnumPublic.SmsSendEvent.注消会员后X分钟:
  1288. case EnumPublic.SmsSendEvent.修改会员支付密码后X分钟:
  1289. case EnumPublic.SmsSendEvent.会员服务卡使用后X分钟:
  1290. case EnumPublic.SmsSendEvent.会员积分有效期到期前X天:
  1291. case EnumPublic.SmsSendEvent.会员储值有效期到期前X天:
  1292. case EnumPublic.SmsSendEvent.会员服务套餐有效期到期前X天:
  1293. case EnumPublic.SmsSendEvent.会员新摄会有效期到期前X天:
  1294. case EnumPublic.SmsSendEvent.会员返现卡有效期到期前X天:
  1295. case EnumPublic.SmsSendEvent.会员返现卡提现后X分钟:
  1296. case EnumPublic.SmsSendEvent.会员返现卡获得返现金后X分钟:
  1297. case EnumPublic.SmsSendEvent.支付成功后X分钟发提醒消息:
  1298. case EnumPublic.SmsSendEvent.客片上传完成后X分钟发通知短信:
  1299. retTitle = smsEvent.ToString().Replace("X", model.ST_SendEventValue);
  1300. break;
  1301. case EnumPublic.SmsSendEvent.宝宝生日前X天且X岁以下:
  1302. if (model.ST_SendEventValue.Trim().Contains(":"))
  1303. {
  1304. string[] tempValues = model.ST_SendEventValue.Trim().Split(':');
  1305. if (tempValues.Length == 2)
  1306. {
  1307. retTitle = smsEvent.ToString().Replace("X天", tempValues[0] + "天").Replace("X岁", tempValues[1] + "岁");
  1308. }
  1309. }
  1310. break;
  1311. case EnumPublic.SmsSendEvent.宝宝X岁前X天成长跟踪短信:
  1312. if (model.ST_SendEventValue.Trim().Contains(":"))
  1313. {
  1314. string[] tempValues = model.ST_SendEventValue.Trim().Split(':');
  1315. if (tempValues.Length == 2)
  1316. {
  1317. retTitle = smsEvent.ToString().Replace("X岁", tempValues[0] + "岁").Replace("X天", tempValues[1] + "天");
  1318. }
  1319. }
  1320. else
  1321. {
  1322. retTitle = smsEvent.ToString().Replace("X岁", model.ST_SendEventValue + "岁").Replace("X天", "0天");
  1323. }
  1324. break;
  1325. case EnumPublic.SmsSendEvent.每天X时X分发送财务短信到X手机:
  1326. if (model.ST_SendEventValue.Trim().Contains(":"))
  1327. {
  1328. string[] tempValues = model.ST_SendEventValue.Trim().Split(':');
  1329. if (tempValues.Length == 2)
  1330. {
  1331. retTitle = smsEvent.ToString().Replace("X时", tempValues[0] + "时").Replace("X分", tempValues[1] + "分").Replace("X手机", model.ST_ReceiveObjects + "手机");
  1332. }
  1333. }
  1334. break;
  1335. }
  1336. }
  1337. catch { }
  1338. return retTitle;
  1339. }
  1340. void tabControlEx1_SelectedIndexChanged(object sender, EventArgs e)
  1341. {
  1342. switch (this.tabControlEx1.SelectedIndex)
  1343. {
  1344. case 1:
  1345. if (this.dgvCommonSMS.Rows.Count <= 0)
  1346. {
  1347. frmSelectSmsInfo.BindSmsClass(this.cboxSmsClass);
  1348. BindDgvCommonSMS();
  1349. }
  1350. break;
  1351. case 2:
  1352. if (this.dgvMicroTemplate.Rows.Count <= 0)
  1353. {
  1354. BindDgvMicroTemplate();
  1355. }
  1356. break;
  1357. case 3:
  1358. if (this.dgvMicroTemplateItem.Rows.Count <= 0)
  1359. {
  1360. BindDgvMicroTemplateIDList();
  1361. }
  1362. break;
  1363. }
  1364. }
  1365. /// <summary>
  1366. /// 邦定微信模板ID配置列表
  1367. /// </summary>
  1368. public void BindDgvMicroTemplateIDList()
  1369. {
  1370. this.dgvMicroTemplateItem.Rows.Clear();
  1371. try
  1372. {
  1373. List<LYFZ.Model.Model_SMSTemplates> smsModelList = null;
  1374. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  1375. {
  1376. try
  1377. {
  1378. smsModelList = smsBLL.GetModelList("ST_Type=" + ((int)EnumPublic.SmsTemplateType.微信模板ID).ToString() + " and ST_DividedShop='" + LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID.Trim() + "'");
  1379. }
  1380. catch
  1381. {
  1382. MessageBoxCustom.Show("加载失败!请检查网络环境或关闭系统后重试!", backgroundWorker: backgroundWorker);
  1383. }
  1384. });
  1385. if (smsModelList != null)
  1386. {
  1387. foreach (LYFZ.Model.Model_SMSTemplates model in smsModelList)
  1388. {
  1389. DataGridViewRow row = new DataGridViewRow();
  1390. row.CreateCells(this.dgvMicroTemplateItem);
  1391. row.Cells[0].Value = model.ST_Title;
  1392. row.Cells[1].Value = model.ST_SMSContent;
  1393. row.Cells[2].Value = model.ST_Remark;
  1394. row.Cells[3].Value = model.ST_UpdateDatetime.ToString("yyyy-MM-dd HH:mm:ss");
  1395. row.Cells[4].Value = "编缉";
  1396. row.Cells[5].Value = "删除";
  1397. row.Tag = model;
  1398. this.dgvMicroTemplateItem.Rows.Add(row);
  1399. }
  1400. if (this.dgvMicroTemplateItem.SortedColumn != null)
  1401. {
  1402. ListSortDirection Direction = ListSortDirection.Descending;
  1403. switch (this.dgvMicroTemplateItem.SortOrder)
  1404. {
  1405. case SortOrder.Ascending:
  1406. Direction = ListSortDirection.Ascending;
  1407. break;
  1408. case SortOrder.Descending:
  1409. Direction = ListSortDirection.Descending;
  1410. break;
  1411. default: break;
  1412. }
  1413. this.dgvMicroTemplateItem.Sort(this.dgvCommonSMS.SortedColumn, Direction);
  1414. }
  1415. }
  1416. }
  1417. catch
  1418. {
  1419. MessageBoxCustom.Show("常用短信记录加载失败!请检查网络环境或关闭系统后重试!");
  1420. }
  1421. }
  1422. /// <summary>
  1423. /// 邦定常用短信
  1424. /// </summary>
  1425. void BindDgvCommonSMS()
  1426. {
  1427. this.dgvCommonSMS.Rows.Clear();
  1428. try
  1429. {
  1430. List<LYFZ.Model.Model_SMSTemplates> smsModelList = null;
  1431. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  1432. {
  1433. try
  1434. {
  1435. smsModelList = smsBLL.GetModelList("ST_Type=" + ((int)EnumPublic.SmsTemplateType.常用样板信息).ToString());
  1436. }
  1437. catch
  1438. {
  1439. MessageBoxCustom.Show("常用短信加载失败!请检查网络环境或关闭系统后重试!", backgroundWorker: backgroundWorker);
  1440. }
  1441. });
  1442. if (smsModelList != null)
  1443. {
  1444. foreach (LYFZ.Model.Model_SMSTemplates model in smsModelList)
  1445. {
  1446. DataGridViewRow row = new DataGridViewRow();
  1447. row.CreateCells(this.dgvCommonSMS);
  1448. row.Cells[0].Value = model.ST_Title;
  1449. row.Cells[1].Value = model.ST_SMSContent;
  1450. row.Cells[2].Value = model.ST_UpdateDatetime.ToString("yyyy-MM-dd HH:mm:ss");
  1451. row.Cells[3].Value = "编缉";
  1452. row.Cells[4].Value = "删除";
  1453. row.Tag = model;
  1454. this.dgvCommonSMS.Rows.Add(row);
  1455. }
  1456. if (this.dgvCommonSMS.SortedColumn != null)
  1457. {
  1458. ListSortDirection Direction = ListSortDirection.Descending;
  1459. switch (this.dgvCommonSMS.SortOrder)
  1460. {
  1461. case SortOrder.Ascending:
  1462. Direction = ListSortDirection.Ascending;
  1463. break;
  1464. case SortOrder.Descending:
  1465. Direction = ListSortDirection.Descending;
  1466. break;
  1467. default: break;
  1468. }
  1469. this.dgvCommonSMS.Sort(this.dgvCommonSMS.SortedColumn, Direction);
  1470. }
  1471. }
  1472. }
  1473. catch {
  1474. MessageBoxCustom.Show("常用短信记录加载失败!请检查网络环境或关闭系统后重试!");
  1475. }
  1476. }
  1477. void btnCommonSMSAdd_Click(object sender, EventArgs e)
  1478. {
  1479. frmAddCommonSMS frmAddSms = new frmAddCommonSMS();
  1480. if (frmAddSms.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
  1481. frmSelectSmsInfo.BindSmsClass(this.cboxSmsClass);
  1482. BindDgvCommonSMS();
  1483. }
  1484. }
  1485. }
  1486. }