示例#1
0
        /// <summary>
        /// 绑定页面上的基本信息
        /// </summary>
        private void bindData(int id, string openid)
        {
            #region 活动详情
            ggkAction = actbll.GetModel(id);
            if (ggkAction == null)
            {
                errorInfo = "该活动不存在!";
                return;
            }
            if (ggkAction.endDate <= DateTime.Now)
            { //说明活动已经结束
                errorInfo = "活动已结束!";
                ggkAction = null;
                return;
            }
            else if (ggkAction.beginDate > DateTime.Now)
            {
                //活动未开始
                errorInfo = "活动尚未开始!<br/>活动时间为:" + ggkAction.beginDate.ToString() + "到" + ggkAction.endDate.ToString();
                ggkAction = null;
                return;
            }
            this.Title = ggkAction.actName;
            List <Model.wx_ggkAwardItem> itemlist = itemBll.GetModelList("actId=" + id);
            StringBuilder         sb   = new StringBuilder("");
            Model.wx_ggkAwardItem item = new Model.wx_ggkAwardItem();
            int ttJpNum = 0;//实际奖品数量
            for (int i = 0; i < itemlist.Count; i++)
            {
                item = itemlist[i];
                sb.Append("<p>" + item.jxName + ":" + item.jpName + "  数量:" + item.jpNum + "</p>");
                ttJpNum += item.jpRealNum.Value;
            }

            if (ggkAction.djPwd.Trim().Length > 0)
            {
                litPwd.Text = "  <p>  <input name=\"\" class=\"px\" id=\"parssword\" type=\"password\" value=\"\" placeholder=\"商家输入兑奖密码\"></p>";
            }

            litJiangXing.Text = sb.ToString();

            litRemark.Text      = ggkAction.brief;
            litContentInfo.Text = ggkAction.contractInfo;
            litTTTimes.Text     = ggkAction.personMaxTimes == null ? "0" : ggkAction.personMaxTimes.Value.ToString();

            #endregion

            lock (this)
            {
                ProcZJ(ttJpNum, id, openid, itemlist);
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            OnlyWeiXinLook();
            if (!IsPostBack)
            {
                int    aid    = MyCommFun.RequestInt("aid", 0);
                int    wid    = MyCommFun.RequestInt("wid", 0);
                string openid = MyCommFun.RequestOpenid();
                if (aid == 0 || wid == 0 || openid.Trim() == "" | openid.Trim() == "loseopenid")
                {
                    errorInfo = "访问的参数有问题!";
                    ggkAction = null;
                    return;
                }

                bindData(aid, openid);
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            OnlyWeiXinLook();

            if (!IsPostBack)
            {
                int id = MyCommFun.RequestInt("aid");
                if (id == 0)
                {
                    return;
                }
                BLL.wx_ggkActionInfo   aBll   = new BLL.wx_ggkActionInfo();
                Model.wx_ggkActionInfo action = aBll.GetModel(id);
                if (action == null)
                {
                    return;
                }
                litEndNotice.Text = action.endContent;
            }
        }
示例#4
0
        /// <summary>
        /// 刮刮卡回复内容
        /// </summary>
        /// <param name="id">模块主键Id</param>
        /// <param name="apiid">微帐号主键id</param>
        /// <param name="openid">openid</param>
        /// <param name="responseType">回复类型:1纯文字,2图文</param>
        /// <param name="responseVaule">回复的内容</param>
        private IList <Model.ResponseContentEntity> GGKReponse(int id, int apiid, string openid)
        {
            IList <Model.ResponseContentEntity> responselist = new List <Model.ResponseContentEntity>();

            Model.ResponseContentEntity responseEntity = new Model.ResponseContentEntity();
            responseEntity.id  = id;
            responseEntity.wid = apiid;

            BLL.wx_ggkActionInfo   ggkActBll = new BLL.wx_ggkActionInfo();
            Model.wx_ggkActionInfo actModel  = ggkActBll.GetModel(id);
            if (actModel.beginDate > DateTime.Now)
            {  //活动尚未开始
                responseEntity.rcType   = Model.ReponseContentType.text;
                responseEntity.rContent = "活动【" + actModel.actName + "】将于" + actModel.beginDate + "开始。";
            }
            else if (actModel.endDate <= DateTime.Now)
            {
                //活动结束
                responseEntity.rcType    = Model.ReponseContentType.txtpic;
                responseEntity.rContent  = actModel.endNotice;
                responseEntity.rContent2 = actModel.endContent;
                responseEntity.detailUrl = MyCommFun.getWebSite() + "/weixin/ggk/end.aspx?wid=" + apiid + "&aid=" + id;
                responseEntity.picUrl    = actModel.endPic;
            }
            else
            {
                //活动正在进行中
                responseEntity.rcType    = Model.ReponseContentType.txtpic;
                responseEntity.rContent  = actModel.actName;
                responseEntity.rContent2 = actModel.actContent;
                responseEntity.detailUrl = MyCommFun.getWebSite() + "/weixin/ggk/index.aspx?wid=" + apiid + "&aid=" + id;
                responseEntity.picUrl    = actModel.beginPic;
            }
            responselist.Add(responseEntity);

            return(responselist);
        }
示例#5
0
        /// <summary>
        /// 绑定页面上的基本信息
        /// </summary>
        private void bindData(int id, string openid)
        {
            #region 活动详情
            ggkAction = actbll.GetModel(id);
            if (ggkAction == null)
            {
                hidStatus.Value = "-2";
                hidErrInfo.Value = "该活动不存在!";
                MessageBox.ResponseScript(this, "alert(\"该活动不存在\");");
                return;
            }
            this.Title = ggkAction.actName;
            List<Model.wx_ggkAwardItem> itemlist = itemBll.GetModelList("actId="+id);
            StringBuilder sb = new StringBuilder("");
            Model.wx_ggkAwardItem item = new Model.wx_ggkAwardItem();
            int ttJpNum = 0;
            for (int i = 0; i < itemlist.Count; i++)
            {
                item = itemlist[i];
                sb.Append("<p>" +item.jxName + ":" + item.jpName + "  数量:" + item.jpNum + "</p>");
                ttJpNum += item.jpRealNum.Value;
            }

            if (ggkAction.djPwd.Trim().Length > 0)
            {
                litPwd.Text = "  <p>  <input name=\"\" class=\"px\" id=\"parssword\" type=\"password\" value=\"\" placeholder=\"商家输入兑奖密码\"></p>";
            }

            litJiangXing.Text = sb.ToString();

            litRemark.Text = ggkAction.brief;
            litContentInfo.Text = ggkAction.contractInfo;
            litTTTimes.Text = ggkAction.personMaxTimes == null ? "0" : ggkAction.personMaxTimes.Value.ToString();

            #endregion
            #region 判断

            if (ggkAction.endDate <= DateTime.Now)
            { //说明活动已经结束
                //非活动期间
                hidStatus.Value = "-1";
                hidErrInfo.Value = "活动已结束!";
                return;
            }
            else if (ggkAction.beginDate > DateTime.Now)
            { 
                //活动未开始
                //非活动期间
                hidStatus.Value = "-2";
                hidErrInfo.Value = "活动尚未开始!";
                return;
            }

            Model.wx_ggkAwardUser awardUser = ubll.getZJinfoByOpenid(id, openid);
            if (awardUser != null &&  awardUser.id > 0)
            {  //说明已经中奖了

                litPrize.Text = awardUser.jxName;
              
                hidAwardId.Value = awardUser.id.ToString();
             
              

                if (awardUser.uTel != null && awardUser.uTel.Trim() != "")
                { //说明已经提交成功了 
                    hidStatus.Value = "110";
                    hidErrInfo.Value = "您已中过奖了,欢迎下次再来!";
                    litJp.Text = awardUser.jxName + " " + awardUser.jpName;
                    litSNM.Text = awardUser.sn;
                }
                else
                {  //中奖了,但是未提交 
                    hidStatus.Value = "100";
                    hidErrInfo.Value = "您已中奖,请提交!";
                    litJiangPing.Text = awardUser.jpName;
                    litSnCode.Text = awardUser.sn;

                    litJp.Text = awardUser.jxName + " " + awardUser.jpName;
                    litSNM.Text = awardUser.sn;

                }
                return;
            }


            int dayMaxTimes = ggkAction.dayMaxTimes == null ? 0 : ggkAction.dayMaxTimes.Value;
            int perMaxTimes = ggkAction.personMaxTimes == null ? 0 : ggkAction.personMaxTimes.Value;
            //判断每人最大抽奖次数,是否超过了
            if (personCJTimes(openid, id) >= ggkAction.personMaxTimes)
            {
                hidStatus.Value = "0";
                hidErrInfo.Value = "您已抽过奖了,欢迎下次再来!";
                return;
            }
            if (isTodayOverSum(id, openid, dayMaxTimes))
            {
                hidStatus.Value = "0";
                hidErrInfo.Value = "每人每天只有" + dayMaxTimes.ToString() + "次抽奖机会。";
                return;
            }

          
            #endregion

            #region 计算中奖信息

            /// 处理是否中奖
            /// hidStatus 状态为-1:不能抽奖,直接跳转到end.aspx页面;
            /// 0:抽奖次数超过设置的最高次数;
            /// 1:还可以继续抽奖;
            /// 2:中奖了;
            IList<Model.wx_ggkAwardUser> auserlist = ubll.getHasZJList(id);//已经中奖的人列表
            int ZhongJiangNum = 0;
            if (auserlist != null)
            {
                ZhongJiangNum = auserlist.Count; //已经中奖的人数
            }
            int syZjNum = ttJpNum - ZhongJiangNum; //剩余的奖品数量
            if (syZjNum <= 0)
            {  //说明已经没有奖品了
                hidStatus.Value = "1";
                hidErrInfo.Value = ggkAction.cfcjhf;
                litPrize.Text = NoAward;
                return;
            }
            ggkAction.personNum = MyCommFun.Obj2Int(ggkAction.personNum, 1);
            ggkAction.personMaxTimes = MyCommFun.Obj2Int(ggkAction.personMaxTimes, 1);
            int fenmo = ggkAction.personNum.Value * ggkAction.personMaxTimes.Value;

            Random rd = new Random((int)DateTime.Now.Ticks);
            int radNum = rd.Next(0, fenmo);//从0到fenmo里随机出一个值
            if (radNum < syZjNum)
            {
                //中奖了,再从剩余奖品里抽取一个奖品
                Model.wx_ggkAwardItem dajiang = getZJItem(itemlist, auserlist);
                if (dajiang != null)
                {
                    //这是中的中奖了
                    string snumber = Get_snumber(id);
                    int uId = ubll.Add(id, "", "", openid, dajiang.jxName, dajiang.jpName, snumber);
                    hidStatus.Value = "2";
                    hidErrInfo.Value = "恭喜你中奖了!";
                    litPrize.Text = dajiang.jxName;
                    litJiangPing.Text = dajiang.jpName;
                    hidAwardId.Value = uId.ToString();
                    litSnCode.Text = snumber;

                    litJp.Text = dajiang.jxName + " " + dajiang.jpName;
                    litSNM.Text = snumber;
                    return;
                }
                else
                {
                    //奖品已经全部中完了
                    hidStatus.Value = "1";
                    hidErrInfo.Value = ggkAction.cfcjhf;
                    litPrize.Text = NoAward;
                    return;
                }

            }
            else
            {
                //这个条件说明:未中奖
                //抛出未中奖的数据 
                hidStatus.Value = "1";
                hidErrInfo.Value = ggkAction.cfcjhf;
                litPrize.Text = NoAward;
            }




            #endregion


        }
        private void ShowInfo(int id)
        {
            hidid.Value = id.ToString();
            Model.wx_ggkActionInfo        ggk       = ggkBll.GetModel(id);
            IList <Model.wx_ggkAwardItem> aItemlist = iBll.GetModelList("actId=" + id);

            Model.wx_requestRule rule = rBll.GetModelList("modelFunctionName='刮刮卡' and modelFunctionId=" + id)[0];
            txtKW.Text = rule.reqKeywords;

            if (ggk.beginPic != null && ggk.beginPic.Trim() != "/weixin/ggk/images/start.jpg")
            {
                txtImgUrl.Text       = ggk.beginPic;
                imgbeginPic.ImageUrl = ggk.beginPic;
            }
            txtactName.Text      = ggk.actName;
            txtcontractInfo.Text = ggk.contractInfo;
            txtbrief.Value       = ggk.brief;
            txtbeginDate.Text    = ggk.beginDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
            txtendDate.Text      = ggk.endDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
            txtactContent.Value  = ggk.actContent;
            txtcfcjhf.Text       = ggk.cfcjhf;
            this.txtdjPwd.Text   = ggk.djPwd;
            //结束
            if (ggk.endPic != null && ggk.endPic.Trim() != "/weixin/ggk/images/end.jpg")
            {
                txtEndPic.Text     = ggk.endPic;
                imgEndPic.ImageUrl = ggk.endPic;
            }
            txtendNotice.Text  = ggk.endNotice;
            txtendContent.Text = ggk.endContent;

            //奖项基本信息
            txtpersonNum.Text      = MyCommFun.ObjToStr(ggk.personNum);
            txtpersonMaxTimes.Text = MyCommFun.ObjToStr(ggk.personMaxTimes);
            txtdayMaxTimes.Text    = MyCommFun.ObjToStr(ggk.dayMaxTimes);


            //绑定奖项信息
            IList <Model.wx_ggkAwardItem> 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;
                Model.wx_ggkAwardItem itemEntity = new Model.wx_ggkAwardItem();
                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)
        {
            Model.wx_userweixin weixin = GetWeiXinCode();

            Model.wx_requestRuleContent rc = new 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 (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 赋值
            Model.wx_ggkActionInfo ggk  = new Model.wx_ggkActionInfo();
            Model.wx_requestRule   rule = new 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)
            {
                ggk = ggkBll.GetModel(id);
            }

            ggk.actName      = txtactName.Text.Trim();
            ggk.contractInfo = txtcontractInfo.Text.Trim();
            ggk.brief        = txtbrief.Value.Trim();
            ggk.beginDate    = begin;
            ggk.endDate      = end;
            ggk.actContent   = txtactContent.Value.Trim();
            ggk.cfcjhf       = txtcfcjhf.Text.Trim();
            ggk.endNotice    = txtendNotice.Text.Trim();
            ggk.endContent   = txtendContent.Text.Trim();
            ggk.djPwd        = txtdjPwd.Text.Trim();

            ggk.beginPic       = beginPic;
            ggk.endPic         = endPic;
            ggk.personNum      = MyCommFun.Str2Int(txtpersonNum.Text);
            ggk.personMaxTimes = MyCommFun.Str2Int(txtpersonMaxTimes.Text);
            ggk.dayMaxTimes    = MyCommFun.Str2Int(txtdayMaxTimes.Text);

            #endregion

            if (id <= 0)
            {  //新增
                ggk.wid        = weixin.id;
                ggk.createDate = DateTime.Now;
                //1新增主表
                id = ggkBll.Add(ggk);

                //2新增奖项表
                EditAwardItem(id);
                //3 新增回复规则表
                AddRule(weixin.id, id);
                AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加刮刮卡活动,主键为" + id); //记录日志
                JscriptMsg("添加刮刮卡活动成功!", "ggklist.aspx", "Success");
            }
            else
            {   //修改
                //1修改主表
                ggkBll.Update(ggk);
                //2删除,且新增奖项表
                EditAwardItem(id);
                //3 修改回复规则表
                IList <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(weixin.id, id);
                }

                AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改刮刮卡活动,主键为" + id); //记录日志
                JscriptMsg("修改刮刮卡活动成功!", "ggklist.aspx", "Success");
            }
        }
示例#8
0
        /// <summary>
        /// 绑定页面上的基本信息
        /// </summary>
        private void bindData(int id, string openid)
        {
            #region 活动详情
            ggkAction = actbll.GetModel(id);
            if (ggkAction == null)
            {
                hidStatus.Value  = "-2";
                hidErrInfo.Value = "该活动不存在!";
                MessageBox.ResponseScript(this, "alert(\"该活动不存在\");");
                return;
            }
            this.Title = ggkAction.actName;
            List <Model.wx_ggkAwardItem> itemlist = itemBll.GetModelList("actId=" + id);
            StringBuilder         sb   = new StringBuilder("");
            Model.wx_ggkAwardItem item = new Model.wx_ggkAwardItem();
            int ttJpNum = 0;
            for (int i = 0; i < itemlist.Count; i++)
            {
                item = itemlist[i];
                sb.Append("<p>" + item.jxName + ":" + item.jpName + "  数量:" + item.jpNum + "</p>");
                ttJpNum += item.jpRealNum.Value;
            }

            if (ggkAction.djPwd.Trim().Length > 0)
            {
                litPwd.Text = "  <p>  <input name=\"\" class=\"px\" id=\"parssword\" type=\"password\" value=\"\" placeholder=\"商家输入兑奖密码\"></p>";
            }

            litJiangXing.Text = sb.ToString();

            litRemark.Text      = ggkAction.brief;
            litContentInfo.Text = ggkAction.contractInfo;
            litTTTimes.Text     = ggkAction.personMaxTimes == null ? "0" : ggkAction.personMaxTimes.Value.ToString();

            #endregion
            #region 判断

            if (ggkAction.endDate <= DateTime.Now)
            { //说明活动已经结束
                //非活动期间
                hidStatus.Value  = "-1";
                hidErrInfo.Value = "活动已结束!";
                return;
            }
            else if (ggkAction.beginDate > DateTime.Now)
            {
                //活动未开始
                //非活动期间
                hidStatus.Value  = "-2";
                hidErrInfo.Value = "活动尚未开始!";
                return;
            }

            Model.wx_ggkAwardUser awardUser = ubll.getZJinfoByOpenid(id, openid);
            if (awardUser != null && awardUser.id > 0)
            {  //说明已经中奖了
                litPrize.Text = awardUser.jxName;

                hidAwardId.Value = awardUser.id.ToString();



                if (awardUser.uTel != null && awardUser.uTel.Trim() != "")
                { //说明已经提交成功了
                    hidStatus.Value  = "110";
                    hidErrInfo.Value = "您已中过奖了,欢迎下次再来!";
                    litJp.Text       = awardUser.jxName + " " + awardUser.jpName;
                    litSNM.Text      = awardUser.sn;
                }
                else
                {  //中奖了,但是未提交
                    hidStatus.Value   = "100";
                    hidErrInfo.Value  = "您已中奖,请提交!";
                    litJiangPing.Text = awardUser.jpName;
                    litSnCode.Text    = awardUser.sn;

                    litJp.Text  = awardUser.jxName + " " + awardUser.jpName;
                    litSNM.Text = awardUser.sn;
                }
                return;
            }


            int dayMaxTimes = ggkAction.dayMaxTimes == null ? 0 : ggkAction.dayMaxTimes.Value;
            int perMaxTimes = ggkAction.personMaxTimes == null ? 0 : ggkAction.personMaxTimes.Value;
            //判断每人最大抽奖次数,是否超过了
            if (personCJTimes(openid, id) >= ggkAction.personMaxTimes)
            {
                hidStatus.Value  = "0";
                hidErrInfo.Value = "您已抽过奖了,欢迎下次再来!";
                return;
            }
            if (isTodayOverSum(id, openid, dayMaxTimes))
            {
                hidStatus.Value  = "0";
                hidErrInfo.Value = "每人每天只有" + dayMaxTimes.ToString() + "次抽奖机会。";
                return;
            }


            #endregion

            #region 计算中奖信息

            /// 处理是否中奖
            /// hidStatus 状态为-1:不能抽奖,直接跳转到end.aspx页面;
            /// 0:抽奖次数超过设置的最高次数;
            /// 1:还可以继续抽奖;
            /// 2:中奖了;
            IList <Model.wx_ggkAwardUser> auserlist = ubll.getHasZJList(id);//已经中奖的人列表
            int ZhongJiangNum = 0;
            if (auserlist != null)
            {
                ZhongJiangNum = auserlist.Count;   //已经中奖的人数
            }
            int syZjNum = ttJpNum - ZhongJiangNum; //剩余的奖品数量
            if (syZjNum <= 0)
            {                                      //说明已经没有奖品了
                hidStatus.Value  = "1";
                hidErrInfo.Value = ggkAction.cfcjhf;
                litPrize.Text    = NoAward;
                return;
            }
            ggkAction.personNum      = MyCommFun.Obj2Int(ggkAction.personNum, 1);
            ggkAction.personMaxTimes = MyCommFun.Obj2Int(ggkAction.personMaxTimes, 1);
            int fenmo = ggkAction.personNum.Value * ggkAction.personMaxTimes.Value;

            Random rd     = new Random((int)DateTime.Now.Ticks);
            int    radNum = rd.Next(0, fenmo);//从0到fenmo里随机出一个值
            if (radNum < syZjNum)
            {
                //中奖了,再从剩余奖品里抽取一个奖品
                Model.wx_ggkAwardItem dajiang = getZJItem(itemlist, auserlist);
                if (dajiang != null)
                {
                    //这是中的中奖了
                    string snumber = Get_snumber(id);
                    int    uId     = ubll.Add(id, "", "", openid, dajiang.jxName, dajiang.jpName, snumber);
                    hidStatus.Value   = "2";
                    hidErrInfo.Value  = "恭喜你中奖了!";
                    litPrize.Text     = dajiang.jxName;
                    litJiangPing.Text = dajiang.jpName;
                    hidAwardId.Value  = uId.ToString();
                    litSnCode.Text    = snumber;

                    litJp.Text  = dajiang.jxName + " " + dajiang.jpName;
                    litSNM.Text = snumber;
                    return;
                }
                else
                {
                    //奖品已经全部中完了
                    hidStatus.Value  = "1";
                    hidErrInfo.Value = ggkAction.cfcjhf;
                    litPrize.Text    = NoAward;
                    return;
                }
            }
            else
            {
                //这个条件说明:未中奖
                //抛出未中奖的数据
                hidStatus.Value  = "1";
                hidErrInfo.Value = ggkAction.cfcjhf;
                litPrize.Text    = NoAward;
            }



            #endregion
        }
示例#9
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Model.wx_userweixin weixin = GetWeiXinCode();

            Model.wx_requestRuleContent rc = new 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 (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 赋值
            Model.wx_ggkActionInfo ggk = new Model.wx_ggkActionInfo();
            Model.wx_requestRule rule = new 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)
            {
                ggk = ggkBll.GetModel(id);
            }

            ggk.actName = txtactName.Text.Trim();
            ggk.contractInfo = txtcontractInfo.Text.Trim();
            ggk.brief = txtbrief.Value.Trim();
            ggk.beginDate = begin;
            ggk.endDate = end;
            ggk.actContent = txtactContent.Value.Trim();
            ggk.cfcjhf = txtcfcjhf.Text.Trim();
            ggk.endNotice = txtendNotice.Text.Trim();
            ggk.endContent = txtendContent.Text.Trim();
            ggk.djPwd = txtdjPwd.Text.Trim();

            ggk.beginPic = beginPic;
            ggk.endPic = endPic;
            ggk.personNum = MyCommFun.Str2Int(txtpersonNum.Text);
            ggk.personMaxTimes = MyCommFun.Str2Int(txtpersonMaxTimes.Text);
            ggk.dayMaxTimes = MyCommFun.Str2Int(txtdayMaxTimes.Text);

            #endregion

            if (id <=0)
            {  //新增
                ggk.wid = weixin.id;
                ggk.createDate = DateTime.Now;
                //1新增主表
                id=  ggkBll.Add(ggk);

                //2新增奖项表
                EditAwardItem(id);
                //3 新增回复规则表
                AddRule(weixin.id, id);
                AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加刮刮卡活动,主键为"+id); //记录日志
                JscriptMsg("添加刮刮卡活动成功!", "ggklist.aspx", "Success");
            }
            else
            {   //修改
                //1修改主表
                ggkBll.Update(ggk);
                //2删除,且新增奖项表
                EditAwardItem(id);
                //3 修改回复规则表
               IList< 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(weixin.id, id);
               }

               AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改刮刮卡活动,主键为" + id); //记录日志
               JscriptMsg("修改刮刮卡活动成功!", "ggklist.aspx", "Success");
            }
        }