Esempio n. 1
0
 public static decimal CalcFreight(int regionId, int totalWeight, ShippingModeInfo shippingModeInfo)
 {
     decimal price = 0M;
     int topRegionId = RegionHelper.GetTopRegionId(regionId);
     int num3 = totalWeight;
     int num4 = 1;
     if ((num3 > shippingModeInfo.Weight) && (shippingModeInfo.AddWeight.HasValue && (shippingModeInfo.AddWeight.Value > 0)))
     {
         int num6 = num3 - shippingModeInfo.Weight;
         if ((num6 % shippingModeInfo.AddWeight) == 0)
         {
             num4 = (num3 - shippingModeInfo.Weight) / shippingModeInfo.AddWeight.Value;
         }
         else
         {
             num4 = ((num3 - shippingModeInfo.Weight) / shippingModeInfo.AddWeight.Value) + 1;
         }
     }
     if ((shippingModeInfo.ModeGroup == null) || (shippingModeInfo.ModeGroup.Count == 0))
     {
         if ((num3 > shippingModeInfo.Weight) && shippingModeInfo.AddPrice.HasValue)
         {
             return ((num4 * shippingModeInfo.AddPrice.Value) + shippingModeInfo.Price);
         }
         return shippingModeInfo.Price;
     }
     int? nullable = null;
     foreach (ShippingModeGroupInfo info in shippingModeInfo.ModeGroup)
     {
         foreach (ShippingRegionInfo info2 in info.ModeRegions)
         {
             if (topRegionId == info2.RegionId)
             {
                 nullable = new int?(info2.GroupId);
                 break;
             }
         }
         if (nullable.HasValue)
         {
             if (num3 > shippingModeInfo.Weight)
             {
                 price = (num4 * info.AddPrice) + info.Price;
             }
             else
             {
                 price = info.Price;
             }
             break;
         }
     }
     if (nullable.HasValue)
     {
         return price;
     }
     if ((num3 > shippingModeInfo.Weight) && shippingModeInfo.AddPrice.HasValue)
     {
         return ((num4 * shippingModeInfo.AddPrice.Value) + shippingModeInfo.Price);
     }
     return shippingModeInfo.Price;
 }
Esempio n. 2
0
 public bool CreateShippingMode(ShippingModeInfo shippingMode)
 {
     bool flag;
     DbCommand storedProcCommand = this.database.GetStoredProcCommand("cp_ShippingMode_Create");
     this.database.AddInParameter(storedProcCommand, "Name", DbType.String, shippingMode.Name);
     this.database.AddInParameter(storedProcCommand, "TemplateId", DbType.Int32, shippingMode.TemplateId);
     this.database.AddOutParameter(storedProcCommand, "ModeId", DbType.Int32, 4);
     this.database.AddOutParameter(storedProcCommand, "Status", DbType.Int32, 4);
     this.database.AddInParameter(storedProcCommand, "Description", DbType.String, shippingMode.Description);
     using (DbConnection connection = this.database.CreateConnection())
     {
         connection.Open();
         DbTransaction transaction = connection.BeginTransaction();
         try
         {
             try
             {
                 this.database.ExecuteNonQuery(storedProcCommand, transaction);
                 flag = ((int) this.database.GetParameterValue(storedProcCommand, "Status")) == 0;
                 if (flag)
                 {
                     int parameterValue = (int) this.database.GetParameterValue(storedProcCommand, "ModeId");
                     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(" ");
                     this.database.AddInParameter(sqlStringCommand, "ModeId", DbType.Int32, parameterValue);
                     StringBuilder builder = new StringBuilder();
                     int num2 = 0;
                     builder.Append("DECLARE @ERR INT; Set @ERR =0;");
                     foreach (string str in shippingMode.ExpressCompany)
                     {
                         builder.Append(" INSERT INTO Hishop_TemplateRelatedShipping(ModeId,ExpressCompanyName) VALUES( @ModeId,").Append("@ExpressCompanyName").Append(num2).Append("); SELECT @ERR=@ERR+@@ERROR;");
                         this.database.AddInParameter(sqlStringCommand, "ExpressCompanyName" + num2, DbType.String, str);
                         num2++;
                     }
                     sqlStringCommand.CommandText = builder.Append("SELECT @ERR;").ToString();
                     int num3 = (int) this.database.ExecuteScalar(sqlStringCommand, transaction);
                     if (num3 != 0)
                     {
                         transaction.Rollback();
                         flag = false;
                     }
                 }
                 transaction.Commit();
             }
             catch
             {
                 if (transaction.Connection != null)
                 {
                     transaction.Rollback();
                 }
                 flag = false;
             }
             return flag;
         }
         finally
         {
             connection.Close();
         }
     }
     return flag;
 }
