Esempio n. 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack)
     {
         if (this.Session["MemID"] != null)
         {
             int memID = int.Parse(this.Session["MemID"].ToString());
             this.txtMemID.Value = memID.ToString();
             if (base.Request["MoneyID"] != null)
             {
                 string moneyID = base.Request["MoneyID"].ToString();
                 this.BindWeiXinMoney(int.Parse(base.Request["MoneyID"]));
                 this.txtGetMoneyID.Value = base.Request["MoneyID"];
             }
             string openid = new Chain.BLL.Mem().GetWeiXinMemCardbyMemID(memID);
             this.OpenID.Value = openid;
             if (base.Request["Win"] != null)
             {
                 Chain.BLL.WeiXinMoney   bllWeiXinMoney   = new Chain.BLL.WeiXinMoney();
                 Chain.Model.WeiXinMoney modelWeiXinMoney = bllWeiXinMoney.GetModel(int.Parse(this.txtGetMoneyID.Value));
                 decimal givemoney  = new Chain.BLL.WeiXinGiveMoney().GetMoneySum(" MoneyID=" + modelWeiXinMoney.MoneyID);
                 decimal totalmoney = modelWeiXinMoney.TotalMoney;
                 if (totalmoney - givemoney < 1m)
                 {
                     this.IsWin.Value  = "-1";
                     this.txtMsg.Value = "红包已抢完!";
                 }
                 else
                 {
                     int intWin = this.isWin(decimal.Parse(this.MoneyRate.Value), int.Parse(this.MemtotalCount.Value));
                     this.IsWin.Value = intWin.ToString();
                     if (intWin == 0)
                     {
                         Chain.BLL.WeiXinGiveMoney bllWeiXinGiveMoney = new Chain.BLL.WeiXinGiveMoney();
                         bllWeiXinGiveMoney.Add(new Chain.Model.WeiXinGiveMoney
                         {
                             MemID     = int.Parse(this.txtMemID.Value),
                             MoneyID   = int.Parse(this.txtGetMoneyID.Value),
                             GiveMoney = 0m,
                             GiveTime  = DateTime.Now,
                             IsWin     = 0
                         });
                     }
                 }
             }
             if (base.Request["IsSuccess"] != null)
             {
                 this.IsSuccess.Value = base.Request["IsSuccess"];
             }
             this.rptWinListBind();
         }
         else
         {
             base.Response.Redirect("login.aspx");
         }
     }
 }
Esempio n. 2
0
        private void BindWeiXinMoney(int moneyID)
        {
            Chain.BLL.WeiXinMoney   bllWeiXinMoney   = new Chain.BLL.WeiXinMoney();
            Chain.Model.WeiXinMoney modelWeiXinMoney = bllWeiXinMoney.GetModel(moneyID);
            this.spEndTime.InnerHtml   = modelWeiXinMoney.EndTime.ToString("yyyy.MM.dd HH:mm");
            this.spStartTime.InnerHtml = modelWeiXinMoney.StartTime.ToString("yyyy.MM.dd HH:mm");
            int count = new Chain.BLL.WeiXinMoneyMem().GetRecordCount("MoneyID=" + modelWeiXinMoney.MoneyID);

            this.MemtotalCount.Value = count.ToString();
            DataTable dt;

            if (modelWeiXinMoney.QuerySql != null)
            {
                dt = new Chain.BLL.Mem().GetList(modelWeiXinMoney.QuerySql).Tables[0];
            }
            else
            {
                dt = new Chain.BLL.Mem().GetList("").Tables[0];
            }
            this.IsOwn.Value = "0";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (this.txtMemID.Value == dt.Rows[i]["MemID"].ToString())
                {
                    this.IsOwn.Value = "1";
                    break;
                }
            }
            int maxcount = modelWeiXinMoney.MaxCount;
            int memcount = new Chain.BLL.WeiXinGiveMoney().GetRecordCount(string.Concat(new object[]
            {
                " MemID=",
                int.Parse(this.txtMemID.Value),
                " and MoneyID=",
                modelWeiXinMoney.MoneyID
            }));

            this.MemCount.Value         = (maxcount - memcount).ToString();
            this.spNoUseCount.InnerHtml = this.MemCount.Value;
            this.MaxCount.Value         = modelWeiXinMoney.MaxCount.ToString();
            this.MoneyRate.Value        = modelWeiXinMoney.MoneyRate.ToString();
            this.TotalMoney.Value       = modelWeiXinMoney.TotalMoney.ToString();
            this.StartMoney.Value       = modelWeiXinMoney.StartMoney.ToString();
            this.EndMoney.Value         = modelWeiXinMoney.EndMoney.ToString();
            this.MoneyType.Value        = modelWeiXinMoney.MoneyType.ToString();
            this.FixedMoney.Value       = modelWeiXinMoney.FixedMoney.ToString();
            this.txtImageUrl.Value      = modelWeiXinMoney.ImageUrl.ToString();
            this.spDesc.InnerHtml       = modelWeiXinMoney.MoneyDesc.ToString();
            decimal money = new Chain.BLL.WeiXinGiveMoney().GetMoneySum(" MoneyID=" + modelWeiXinMoney.MoneyID);

            this.GiveMoney.Value = money.ToString();
        }
