Ejemplo n.º 1
0
 protected void btnSave_OnClick(object sender, EventArgs e)
 {
     Maticsoft.Model.Shop.Sales.SalesRule model = new Maticsoft.Model.Shop.Sales.SalesRule {
         RuleName = this.txtRuleName.Text,
         RuleMode = Globals.SafeInt(this.radMode.SelectedValue, 0),
         RuleUnit = Globals.SafeInt(this.radUnit.SelectedValue, 0),
         Status = Globals.SafeInt(this.radStatus.SelectedValue, 0),
         CreatedDate = DateTime.Now,
         CreatedUserID = base.CurrentUser.UserID
     };
     string str = this.hfItems.Value;
     if (string.IsNullOrWhiteSpace(str))
     {
         MessageBox.ShowFailTip(this, "请填写优惠规则项");
     }
     else
     {
         int num = this.ruleBll.Add(model);
         if (num > 0)
         {
             string[] strArray = str.Split(new char[] { ',' });
             int num2 = Globals.SafeInt(this.radItemType.SelectedValue, 0);
             foreach (string str2 in strArray)
             {
                 Maticsoft.Model.Shop.Sales.SalesItem item = new Maticsoft.Model.Shop.Sales.SalesItem {
                     ItemType = num2,
                     UnitValue = Globals.SafeInt(str2.Split(new char[] { '|' })[0], 0),
                     RateValue = Globals.SafeInt(str2.Split(new char[] { '|' })[1], 0),
                     RuleId = num
                 };
                 this.itemBll.Add(item);
             }
             for (int i = 0; i < this.ChkUserRank.Items.Count; i++)
             {
                 if (this.ChkUserRank.Items[i].Selected)
                 {
                     Maticsoft.Model.Shop.Sales.SalesUserRank rank = new Maticsoft.Model.Shop.Sales.SalesUserRank {
                         RankId = Globals.SafeInt(this.ChkUserRank.Items[i].Value, 0),
                         RuleId = num
                     };
                     this.userRankBll.Add(rank);
                 }
             }
             for (int j = 0; j < this.ChkDealerRank.Items.Count; j++)
             {
                 if (this.ChkDealerRank.Items[j].Selected)
                 {
                     Maticsoft.Model.Shop.Sales.SalesUserRank rank2 = new Maticsoft.Model.Shop.Sales.SalesUserRank {
                         RankId = Globals.SafeInt(this.ChkUserRank.Items[j].Value, 0),
                         RuleId = num
                     };
                     this.userRankBll.Add(rank2);
                 }
             }
             MessageBox.ShowSuccessTipScript(this, "操作成功!", "window.parent.location.reload();");
         }
     }
 }
Ejemplo n.º 2
0
 public Maticsoft.Model.Shop.Sales.SalesRule DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Shop.Sales.SalesRule rule = new Maticsoft.Model.Shop.Sales.SalesRule();
     if (row != null)
     {
         if ((row["RuleId"] != null) && (row["RuleId"].ToString() != ""))
         {
             rule.RuleId = int.Parse(row["RuleId"].ToString());
         }
         if (row["RuleName"] != null)
         {
             rule.RuleName = row["RuleName"].ToString();
         }
         if ((row["RuleMode"] != null) && (row["RuleMode"].ToString() != ""))
         {
             rule.RuleMode = int.Parse(row["RuleMode"].ToString());
         }
         if ((row["RuleUnit"] != null) && (row["RuleUnit"].ToString() != ""))
         {
             rule.RuleUnit = int.Parse(row["RuleUnit"].ToString());
         }
         if ((row["Status"] != null) && (row["Status"].ToString() != ""))
         {
             rule.Status = int.Parse(row["Status"].ToString());
         }
         if ((row["CreatedDate"] != null) && (row["CreatedDate"].ToString() != ""))
         {
             rule.CreatedDate = DateTime.Parse(row["CreatedDate"].ToString());
         }
         if ((row["CreatedUserID"] != null) && (row["CreatedUserID"].ToString() != ""))
         {
             rule.CreatedUserID = int.Parse(row["CreatedUserID"].ToString());
         }
     }
     return rule;
 }