Esempio n. 3
0
 public static bool CreateShippingMode(ShippingModeInfo shippingMode)
 {
     if (null == shippingMode)
     {
         return false;
     }
     return new ShippingModeDao().CreateShippingMode(shippingMode);
 }
Esempio n. 4
0
 private void BindControl(ShippingModeInfo modeItem)
 {
     txtModeName.Text = Globals.HtmlDecode(modeItem.Name);
     fck.Text = modeItem.Description;
     if (modeItem.TemplateId > 0)
     {
         shippingTemplatesDropDownList.SelectedValue = new int?(modeItem.TemplateId);
     }
 }
Esempio n. 5
0
 private void btnUpDate_Click(object sender, EventArgs e)
 {
     ShippingModeInfo info3 = new ShippingModeInfo();
     info3.Name = Globals.HtmlEncode(txtModeName.Text.Trim());
     info3.ModeId = modeId;
     info3.Description = fck.Text.Replace("\r\n", "").Replace("\r", "").Replace("\n", "");
     ShippingModeInfo target = info3;
     if (shippingTemplatesDropDownList.SelectedValue.HasValue)
     {
         target.TemplateId = shippingTemplatesDropDownList.SelectedValue.Value;
     }
     else
     {
         ShowMsg("请选择配送模板", false);
         return;
     }
     foreach (ListItem item in expressCheckBoxList.Items)
     {
         if (item.Selected)
         {
             ExpressCompanyInfo info2 = new ExpressCompanyInfo();
             info2.ExpressCompanyName = item.Text;
             info2.ExpressCompanyAbb = item.Value;
             target.ExpressCompany.Add(info2);
         }
     }
     if (target.ExpressCompany.Count == 0)
     {
         ShowMsg("至少要选择一个配送公司", false);
     }
     else
     {
         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.UpdateShippMode(target))
         {
             Page.Response.Redirect("EditShippingType.aspx?modeId=" + target.ModeId + "&isUpdate=true");
         }
         else
         {
             ShowMsg("更新失败", false);
         }
     }
 }
Esempio n. 6
0
 protected void btnCreate_Click(object sender, EventArgs e)
 {
     ShippingModeInfo target = new ShippingModeInfo();
     target.Name = Globals.HtmlEncode(txtModeName.Text.Trim());
     target.Description = fck.Text.Replace("\r\n", "").Replace("\r", "").Replace("\n", "");
     if (shippingTemplatesDropDownList.SelectedValue.HasValue)
     {
         target.TemplateId = shippingTemplatesDropDownList.SelectedValue.Value;
     }
     else
     {
         ShowMsg("请选择配送模板", false);
         return;
     }
     foreach (ListItem item in expressCheckBoxList.Items)
     {
         if (item.Selected)
         {
             ExpressCompanyInfo expressCompanyInfo = new ExpressCompanyInfo();
             expressCompanyInfo.ExpressCompanyName = item.Text;
             expressCompanyInfo.ExpressCompanyAbb = item.Value;
             target.ExpressCompany.Add(expressCompanyInfo);
         }
     }
     if (target.ExpressCompany.Count == 0)
     {
         ShowMsg("至少要选择一个配送公司", false);
     }
     else
     {
         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.CreateShippingMode(target))
         {
             ClearControlValue();
             ShowMsg("成功添加了一个配送方式", true);
         }
         else
         {
             ShowMsg("添加失败,请确定填写了所有必填项", false);
         }
     }
 }
