Example #1
0
        private DataGridViewModel <Dictionary <string, object> > GetDataList(CouponsSearch query)
        {
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();

            if (query != null)
            {
                DbQueryResult couponInfos = CouponHelper.GetCouponInfos(query, "");
                dataGridViewModel.rows  = DataHelper.DataTableToDictionary(couponInfos.Data);
                dataGridViewModel.total = couponInfos.TotalRecords;
                foreach (Dictionary <string, object> row in dataGridViewModel.rows)
                {
                    CouponInfo couponInfo    = row.ToObject <CouponInfo>();
                    int        couponSurplus = CouponHelper.GetCouponSurplus(couponInfo.CouponId);
                    row.Add("LastCount", couponSurplus);
                    int couponObtainUserNum = CouponHelper.GetCouponObtainUserNum(couponInfo.CouponId);
                    int couponObtainNum     = CouponHelper.GetCouponObtainNum(couponInfo.CouponId, 0);
                    row.Add("UserCount", couponObtainUserNum);
                    row.Add("UserGetCount", couponObtainNum);
                    int couponUsedNum = CouponHelper.GetCouponUsedNum(couponInfo.CouponId);
                    row.Add("UseCount", couponUsedNum);
                    row.Add("IsCouponEnd", this.IsCouponEnd(couponInfo.ClosingTime));
                }
            }
            return(dataGridViewModel);
        }
Example #2
0
        private void Refresh()
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();

            this.hidSelectCouponIds.Value = ",";
            string        sWhere      = "and COUPONID IN ('" + masterSettings.GiftCouponList.Replace(",", "','") + "')";
            DbQueryResult couponInfos = CouponHelper.GetCouponInfos(this.GetCouponsSearch(), sWhere);

            this.rpCoupons.DataSource = couponInfos.Data;
            this.rpCoupons.DataBind();
        }
Example #3
0
        private DataGridViewModel <Dictionary <string, object> > GetDataList(CouponsSearch query)
        {
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();

            if (query != null)
            {
                DbQueryResult couponInfos = CouponHelper.GetCouponInfos(query, "");
                dataGridViewModel.rows  = DataHelper.DataTableToDictionary(couponInfos.Data);
                dataGridViewModel.total = couponInfos.TotalRecords;
                foreach (Dictionary <string, object> row in dataGridViewModel.rows)
                {
                    row.Add("CouponSurplus", this.GetCouponSurplus(row["CouponId"].ToInt(0)));
                }
            }
            return(dataGridViewModel);
        }
        private void BindRegisterCoupons()
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();

            if (!masterSettings.IsOpenGiftCoupons)
            {
                HttpContext.Current.Response.Redirect("RegisteredCouponsEnd.aspx");
            }
            this.hidIsOpenGiftCoupons.Value = (masterSettings.IsOpenGiftCoupons ? "1" : "0");
            this.btnToGo.NavigateUrl        = "";
            string        sWhere      = "and COUPONID IN ('" + masterSettings.GiftCouponList.Replace(",", "','") + "')";
            DbQueryResult couponInfos = CouponHelper.GetCouponInfos(this.GetCouponsSearch(), sWhere);
            decimal       num         = default(decimal);

            if (couponInfos.Data != null)
            {
                DataTable data = couponInfos.Data;
                data.Columns.Add("ItemIndex");
                data.Columns.Add("isEnd");
                int num2 = 0;
                foreach (DataRow row in data.Rows)
                {
                    int couponSurplus = CouponHelper.GetCouponSurplus(row["CouponId"].ToInt(0));
                    if (couponSurplus <= 0)
                    {
                        row["isEnd"] = "couponed";
                    }
                    if (row["ClosingTime"].ToDateTime().HasValue&& row["ClosingTime"].ToDateTime().Value < DateTime.Now)
                    {
                        row["isEnd"] = "couponed";
                    }
                    num += row["Price"].ToDecimal(0);
                    if (data.Rows.Count == num2 + 1 && data.Rows.Count % 2 == 1)
                    {
                        row["ItemIndex"] = -1;
                    }
                    else
                    {
                        row["ItemIndex"] = num2;
                    }
                    num2++;
                }
                this.rptRegisterCoupons.DataSource = data;
                this.rptRegisterCoupons.DataBind();
            }
            this.lblTotalPrice.Text = num.F2ToString("f2");
        }
