Esempio n. 1
0
 public static CouponInfo PopulateCoupon(IDataReader reader)
 {
     if (null == reader)
     {
         return null;
     }
     CouponInfo info = new CouponInfo {
         CouponId = (int) reader["CouponId"],
         Name = (string) reader["Name"],
         StartTime = (DateTime) reader["StartTime"],
         ClosingTime = (DateTime) reader["ClosingTime"]
     };
     if (reader["Description"] != DBNull.Value)
     {
         info.Description = (string) reader["Description"];
     }
     if (reader["Amount"] != DBNull.Value)
     {
         info.Amount = new decimal?((decimal) reader["Amount"]);
     }
     info.DiscountValue = (decimal) reader["DiscountValue"];
     info.SentCount = (int) reader["SentCount"];
     info.UsedCount = (int) reader["UsedCount"];
     info.NeedPoint = (int) reader["NeedPoint"];
     return info;
 }
Esempio n. 2
0
 public CouponActionStatus CreateCoupon(CouponInfo coupon, int count, out string lotNumber)
 {
     CouponActionStatus unknowError = CouponActionStatus.UnknowError;
     lotNumber = string.Empty;
     if (count <= 0)
     {
         lotNumber = string.Empty;
         if (null == coupon)
         {
             return CouponActionStatus.UnknowError;
         }
         DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT CouponId  FROM Hishop_Coupons WHERE Name=@Name");
         this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, coupon.Name);
         if (Convert.ToInt32(this.database.ExecuteScalar(sqlStringCommand)) >= 1)
         {
             return CouponActionStatus.DuplicateName;
         }
         sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO Hishop_Coupons ([Name],  ClosingTime,StartTime, Description, Amount, DiscountValue,SentCount,UsedCount,NeedPoint) VALUES(@Name, @ClosingTime,@StartTime, @Description, @Amount, @DiscountValue,0,0,@NeedPoint); SELECT @@IDENTITY");
         this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, coupon.Name);
         this.database.AddInParameter(sqlStringCommand, "ClosingTime", DbType.DateTime, coupon.ClosingTime);
         this.database.AddInParameter(sqlStringCommand, "StartTime", DbType.DateTime, coupon.StartTime);
         this.database.AddInParameter(sqlStringCommand, "Description", DbType.String, coupon.Description);
         this.database.AddInParameter(sqlStringCommand, "DiscountValue", DbType.Currency, coupon.DiscountValue);
         this.database.AddInParameter(sqlStringCommand, "NeedPoint", DbType.Int32, coupon.NeedPoint);
         if (coupon.Amount.HasValue)
         {
             this.database.AddInParameter(sqlStringCommand, "Amount", DbType.Currency, coupon.Amount.Value);
         }
         else
         {
             this.database.AddInParameter(sqlStringCommand, "Amount", DbType.Currency, DBNull.Value);
         }
         object obj2 = this.database.ExecuteScalar(sqlStringCommand);
         if ((obj2 != null) && (obj2 != DBNull.Value))
         {
             unknowError = CouponActionStatus.CreateClaimCodeSuccess;
         }
         return unknowError;
     }
     unknowError = CouponActionStatus.CreateClaimCodeSuccess;
     DbCommand storedProcCommand = this.database.GetStoredProcCommand("cp_ClaimCode_Create");
     this.database.AddInParameter(storedProcCommand, "CouponId", DbType.Int32, coupon.CouponId);
     this.database.AddInParameter(storedProcCommand, "row", DbType.Int32, count);
     this.database.AddInParameter(storedProcCommand, "UserId", DbType.Int32, null);
     this.database.AddInParameter(storedProcCommand, "UserName", DbType.String, null);
     this.database.AddInParameter(storedProcCommand, "EmailAddress", DbType.String, null);
     this.database.AddOutParameter(storedProcCommand, "ReturnLotNumber", DbType.String, 300);
     try
     {
         this.database.ExecuteNonQuery(storedProcCommand);
         lotNumber = (string) this.database.GetParameterValue(storedProcCommand, "ReturnLotNumber");
     }
     catch
     {
         unknowError = CouponActionStatus.CreateClaimCodeError;
     }
     return unknowError;
 }
