Esempio n. 1
0
        protected override bool BeforeLoad()
        {
            if (null == Request.QueryString["id"])
            {
                return(false);
            }
            CouponID = Common.Common.NoHtml(Request.QueryString["id"].ToString());
            string strGuid = string.Empty;

            if (null != Request.QueryString["sitecode"] && null != Request.QueryString["openid"])
            {
                SiteCode = Common.Common.NoHtml(Request.QueryString["sitecode"].ToString());
                OpenID   = Common.Common.NoHtml(Request.QueryString["openid"].ToString());
                //插入优惠券
                SiteActivityDAL dalActive = new SiteActivityDAL();
                DataSet         dsActive  = dalActive.GetActivityDetail(CouponID);
                if (null != dsActive && dsActive.Tables.Count > 0 && dsActive.Tables[0].Rows.Count > 0)
                {
                    strGuid = Guid.NewGuid().ToString("N");
                    CouponDAL cdal = new CouponDAL();
                    if (!cdal.ExistCoupon(SiteCode, CouponID, OpenID))
                    {
                        Coupon coupon = new Coupon()
                        {
                            ID             = strGuid,
                            SiteCode       = SiteCode,
                            SiteActivityID = CouponID,
                            OpenID         = OpenID,
                            CouponStatus   = 0
                        };
                        cdal.InsertInfo(coupon);
                    }
                }
                CouponID = strGuid;
            }
            else
            {
                SiteActivityDAL dalActive = new SiteActivityDAL();
                DataSet         dsActive  = dalActive.GetActivityDetail(CouponID);
                if (null != dsActive && dsActive.Tables.Count > 0 && dsActive.Tables[0].Rows.Count > 0)
                {
                    SiteCode = dsActive.Tables[0].Rows[0]["SIteCode"].ToString();
                }
            }
            return(base.BeforeLoad());
        }
Esempio n. 2
0
        public void ShowActivityInfo(string strID)
        {
            SiteActivityDAL dal   = new SiteActivityDAL();
            DataSet         ds    = dal.GetActivityDetail(strID);
            SiteActivity    model = DataConvert.DataRowToModel <SiteActivity>(ds.Tables[0].Rows[0]);

            this.txtName.Text     = model.ActTitle;
            this.hd_content.Value = model.ActContent;
            this.txtSummary.Text  = model.Remark;
            starttime.Text        = model.StartTime;
            endtime.Text          = model.EndTime;
            cutTime.Text          = model.CutOffTime;
            Discount.Text         = model.DisCount;
            opentime.Text         = model.OpenTime;
            closetime.Text        = model.CloseTime;
            daylimit.Text         = model.DayLimit.ToString();
            if (model.ActStatus == 0)
            {
                ActStatusno.Checked = true;
            }
            else
            {
                ActStatusyes.Checked = true;
            }
            img0.Src = "../../" + model.Photo;
            if (strAction == "show")
            {
                this.btnReset.Visible = false;
                this.btnSave.Visible  = false;
                starttime.ReadOnly    = true;
                endtime.ReadOnly      = true;
                txtName.ReadOnly      = true;
                txtSummary.ReadOnly   = true;
            }
            else
            {
                starttime.Attributes.Add("onclick", "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})");
                endtime.Attributes.Add("onclick", "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})");
                cutTime.Attributes.Add("onclick", "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})");
                opentime.Attributes.Add("onclick", "WdatePicker({dateFmt:'HH:mm:ss'})");
                closetime.Attributes.Add("onclick", "WdatePicker({dateFmt:'HH:mm:ss'})");
            }
        }
Esempio n. 3
0
        protected override bool BeforeLoad()
        {
            string strGuid = string.Empty;


            if (null != Request.QueryString["sitecode"] && null != Request.QueryString["openid"] && null != Request.QueryString["couponid"])
            {
                CouponID = Common.Common.NoHtml(Request.QueryString["couponid"].ToString());
                SiteCode = Common.Common.NoHtml(Request.QueryString["sitecode"].ToString());

                if (Request.QueryString["sitecode"].ToString().Length > 6)
                {
                    return(false);
                }

                if (Request.QueryString["couponid"].ToString().Length != 32)
                {
                    return(false);
                }

                if (Request.QueryString["openid"].ToString().Length > 29 || Request.QueryString["openid"].ToString().Length < 25)
                {
                    return(false);
                }
                else
                {
                    OpenID = Request.QueryString["openid"].ToString();
                }

                //插入优惠券
                SiteActivityDAL dalActive = new SiteActivityDAL();
                DataSet         dsActive  = dalActive.GetActivityDetail(CouponID);
                if (null != dsActive && dsActive.Tables.Count > 0 && dsActive.Tables[0].Rows.Count > 0)
                {
                    strGuid = Guid.NewGuid().ToString("N");
                    CouponDAL cdal = new CouponDAL();
                    if (!cdal.ExistCoupon(SiteCode, CouponID, OpenID))
                    {
                        //判断是否可以参加
                        //取当前已经参加的人数
                        int iCount = 10000000;
                        if (null != dsActive.Tables[0].Rows[0]["DayLimit"].ToString())
                        {
                            string strCount = "SiteCode = '" + SiteCode + "' AND SiteActivityID = '" + CouponID + "' AND CONVERT(VARCHAR(10),AddTime,120) = CONVERT(VARCHAR(10),GETDATE(),120)";
                            iCount = cdal.GetCouponCount(strCount);
                        }
                        string strStartTime = dsActive.Tables[0].Rows[0]["StartTime"].ToString();
                        string strEndTime   = dsActive.Tables[0].Rows[0]["EndTime"].ToString();
                        string strOpenTime  = dsActive.Tables[0].Rows[0]["OpenTime"].ToString();
                        string strCloseTime = dsActive.Tables[0].Rows[0]["CloseTime"].ToString();
                        string strDayLimit  = dsActive.Tables[0].Rows[0]["DayLimit"].ToString();

                        if (DateTime.Now >= Convert.ToDateTime(strStartTime) &&
                            DateTime.Now < Convert.ToDateTime(strEndTime) &&
                            DateTime.Now.Hour >= int.Parse(strOpenTime) &&
                            DateTime.Now.Hour < int.Parse(strCloseTime)
                            )
                        {
                            if (iCount < int.Parse(strDayLimit))
                            {
                                Coupon coupon = new Coupon()
                                {
                                    ID             = strGuid,
                                    SiteCode       = SiteCode,
                                    SiteActivityID = CouponID,
                                    OpenID         = OpenID,
                                    CouponStatus   = 0
                                };
                                cdal.InsertInfo(coupon);
                                strReHtml = "RushBuyOK.html";
                            }
                            else
                            {
                                strReHtml  = "RushBuyOver.html";
                                strMessage = "抱歉!优惠券已经被抢完,请关注下期活动!";
                            }
                        }
                        else
                        {
                            strReHtml  = "RushBuyOver.html";
                            strMessage = "抱歉!近期活动未开始或者已经结束,请关注公方微信优惠消息!";
                        }
                    }
                    else
                    {
                        strReHtml  = "RushBuyOver.html";
                        strMessage = "抱歉!您已经参与了活动,请把机会留给其余的顾客。";
                    }
                }
                CouponID = strGuid;
            }
            else
            {
                Response.Write("<script>window.opener=null;window.close();</script>");
                return(false);
            }
            return(base.BeforeLoad());
        }