Пример #1
0
        public string SavePromotionCouponInfo(PromotionCoupon oBackCoupon, FormCollection formCollection)
        {
            int nCouponCount = Int32.Parse(formCollection["CouponCount"]);
            //根据需要的卡的数量来生成相应的卡号
            for (int i = 0; i < nCouponCount; i++)
            {
                string couponCode = RndStr(nCodeLenth);
                //递归取得不重复的卡号
                couponCode = GetNewCouponCode(couponCode);
                PromotionCoupon oNewPromotionCoupon = new PromotionCoupon();
                oNewPromotionCoupon.PromID = globlePromotionGid;
                oNewPromotionCoupon.Code = couponCode;
                oNewPromotionCoupon.Passcode = RndStr(nPasswordLenth);
                oNewPromotionCoupon.Cstatus = oBackCoupon.Cstatus;
                oNewPromotionCoupon.aCurrency = oBackCoupon.aCurrency;
                oNewPromotionCoupon.Amount = oBackCoupon.Amount;
                oNewPromotionCoupon.MinCharge = oBackCoupon.MinCharge;
                oNewPromotionCoupon.Cashier = oBackCoupon.Cashier;
                oNewPromotionCoupon.OnceUse = oBackCoupon.OnceUse;
                if (!formCollection["StartTime"].Equals(""))
                {
                    oNewPromotionCoupon.StartTime = DateTimeOffset.Parse(formCollection["StartTime"]);
                }
                if (!formCollection["EndTime"].Equals(""))
                {
                    oNewPromotionCoupon.EndTime = DateTimeOffset.Parse(formCollection["EndTime"]);
                }
                oNewPromotionCoupon.Remark = oBackCoupon.Remark;
                dbEntity.PromotionCoupons.Add(oNewPromotionCoupon);
                dbEntity.SaveChanges();
            }

            return "success";
        }
Пример #2
0
 /// <summary>
 /// 批量添加促销券的页面
 /// </summary>
 /// <returns></returns>
 public ActionResult PromotionCouponAdd()
 {
     PromotionCoupon oNewPromotionCoupon = new PromotionCoupon();
     List<SelectListItem> oCstatusList = new List<SelectListItem>();
     oCstatusList = GetSelectList(oNewPromotionCoupon.CouponStatusList);
     ViewBag.oCstatusList = oCstatusList;
     List<SelectListItem> oCurrencyList = new List<SelectListItem>();
     List<MemberOrgCulture> listOrgCurrency = dbEntity.MemberOrgCultures.Include("Currency").Where(p => p.OrgID == promotionOrgGid && p.Deleted == false && p.Ctype == 1).ToList();
     for (int i = 0; i < listOrgCurrency.Count; i++)
     {
         SelectListItem item = new SelectListItem { Text = listOrgCurrency.ElementAt(i).Currency.Name.GetResource(CurrentSession.Culture), Value = listOrgCurrency.ElementAt(i).Currency.Gid.ToString() };
         oCurrencyList.Add(item);
     }
     ViewBag.oCurrencyList = oCurrencyList;
     List<SelectListItem> oCashierList = new List<SelectListItem>();
     oCashierList.Add(new SelectListItem { Text = LiveAzure.Resource.Common.Yes, Value = true.ToString() });
     oCashierList.Add(new SelectListItem { Text = LiveAzure.Resource.Common.No, Value = false.ToString() });
     ViewBag.oCashierList = oCashierList;
     List<SelectListItem> oOnceUseList = new List<SelectListItem>();
     oOnceUseList.Add(new SelectListItem { Text = LiveAzure.Resource.Common.Yes, Value = true.ToString() });
     oOnceUseList.Add(new SelectListItem { Text = LiveAzure.Resource.Common.No, Value = false.ToString() });
     ViewBag.oOnceUseList = oOnceUseList;
     return View(oNewPromotionCoupon);
 }