示例#1
0
 public Maticsoft.Model.Shop.Coupon.CouponRule DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Shop.Coupon.CouponRule rule = new Maticsoft.Model.Shop.Coupon.CouponRule();
     if (row != null)
     {
         if ((row["RuleId"] != null) && (row["RuleId"].ToString() != ""))
         {
             rule.RuleId = int.Parse(row["RuleId"].ToString());
         }
         if ((row["CategoryId"] != null) && (row["CategoryId"].ToString() != ""))
         {
             rule.CategoryId = int.Parse(row["CategoryId"].ToString());
         }
         if ((row["ClassId"] != null) && (row["ClassId"].ToString() != ""))
         {
             rule.ClassId = int.Parse(row["ClassId"].ToString());
         }
         if ((row["SupplierId"] != null) && (row["SupplierId"].ToString() != ""))
         {
             rule.SupplierId = int.Parse(row["SupplierId"].ToString());
         }
         if (row["Name"] != null)
         {
             rule.Name = row["Name"].ToString();
         }
         if (row["PreName"] != null)
         {
             rule.PreName = row["PreName"].ToString();
         }
         if (row["ImageUrl"] != null)
         {
             rule.ImageUrl = row["ImageUrl"].ToString();
         }
         if ((row["CouponPrice"] != null) && (row["CouponPrice"].ToString() != ""))
         {
             rule.CouponPrice = decimal.Parse(row["CouponPrice"].ToString());
         }
         if ((row["LimitPrice"] != null) && (row["LimitPrice"].ToString() != ""))
         {
             rule.LimitPrice = decimal.Parse(row["LimitPrice"].ToString());
         }
         if (row["CouponDesc"] != null)
         {
             rule.CouponDesc = row["CouponDesc"].ToString();
         }
         if ((row["SendCount"] != null) && (row["SendCount"].ToString() != ""))
         {
             rule.SendCount = int.Parse(row["SendCount"].ToString());
         }
         if ((row["NeedPoint"] != null) && (row["NeedPoint"].ToString() != ""))
         {
             rule.NeedPoint = int.Parse(row["NeedPoint"].ToString());
         }
         if ((row["IsPwd"] != null) && (row["IsPwd"].ToString() != ""))
         {
             rule.IsPwd = int.Parse(row["IsPwd"].ToString());
         }
         if ((row["IsReuse"] != null) && (row["IsReuse"].ToString() != ""))
         {
             rule.IsReuse = int.Parse(row["IsReuse"].ToString());
         }
         if ((row["Status"] != null) && (row["Status"].ToString() != ""))
         {
             rule.Status = int.Parse(row["Status"].ToString());
         }
         if ((row["Recommend"] != null) && (row["Recommend"].ToString() != ""))
         {
             rule.Recommend = int.Parse(row["Recommend"].ToString());
         }
         if ((row["StartDate"] != null) && (row["StartDate"].ToString() != ""))
         {
             rule.StartDate = DateTime.Parse(row["StartDate"].ToString());
         }
         if ((row["EndDate"] != null) && (row["EndDate"].ToString() != ""))
         {
             rule.EndDate = DateTime.Parse(row["EndDate"].ToString());
         }
         if ((row["CreateDate"] != null) && (row["CreateDate"].ToString() != ""))
         {
             rule.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
         }
         if ((row["CreateUserId"] != null) && (row["CreateUserId"].ToString() != ""))
         {
             rule.CreateUserId = int.Parse(row["CreateUserId"].ToString());
         }
     }
     return rule;
 }
示例#2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Maticsoft.Model.Shop.Coupon.CouponRule model = new Maticsoft.Model.Shop.Coupon.CouponRule();
     string text = this.txtName.Text;
     if (string.IsNullOrWhiteSpace(text))
     {
         MessageBox.ShowFailTip(this, "请填写优惠券名称");
     }
     else
     {
         decimal num = Globals.SafeDecimal(this.txtLimitPrice.Text, (decimal) -1M);
         if (num == -1M)
         {
             MessageBox.ShowFailTip(this, "请填写最低消费金额");
         }
         else
         {
             decimal num2 = Globals.SafeDecimal(this.txtPrice.Text, (decimal) -1M);
             if (num2 == -1M)
             {
                 MessageBox.ShowFailTip(this, "请填写消费券面值");
             }
             else if (string.IsNullOrWhiteSpace(this.txtStartDate.Text) || string.IsNullOrWhiteSpace(this.txtEndDate.Text))
             {
                 MessageBox.ShowFailTip(this, "请选择优惠券使用时间");
             }
             else
             {
                 int num3 = Globals.SafeInt(this.txtSendCount.Text, 0);
                 if (num3 == 0)
                 {
                     MessageBox.ShowFailTip(this, "请填写生成数量");
                 }
                 else
                 {
                     model.Name = text;
                     model.NeedPoint = Globals.SafeInt(this.txtPoint.Text, 0);
                     model.IsPwd = this.chkIsPwd.Checked ? 1 : 0;
                     model.IsReuse = this.chkIsReuse.Checked ? 1 : 0;
                     model.LimitPrice = num;
                     model.PreName = this.txtPreName.Text;
                     model.SendCount = num3;
                     model.StartDate = Globals.SafeDateTime(this.txtStartDate.Text, DateTime.Now);
                     model.Status = this.chkStatus.Checked ? 1 : 0;
                     model.SupplierId = Globals.SafeInt(this.ddlSupplier.SelectedValue, 0);
                     model.CategoryId = Globals.SafeInt(this.ddlCateList.SelectedValue, 0);
                     model.ClassId = Globals.SafeInt(this.ddlClass.SelectedValue, 0);
                     model.CouponPrice = num2;
                     model.CreateDate = DateTime.Now;
                     model.CreateUserId = base.CurrentUser.UserID;
                     model.EndDate = Globals.SafeDateTime(this.txtEndDate.Text, DateTime.MaxValue);
                     int cpLength = Globals.SafeInt(this.ddlLength.SelectedValue, 0);
                     int pwdLegth = Globals.SafeInt(this.ddlPwd.SelectedValue, 0);
                     if (this.ruleBll.AddEx(model, cpLength, pwdLegth))
                     {
                         MessageBox.ShowSuccessTip(this, "生成优惠券成功", "CouponList.aspx");
                     }
                     else
                     {
                         MessageBox.ShowFailTip(this, "生成优惠券失败");
                     }
                 }
             }
         }
     }
 }