Esempio n. 7
0
 private void BindControl(ShippingModeInfo modeItem)
 {
     txtModeName.Text = Globals.HtmlDecode(modeItem.Name);
     txtWeight.Text = modeItem.Weight.ToString();
     txtAddWeight.Text = modeItem.AddWeight.ToString();
     if (modeItem.AddPrice.HasValue)
     {
         txtAddPrice.Text = modeItem.AddPrice.Value.ToString("F2");
     }
     txtPrice.Text = modeItem.Price.ToString("F2");
     RegionList.Clear();
     if ((modeItem.ModeGroup != null) && (modeItem.ModeGroup.Count > 0))
     {
         foreach (ShippingModeGroupInfo info in modeItem.ModeGroup)
         {
             Region region2 = new Region();
             region2.RegionPrice = decimal.Parse(info.Price.ToString("F2"));
             region2.RegionAddPrice = decimal.Parse(info.AddPrice.ToString("F2"));
             Region item = region2;
             StringBuilder builder = new StringBuilder();
             StringBuilder builder2 = new StringBuilder();
             foreach (ShippingRegionInfo info2 in info.ModeRegions)
             {
                 builder.Append(info2.RegionId + ",");
                 builder2.Append(RegionHelper.GetFullRegion(info2.RegionId, ",") + ",");
             }
             if (!string.IsNullOrEmpty(builder.ToString()))
             {
                 item.RegionsId = builder.ToString().Substring(0, builder.ToString().Length - 1);
             }
             if (!string.IsNullOrEmpty(builder2.ToString()))
             {
                 item.Regions = builder2.ToString().Substring(0, builder2.ToString().Length - 1);
             }
             RegionList.Add(item);
         }
     }
 }
Esempio n. 8
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     ShippingModeInfo shippingMode = new ShippingModeInfo {
         Name = Globals.HtmlEncode(this.txtModeName.Text.Trim()),
         Description = this.fck.Text.Replace("\r\n", "").Replace("\r", "").Replace("\n", "")
     };
     if (this.shippingTemplatesDropDownList.SelectedValue.HasValue)
     {
         shippingMode.TemplateId = this.shippingTemplatesDropDownList.SelectedValue.Value;
     }
     else
     {
         this.ShowMsg("请选择运费模板", false);
         return;
     }
     foreach (ListItem item in this.expressCheckBoxList.Items)
     {
         if (item.Selected)
         {
             shippingMode.ExpressCompany.Add(item.Value);
         }
     }
     if (shippingMode.ExpressCompany.Count == 0)
     {
         this.ShowMsg("至少要选择一个配送公司", false);
     }
     else if (SalesHelper.CreateShippingMode(shippingMode))
     {
         this.ClearControlValue();
         this.ShowMsg("成功添加了一个配送方式", true);
     }
     else
     {
         this.ShowMsg("添加失败,请确定填写了所有必填项", false);
     }
 }
Esempio n. 9
0
 private void btnUpDate_Click(object sender, EventArgs e)
 {
     ShippingModeInfo shippingMode = new ShippingModeInfo {
         Name = Globals.HtmlEncode(this.txtModeName.Text.Trim()),
         ModeId = this.modeId,
         Description = this.fck.Text.Replace("\r\n", "").Replace("\r", "").Replace("\n", "")
     };
     if (this.shippingTemplatesDropDownList.SelectedValue.HasValue)
     {
         shippingMode.TemplateId = this.shippingTemplatesDropDownList.SelectedValue.Value;
     }
     else
     {
         this.ShowMsg("请选择运费模板", false);
         return;
     }
     foreach (ListItem item in this.expressCheckBoxList.Items)
     {
         if (item.Selected)
         {
             shippingMode.ExpressCompany.Add(item.Value);
         }
     }
     if (shippingMode.ExpressCompany.Count == 0)
     {
         this.ShowMsg("至少要选择一个配送公司", false);
     }
     else if (SalesHelper.UpdateShippMode(shippingMode))
     {
         this.Page.Response.Redirect("EditShippingType.aspx?modeId=" + shippingMode.ModeId + "&isUpdate=true");
     }
     else
     {
         this.ShowMsg("更新失败", false);
     }
 }