Example #5
0
        private void BindRegisterCoupons()
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();

            this.hidIsOpenGiftCoupons.Value = (masterSettings.IsOpenGiftCoupons ? "1" : "0");
            this.btnToGo.Text        = (masterSettings.IsOpenGiftCoupons ? "去注册" : "去购物");
            this.btnToGo.NavigateUrl = (masterSettings.IsOpenGiftCoupons ? "/Register.aspx" : "/");
            MemberInfo user = HiContext.Current.User;

            if (masterSettings.IsOpenGiftCoupons)
            {
                string        sWhere      = "and COUPONID IN ('" + masterSettings.GiftCouponList.Replace(",", "','") + "')";
                DbQueryResult couponInfos = CouponHelper.GetCouponInfos(this.GetCouponsSearch(), sWhere);
                decimal       num         = default(decimal);
                if (couponInfos.Data != null)
                {
                    DataTable data = couponInfos.Data;
                    data.Columns.Add("isEnd");
                    foreach (DataRow row in data.Rows)
                    {
                        num += row["Price"].ToDecimal(0);
                        int couponSurplus = CouponHelper.GetCouponSurplus(row["CouponId"].ToInt(0));
                        if (couponSurplus <= 0)
                        {
                            row["isEnd"] = "end";
                        }
                        if (row["ClosingTime"].ToDateTime().HasValue&& row["ClosingTime"].ToDateTime().Value < DateTime.Now)
                        {
                            row["isEnd"] = "end";
                        }
                    }
                    this.rptRegisterCoupons.DataSource = couponInfos.Data;
                    this.rptRegisterCoupons.DataBind();
                }
                this.lblTotalPrice.Text = num.F2ToString("f2");
                if (user.UserId > 0 && user.IsLogined)
                {
                    this.btnToGo.NavigateUrl = "RegisteredCoupons.aspx?isOldUser=true";
                }
            }
            if (this.isOldUser)
            {
                this.hidIsOpenGiftCoupons.Value = "2";
                this.btnToGo.Text        = "去购物";
                this.btnToGo.NavigateUrl = "/";
            }
        }
Example #6
0
        private void BindCouponList()
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();

            this.ooOpen.SelectedValue = masterSettings.IsOpenGiftCoupons;
            if (masterSettings.IsOpenGiftCoupons)
            {
                this.hidSelectCouponIds.Value = ",";
                string        sWhere      = "and COUPONID IN ('" + masterSettings.GiftCouponList.Replace(",", "','") + "')";
                DbQueryResult couponInfos = CouponHelper.GetCouponInfos(this.GetCouponsSearch(), sWhere);
                this.rpCoupons.DataSource = couponInfos.Data;
                this.rpCoupons.DataBind();
            }
            else
            {
                this.hidSelectCouponIds.Value = "";
                this.rpCoupons.DataSource     = null;
                this.rpCoupons.DataBind();
            }
        }
Example #7
0
        private DataGridViewModel <Dictionary <string, object> > GetDataList(CouponsSearch query, string NotInCouponIds = "")
        {
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();

            if (query != null)
            {
                string sWhere = "";
                if (!string.IsNullOrWhiteSpace(NotInCouponIds))
                {
                    sWhere = "and COUPONID NOT IN ('" + NotInCouponIds.Replace(",", "','") + "')";
                }
                DbQueryResult couponInfos = CouponHelper.GetCouponInfos(query, sWhere);
                dataGridViewModel.rows  = DataHelper.DataTableToDictionary(couponInfos.Data);
                dataGridViewModel.total = couponInfos.TotalRecords;
                foreach (Dictionary <string, object> row in dataGridViewModel.rows)
                {
                    row.Add("CouponSurplus", this.GetCouponSurplus(row["CouponId"].ToInt(0)));
                }
            }
            return(dataGridViewModel);
        }
