private bool DoAdd() { string strErr = ""; if (this.txtreqKeywords.Text.Trim().Length == 0) { strErr += "关键词不能为空!"; } if (this.txtrContent.Text.Trim().Length == 0) { strErr += "内容或简介不能为空!"; } if (strErr != "") { JscriptMsg(strErr, "back", "Error"); return(false); } Cms.Model.C_admin admin = adminUser.GetLoginState(); Cms.Model.wx_requestRule rule = new Cms.Model.wx_requestRule(); rule.uId = admin.id; rule.wId = 1; rule.ruleName = "纯文本回复"; rule.reqKeywords = txtreqKeywords.Text.Trim(); rule.reqestType = 1; rule.responseType = 1; string radoValue = rblisLikeSearch.SelectedItem.Value; if (radoValue == "0") { rule.isLikeSearch = false; } else { rule.isLikeSearch = true; } rule.createDate = DateTime.Now; int rId = rBll.Add(rule); Cms.Model.wx_requestRuleContent rc = new Cms.Model.wx_requestRuleContent(); rc.uId = admin.id; rc.rId = rId; rc.rContent = txtrContent.Text.Trim(); rc.createDate = DateTime.Now; int rcId = rcBll.Add(rc); if (rcId > 0) { adminUser.AddAdminLog(Enums.ActionEnum.Add.ToString(), "添加纯文本回复,主键为:" + rId + ",关键词为:" + txtreqKeywords.Text.Trim()); //记录日志 return(true); } return(false); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // ChkAdminLevel("manager_list", MXEnums.ActionEnum.View.ToString()); //检查权限 int rid = MyCommFun.RequestInt("rid"); Cms.BLL.wx_requestRule rbll = new Cms.BLL.wx_requestRule(); Cms.Model.wx_requestRule rule = rbll.GetModel(rid); this.lblKeyWords.Text = MyCommFun.SubStrAddSuffix(rule.reqKeywords, 10, "..."); hlAddTuWen.NavigateUrl = "editTuWen.aspx?rid=" + rid + "&action=" + Enums.ActionEnum.Add; RptBind(); } }
private bool DoEdit(int _id) { string strErr = ""; if (this.txtreqKeywords.Text.Trim().Length == 0) { strErr += "关键词不能为空!"; } if (this.txtrContent.Text.Trim().Length == 0) { strErr += "内容或简介不能为空!"; } if (strErr != "") { JscriptMsg(strErr, "back", "Error"); return(false); } Cms.Model.wx_requestRule rule = rBll.GetModel(id); rule.reqKeywords = txtreqKeywords.Text.Trim(); string radoValue = rblisLikeSearch.SelectedItem.Value; if (radoValue == "0") { rule.isLikeSearch = false; } else { rule.isLikeSearch = true; } bool ret = rBll.Update(rule); IList <Cms.Model.wx_requestRuleContent> ruleContentList = rcBll.GetModelList("rId=" + id); if (ruleContentList != null && ruleContentList.Count > 0) { Cms.Model.wx_requestRuleContent ruleContent = ruleContentList[0]; ruleContent.rContent = txtrContent.Text; ret = rcBll.Update(ruleContent); } if (ret) { adminUser.AddAdminLog(Enums.ActionEnum.Edit.ToString(), "修改纯文本回复,主键为:" + rule.id); //记录日志 return(true); } return(false); }
/// <summary> /// 编辑状态:赋值页面上的值 /// </summary> /// <param name="id"></param> private void BindData(int id) { Cms.Model.wx_requestRule rule = rBll.GetModel(id); if (rule != null) { txtreqKeywords.Text = rule.reqKeywords; if (rule.isLikeSearch.ToString().ToLower() == "false") { this.rblisLikeSearch.SelectedValue = "0"; } else { this.rblisLikeSearch.SelectedValue = "1"; } } }
/// <summary> /// 添加/修改规则 /// </summary> /// <returns></returns> private void AddRule(int id) { Cms.Model.C_admin admin = adminUser.GetLoginState(); Cms.Model.wx_requestRule rule = new Cms.Model.wx_requestRule(); if (id == 0) { rule.uId = admin.id; rule.wId = 1; rule.ruleName = "图文回复"; rule.isDefault = false; rule.reqestType = 1; //关键词回复 rule.createDate = DateTime.Now; rule.responseType = 2; //回复的类型:文本1,图文2,语音3,视频4,第三方接口5 } else { rule = rBll.GetModel(id); } string radoValue = rblisLikeSearch.SelectedItem.Value; if (radoValue == "0") { rule.isLikeSearch = false; } else { rule.isLikeSearch = true; } rule.reqKeywords = txtreqKeywords.Text.Trim(); if (id == 0) { rBll.Add(rule); } else { rBll.Update(rule); } }
private void ShowInfo(int id) { hidid.Value = id.ToString(); Cms.Model.wx_dzpActionInfo dzpAction = dzpBll.GetModel(id); IList <Cms.Model.wx_dzpAwardItem> aItemlist = iBll.GetModelList("actId=" + id); Cms.Model.wx_requestRule rule = rBll.GetModelList("modelFunctionName='大转盘' and modelFunctionId=" + id)[0]; txtKW.Text = rule.reqKeywords; if (dzpAction.beginPic != null && dzpAction.beginPic.Trim() != "/weixin/dzp/images/start.jpg") { txtImgUrl.Text = dzpAction.beginPic; imgbeginPic.ImageUrl = dzpAction.beginPic; } txtactName.Text = dzpAction.actName; txtcontractInfo.Text = dzpAction.contractInfo; txtbrief.Value = dzpAction.brief; txtbeginDate.Text = dzpAction.beginDate.Value.ToString("yyyy-MM-dd HH:mm:ss"); txtendDate.Text = dzpAction.endDate.Value.ToString("yyyy-MM-dd HH:mm:ss"); txtactContent.Value = dzpAction.actContent; txtcfcjhf.Text = dzpAction.cfcjhf; this.txtdjPwd.Text = dzpAction.djPwd; //结束 if (dzpAction.endPic != null && dzpAction.endPic.Trim() != "/weixin/dzp/images/end.jpg") { txtEndPic.Text = dzpAction.endPic; imgEndPic.ImageUrl = dzpAction.endPic; } txtendNotice.Text = dzpAction.endNotice; txtendContent.Text = dzpAction.endContent; //奖项基本信息 txtpersonNum.Text = MyCommFun.ObjToStr(dzpAction.personNum); txtpersonMaxTimes.Text = MyCommFun.ObjToStr(dzpAction.personMaxTimes); txtdayMaxTimes.Text = MyCommFun.ObjToStr(dzpAction.dayMaxTimes); //绑定奖项信息 IList <Cms.Model.wx_dzpAwardItem> itemlist = iBll.GetModelList("actId=" + id + " order by sort_id asc"); if (itemlist != null && itemlist.Count > 0) { int count = itemlist.Count; TextBox txtJXName; TextBox txtJPName; TextBox txtNum; TextBox txtRealNum; Cms.Model.wx_dzpAwardItem itemEntity = new Cms.Model.wx_dzpAwardItem(); for (int i = 1; i <= count; i++) { itemEntity = itemlist[(i - 1)]; txtJXName = this.FindControl("txt" + i + "JXName") as TextBox; txtJPName = this.FindControl("txt" + i + "JPName") as TextBox; txtNum = this.FindControl("txt" + i + "Num") as TextBox; txtRealNum = this.FindControl("txt" + i + "RealNum") as TextBox; txtJXName.Text = itemEntity.jxName; txtJPName.Text = itemEntity.jpName; txtNum.Text = itemEntity.jpNum == null ? "0" : itemEntity.jpNum.Value.ToString(); txtRealNum.Text = itemEntity.jpRealNum == null ? "0" : itemEntity.jpRealNum.Value.ToString(); } } }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ////Cms.Model.C_user weixin = GetWeiXinCode(); Cms.Model.wx_requestRuleContent rc = new Cms.Model.wx_requestRuleContent(); int id = MyCommFun.Str2Int(hidid.Value); #region //先判断 string strErr = ""; if (this.txtKW.Text.Trim().Length == 0) { strErr += "关键词不能为空!"; } if (this.txtactName.Text.Trim().Length == 0) { strErr += "活动名称不能为空!"; } if (this.txtbeginDate.Text.Trim().Length == 0 || !MyCommFun.isDateTime(txtbeginDate.Text)) { strErr += "开始时间不能为空!"; } if (this.txtendDate.Text.Trim().Length == 0 || !MyCommFun.isDateTime(txtendDate.Text)) { strErr += "结束时间不能为空!"; } if (txt1JXName.Text.Trim().Length == 0 || txt1JPName.Text.Trim().Length == 0 || txt1Num.Text.Trim().Length == 0 || txt1RealNum.Text.Trim().Length == 0) { strErr += "第一个奖项不能为空!"; } if (txt2JXName.Text.Trim().Length == 0 || txt2JPName.Text.Trim().Length == 0 || txt2Num.Text.Trim().Length == 0 || txt2RealNum.Text.Trim().Length == 0) { strErr += "第二个奖项不能为空!"; } if (strErr != "") { JscriptMsg(strErr, "back", "Error"); return; } DateTime begin = DateTime.Parse(txtbeginDate.Text.Trim()); DateTime end = DateTime.Parse(txtendDate.Text.Trim()); if (begin >= end) { JscriptMsg("开始时间必须小于结束时间", "back", "Error"); return; } #endregion #region 赋值 Cms.Model.wx_dzpActionInfo dzp = new Cms.Model.wx_dzpActionInfo(); Cms.Model.wx_requestRule rule = new Cms.Model.wx_requestRule(); string beginPic = imgbeginPic.ImageUrl; if (txtImgUrl.Text.Trim() != "") { beginPic = txtImgUrl.Text.Trim(); } string endPic = imgEndPic.ImageUrl; if (txtEndPic.Text.Trim() != "") { endPic = txtEndPic.Text.Trim(); } if (id > 0) { dzp = dzpBll.GetModel(id); } dzp.actName = txtactName.Text.Trim(); dzp.contractInfo = txtcontractInfo.Text.Trim(); dzp.brief = txtbrief.Value.Trim(); dzp.beginDate = begin; dzp.endDate = end; dzp.actContent = txtactContent.Value.Trim(); dzp.cfcjhf = txtcfcjhf.Text.Trim(); dzp.endNotice = txtendNotice.Text.Trim(); dzp.endContent = txtendContent.Text.Trim(); dzp.djPwd = txtdjPwd.Text.Trim(); dzp.beginPic = beginPic; dzp.endPic = endPic; dzp.personNum = MyCommFun.Str2Int(txtpersonNum.Text); dzp.personMaxTimes = MyCommFun.Str2Int(txtpersonMaxTimes.Text); dzp.dayMaxTimes = MyCommFun.Str2Int(txtdayMaxTimes.Text); #endregion if (id <= 0) { //新增 dzp.wid = 1; dzp.createDate = DateTime.Now; //1新增主表 id = dzpBll.Add(dzp); //2新增奖项表 EditAwardItem(id); //3 新增回复规则表 AddRule(1, id); adminUser.AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加大转盘活动,主键为" + id); //记录日志 JscriptMsg("添加大转盘活动成功!", "dzplist.aspx", "Success"); } else { //修改 //1修改主表 dzpBll.Update(dzp); //2删除,且新增奖项表 EditAwardItem(id); //3 修改回复规则表 IList <Cms.Model.wx_requestRule> rlist = rBll.GetModelList("modelFunctionName = '大转盘' and modelFunctionId=" + id); if (rlist != null && rlist.Count > 0) { rule = rlist[0]; rule.reqKeywords = txtKW.Text.Trim(); rBll.Update(rule); } else { AddRule(1, id); } adminUser.AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改大转盘活动,主键为" + id); //记录日志 JscriptMsg("修改大转盘活动成功!", "dzplist.aspx", "Success"); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Cms.Model.wx_requestRule model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Cms.Model.wx_requestRule model) { return(dal.Add(model)); }