Esempio n. 10
0
 public static bool UpdateShippMode(ShippingModeInfo shippingMode)
 {
     if (shippingMode == null)
     {
         return false;
     }
     Globals.EntityCoding(shippingMode, true);
     return new ShippingModeDao().UpdateShippingMode(shippingMode);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     orderIds = Page.Request.QueryString["orderIds"];
     if (string.IsNullOrEmpty(orderIds))
     {
         litmsg.Text = "没有要转换的订单";
     }
     else
     {
         int result = 0;
         int.TryParse(Page.Request.QueryString["shippingModeId"], out result);
         shippingMode = SubsiteSalesHelper.GetShippingMode(result, true);
         if (shippingMode == null)
         {
             litmsg.Text = "没有选择配送方式";
         }
         else
         {
             distributor = HiContext.Current.User as Hidistro.Membership.Context.Distributor;
             cookie = HiContext.Current.Context.Request.Cookies["TopSession_" + HiContext.Current.User.UserId.ToString()];
             string serverUrl = "http://gw.api.taobao.com/router/rest";
             SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
             string appKey = Cryptographer.Decrypt(masterSettings.Topkey);
             string appSecret = Cryptographer.Decrypt(masterSettings.TopSecret);
             client = new DefaultTopClient(serverUrl, appKey, appSecret, "json");
             TradeFullinfoGetRequest request2 = new TradeFullinfoGetRequest();
             request2.Fields = "tid,receiver_name,receiver_state,payment,receiver_district,receiver_city,receiver_address,receiver_phone,receiver_zip,receiver_mobile,post_fee,adjust_fee,total_fee,orders";
             TradeFullinfoGetRequest request = request2;
             string[] strArray = orderIds.Split(new char[] { ',' });
             int count = 0;
             decimal expenditure = 0M;
             foreach (string str4 in strArray)
             {
                 request.Tid = new long?(long.Parse(str4));
                 TradeFullinfoGetResponse response = client.Execute<TradeFullinfoGetResponse>(request, cookie.Value);
                 if (!response.IsError)
                 {
                     try
                     {
                         PurchaseOrderInfo purchaseOrder = GetPurchaseOrder(response.Trade);
                         if ((purchaseOrder != null) && SubsiteSalesHelper.CreatePurchaseOrder(purchaseOrder))
                         {
                             expenditure += purchaseOrder.OrderTotal;
                             count++;
                         }
                     }
                     catch
                     {
                         litmsg.Text = "生成采购单发生错误,请重新尝试";
                     }
                 }
             }
             if (count > 0)
             {
                 SendHttpRequest(count, expenditure);
                 litmsg.Text = string.Format("你选择的{0}淘宝订单已经成功的转换了{1}个采购单", strArray.Length, count);
             }
             else
             {
                 litmsg.Text = "生成采购单失败,可能您选择的淘宝订单在系统中没有找到对应的商品";
             }
         }
     }
 }