Esempio n. 3
0
        private void BindData(int MoneyID)
        {
            Chain.BLL.WeiXinMoney   bllWeiXinMoney   = new Chain.BLL.WeiXinMoney();
            Chain.Model.WeiXinMoney modelWeiXinMoney = bllWeiXinMoney.GetModel(MoneyID);
            this.txtMoneyTitle.Value = modelWeiXinMoney.MoneyTitle;
            this.txtMoneyDesc.Value  = modelWeiXinMoney.MoneyDesc;
            this.txtMoneyWish.Value  = modelWeiXinMoney.MoneyWish;
            this.imgMoneyPhoto.Src   = modelWeiXinMoney.ImageUrl;
            this.txtMoneyPhoto.Value = modelWeiXinMoney.ImageUrl;
            this.txtEndTime.Value    = modelWeiXinMoney.EndTime.ToString("yyyy-MM-dd HH:mm");
            this.txtStartTime.Value  = modelWeiXinMoney.StartTime.ToString("yyyy-MM-dd HH:mm");
            this.txtTotalMoney.Value = modelWeiXinMoney.TotalMoney.ToString();
            if (modelWeiXinMoney.MoneyType == 1)
            {
                this.radMoneyTypeOne.Checked = true;
                this.radMoneyTypeTwo.Checked = false;
                this.txtStartMoney.Value     = modelWeiXinMoney.StartMoney.ToString();
                this.txtEndMoney.Value       = modelWeiXinMoney.EndMoney.ToString();
            }
            else
            {
                this.radMoneyTypeOne.Checked = false;
                this.radMoneyTypeTwo.Checked = true;
                this.txtFixedMoney.Value     = modelWeiXinMoney.FixedMoney.ToString();
            }
            this.txtMaxCount.Value    = modelWeiXinMoney.MaxCount.ToString();
            this.txtMoneyRate.Value   = modelWeiXinMoney.MoneyRate.ToString();
            this.txtMoneyRegion.Value = modelWeiXinMoney.MoneyRegion;
            this.txtQuerySql.Value    = modelWeiXinMoney.QuerySql;
            DataTable dt = new Chain.BLL.Mem().GetList(this.txtQuerySql.Value).Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                HtmlTextArea expr_1EA = this.txtMemList;
                string       value    = expr_1EA.Value;
                expr_1EA.Value = string.Concat(new string[]
                {
                    value,
                    dt.Rows[i]["MemCard"].ToString(),
                    "[",
                    dt.Rows[i]["MemName"].ToString(),
                    "];"
                });
                this.txtMemIDList.Value = dt.Rows[i]["MemID"].ToString();
            }
            this.lblStartTime.Visible = false;
        }
