using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace LYFZ.Software.MainBusiness.OAShopManagement { public class frmMicroLetterAutoReply : LYFZ.Software.UI.OAShopManagement.frmMicroLetterAutoReply { public frmMicroLetterAutoReply() { this.btnAddKeyword.Click += btnAddKeyword_Click; this.btnTxt.Click += btnTxt_Click; this.btnPicTxt.Click += btnPicTxt_Click; this.Load += frmMicroLetterAutoReply_Load; this.trwRuleReplyList.NodeMouseDoubleClick += trwRuleReplyList_NodeMouseDoubleClick; this.trwRuleReplyList.NodeMouseClick += trwRuleReplyList_NodeMouseClick; this.btnAdd.Click += btnAdd_Click; this.btnDel.Click += btnDel_Click; this.btnSave.Click += btnSave_Click; } void btnSave_Click(object sender, EventArgs e) { } void btnDel_Click(object sender, EventArgs e) { if (this.trwRuleReplyList.SelectedNode != null) { if (this.trwRuleReplyList.SelectedNode.Name.StartsWith("TND_")) { MessageBoxCustom.Show(this.trwRuleReplyList.SelectedNode.Text+" 规则不能删除!"); } else { if (MessageBoxCustom.Show("您确定要删除选择规则吗?") == System.Windows.Forms.DialogResult.OK) { bool isDelOK = false; if (this.trwRuleReplyList.SelectedNode.Tag != null) { LYFZ.Model.Model_WeixinMessageRule cDelModel = (LYFZ.Model.Model_WeixinMessageRule)this.trwRuleReplyList.SelectedNode.Tag; LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker) { try { backgroundWorker.ReportProgress(0, "正在删除数据..."); isDelOK = wMRBll.Delete(cDelModel); wMLListBll.Delete("Wrl_RuleID='" + cDelModel.Wrm_RuleID + "'"); } catch (Exception ex){ MessageBoxCustom.Show("删除失败,原因:"+ex.Message,backgroundWorker:backgroundWorker); } }); } else { isDelOK = true; } if (isDelOK) { this.trwRuleReplyList.SelectedNode.Remove(); btnAdd_Click(null, null); } else { MessageBoxCustom.Show("删除失败,请稍后重试"); } } } } else { MessageBoxCustom.Show("请选择您要删除的规则"); } } void btnAdd_Click(object sender, EventArgs e) { this.txtname.Text = ""; this.dgvKeywordList.Rows.Clear(); this.dgvTextList.Rows.Clear(); this.txtname.ReadOnly = false; this.btnAddKeyword.Enabled = true; } void trwRuleReplyList_NodeMouseClick(object sender, System.Windows.Forms.TreeNodeMouseClickEventArgs e) { } void trwRuleReplyList_NodeMouseDoubleClick(object sender, System.Windows.Forms.TreeNodeMouseClickEventArgs e) { if (e.Node != null) { if (e.Node.Name.StartsWith("TND_")) { this.txtname.ReadOnly = true; this.btnAddKeyword.Enabled = false; } else { this.txtname.ReadOnly = false; this.btnAddKeyword.Enabled = true; } this.txtname.Text = e.Node.Text.Trim(); if (e.Node.Tag != null) { int cModelID = (int)e.Node.Tag; LYFZ.Model.Model_WeixinMessageRule weixinModel = null; List WeixinNewsList = new List(); LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker) { try { backgroundWorker.ReportProgress(0, "正在加载数据..."); weixinModel = wMRBll.GetModel(cModelID); if (weixinModel != null && weixinModel.ID > 0) { WeixinNewsList = wMLListBll.GetModelList("Wrl_RuleID='" + weixinModel.Wrm_RuleID + "'"); } } catch (Exception ex) { MessageBoxCustom.Show("加载数据失败,原因:" + ex.Message, backgroundWorker: backgroundWorker); } }); BindKeywordsList(weixinModel); BindNewsList(WeixinNewsList); } } } /// /// 邦定关键字 /// /// void BindKeywordsList(LYFZ.Model.Model_WeixinMessageRule weixinModel) { if (weixinModel != null && weixinModel.ID > 0) { } } /// /// 邦定回复消息 /// /// void BindNewsList(List WeixinNewsList) { } LYFZ.BLL.BLL_WeixinMessageRule wMRBll = new BLL.BLL_WeixinMessageRule(); LYFZ.BLL.BLL_WeixinMessageList wMLListBll = new BLL.BLL_WeixinMessageList(); List WeixinMessageRuleList = new List(); void frmMicroLetterAutoReply_Load(object sender, EventArgs e) { LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker) { backgroundWorker.ReportProgress(0, "正在加载数据..."); WeixinMessageRuleList= wMRBll.GetModelList("1=1"); }); BidRuleReplyList(); } void BidRuleReplyList() { this.trwRuleReplyList.Nodes.Clear(); if (WeixinMessageRuleList.Count > 0) { foreach (LYFZ.Model.Model_WeixinMessageRule model in WeixinMessageRuleList) { TreeNode new_node = new TreeNode(); new_node.Name = model.Wrm_RuleID.Trim(); new_node.Text = model.Wmr_RuleName.Trim(); if (new_node.Name.StartsWith("TND_")) { new_node.ForeColor = Color.Green; } new_node.Tag = model.ID; } } else { TreeNode node_GZ = new TreeNode(); node_GZ.ForeColor = Color.Green; node_GZ.Name = "TND_GZ"; node_GZ.Text = "粉丝关注公众号回复"; TreeNode node_QXGZ = new TreeNode(); node_QXGZ.ForeColor = Color.Green; node_QXGZ.Name = "TND_QXGZ"; node_QXGZ.Text = "粉丝取消关注时回复"; TreeNode node_NOMatchy = new TreeNode(); node_NOMatchy.ForeColor = Color.Green; node_NOMatchy.Name = "TND_NOMatchy"; node_NOMatchy.Text = "未匹配关键字时回复"; this.trwRuleReplyList.Nodes.Add(node_GZ); this.trwRuleReplyList.Nodes.Add(node_QXGZ); this.trwRuleReplyList.Nodes.Add(node_NOMatchy); } } void btnPicTxt_Click(object sender, EventArgs e) { frmAddTeletextNews addNews= new frmAddTeletextNews(); addNews.Text = "添加图文消息"; if (addNews.ShowDialog() == System.Windows.Forms.DialogResult.OK) { } } void btnTxt_Click(object sender, EventArgs e) { frmKeywordAndText addtext = new frmKeywordAndText(); addtext.Text = "添加回复文字"; addtext.lbTitle.Text = "最多可以输入300个字符"; addtext.txtValue.WaterText = "最多可以输入300个字符"; if (addtext.ShowDialog() == System.Windows.Forms.DialogResult.OK) { } } void btnAddKeyword_Click(object sender, EventArgs e) { frmKeywordAndText addtext = new frmKeywordAndText(); addtext.Text = "添加关键字"; addtext.lbTitle.Text = "按回车可添加多个关键字,每个关键字少于30个字符"; addtext.txtValue.WaterText = "按回车可添加多个关键字,每个关键字少于30个字符"; if (addtext.ShowDialog() == System.Windows.Forms.DialogResult.OK) { } } } }