Esempio n. 12
0
        public override bool CreateShippingTemplate(ShippingModeInfo shippingMode)
        {
            bool flag = false;
            DbCommand sqlStringCommand = database.GetSqlStringCommand("INSERT INTO Hishop_ShippingTemplates(TemplateName,Weight,AddWeight,Price,AddPrice) VALUES(@TemplateName,@Weight,@AddWeight,@Price,@AddPrice);SELECT @@Identity");
            database.AddInParameter(sqlStringCommand, "TemplateName", DbType.String, shippingMode.Name);
            database.AddInParameter(sqlStringCommand, "Weight", DbType.Int32, shippingMode.Weight);
            if (shippingMode.AddWeight.HasValue)
            {
                database.AddInParameter(sqlStringCommand, "AddWeight", DbType.Int32, shippingMode.AddWeight);
            }
            else
            {
                database.AddInParameter(sqlStringCommand, "AddWeight", DbType.Int32, 0);
            }
            database.AddInParameter(sqlStringCommand, "Price", DbType.Currency, shippingMode.Price);
            if (shippingMode.AddPrice.HasValue)
            {
                database.AddInParameter(sqlStringCommand, "AddPrice", DbType.Currency, shippingMode.AddPrice);
            }
            else
            {
                database.AddInParameter(sqlStringCommand, "AddPrice", DbType.Currency, 0);
            }

            using (DbConnection connection = database.CreateConnection())
            {
                connection.Open();

                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    object obj2 = database.ExecuteScalar(sqlStringCommand, transaction);
                    int result = 0;
                    if ((obj2 != null) && (obj2 != DBNull.Value))
                    {
                        int.TryParse(obj2.ToString(), out result);
                        flag = result > 0;
                    }
                    if (flag)
                    {
                        DbCommand command = database.GetSqlStringCommand(" ");
                        database.AddInParameter(command, "TemplateId", DbType.Int32, result);
                        if ((shippingMode.ModeGroup != null) && (shippingMode.ModeGroup.Count > 0))
                        {
                            StringBuilder builder = new StringBuilder();
                            int num2 = 0;
                            int num3 = 0;
                            builder.Append("DECLARE @ERR INT; Set @ERR =0;");
                            builder.Append(" DECLARE @GroupId Int;");
                            foreach (ShippingModeGroupInfo info in shippingMode.ModeGroup)
                            {
                                builder.Append(" INSERT INTO Hishop_ShippingTypeGroups(TemplateId,Price,AddPrice) VALUES( @TemplateId,").Append("@Price").Append(num2).Append(",@AddPrice").Append(num2).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                database.AddInParameter(command, "Price" + num2, DbType.Currency, info.Price);
                                database.AddInParameter(command, "AddPrice" + num2, DbType.Currency, info.AddPrice);
                                builder.Append("Set @GroupId =@@identity;");
                                foreach (ShippingRegionInfo info2 in info.ModeRegions)
                                {
                                    builder.Append(" INSERT INTO Hishop_ShippingRegions(TemplateId,GroupId,RegionId) VALUES(@TemplateId,@GroupId").Append(",@RegionId").Append(num3).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                    database.AddInParameter(command, "RegionId" + num3, DbType.Int32, info2.RegionId);
                                    num3++;
                                }
                                num2++;
                            }
                            command.CommandText = builder.Append("SELECT @ERR;").ToString();

                            int num4 = (int)database.ExecuteScalar(command, transaction);

                            if (num4 != 0)
                            {
                                transaction.Rollback();
                                flag = false;
                            }

                        }

                    }

                    transaction.Commit();

                }
                catch
                {
                    if (transaction.Connection != null)
                    {
                        transaction.Rollback();
                    }
                    flag = false;
                }
                finally
                {
                    if (null != connection)
                    {
                        connection.Close();
                    }
                }

            }
            return flag;
        }
Esempio n. 13
0
        public override bool UpdateShippingTemplate(ShippingModeInfo shippingMode)
        {
            bool flag = false;

            DbCommand sqlStringCommand = database.GetSqlStringCommand(new StringBuilder("UPDATE Hishop_ShippingTemplates SET TemplateName=@TemplateName,Weight=@Weight,AddWeight=@AddWeight,Price=@Price,AddPrice=@AddPrice WHERE TemplateId=@TemplateId;").ToString());
            database.AddInParameter(sqlStringCommand, "TemplateName", DbType.String, shippingMode.Name);
            database.AddInParameter(sqlStringCommand, "Weight", DbType.Int32, shippingMode.Weight);
            database.AddInParameter(sqlStringCommand, "AddWeight", DbType.Int32, shippingMode.AddWeight);
            database.AddInParameter(sqlStringCommand, "Price", DbType.Currency, shippingMode.Price);
            database.AddInParameter(sqlStringCommand, "AddPrice", DbType.Currency, shippingMode.AddPrice);
            database.AddInParameter(sqlStringCommand, "TemplateId", DbType.Int32, shippingMode.TemplateId);

            using (DbConnection connection = database.CreateConnection())
            {
                connection.Open();

                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    flag = database.ExecuteNonQuery(sqlStringCommand, transaction) > 0;
                    if (flag)
                    {
                        DbCommand command = database.GetSqlStringCommand(" ");
                        database.AddInParameter(command, "TemplateId", DbType.Int32, shippingMode.TemplateId);
                        StringBuilder builder2 = new StringBuilder();
                        int num = 0;
                        int num2 = 0;
                        builder2.Append("DELETE Hishop_ShippingTypeGroups WHERE TemplateId=@TemplateId;");
                        builder2.Append("DELETE Hishop_ShippingRegions WHERE TemplateId=@TemplateId;");
                        builder2.Append("DECLARE @ERR INT; Set @ERR =0;");
                        builder2.Append(" DECLARE @GroupId Int;");
                        if ((shippingMode.ModeGroup != null) && (shippingMode.ModeGroup.Count > 0))
                        {
                            foreach (ShippingModeGroupInfo info in shippingMode.ModeGroup)
                            {
                                builder2.Append(" INSERT INTO Hishop_ShippingTypeGroups(TemplateId,Price,AddPrice) VALUES( @TemplateId,").Append("@Price").Append(num).Append(",@AddPrice").Append(num).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                database.AddInParameter(command, "Price" + num, DbType.Currency, info.Price);
                                database.AddInParameter(command, "AddPrice" + num, DbType.Currency, info.AddPrice);
                                builder2.Append("Set @GroupId =@@identity;");
                                foreach (ShippingRegionInfo info2 in info.ModeRegions)
                                {
                                    builder2.Append(" INSERT INTO Hishop_ShippingRegions(TemplateId,GroupId,RegionId) VALUES(@TemplateId,@GroupId").Append(",@RegionId").Append(num2).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                    database.AddInParameter(command, "RegionId" + num2, DbType.Int32, info2.RegionId);
                                    num2++;
                                }
                                num++;
                            }
                        }
                        command.CommandText = builder2.Append("SELECT @ERR;").ToString();
                        int num3 = (int)database.ExecuteScalar(command, transaction);
                        if (num3 != 0)
                        {
                            transaction.Rollback();
                            flag = false;
                        }
                    }
                    transaction.Commit();
                }
                catch
                {
                    if (transaction.Connection != null)
                    {
                        transaction.Rollback();
                    }
                    flag = false;
                }

                finally
                {
                    connection.Close();
                }
            }
            return flag;
        }