Esempio n. 3
0
 private void btnEditCoupons_Click(object sender, EventArgs e)
 {
     decimal num;
     decimal? nullable;
     int num2;
     if (ValidateValues(out nullable, out num, out num2))
     {
         if (!calendarEndDate.SelectedDate.HasValue)
         {
             ShowMsg("请选择结束日期!", false);
         }
         else
         {
             string msg = string.Empty;
             CouponInfo info2 = new CouponInfo();
             info2.CouponId = couponId;
             info2.Name = txtCouponName.Text;
             info2.ClosingTime = calendarEndDate.SelectedDate.Value;
             info2.Amount = nullable;
             info2.DiscountValue = num;
             info2.NeedPoint = num2;
             CouponInfo target = info2;
             ValidationResults results = Hishop.Components.Validation.Validation.Validate<CouponInfo>(target, new string[] { "ValCoupon" });
             if (!results.IsValid)
             {
                 foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
                 {
                     msg = msg + Formatter.FormatErrorMessage(result.Message);
                     ShowMsg(msg, false);
                     return;
                 }
             }
             CouponActionStatus status = CouponHelper.UpdateCoupon(target);
             if (status == CouponActionStatus.Success)
             {
                 RestCoupon();
                 ShowMsg("成功修改了优惠券信息", true);
             }
             else if (status == CouponActionStatus.DuplicateName)
             {
                 ShowMsg("修改优惠券信息错误,已经具有此优惠券名称", false);
             }
             else
             {
                 ShowMsg("未知错误", false);
                 RestCoupon();
             }
         }
     }
 }
Esempio n. 4
0
 private void btnAddCoupons_Click(object sender, EventArgs e)
 {
     decimal num;
     decimal? nullable;
     int num2;
     int num3;
     string msg = string.Empty;
     if (ValidateValues(out nullable, out num, out num2, out num3))
     {
         if (!calendarEndDate.SelectedDate.HasValue)
         {
             ShowMsg("请选择结束日期!", false);
         }
         else
         {
             CouponInfo target = new CouponInfo();
             target.Name = txtCouponName.Text;
             target.ClosingTime = calendarEndDate.SelectedDate.Value;
             target.Amount = nullable;
             target.DiscountValue = num;
             target.NeedPoint = num3;
             ValidationResults results = Hishop.Components.Validation.Validation.Validate<CouponInfo>(target, new string[] { "ValCoupon" });
             if (!results.IsValid)
             {
                 foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
                 {
                     msg = msg + Formatter.FormatErrorMessage(result.Message);
                     ShowMsg(msg, false);
                     return;
                 }
             }
             string lotNumber = string.Empty;
             CouponActionStatus status = CouponHelper.CreateCoupon(target, num2, out lotNumber);
             if (status == CouponActionStatus.UnknowError)
             {
                 ShowMsg("未知错误", false);
             }
             else
             {
                 CouponActionStatus status2 = status;
                 if (status2 == CouponActionStatus.DuplicateName)
                 {
                     ShowMsg("已经存在相同的优惠券名称", false);
                 }
                 else if (status2 == CouponActionStatus.CreateClaimCodeError)
                 {
                     ShowMsg("生成优惠券号码错误", false);
                 }
                 else
                 {
                     if ((status == CouponActionStatus.CreateClaimCodeSuccess) && !string.IsNullOrEmpty(lotNumber))
                     {
                         IList<CouponItemInfo> couponItemInfos = CouponHelper.GetCouponItemInfos(lotNumber);
                         StringWriter writer = new StringWriter();
                         writer.WriteLine("优惠券批次号\t优惠券号码\t优惠券金额\t过期时间");
                         foreach (CouponItemInfo info2 in couponItemInfos)
                         {
                             string str3 = string.Concat(new object[] { lotNumber, "\t", info2.ClaimCode, "\t", target.DiscountValue, "\t", target.ClosingTime });
                             writer.WriteLine(str3);
                         }
                         writer.Close();
                         Page.Response.AddHeader("Content-Disposition", "attachment; filename=CouponsInfo_" + DateTime.Now + ".xls");
                         Page.Response.ContentType = "application/ms-excel";
                         Page.Response.ContentEncoding = Encoding.GetEncoding("GB2312");
                         Page.Response.Write(writer);
                         Page.Response.End();
                     }
                     ShowMsg("添加优惠卷成功", true);
                     RestCoupon();
                 }
             }
         }
     }
 }
