private void ShowInfo(int id) { hidid.Value = id.ToString(); Model.wx_dati_base dati = datiBll.GetModel(id); hidid.Value = dati.id.ToString(); //绑定控件的值 txttitle.Text = dati.title.Trim().ToString(); //封面图片 if (dati.headimg != null && dati.headimg.Trim() != "" && dati.headimg.Trim() != "/images/noneimg.jpg") { txtHeadimg.Text = dati.headimg.Trim(); imgbjurl.ImageUrl = dati.headimg.Trim(); } txtsummary.InnerText = dati.summary.Trim(); txtdttime.Text = dati.dttime.ToString().Trim(); rblisshowend.SelectedValue = dati.isshowend == true ? "1" : "0"; txtdxtitle.Text = dati.dxtitle.Trim().ToString(); txtdxgetnum.Text = dati.dxgetnum.ToString(); txtdxscore.Text = dati.dxscore.ToString(); txtbjcolor.Text = dati.bjcolor.Trim(); txtstarttime.Text = dati.starttime.Value.ToString("yyyy-MM-dd HH:mm:ss"); txtendtime.Text = dati.endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"); txtjfval.Text = dati.jfval.ToString(); ddlJFtype.SelectedIndex = (dati.jftype); litwUrl.Text = MyCommFun.getWebSite() + "/weixin/dati/index.aspx?wid=" + dati.wid + "&id=" + id; }
protected void Page_Load(object sender, EventArgs e) { string _action = MXRequest.GetQueryString("action"); pid = MXRequest.GetQueryInt("pid"); int id = 0; if (!string.IsNullOrEmpty(_action) && _action == MXEnums.ActionEnum.Edit.ToString()) { this.action = MXEnums.ActionEnum.Edit.ToString();//修改类型 if (!int.TryParse(Request.QueryString["id"] as string, out id)) { JscriptMsg("传输参数不正确!", "back", "Error"); return; } if (!datiBll.Exists(id)) { JscriptMsg("记录不存在或已被删除!", "back", "Error"); return; } } BLL.wx_dati_base dtBll = new BLL.wx_dati_base(); Model.wx_dati_base getdt = dtBll.GetModel(pid); txtscore.Text = getdt.dxscore.ToString(); if (!Page.IsPostBack) { if (action == MXEnums.ActionEnum.Edit.ToString()) //修改 { ShowInfo(id); } } }
protected void Page_Load(object sender, EventArgs e) { OnlyWeiXinLook(); MyCommFun.getTotalUrl(); id = MyCommFun.RequestInt("id", 0); wid = MyCommFun.RequestWid(); openid = MyCommFun.RequestOpenid(); string whereStr = " wid=" + wid + " and id=" + id; wx_dati_base baseBll = new wx_dati_base(); Model.wx_dati_base baseDT = baseBll.GetModel(whereStr); //红包设置 bool hbreISopen = false; int reMsg = 0; bool hbISopen = true; //红包是否开启 int hbWhere = 0; //红包参与条件 int hbMTnum = 10; //第天领取人数 int hbMRnum = 5; //每人领取次数 int hbRCnum = 3; //容错次数 if (hbISopen) { hbreISopen = true; } //红包参与条件 //取用户答题记录 // int getUseridCount = baseBll.GetRecordCount(" openid='" + openid + "'"); // if (getUseridCount >= hbRCnum) hbreISopen = false; //用户信息 wx_dati_user userBLL = new wx_dati_user(); Model.wx_dati_user usermodel = userBLL.GetModel(" openid='" + openid + "' "); int getUseridCount = userBLL.GetRecordCount(" openid='" + openid + "'"); if (getUseridCount >= 3) { isusersub = true; } if (usermodel != null) { usersum = usermodel.score.ToString(); } ///end if (id == 0 || wid == 0 || openid.Trim() == "") { Response.Redirect("err.aspx?rev=1"); return; } if (baseDT.starttime > DateTime.Now) { //说明活动未开始 Response.Redirect("err.aspx?rev=2"); return; } if (baseDT.endtime <= DateTime.Now) { //说明活动已经结束 Response.Redirect("err.aspx?rev=3"); return; } htmlTitle = baseDT.title; summary = baseDT.summary; headimg = baseDT.headimg; bjcolor = baseDT.bjcolor; dtime = baseDT.dttime; dxgetnum = int.Parse(baseDT.dxgetnum.ToString()); ////// string dxwhereStr; if (dxgetnum > 0) {//抽取 int count = dxBLL.GetRecordCount(" pid=" + id); //////生成随机题号 string inStr = ""; Hashtable hashtable = new Hashtable(); Random rm = new Random(); int RmNum = dxgetnum; for (int i = 0; hashtable.Count < RmNum; i++) { int nValue = rm.Next(1, count); if (!hashtable.ContainsValue(nValue) && nValue != 0) { hashtable.Add(nValue, nValue); } } foreach (DictionaryEntry de in hashtable) { inStr += de.Value.ToString() + ","; } ///// dxwhereStr = " pid=" + id + " and isshow=1 and sid in (" + inStr.Substring(0, inStr.Length - 1) + ")"; } else { dxwhereStr = " pid=" + id + " and isshow=1 "; } dxDT = dxBLL.GetList(dxwhereStr); }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { Model.wx_userweixin weixin = GetWeiXinCode(); int id = MyCommFun.Str2Int(hidid.Value); #region //先判断 string strErr = ""; if (this.txttitle.Text.Trim().Length == 0) { strErr += "题库名称不能为空! "; } if (strErr != "") { JscriptMsg(strErr, "back", "Error"); return; } #endregion #region 赋值 Model.wx_dati_base dati = new Model.wx_dati_base(); if (id > 0) { dati = datiBll.GetModel(id); } string facePicc = ""; if (txtHeadimg.Text.Trim() != "") { facePicc = txtHeadimg.Text.Trim(); } dati.title = txttitle.Text.Trim(); dati.headimg = facePicc; dati.bjcolor = txtbjcolor.Text.Trim(); dati.summary = txtsummary.Value.Trim(); dati.dttime = int.Parse(txtdttime.Text); dati.isshowend = rblisshowend.SelectedValue == "0" ? false : true; //单选 dati.dxtitle = txtdxtitle.Text.Trim(); dati.dxgetnum = int.Parse(txtdxgetnum.Text); dati.dxscore = int.Parse(txtdxscore.Text); DateTime start = DateTime.Parse(txtstarttime.Text.Trim()); DateTime end = DateTime.Parse(txtendtime.Text.Trim()); dati.starttime = start; dati.endtime = end; dati.jfval = int.Parse(txtjfval.Text.ToString()); dati.jftype = MyCommFun.Str2Int(ddlJFtype.SelectedItem.Value); #endregion if (id <= 0) { //新增 dati.wid = weixin.id; dati.addtime = DateTime.Now; //1新增主表 id = datiBll.Add(dati); AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加题库信息,主键为" + id); //记录日志 JscriptMsg("添加题库信息成功!", "index.aspx", "Success"); } else { //修改 datiBll.Update(dati); AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改题库信息,主键为" + id); //记录日志 JscriptMsg("修改题库信息成功!", "index.aspx", "Success"); } }
public void userinfoAdd() { Dictionary <string, string> jsonDict = new Dictionary <string, string>(); //取值 int? wid = MyCommFun.RequestInt("wid", 0); int aid = MyCommFun.RequestInt("aid"); string openid = MyCommFun.RequestOpenid(); string atitle = MyCommFun.QueryString("atitle"); string usersum = MyCommFun.QueryString("usersum"); bool ISnum = true; if (wid == 0 || aid == 0 || openid == "" || usersum == "") { jsonDict.Add("re", "err"); jsonDict.Add("content", "参数错误!"); jsonDict.Add("isnum", "false"); content.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } BLL.wx_dati_user userBLL = new BLL.wx_dati_user(); // Model.wx_dati_user usermodel = userBLL.GetModel(" openid='" + openid + "' "); int getcont = userBLL.GetRecordCount(" openid='" + openid + "' "); if (getcont == 3) { jsonDict.Add("re", "err"); jsonDict.Add("content", "你已参加过了"); jsonDict.Add("isnum", "false"); content.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } int sy = 2 - getcont; BLL.wx_dati_base baseBLL = new BLL.wx_dati_base(); Model.wx_dati_base baseModel = baseBLL.GetModel(aid); int?jf = 0; int jftype = baseModel.jftype; int jfval = baseModel.jfval; if (jftype == 0) { jf = 0; } else if (jftype == 1) { jf = jfval; } else if (jftype == 2) { jf = int.Parse(usersum); } BLL.wx_dati_user dxBLL = new BLL.wx_dati_user(); Model.wx_dati_user dxmodel = new Model.wx_dati_user(); dxmodel.wid = wid; dxmodel.openid = openid; dxmodel.aid = aid; dxmodel.atitle = atitle; dxmodel.usersum = usersum; dxmodel.score = jf; dxmodel.addtime = DateTime.Now; dxBLL.Add(dxmodel); //得分 if (jf == 5) { jsonDict.Add("re", "OK"); jsonDict.Add("cjscore", jf.ToString()); jsonDict.Add("content", "你获得了一次红包机会!"); jsonDict.Add("isnum", "false"); content.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } else { jsonDict.Add("re", "OK"); jsonDict.Add("cjscore", jf.ToString()); jsonDict.Add("content", "答卷提交成功!(" + sy + ")次机会"); jsonDict.Add("isnum", "true"); content.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } }