コード例 #1
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     decimal num;
     decimal? nullable;
     decimal num2;
     decimal? nullable2;
     if (this.ValidateRegionValues(out num, out nullable, out num2, out nullable2))
     {
         new List<ShippingModeGroupInfo>();
         ShippingModeInfo shippingMode = new ShippingModeInfo {
             Name = Globals.HtmlEncode(this.txtModeName.Text.Trim()),
             Weight = num,
             AddWeight = nullable,
             Price = num2,
             AddPrice = nullable2,
             TemplateId = this.templateId
         };
         foreach (GridViewRow row in this.grdRegion.Rows)
         {
             decimal result = 0M;
             decimal num4 = 0M;
             decimal.TryParse(((TextBox) row.FindControl("txtModeRegionPrice")).Text, out result);
             decimal.TryParse(((TextBox) row.FindControl("txtModeRegionAddPrice")).Text, out num4);
             ShippingModeGroupInfo item = new ShippingModeGroupInfo {
                 Price = result,
                 AddPrice = num4
             };
             TextBox box = (TextBox) this.grdRegion.Rows[row.RowIndex].FindControl("txtRegionvalue_Id");
             if (!string.IsNullOrEmpty(box.Text))
             {
                 foreach (string str in box.Text.Split(new char[] { ',' }))
                 {
                     ShippingRegionInfo info3 = new ShippingRegionInfo {
                         RegionId = Convert.ToInt32(str.Trim())
                     };
                     item.ModeRegions.Add(info3);
                 }
             }
             shippingMode.ModeGroup.Add(item);
         }
         if (SalesHelper.UpdateShippingTemplate(shippingMode))
         {
             this.Page.Response.Redirect("EditShippingTemplate.aspx?TemplateId=" + shippingMode.TemplateId + "&isUpdate=true");
         }
         else
         {
             this.ShowMsg("您添加的地区有重复", false);
         }
     }
 }
コード例 #2
0
ファイル: DataMapper.cs プロジェクト: davinx/himedi
 public static ShippingRegionInfo PopulateShippingRegion(IDataRecord reader)
 {
     if (null == reader)
     {
         return null;
     }
     ShippingRegionInfo info = new ShippingRegionInfo();
     info.TemplateId = (int) reader["TemplateId"];
     info.GroupId = (int) reader["GroupId"];
     info.RegionId = (int) reader["RegionId"];
     return info;
 }
コード例 #3
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            int weight = 0;
            int? addWeight = 0;
            decimal price = 0m;
            decimal? addPrice = 0;

            if (ValidateRegionValues(out weight, out addWeight, out price, out addPrice))
            {
                new List<ShippingModeGroupInfo>();

                ShippingModeInfo shippingModeInfo = new ShippingModeInfo();

                shippingModeInfo.Name = Globals.HtmlEncode(txtModeName.Text.Trim());
                shippingModeInfo.Weight = weight;
                shippingModeInfo.AddWeight = addWeight;
                shippingModeInfo.Price = price;
                shippingModeInfo.AddPrice = addPrice;

                ShippingModeGroupInfo shippingModeGroupInfo = null;

                ShippingRegionInfo shippingRegionInfo = null;

                foreach (GridViewRow row in grdRegion.Rows)
                {
                    shippingModeGroupInfo = new ShippingModeGroupInfo();

                    shippingModeGroupInfo.Price = decimal.Parse(((TextBox)row.FindControl("txtModeRegionPrice")).Text);
                    shippingModeGroupInfo.AddPrice = decimal.Parse(((TextBox)row.FindControl("txtModeRegionAddPrice")).Text);

                    TextBox box = (TextBox)grdRegion.Rows[row.RowIndex].FindControl("txtRegionvalue_Id");

                    foreach (string str in box.Text.Split(new char[] { ',' }))
                    {
                        shippingRegionInfo = new ShippingRegionInfo();
                        shippingRegionInfo.RegionId = Convert.ToInt32(str.Trim());
                        shippingModeGroupInfo.ModeRegions.Add(shippingRegionInfo);
                    }

                    shippingModeInfo.ModeGroup.Add(shippingModeGroupInfo);

                }

                ValidationResults results = Hishop.Components.Validation.Validation.Validate<ShippingModeInfo>(shippingModeInfo, "ValShippingModeInfo");

                string msg = string.Empty;

                if (!results.IsValid)
                {
                    foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
                    {
                        msg = msg + Formatter.FormatErrorMessage(result.Message);
                    }
                    ShowMsg(msg, false);
                }
                else if (SalesHelper.CreateShippingTemplate(shippingModeInfo))
                {
                    ClearControlValue();
                    ShowMsg("成功添加了一个配送方式模板", true);
                }
                else
                {
                    ShowMsg("您添加的地区有重复", false);
                }
            }
        }
コード例 #4
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     int num;
     int? nullable;
     decimal num2;
     decimal? nullable2;
     if (ValidateRegionValues(out num, out nullable, out num2, out nullable2))
     {
         new List<ShippingModeGroupInfo>();
         ShippingModeInfo info6 = new ShippingModeInfo();
         info6.Name = Globals.HtmlEncode(txtModeName.Text.Trim());
         info6.Weight = num;
         info6.AddWeight = nullable;
         info6.Price = num2;
         info6.AddPrice = nullable2;
         info6.TemplateId = templateId;
         ShippingModeInfo target = info6;
         foreach (GridViewRow row in grdRegion.Rows)
         {
             ShippingModeGroupInfo info5 = new ShippingModeGroupInfo();
             info5.Price = decimal.Parse(((TextBox)row.FindControl("txtModeRegionPrice")).Text);
             info5.AddPrice = decimal.Parse(((TextBox)row.FindControl("txtModeRegionAddPrice")).Text);
             ShippingModeGroupInfo item = info5;
             TextBox box = (TextBox)grdRegion.Rows[row.RowIndex].FindControl("txtRegionvalue_Id");
             foreach (string str in box.Text.Split(new char[] { ',' }))
             {
                 ShippingRegionInfo info4 = new ShippingRegionInfo();
                 info4.RegionId = Convert.ToInt32(str.Trim());
                 ShippingRegionInfo info3 = info4;
                 item.ModeRegions.Add(info3);
             }
             target.ModeGroup.Add(item);
         }
         ValidationResults results = Hishop.Components.Validation.Validation.Validate<ShippingModeInfo>(target, new string[] { "ValShippingModeInfo" });
         string msg = string.Empty;
         if (!results.IsValid)
         {
             foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
             {
                 msg = msg + Formatter.FormatErrorMessage(result.Message);
             }
             ShowMsg(msg, false);
         }
         else if (SalesHelper.UpdateShippingTemplate(target))
         {
             Page.Response.Redirect("EditShippingTemplate.aspx?TemplateId=" + target.TemplateId + "&isUpdate=true");
         }
         else
         {
             ShowMsg("您添加的地区有重复", false);
         }
     }
 }
コード例 #5
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     decimal num;
     decimal? nullable;
     decimal num2;
     decimal? nullable2;
     if (this.ValidateRegionValues(out num, out nullable, out num2, out nullable2))
     {
         new List<ShippingModeGroupInfo>();
         ShippingModeInfo shippingMode = new ShippingModeInfo {
             Name = Globals.HtmlEncode(this.txtModeName.Text.Trim()),
             Weight = num,
             AddWeight = nullable,
             Price = num2,
             AddPrice = nullable2
         };
         foreach (GridViewRow row in this.grdRegion.Rows)
         {
             decimal result = 0M;
             decimal num4 = 0M;
             decimal.TryParse(((TextBox) row.FindControl("txtModeRegionPrice")).Text, out result);
             decimal.TryParse(((TextBox) row.FindControl("txtModeRegionAddPrice")).Text, out num4);
             ShippingModeGroupInfo item = new ShippingModeGroupInfo {
                 Price = result,
                 AddPrice = num4
             };
             TextBox box = (TextBox) this.grdRegion.Rows[row.RowIndex].FindControl("txtRegionvalue_Id");
             if (!string.IsNullOrEmpty(box.Text))
             {
                 foreach (string str in box.Text.Split(new char[] { ',' }))
                 {
                     ShippingRegionInfo info3 = new ShippingRegionInfo {
                         RegionId = Convert.ToInt32(str.Trim())
                     };
                     item.ModeRegions.Add(info3);
                 }
             }
             shippingMode.ModeGroup.Add(item);
         }
         if (SalesHelper.CreateShippingTemplate(shippingMode))
         {
             if (!string.IsNullOrEmpty(this.Page.Request.QueryString["source"]) && (this.Page.Request.QueryString["source"] == "add"))
             {
                 this.CloseWindow();
             }
             else
             {
                 this.ClearControlValue();
                 this.ShowMsg("成功添加了一个配送方式模板", true);
             }
         }
         else
         {
             this.ShowMsg("您添加的地区有重复", false);
         }
     }
 }
コード例 #6
0
 public ShippingModeInfo GetShippingMode(int modeId, bool includeDetail)
 {
     ShippingModeInfo info = null;
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_ShippingTypes st INNER JOIN Hishop_ShippingTemplates temp ON st.TemplateId=temp.TemplateId Where ModeId =@ModeId");
     if (includeDetail)
     {
         sqlStringCommand.CommandText = sqlStringCommand.CommandText + " SELECT * FROM Hishop_TemplateRelatedShipping Where ModeId =@ModeId";
         sqlStringCommand.CommandText = sqlStringCommand.CommandText + " SELECT * FROM Hishop_ShippingTypeGroups WHERE TemplateId = (SELECT TemplateId FROM Hishop_ShippingTypes WHERE ModeId =@ModeId )";
     }
     this.database.AddInParameter(sqlStringCommand, "ModeId", DbType.Int32, modeId);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulateShippingMode(reader);
         }
         if (!includeDetail)
         {
             return info;
         }
         reader.NextResult();
         while (reader.Read())
         {
             if (reader["ExpressCompanyName"] != DBNull.Value)
             {
                 info.ExpressCompany.Add((string) reader["ExpressCompanyName"]);
             }
         }
         reader.NextResult();
         while (reader.Read())
         {
             ShippingModeGroupInfo item = new ShippingModeGroupInfo {
                 AddPrice = (decimal) reader["AddPrice"],
                 Price = (decimal) reader["Price"],
                 TemplateId = (int) reader["TemplateId"],
                 GroupId = (int) reader["GroupId"]
             };
             info.ModeGroup.Add(item);
         }
         string commandText = "";
         foreach (ShippingModeGroupInfo info3 in info.ModeGroup)
         {
             commandText = "SELECT RegionId FROM Hishop_ShippingRegions WHERE GroupId = " + info3.GroupId;
             using (IDataReader reader2 = this.database.ExecuteReader(CommandType.Text, commandText))
             {
                 while (reader2.Read())
                 {
                     ShippingRegionInfo info4 = new ShippingRegionInfo {
                         GroupId = info3.GroupId,
                         TemplateId = info3.TemplateId,
                         RegionId = (int) reader2["RegionId"]
                     };
                     info3.ModeRegions.Add(info4);
                 }
             }
         }
     }
     return info;
 }