Esempio n. 5
0
        private void btnAddCoupons_Click(object sender, EventArgs e)
        {
            decimal num;
            decimal? nullable;
            int num2;
            string msg = string.Empty;
            if (this.ValidateValues(out nullable, out num, out num2))
            {
                if (!this.calendarStartDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择开始日期!", false);
                }
                else if (!this.calendarEndDate.SelectedDate.HasValue)
                {
                    this.ShowMsg("请选择结束日期!", false);
                }
                else if (this.calendarStartDate.SelectedDate.Value.CompareTo(this.calendarEndDate.SelectedDate.Value) >= 0)
                {
                    this.ShowMsg("开始日期不能晚于结束日期!", false);
                }
                else
                {
                    CouponInfo target = new CouponInfo {
                        Name = this.txtCouponName.Text,
                        ClosingTime = this.calendarEndDate.SelectedDate.Value,
                        StartTime = this.calendarStartDate.SelectedDate.Value,
                        Amount = nullable,
                        DiscountValue = num,
                        NeedPoint = num2
                    };
                    ValidationResults results = Hishop.Components.Validation.Validation.Validate<CouponInfo>(target, new string[] { "ValCoupon" });
                    if (!results.IsValid)
                    {
                        foreach (ValidationResult result in (IEnumerable<ValidationResult>) results)
                        {
                            msg = msg + Formatter.FormatErrorMessage(result.Message);
                            this.ShowMsg(msg, false);
                            return;
                        }
                    }
                    string lotNumber = string.Empty;
                    CouponActionStatus status = CouponHelper.CreateCoupon(target, 0, out lotNumber);
                    if (status != CouponActionStatus.UnknowError)
                    {
                        switch (status)
                        {
                            case CouponActionStatus.DuplicateName:
                                this.ShowMsg("已经存在相同的优惠券名称", false);
                                return;

                            case CouponActionStatus.CreateClaimCodeError:
                                this.ShowMsg("生成优惠券号码错误", false);
                                return;
                        }
                        this.ShowMsg("添加优惠券成功", true);
                        this.RestCoupon();
                    }
                    else
                    {
                        this.ShowMsg("未知错误", false);
                    }
                }
            }
        }
Esempio n. 6
0
 public static CouponActionStatus UpdateCoupon(CouponInfo coupon)
 {
     Globals.EntityCoding(coupon, true);
     return new CouponDao().UpdateCoupon(coupon);
 }
Esempio n. 7
0
 public static CouponActionStatus CreateCoupon(CouponInfo coupon, int count, out string lotNumber)
 {
     Globals.EntityCoding(coupon, true);
     return new CouponDao().CreateCoupon(coupon, count, out lotNumber);
 }
Esempio n. 8
0
 public static CouponActionStatus UpdateCoupon(CouponInfo coupon)
 {
     Globals.EntityCoding(coupon, true);
     return PromotionsProvider.Instance().UpdateCoupon(coupon);
 }
Esempio n. 9
0
 public static CouponActionStatus CreateCoupon(CouponInfo coupon, int count, out string lotNumber)
 {
     Globals.EntityCoding(coupon, true);
     return PromotionsProvider.Instance().CreateCoupon(coupon, count, out lotNumber);
 }
Esempio n. 10
0
 public abstract CouponActionStatus CreateCoupon(CouponInfo coupon, int count, out string lotNumber);
Esempio n. 11
0
 public abstract CouponActionStatus UpdateCoupon(CouponInfo coupon);
Esempio n. 12
0
 public override CouponActionStatus UpdateCoupon(CouponInfo coupon)
 {
     if (null != coupon)
     {
         DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT CouponId  FROM distro_Coupons WHERE Name=@Name AND CouponId<>@CouponId AND DistributorUserId=@DistributorUserId");
         database.AddInParameter(sqlStringCommand, "Name", DbType.String, coupon.Name);
         database.AddInParameter(sqlStringCommand, "CouponId", DbType.Int32, coupon.CouponId);
         database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
         if (Convert.ToInt32(database.ExecuteScalar(sqlStringCommand)) >= 1)
         {
             return CouponActionStatus.DuplicateName;
         }
         sqlStringCommand = database.GetSqlStringCommand("UPDATE distro_Coupons SET [Name]=@Name, ClosingTime=@ClosingTime, Description=@Description, Amount=@Amount, DiscountValue=@DiscountValue, NeedPoint = @NeedPoint WHERE CouponId=@CouponId");
         database.AddInParameter(sqlStringCommand, "CouponId", DbType.String, coupon.CouponId);
         database.AddInParameter(sqlStringCommand, "Name", DbType.String, coupon.Name);
         database.AddInParameter(sqlStringCommand, "ClosingTime", DbType.DateTime, coupon.ClosingTime);
         database.AddInParameter(sqlStringCommand, "Description", DbType.String, coupon.Description);
         database.AddInParameter(sqlStringCommand, "DiscountValue", DbType.Currency, coupon.DiscountValue);
         database.AddInParameter(sqlStringCommand, "NeedPoint", DbType.Int32, coupon.NeedPoint);
         if (coupon.Amount.HasValue)
         {
             database.AddInParameter(sqlStringCommand, "Amount", DbType.Currency, coupon.Amount.Value);
         }
         else
         {
             database.AddInParameter(sqlStringCommand, "Amount", DbType.Currency, DBNull.Value);
         }
         if (database.ExecuteNonQuery(sqlStringCommand) == 1)
         {
             return CouponActionStatus.Success;
         }
     }
     return CouponActionStatus.UnknowError;
 }
Esempio n. 13
0
 public override CouponActionStatus CreateCoupon(CouponInfo coupon, int count, out string lotNumber)
 {
     CouponActionStatus unknowError = CouponActionStatus.UnknowError;
     lotNumber = string.Empty;
     if (null == coupon)
     {
         return CouponActionStatus.UnknowError;
     }
     DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT CouponId  FROM distro_Coupons WHERE Name=@Name AND DistributorUserId=@DistributorUserId");
     database.AddInParameter(sqlStringCommand, "Name", DbType.String, coupon.Name);
     database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
     if (Convert.ToInt32(database.ExecuteScalar(sqlStringCommand)) >= 1)
     {
         return CouponActionStatus.DuplicateName;
     }
     sqlStringCommand = database.GetSqlStringCommand("INSERT INTO distro_Coupons ([Name],  ClosingTime, Description, Amount, DiscountValue,DistributorUserId,SentCount,UsedCount,NeedPoint) VALUES(@Name, @ClosingTime, @Description, @Amount, @DiscountValue,@DistributorUserId,0,0,@NeedPoint); SELECT @@IDENTITY");
     database.AddInParameter(sqlStringCommand, "Name", DbType.String, coupon.Name);
     database.AddInParameter(sqlStringCommand, "ClosingTime", DbType.DateTime, coupon.ClosingTime);
     database.AddInParameter(sqlStringCommand, "Description", DbType.String, coupon.Description);
     database.AddInParameter(sqlStringCommand, "DiscountValue", DbType.Currency, coupon.DiscountValue);
     database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
     database.AddInParameter(sqlStringCommand, "NeedPoint", DbType.Int32, coupon.NeedPoint);
     if (coupon.Amount.HasValue)
     {
         database.AddInParameter(sqlStringCommand, "Amount", DbType.Currency, coupon.Amount.Value);
     }
     else
     {
         database.AddInParameter(sqlStringCommand, "Amount", DbType.Currency, DBNull.Value);
     }
     object obj2 = database.ExecuteScalar(sqlStringCommand);
     if ((obj2 != null) && (obj2 != DBNull.Value))
     {
         unknowError = CouponActionStatus.CreateClaimCodeSuccess;
         int result = 0;
         int.TryParse(obj2.ToString(), out result);
         if ((result > 0) && (count > 0))
         {
             DbCommand storedProcCommand = database.GetStoredProcCommand("ss_ClaimCode_Create");
             database.AddInParameter(storedProcCommand, "CouponId", DbType.Int32, result);
             database.AddInParameter(storedProcCommand, "row", DbType.Int32, count);
             database.AddInParameter(storedProcCommand, "UserId", DbType.Int32, null);
             database.AddInParameter(storedProcCommand, "EmailAddress", DbType.String, null);
             database.AddOutParameter(storedProcCommand, "ReturnLotNumber", DbType.String, 300);
             try
             {
                 database.ExecuteNonQuery(storedProcCommand);
                 lotNumber = (string)database.GetParameterValue(storedProcCommand, "ReturnLotNumber");
                 storedProcCommand = database.GetSqlStringCommand("UPDATE distro_Coupons SET SentCount=@SentCount WHERE CouponId=@CouponId AND DistributorUserId=@DistributorUserId");
                 database.AddInParameter(storedProcCommand, "CouponId", DbType.Int32, result);
                 database.AddInParameter(storedProcCommand, "SentCount", DbType.Int32, count);
                 database.AddInParameter(storedProcCommand, "DistributorUserId", DbType.Int32, HiContext.Current.User.UserId);
                 database.ExecuteNonQuery(storedProcCommand);
             }
             catch
             {
                 unknowError = CouponActionStatus.CreateClaimCodeError;
             }
         }
     }
     return unknowError;
 }