frmMicroLetterAutoReply.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Windows.Forms;
  7. namespace LYFZ.Software.MainBusiness.OAShopManagement
  8. {
  9. public class frmMicroLetterAutoReply : LYFZ.Software.UI.OAShopManagement.frmMicroLetterAutoReply
  10. {
  11. public frmMicroLetterAutoReply() {
  12. this.btnAddKeyword.Click += btnAddKeyword_Click;
  13. this.btnTxt.Click += btnTxt_Click;
  14. this.btnPicTxt.Click += btnPicTxt_Click;
  15. this.Load += frmMicroLetterAutoReply_Load;
  16. this.trwRuleReplyList.NodeMouseDoubleClick += trwRuleReplyList_NodeMouseDoubleClick;
  17. this.trwRuleReplyList.NodeMouseClick += trwRuleReplyList_NodeMouseClick;
  18. this.btnAdd.Click += btnAdd_Click;
  19. this.btnDel.Click += btnDel_Click;
  20. this.btnSave.Click += btnSave_Click;
  21. }
  22. void btnSave_Click(object sender, EventArgs e)
  23. {
  24. }
  25. void btnDel_Click(object sender, EventArgs e)
  26. {
  27. if (this.trwRuleReplyList.SelectedNode != null)
  28. {
  29. if (this.trwRuleReplyList.SelectedNode.Name.StartsWith("TND_"))
  30. {
  31. MessageBoxCustom.Show(this.trwRuleReplyList.SelectedNode.Text+" 规则不能删除!");
  32. }
  33. else
  34. {
  35. if (MessageBoxCustom.Show("您确定要删除选择规则吗?") == System.Windows.Forms.DialogResult.OK)
  36. {
  37. bool isDelOK = false;
  38. if (this.trwRuleReplyList.SelectedNode.Tag != null)
  39. {
  40. LYFZ.Model.Model_WeixinMessageRule cDelModel = (LYFZ.Model.Model_WeixinMessageRule)this.trwRuleReplyList.SelectedNode.Tag;
  41. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
  42. {
  43. try
  44. {
  45. backgroundWorker.ReportProgress(0, "正在删除数据...");
  46. isDelOK = wMRBll.Delete(cDelModel);
  47. wMLListBll.Delete("Wrl_RuleID='" + cDelModel.Wrm_RuleID + "'");
  48. }
  49. catch (Exception ex){
  50. MessageBoxCustom.Show("删除失败,原因:"+ex.Message,backgroundWorker:backgroundWorker);
  51. }
  52. });
  53. }
  54. else {
  55. isDelOK = true;
  56. }
  57. if (isDelOK)
  58. {
  59. this.trwRuleReplyList.SelectedNode.Remove();
  60. btnAdd_Click(null, null);
  61. }
  62. else {
  63. MessageBoxCustom.Show("删除失败,请稍后重试");
  64. }
  65. }
  66. }
  67. }
  68. else {
  69. MessageBoxCustom.Show("请选择您要删除的规则");
  70. }
  71. }
  72. void btnAdd_Click(object sender, EventArgs e)
  73. {
  74. this.txtname.Text = "";
  75. this.dgvKeywordList.Rows.Clear();
  76. this.dgvTextList.Rows.Clear();
  77. this.txtname.ReadOnly = false;
  78. this.btnAddKeyword.Enabled = true;
  79. }
  80. void trwRuleReplyList_NodeMouseClick(object sender, System.Windows.Forms.TreeNodeMouseClickEventArgs e)
  81. {
  82. }
  83. void trwRuleReplyList_NodeMouseDoubleClick(object sender, System.Windows.Forms.TreeNodeMouseClickEventArgs e)
  84. {
  85. if (e.Node != null)
  86. {
  87. if (e.Node.Name.StartsWith("TND_"))
  88. {
  89. this.txtname.ReadOnly = true;
  90. this.btnAddKeyword.Enabled = false;
  91. }
  92. else
  93. {
  94. this.txtname.ReadOnly = false;
  95. this.btnAddKeyword.Enabled = true;
  96. }
  97. this.txtname.Text = e.Node.Text.Trim();
  98. if (e.Node.Tag != null)
  99. {
  100. int cModelID = (int)e.Node.Tag;
  101. LYFZ.Model.Model_WeixinMessageRule weixinModel = null;
  102. List<LYFZ.Model.Model_WeixinMessageList> WeixinNewsList = new List<Model.Model_WeixinMessageList>();
  103. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
  104. {
  105. try
  106. {
  107. backgroundWorker.ReportProgress(0, "正在加载数据...");
  108. weixinModel = wMRBll.GetModel(cModelID);
  109. if (weixinModel != null && weixinModel.ID > 0)
  110. {
  111. WeixinNewsList = wMLListBll.GetModelList("Wrl_RuleID='" + weixinModel.Wrm_RuleID + "'");
  112. }
  113. }
  114. catch (Exception ex)
  115. {
  116. MessageBoxCustom.Show("加载数据失败,原因:" + ex.Message, backgroundWorker: backgroundWorker);
  117. }
  118. });
  119. BindKeywordsList(weixinModel);
  120. BindNewsList(WeixinNewsList);
  121. }
  122. }
  123. }
  124. /// <summary>
  125. /// 邦定关键字
  126. /// </summary>
  127. /// <param name="weixinModel"></param>
  128. void BindKeywordsList(LYFZ.Model.Model_WeixinMessageRule weixinModel)
  129. {
  130. if (weixinModel != null && weixinModel.ID > 0)
  131. {
  132. }
  133. }
  134. /// <summary>
  135. /// 邦定回复消息
  136. /// </summary>
  137. /// <param name="WeixinNewsList"></param>
  138. void BindNewsList(List<LYFZ.Model.Model_WeixinMessageList> WeixinNewsList)
  139. {
  140. }
  141. LYFZ.BLL.BLL_WeixinMessageRule wMRBll = new BLL.BLL_WeixinMessageRule();
  142. LYFZ.BLL.BLL_WeixinMessageList wMLListBll = new BLL.BLL_WeixinMessageList();
  143. List<LYFZ.Model.Model_WeixinMessageRule> WeixinMessageRuleList = new List<Model.Model_WeixinMessageRule>();
  144. void frmMicroLetterAutoReply_Load(object sender, EventArgs e)
  145. {
  146. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
  147. {
  148. backgroundWorker.ReportProgress(0, "正在加载数据...");
  149. WeixinMessageRuleList= wMRBll.GetModelList("1=1");
  150. });
  151. BidRuleReplyList();
  152. }
  153. void BidRuleReplyList()
  154. {
  155. this.trwRuleReplyList.Nodes.Clear();
  156. if (WeixinMessageRuleList.Count > 0)
  157. {
  158. foreach (LYFZ.Model.Model_WeixinMessageRule model in WeixinMessageRuleList)
  159. {
  160. TreeNode new_node = new TreeNode();
  161. new_node.Name = model.Wrm_RuleID.Trim();
  162. new_node.Text = model.Wmr_RuleName.Trim();
  163. if (new_node.Name.StartsWith("TND_"))
  164. {
  165. new_node.ForeColor = Color.Green;
  166. }
  167. new_node.Tag = model.ID;
  168. }
  169. }
  170. else
  171. {
  172. TreeNode node_GZ = new TreeNode();
  173. node_GZ.ForeColor = Color.Green;
  174. node_GZ.Name = "TND_GZ";
  175. node_GZ.Text = "粉丝关注公众号回复";
  176. TreeNode node_QXGZ = new TreeNode();
  177. node_QXGZ.ForeColor = Color.Green;
  178. node_QXGZ.Name = "TND_QXGZ";
  179. node_QXGZ.Text = "粉丝取消关注时回复";
  180. TreeNode node_NOMatchy = new TreeNode();
  181. node_NOMatchy.ForeColor = Color.Green;
  182. node_NOMatchy.Name = "TND_NOMatchy";
  183. node_NOMatchy.Text = "未匹配关键字时回复";
  184. this.trwRuleReplyList.Nodes.Add(node_GZ);
  185. this.trwRuleReplyList.Nodes.Add(node_QXGZ);
  186. this.trwRuleReplyList.Nodes.Add(node_NOMatchy);
  187. }
  188. }
  189. void btnPicTxt_Click(object sender, EventArgs e)
  190. {
  191. frmAddTeletextNews addNews= new frmAddTeletextNews();
  192. addNews.Text = "添加图文消息";
  193. if (addNews.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  194. {
  195. }
  196. }
  197. void btnTxt_Click(object sender, EventArgs e)
  198. {
  199. frmKeywordAndText addtext = new frmKeywordAndText();
  200. addtext.Text = "添加回复文字";
  201. addtext.lbTitle.Text = "最多可以输入300个字符";
  202. addtext.txtValue.WaterText = "最多可以输入300个字符";
  203. if (addtext.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  204. {
  205. }
  206. }
  207. void btnAddKeyword_Click(object sender, EventArgs e)
  208. {
  209. frmKeywordAndText addtext = new frmKeywordAndText();
  210. addtext.Text = "添加关键字";
  211. addtext.lbTitle.Text = "按回车可添加多个关键字,每个关键字少于30个字符";
  212. addtext.txtValue.WaterText = "按回车可添加多个关键字,每个关键字少于30个字符";
  213. if (addtext.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  214. {
  215. }
  216. }
  217. }
  218. }