Esempio n. 14
0
        public override bool UpdateShippingMode(ShippingModeInfo shippingMode)
        {
            bool flag;
            DbCommand storedProcCommand = database.GetStoredProcCommand("cp_ShippingMode_Update");
            database.AddInParameter(storedProcCommand, "Name", DbType.String, shippingMode.Name);
            database.AddInParameter(storedProcCommand, "TemplateId", DbType.Int32, shippingMode.TemplateId);
            database.AddInParameter(storedProcCommand, "ModeId", DbType.Int32, shippingMode.ModeId);
            database.AddOutParameter(storedProcCommand, "Status", DbType.Int32, 4);
            database.AddInParameter(storedProcCommand, "Description", DbType.String, shippingMode.Description);
            using (DbConnection connection = database.CreateConnection())
            {
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    database.ExecuteNonQuery(storedProcCommand, transaction);

                    flag = ((int)database.GetParameterValue(storedProcCommand, "Status")) == 0;

                    if (flag)
                    {
                        DbCommand sqlStringCommand = database.GetSqlStringCommand(" ");

                        database.AddInParameter(sqlStringCommand, "ModeId", DbType.Int32, shippingMode.ModeId);

                        if ((shippingMode.ExpressCompany != null) && (shippingMode.ExpressCompany.Count > 0))
                        {
                            StringBuilder builder = new StringBuilder();
                            int num = 0;
                            builder.Append("DECLARE @ERR INT; Set @ERR =0;");

                            foreach (ExpressCompanyInfo info in shippingMode.ExpressCompany)
                            {
                                builder.Append(" INSERT INTO Hishop_TemplateRelatedShipping(ModeId,ExpressCompanyName,ExpressCompanyAbb) VALUES( @ModeId,").Append("@ExpressCompanyName").Append(num).Append(",@ExpressCompanyAbb").Append(num).Append("); SELECT @ERR=@ERR+@@ERROR;");
                                database.AddInParameter(sqlStringCommand, "ExpressCompanyName" + num, DbType.String, info.ExpressCompanyName);
                                database.AddInParameter(sqlStringCommand, "ExpressCompanyAbb" + num, DbType.String, info.ExpressCompanyAbb);
                                num++;
                            }

                            sqlStringCommand.CommandText = builder.Append("SELECT @ERR;").ToString();

                            int num2 = (int)database.ExecuteScalar(sqlStringCommand, transaction);

                            if (num2 != 0)
                            {
                                transaction.Rollback();
                                flag = false;
                            }

                        }
                    }

                    transaction.Commit();

                }
                catch
                {
                    if (transaction.Connection != null)
                    {
                        transaction.Rollback();
                    }
                    flag = false;
                }
                finally
                {
                    if (null != connection)
                    {
                        connection.Close();
                    }
                }

            }
            return flag;
        }
 private void btnMondifyShip_Click(object sender, EventArgs e)
 {
     ShippingModeInfo shippingMode = new ShippingModeInfo();
     shippingMode = SalesHelper.GetShippingMode(ddlshippingMode.SelectedValue.Value, false);
     base.purchaseOrder.ShippingModeId = shippingMode.ModeId;
     base.purchaseOrder.ModeName = shippingMode.Name;
     if (SalesHelper.UpdatePurchaseOrderShippingMode(base.purchaseOrder))
     {
         chargesList.LoadControl();
         shippingAddress.LoadControl();
         ShowMsg("修改配送方式成功", true);
     }
     else
     {
         ShowMsg("修改配送方式失败", false);
     }
 }
Esempio n. 16
0
 public static bool UpdateShippMode(ShippingModeInfo shippingMode)
 {
     if (shippingMode == null)
     {
         return false;
     }
     Globals.EntityCoding(shippingMode, true);
     return SalesProvider.Instance().UpdateShippingMode(shippingMode);
 }
Esempio n. 17
0
 public static bool CreateShippingTemplate(ShippingModeInfo shippingMode)
 {
     return new ShippingModeDao().CreateShippingTemplate(shippingMode);
 }
Esempio n. 18
0
 public static ShippingModeInfo PopulateShippingTemplate(IDataRecord reader)
 {
     if (null == reader)
     {
         return null;
     }
     ShippingModeInfo info = new ShippingModeInfo();
     if (reader["TemplateId"] != DBNull.Value)
     {
         info.TemplateId = (int) reader["TemplateId"];
     }
     info.Name = (string) reader["TemplateName"];
     info.Weight = (decimal) reader["Weight"];
     if (DBNull.Value != reader["AddWeight"])
     {
         info.AddWeight = new decimal?((decimal) reader["AddWeight"]);
     }
     info.Price = (decimal) reader["Price"];
     if (DBNull.Value != reader["AddPrice"])
     {
         info.AddPrice = new decimal?((decimal) reader["AddPrice"]);
     }
     return info;
 }
Esempio n. 19
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);
         }
     }
 }
Esempio n. 20
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);
         }
     }
 }
Esempio n. 21
0
 public static bool CreateShippingMode(ShippingModeInfo shippingMode)
 {
     if (null == shippingMode)
     {
         return false;
     }
     return SalesProvider.Instance().CreateShippingMode(shippingMode);
 }
Esempio n. 22
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);
                }
            }
        }
Esempio n. 23
0
 public static bool UpdateShippingTemplate(ShippingModeInfo shippingMode)
 {
     return SalesProvider.Instance().UpdateShippingTemplate(shippingMode);
 }
Esempio n. 24
0
 public abstract bool UpdateShippingMode(ShippingModeInfo shippingMode);
Esempio n. 25
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);
         }
     }
 }
Esempio n. 26
0
 public abstract bool CreateShippingTemplate(ShippingModeInfo shippingMode);