Esempio n. 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack)
     {
         if (this.Session["MemID"] != null)
         {
             int memID = int.Parse(this.Session["MemID"].ToString());
             this.txtMemID.Value = memID.ToString();
             if (base.Request.QueryString["MoneyID"] != null)
             {
                 this.txtMoneyID.Value = base.Request.QueryString["MoneyID"].ToString();
                 this.BindWeiXinMoney(int.Parse(this.txtMoneyID.Value));
             }
             if (int.Parse(this.MemCount.Value) > 0)
             {
                 string openid = new Chain.BLL.Mem().GetModel(memID).MemWeiXinCard;
                 if (string.IsNullOrEmpty(openid))
                 {
                     base.Response.Write("<span style='color:#FF0000;font-size:20px'>页面传参出错,请返回重试</span>");
                 }
                 else
                 {
                     double getmoney = double.Parse(this.txtgetmoney.Value);
                     Chain.BLL.WeiXinMoney   bllWeiXinMoney   = new Chain.BLL.WeiXinMoney();
                     Chain.Model.WeiXinMoney modelWeiXinMoney = bllWeiXinMoney.GetModel(int.Parse(this.txtMoneyID.Value));
                     string    mch_billno   = DateTime.Now.ToString("yyMMddHHmmssffff");
                     int       total_amount = int.Parse((getmoney * 100.0).ToString(""));
                     string    wishing      = modelWeiXinMoney.MoneyWish;
                     string    remark       = modelWeiXinMoney.MoneyDesc;
                     string    act_name     = modelWeiXinMoney.MoneyTitle;
                     string    re_openid    = openid;
                     WxPayData data         = new WxPayData();
                     data.SetValue("mch_billno", mch_billno);
                     data.SetValue("mch_id", PubFunction.curParameter.strMchid);
                     data.SetValue("wxappid", PubFunction.curParameter.strWeiXinAppID);
                     data.SetValue("send_name", "智络");
                     data.SetValue("re_openid", re_openid);
                     data.SetValue("total_amount", total_amount);
                     data.SetValue("total_num", 1);
                     data.SetValue("wishing", wishing);
                     data.SetValue("client_ip", PubFunction.ipAdress);
                     data.SetValue("act_name", act_name);
                     data.SetValue("remark", remark);
                     WxPayData result = WxPayApi.Sendredpack(data, PubFunction.curParameter.strMchKey, "cert\\apiclient_cert.p12", PubFunction.curParameter.strMchid, 10);
                     if (!result.IsSet("return_code") || result.GetValue("return_code").ToString() == "FAIL")
                     {
                         string arg_2DD_0 = result.IsSet("return_msg") ? result.GetValue("return_msg").ToString() : "";
                         this.spGetMoney.InnerHtml   = "";
                         this.spResultInfo.InnerHtml = "红包接口调用失败!" + result.GetValue("return_msg").ToString();
                     }
                     else if (result.GetValue("return_code").ToString() == "SUCCESS" && result.GetValue("result_code").ToString() == "SUCCESS")
                     {
                         if (int.Parse(this.MemCount.Value) > 0)
                         {
                             Chain.BLL.WeiXinGiveMoney bllWeiXinGiveMoney = new Chain.BLL.WeiXinGiveMoney();
                             bllWeiXinGiveMoney.Add(new Chain.Model.WeiXinGiveMoney
                             {
                                 MemID     = int.Parse(this.txtMemID.Value),
                                 MoneyID   = int.Parse(this.txtMoneyID.Value),
                                 GiveMoney = decimal.Parse(getmoney.ToString()),
                                 GiveTime  = DateTime.Now,
                                 IsWin     = 1
                             });
                             bllWeiXinMoney.UpdateGiveMoney(int.Parse(this.txtMoneyID.Value), decimal.Parse(getmoney.ToString()));
                             this.spResultInfo.InnerHtml = "红包发放成功!";
                             this.spGetMoney.InnerHtml   = getmoney.ToString("#0.00");
                             this.moneyInfo.Visible      = true;
                         }
                         else
                         {
                             this.spGetMoney.InnerHtml   = "";
                             this.spResultInfo.InnerHtml = "您的红包领取次数已用完!";
                         }
                     }
                     else
                     {
                         this.spGetMoney.InnerHtml   = "";
                         this.spResultInfo.InnerHtml = "红包发放失败!" + result.GetValue("return_msg").ToString();
                     }
                 }
             }
         }
         else
         {
             base.Response.Redirect("login.aspx");
         }
     }
 }