Example #8
0
        private void BindData()
        {
            decimal?minValue = null;
            decimal?maxValue = null;

            System.DateTime?beginDate = null;
            System.DateTime?endDate   = null;
            string          text      = this.txt_name.Text;
            decimal         value     = 0m;

            System.DateTime now = System.DateTime.Now;
            if (this.bDecimal(this.txt_minVal.Text, ref value))
            {
                minValue = new decimal?(value);
            }
            if (this.bDecimal(this.txt_maxVal.Text, ref value))
            {
                maxValue = new decimal?(value);
            }
            if (this.bDate(this.calendarStartDate.Text, ref now))
            {
                beginDate = new System.DateTime?(now);
            }
            if (this.bDate(this.calendarEndDate.Text, ref now))
            {
                endDate = new System.DateTime?(now);
            }
            DbQueryResult couponInfos = CouponHelper.GetCouponInfos(new CouponsSearch
            {
                CouponName = text,
                minValue   = minValue,
                maxValue   = maxValue,
                beginDate  = beginDate,
                endDate    = endDate,
                IsCount    = true,
                PageIndex  = this.pager1.PageIndex,
                PageSize   = this.pager1.PageSize,
                SortBy     = "CouponId",
                SortOrder  = SortAction.Desc
            });

            System.Data.DataTable dataTable = (System.Data.DataTable)couponInfos.Data;
            if (dataTable.Rows.Count > 0)
            {
                dataTable.Columns.Add("useConditon");
                dataTable.Columns.Add("ReceivNum");
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    decimal d = decimal.Parse(dataTable.Rows[i]["ConditionValue"].ToString());
                    if (d == 0m)
                    {
                        dataTable.Rows[i]["useConditon"] = "不限制";
                    }
                    else
                    {
                        dataTable.Rows[i]["useConditon"] = "满" + d.ToString("F2") + "可使用";
                    }
                    string text2 = dataTable.Rows[i]["maxReceivNum"].ToString();
                    if (text2 == "0")
                    {
                        dataTable.Rows[i]["ReceivNum"] = "无限制";
                    }
                    else
                    {
                        dataTable.Rows[i]["ReceivNum"] = text2 + "/张每人";
                    }
                }
            }
            this.grdCoupondsList.DataSource = dataTable;
            this.grdCoupondsList.DataBind();
            this.pager1.TotalRecords = couponInfos.TotalRecords;
        }
Example #9
0
        private void BindData()
        {
            string   text          = "";
            string   selectedValue = "";
            decimal? nullable      = null;
            decimal? nullable2     = null;
            DateTime?selectedDate  = null;
            DateTime?nullable4     = null;

            text = this.txt_name.Text;
            decimal  i   = 0M;
            DateTime now = DateTime.Now;

            if (this.bDecimal(this.txt_minVal.Text, ref i))
            {
                nullable = new decimal?(i);
            }
            if (this.bDecimal(this.txt_maxVal.Text, ref i))
            {
                nullable2 = new decimal?(i);
            }
            selectedDate  = this.calendarStartDate.SelectedDate;
            nullable4     = this.calendarEndDate.SelectedDate;
            selectedValue = this.ddlCouponType.SelectedValue;
            CouponsSearch search = new CouponsSearch
            {
                CouponName = text,
                minValue   = nullable,
                maxValue   = nullable2,
                beginDate  = selectedDate,
                endDate    = nullable4,
                IsCount    = true,
                PageIndex  = this.pager1.PageIndex,
                PageSize   = this.pager1.PageSize,
                SortBy     = "CouponId",
                SortOrder  = SortAction.Desc,
                Finished   = new bool?(bFininshed),
                SearchType = new int?(string.IsNullOrEmpty(selectedValue) ? 0 : int.Parse(selectedValue))
            };
            DbQueryResult couponInfos = CouponHelper.GetCouponInfos(search);

            if (couponInfos != null)
            {
                DataTable data = (DataTable)couponInfos.Data;
                if (data.Rows.Count > 0)
                {
                    data.Columns.Add("useConditon");
                    data.Columns.Add("ReceivNum");
                    data.Columns.Add("expire");
                    for (int j = 0; j < data.Rows.Count; j++)
                    {
                        decimal num3 = decimal.Parse(data.Rows[j]["ConditionValue"].ToString());
                        if (num3 == 0M)
                        {
                            data.Rows[j]["useConditon"] = "不限制";
                        }
                        else
                        {
                            data.Rows[j]["useConditon"] = "满" + num3.ToString("F2") + "可使用";
                        }
                        string str3 = data.Rows[j]["maxReceivNum"].ToString();
                        if (str3 == "0")
                        {
                            data.Rows[j]["ReceivNum"] = "无限制";
                        }
                        else
                        {
                            data.Rows[j]["ReceivNum"] = str3 + "/张每人";
                        }
                        data.Rows[j]["expire"] = DateTime.Parse(data.Rows[j]["EndDate"].ToString()) <= DateTime.Now;
                    }
                }
                this.grdCoupondsList.DataSource = data;
                this.grdCoupondsList.DataBind();
            }
            this.pager1.TotalRecords = couponInfos.TotalRecords;
        }
