Example #1
0
        public void GetSelectProductType(System.Web.HttpContext context)
        {
            context.Response.ContentType = "application/json";

            StringBuilder stringBuilder = new StringBuilder();

            int couponId;

            if (!int.TryParse(context.Request["couponId"].ToString(), out couponId))
            {
                context.Response.Write("{\"success\":false,\"msg\":\"异常操作\"}");
                return;
            }

            else
            {
                CouponInfo coupon = CouponHelper.GetCoupon(couponId);

                IList <CouponsSendTypeItem> listSendTypeItem = CouponHelper.GetCouponsSendTypeItems(coupon.CouponId);

                IList <int> productTypeIds = new List <int>();
                foreach (CouponsSendTypeItem item in listSendTypeItem)
                {
                    productTypeIds.Add(item.BindId);
                }


                IList <CategoryInfo> categorylist = CatalogHelper.GetCategoryByIds(productTypeIds);

                if (categorylist != null)
                {
                    int i = 0;
                    stringBuilder.Append("[");
                    foreach (CategoryInfo category in categorylist)
                    {
                        stringBuilder.Append("{");
                        stringBuilder.AppendFormat("\"id\":{0},", category.CategoryId);
                        stringBuilder.AppendFormat("\"pId\":{0},", category.ParentCategoryId);
                        stringBuilder.AppendFormat("\"name\":\"{0}\"", category.Name);
                        stringBuilder.Append("}");
                        if (i < categorylist.Count - 1)
                        {
                            stringBuilder.Append(",");
                        }
                        i++;
                    }

                    stringBuilder.Append("]");

                    context.Response.Write(stringBuilder.ToString());
                }
            }
        }
Example #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!int.TryParse(this.Page.Request.QueryString["couponId"], out this.couponId))
            {
                base.GotoResourceNotFound();
                return;
            }
            this.btnAddCoupons.Click += new System.EventHandler(this.btnAddCoupons_Click);

            this.ddcSupplier.SelectedIndexChanged += new System.EventHandler(this.ddcSupplier_SelectedIndexChanged);
            this.ddcBrand.SelectedIndexChanged    += new System.EventHandler(this.ddcBrand_SelectedIndexChanged);

            if (this.couponId > 0)
            {
                btnAddCoupons.Text = "保存";
            }
            if (!IsPostBack)
            {
                BindSupplier();
                BindBrand();
                if (couponId > 0)
                {
                    CouponInfo coupon = CouponHelper.GetCoupon(this.couponId);
                    if (coupon == null)
                    {
                        base.GotoResourceNotFound();
                        return;
                    }
                    if (coupon.SendType != 4 && coupon.ClosingTime.CompareTo(System.DateTime.Now) < 0)
                    {
                        this.ShowMsg("该优惠券已经结束!", false);
                        return;
                    }
                    Globals.EntityCoding(coupon, false);
                    this.txtCouponName.Text = coupon.Name;
                    if (coupon.Amount.HasValue)
                    {
                        this.txtAmount.Text = string.Format("{0:F2}", coupon.Amount);
                    }
                    this.txtDiscountValue.Text          = coupon.DiscountValue.ToString("F2");
                    this.calendarEndDate.SelectedDate   = new System.DateTime?(coupon.ClosingTime);
                    this.calendarStartDate.SelectedDate = new System.DateTime?(coupon.StartTime);
                    this.txtNeedPoint.Text         = coupon.NeedPoint.ToString();
                    this.outBeginDate.SelectedDate = new DateTime?(coupon.OutBeginDate);
                    this.outEndDate.SelectedDate   = new DateTime?(coupon.OutEndDate);
                    this.txtTotalQ.Text            = coupon.TotalQ.ToString();
                    this.txtRemark.Text            = coupon.Remark.ToString();
                    if (coupon.Validity > 0)
                    {
                        this.txtValidity.Text = coupon.Validity.ToString();
                    }

                    IList <CouponsSendTypeItem> listSendTypeItem = CouponHelper.GetCouponsSendTypeItems(coupon.CouponId);
                    switch (coupon.UseType)
                    {
                    case 0: rdoAll.Checked = true; break;

                    case 1: rdoProduct.Checked = true; break;

                    case 2: rdoProductType.Checked = true; break;

                    case 3: rdoBrand.Checked = true; setSelectBrand(listSendTypeItem); break;

                    case 4: rdoSupplier.Checked = true; setSelectSupplier(listSendTypeItem); break;

                    default: break;
                    }

                    switch (coupon.SendType)
                    {
                    case 0: rdoManually.Checked = true; break;

                    case 1: rdoOverMoney.Checked = true; this.txtOverMoney.Text = coupon.SendTypeItem; break;

                    case 2: rdoRegist.Checked = true; break;

                    case 3: rdoLq.Checked = true; break;

                    case 4: rdorefund.Checked = true; break;

                    case 5: rdZC.Checked = true; break;
                    }
                    switch (coupon.Status)
                    {
                    case 0:
                        rdoSDisEnable.Checked = true;
                        break;

                    case 1:
                        this.rdoSEnable.Checked = true;
                        break;
                    }
                }

                else
                {
                    rdoAll.Checked      = true;
                    rdoManually.Checked = true;
                    rdoSEnable.Checked  = true;
                }
            }
        }