Esempio n. 5
0
        protected void btnMoneySave_Click(object sender, EventArgs e)
        {
            Chain.Model.WeiXinMoney modelWeiXinMoney = new Chain.Model.WeiXinMoney();
            Chain.BLL.WeiXinMoney   bllWeiXinMoney   = new Chain.BLL.WeiXinMoney();
            int      MoneyID = 0;
            DateTime StartTime;

            if (this.radStartTypeOne.Checked)
            {
                StartTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
            }
            else
            {
                StartTime = DateTime.Parse(DateTime.Parse(this.txtStartTime.Value).ToString("yyyy-MM-dd HH:mm"));
            }
            if (this.txtMoneyID.Value != "")
            {
                MoneyID   = int.Parse(this.txtMoneyID.Value);
                StartTime = DateTime.Parse(DateTime.Parse(this.txtStartTime.Value).ToString("yyyy-MM-dd HH:mm"));
            }
            string   ImageUrl   = this.txtMoneyPhoto.Value;
            string   MoneyDesc  = this.txtMoneyDesc.Value;
            string   MoneyTitle = this.txtMoneyTitle.Value;
            string   MoneyWish  = this.txtMoneyWish.Value;
            DateTime EndTime    = DateTime.Parse(DateTime.Parse(this.txtEndTime.Value).ToString("yyyy-MM-dd HH:mm"));
            decimal  TotalMoney = decimal.Parse(this.txtTotalMoney.Value);
            decimal  StartMoney = 0m;
            decimal  EndMoney   = 0m;
            decimal  FixedMoney = 0m;
            int      MoneyType;

            if (this.radMoneyTypeOne.Checked)
            {
                StartMoney = decimal.Parse(this.txtStartMoney.Value);
                EndMoney   = decimal.Parse(this.txtEndMoney.Value);
                MoneyType  = 1;
            }
            else
            {
                FixedMoney = decimal.Parse(this.txtFixedMoney.Value);
                MoneyType  = 2;
            }
            int     MaxCount  = int.Parse(this.txtMaxCount.Value);
            decimal MoneyRate = decimal.Parse(this.txtMoneyRate.Value);
            string  MemIDList = this.txtMemIDList.Value.TrimEnd(new char[]
            {
                ','
            });

            string[] strMemIDList = MemIDList.Split(new char[]
            {
                ','
            });
            modelWeiXinMoney.MoneyTitle  = MoneyTitle;
            modelWeiXinMoney.MoneyWish   = MoneyWish;
            modelWeiXinMoney.MoneyDesc   = MoneyDesc;
            modelWeiXinMoney.ImageUrl    = ImageUrl;
            modelWeiXinMoney.StartTime   = StartTime;
            modelWeiXinMoney.EndTime     = EndTime;
            modelWeiXinMoney.TotalMoney  = TotalMoney;
            modelWeiXinMoney.MoneyType   = MoneyType;
            modelWeiXinMoney.StartMoney  = StartMoney;
            modelWeiXinMoney.EndMoney    = EndMoney;
            modelWeiXinMoney.FixedMoney  = FixedMoney;
            modelWeiXinMoney.MaxCount    = MaxCount;
            modelWeiXinMoney.MoneyRate   = MoneyRate;
            modelWeiXinMoney.GiveMoney   = 0m;
            modelWeiXinMoney.MoneyRegion = this.txtMoneyRegion.Value;
            modelWeiXinMoney.QuerySql    = this.txtQuerySql.Value;
            if (MoneyID == 0)
            {
                modelWeiXinMoney.CreateTime   = DateTime.Now;
                modelWeiXinMoney.CreateUserID = this._UserID;
                int intMoneyID = bllWeiXinMoney.Add(modelWeiXinMoney);
                Chain.BLL.WeiXinMoneyMem bllWeiXinMoneyMem = new Chain.BLL.WeiXinMoneyMem();
                for (int i = 0; i < strMemIDList.Length; i++)
                {
                    bllWeiXinMoneyMem.Add(new Chain.Model.WeiXinMoneyMem
                    {
                        MemID   = int.Parse(strMemIDList[i]),
                        MoneyID = intMoneyID
                    });
                }
                base.MessagePageShowError("保存成功!");
                base.Response.Redirect("WeiXinMoneyList.aspx");
            }
            else
            {
                modelWeiXinMoney.MoneyID = MoneyID;
                if (bllWeiXinMoney.Update(modelWeiXinMoney) > 0)
                {
                    base.MessagePageShowError("修改成功!");
                    base.Response.Redirect("WeiXinMoneyList.aspx");
                }
                else
                {
                    base.MessagePageShowError("修改失败!");
                }
            }
        }