Example #10
0
        private void BindData()
        {
            string   text      = "";
            decimal? nullable  = null;
            decimal? nullable2 = null;
            DateTime?nullable3 = null;
            DateTime?nullable4 = null;

            text = this.txt_name.Text;
            decimal  i   = 0M;
            DateTime now = DateTime.Now;

            if (this.bDecimal(this.txt_minVal.Text, ref i))
            {
                nullable = new decimal?(i);
            }
            if (this.bDecimal(this.txt_maxVal.Text, ref i))
            {
                nullable2 = new decimal?(i);
            }
            if (this.bDate(this.calendarStartDate.Text, ref now))
            {
                nullable3 = new DateTime?(now);
            }
            if (this.bDate(this.calendarEndDate.Text, ref now))
            {
                nullable4 = new DateTime?(now);
            }
            CouponsSearch search = new CouponsSearch
            {
                CouponName = text,
                minValue   = nullable,
                maxValue   = nullable2,
                beginDate  = nullable3,
                endDate    = nullable4,
                IsCount    = true,
                PageIndex  = this.pager1.PageIndex,
                PageSize   = this.pager1.PageSize,
                SortBy     = "CouponId",
                SortOrder  = SortAction.Desc
            };
            DbQueryResult couponInfos = CouponHelper.GetCouponInfos(search);
            DataTable     data        = (DataTable)couponInfos.Data;

            if (data.Rows.Count > 0)
            {
                data.Columns.Add("useConditon");
                data.Columns.Add("ReceivNum");
                for (int j = 0; j < data.Rows.Count; j++)
                {
                    decimal num3 = decimal.Parse(data.Rows[j]["ConditionValue"].ToString());
                    if (num3 == 0M)
                    {
                        data.Rows[j]["useConditon"] = "不限制";
                    }
                    else
                    {
                        data.Rows[j]["useConditon"] = "满" + num3.ToString("F2") + "可使用";
                    }
                    string str2 = data.Rows[j]["maxReceivNum"].ToString();
                    if (str2 == "0")
                    {
                        data.Rows[j]["ReceivNum"] = "无限制";
                    }
                    else
                    {
                        data.Rows[j]["ReceivNum"] = str2 + "/张每人";
                    }
                }
            }
            this.grdCoupondsList.DataSource = data;
            this.grdCoupondsList.DataBind();
            this.pager1.TotalRecords = couponInfos.TotalRecords;
        }
Example #11
0
 public DbQueryResult GetCouponsTable(HttpContext context)
 {
     return(CouponHelper.GetCouponInfos(this.GetCouponsSearch(context)));
 }
Example #12
0
 public void LoadCoupon()
 {
     if (!string.IsNullOrEmpty(this.context.Request["PageSize"]) && !string.IsNullOrEmpty(this.context.Request["CurrentPage"]))
     {
         int pageSize  = int.Parse(this.context.Request["PageSize"]);
         int pageIndex = int.Parse(this.context.Request["CurrentPage"]);
         int value     = 0;
         int.TryParse(this.context.Request["obtainWay"], out value);
         int        num  = 0;
         MemberInfo user = Users.GetUser(HiContext.Current.UserId);
         if (user != null)
         {
             num = user.UserId;
         }
         CouponsSearch couponsSearch = new CouponsSearch();
         couponsSearch.ObtainWay = value;
         couponsSearch.PageIndex = pageIndex;
         couponsSearch.PageSize  = pageSize;
         couponsSearch.IsValid   = true;
         DbQueryResult couponInfos = CouponHelper.GetCouponInfos(couponsSearch, "");
         DataTable     data        = couponInfos.Data;
         string        str         = "{\"totalCount\":\"" + couponInfos.TotalRecords + "\",\"data\":[";
         string        text        = "";
         for (int i = 0; i < data.Rows.Count; i++)
         {
             if (text != "")
             {
                 text += ",";
             }
             object[] obj = new object[24]
             {
                 text,
                 "{\"CouponId\":\"",
                 data.Rows[i]["CouponId"],
                 "\",\"CouponName\":\"",
                 data.Rows[i]["CouponName"],
                 "\",\"Price\":\"",
                 data.Rows[i]["Price"],
                 "\",\"SendCount\":\"",
                 data.Rows[i]["SendCount"],
                 "\",\"UserLimitCount\":\"",
                 data.Rows[i]["UserLimitCount"],
                 "\",\"OrderUseLimit\":\"",
                 data.Rows[i]["OrderUseLimit"],
                 "\",\"StartTime\":\"",
                 null,
                 null,
                 null,
                 null,
                 null,
                 null,
                 null,
                 null,
                 null,
                 null
             };
             DateTime dateTime = DateTime.Parse(data.Rows[i]["StartTime"].ToString());
             obj[14]  = dateTime.ToString("yyyy.MM.dd");
             obj[15]  = "\",\"ClosingTime\":\"";
             dateTime = DateTime.Parse(data.Rows[i]["ClosingTime"].ToString());
             obj[16]  = dateTime.ToString("yyyy.MM.dd");
             obj[17]  = "\",\"CanUseProducts\":\"";
             obj[18]  = data.Rows[i]["CanUseProducts"];
             obj[19]  = "\",\"ObtainWay\":\"";
             obj[20]  = data.Rows[i]["ObtainWay"];
             obj[21]  = "\",\"NeedPoint\":\"";
             obj[22]  = data.Rows[i]["NeedPoint"];
             obj[23]  = "\"}";
             text     = string.Concat(obj);
         }
         str += text;
         str += "]}";
         this.context.Response.Write(str);
     }
 }
Example #13
0
        private void BindData()
        {
            decimal?minValue = null;
            decimal?maxValue = null;

            System.DateTime?beginDate = null;
            System.DateTime?endDate   = null;
            string          text      = this.txt_name.Text;
            decimal         value     = 0m;

            System.DateTime arg_45_0 = System.DateTime.Now;
            if (this.bDecimal(this.txt_minVal.Text, ref value))
            {
                minValue = new decimal?(value);
            }
            if (this.bDecimal(this.txt_maxVal.Text, ref value))
            {
                maxValue = new decimal?(value);
            }
            beginDate = this.calendarStartDate.SelectedDate;
            endDate   = this.calendarEndDate.SelectedDate;
            string        selectedValue = this.ddlCouponType.SelectedValue;
            DbQueryResult couponInfos   = CouponHelper.GetCouponInfos(new CouponsSearch
            {
                CouponName = text,
                minValue   = minValue,
                maxValue   = maxValue,
                beginDate  = beginDate,
                endDate    = endDate,
                IsCount    = true,
                PageIndex  = this.pager1.PageIndex,
                PageSize   = this.pager1.PageSize,
                SortBy     = "CouponId",
                SortOrder  = SortAction.Desc,
                Finished   = new bool?(CouponsList.bFininshed),
                SearchType = new int?(string.IsNullOrEmpty(selectedValue) ? 0 : int.Parse(selectedValue))
            });

            if (couponInfos != null)
            {
                System.Data.DataTable dataTable = (System.Data.DataTable)couponInfos.Data;
                if (dataTable.Rows.Count > 0)
                {
                    dataTable.Columns.Add("useConditon");
                    dataTable.Columns.Add("ReceivNum");
                    dataTable.Columns.Add("expire");
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        decimal d = decimal.Parse(dataTable.Rows[i]["ConditionValue"].ToString());
                        if (d == 0m)
                        {
                            dataTable.Rows[i]["useConditon"] = "不限制";
                        }
                        else
                        {
                            dataTable.Rows[i]["useConditon"] = "满" + d.ToString("F2") + "可使用";
                        }
                        string text2 = dataTable.Rows[i]["maxReceivNum"].ToString();
                        if (text2 == "0")
                        {
                            dataTable.Rows[i]["ReceivNum"] = "无限制";
                        }
                        else
                        {
                            dataTable.Rows[i]["ReceivNum"] = text2 + "/张每人";
                        }
                        dataTable.Rows[i]["expire"] = (System.DateTime.Parse(dataTable.Rows[i]["EndDate"].ToString()) <= System.DateTime.Now);
                    }
                }
                this.grdCoupondsList.DataSource = dataTable;
                this.grdCoupondsList.DataBind();
            }
            this.pager1.TotalRecords = couponInfos.TotalRecords;
        }