public static void SaveField(string fieldName)
        {
            using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
            {
                CustomField cat = new CustomField
                {
                    FieldName = fieldName,
                    FieldType = 1,
                    Active    = true
                };

                context.CustomFields.InsertOnSubmit(cat);
                context.SubmitChanges();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// LINQ to SQL Connection for Commitment
        /// </summary>
        /// <param name="CategoryName"></param>
        /// <param name="Ordernum"></param>
        public static void SaveCategory(string CategoryName, int Ordernum)
        {
            using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
            {
                Category cat = new Category
                {
                    Title   = CategoryName,
                    Orderno = Ordernum,
                    Visible = true
                };

                context.Categories.InsertOnSubmit(cat);
                context.SubmitChanges();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// LINQ to SQL Connection for Commitment
        /// </summary>
        /// <param name="CategoryName"></param>
        /// <param name="Ordernum"></param>
        public static void SaveVersion(string versionName, string shortName, bool visible, int categoryId)
        {
            using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
            {
                Version verItem = new Version
                {
                    Title      = versionName,
                    ShortName  = shortName,
                    Visible    = visible,
                    CategoryId = categoryId
                };

                context.Versions.InsertOnSubmit(verItem);
                context.SubmitChanges();
            }
        }
        public static bool IsValidShippingRegion(int countryId, int?stateId)
        {
            bool retValue = false;

            using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
            {
                var query = from c in context.ShippingRegions
                            where (c.CountryId == countryId) && object.Equals(c.StateId, stateId)
                            select c;

                if (query.Count() > 0)
                {
                    retValue = true;
                }
                return(retValue);
            }
        }
Esempio n. 5
0
        public static void SavePreference(DateTime pathorderDate, string currencyName, bool includeShippingTax, int orderProcess, bool geoTarget, bool paymentGateway, bool fullFillmentHouse, string title, string imagePath, int days, string siteName, string siteUrl)
        {
            using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
            {
                SitePref Item = context.SitePrefs.First();
                if (Item != null)
                {
                    Item.PathOrderDate           = pathorderDate;
                    Item.Currency                = currencyName;
                    Item.OrderTotalShipping      = includeShippingTax;
                    Item.OrderProcessType        = orderProcess;
                    Item.ArchiveData             = days;
                    Item.GeoTargetService        = geoTarget;
                    Item.PaymentGatewayService   = paymentGateway;
                    Item.FulfillmentHouseService = fullFillmentHouse;
                    Item.SiteHeader              = title;
                    Item.LogoPath                = imagePath;
                    Item.SiteName                = siteName;
                    Item.SiteUrl = siteUrl;
                    context.SubmitChanges();
                }
                else
                {
                    SitePref item = new SitePref
                    {
                        PathOrderDate         = pathorderDate,
                        Currency              = currencyName,
                        OrderTotalShipping    = includeShippingTax,
                        OrderProcessType      = orderProcess,
                        GeoTargetService      = geoTarget,
                        PaymentGatewayService = paymentGateway,
                        SiteHeader            = title,
                        LogoPath              = imagePath,
                        ArchiveData           = days,
                        SiteName              = siteName,
                        SiteUrl = siteUrl
                    };

                    context.SitePrefs.InsertOnSubmit(item);
                    context.SubmitChanges();
                }
            }
        }
Esempio n. 6
0
        public CSBusiness.CustomerManagement.Address GetAddressById(int addressId)
        {
            if (addressId == 0)
            {
                return(null);
            }

            CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection());

            var query = from c in context.Addresses
                        where c.AddressId == addressId
                        select c;
            var address = query.FirstOrDefault();

            CSBusiness.CustomerManagement.Address newAddress = new CSBusiness.CustomerManagement.Address {
                AddressId = address.AddressId
            };
            Security.Encryption.DecryptValues(newAddress);
            return(newAddress);
        }
Esempio n. 7
0
        protected void lbAddShippingCharge_Command(object sender, CommandEventArgs e)
        {
            if (Page.IsValid)
            {
                using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
                {
                    ShippingCharge shippingCharge = new ShippingCharge()
                    {
                        PrefId     = CurrentSitePreferenceId,
                        Key        = string.Empty,
                        Cost       = 0,
                        CreateDate = DateTime.Now
                    };

                    context.ShippingCharges.InsertOnSubmit(shippingCharge);
                    context.SubmitChanges();

                    BindAll();
                }
            }
        }
Esempio n. 8
0
        public static void SaveVersionCategory(int categoryId, string CategoryName)
        {
            using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
            {
                VersionCategory Item = context.VersionCategories.FirstOrDefault(x => x.CategoryId == categoryId);
                if (Item != null)
                {
                    Item.Title = CategoryName;
                    context.SubmitChanges();
                }
                else
                {
                    VersionCategory item = new VersionCategory
                    {
                        Title   = CategoryName,
                        Visible = true
                    };

                    context.VersionCategories.InsertOnSubmit(item);
                    context.SubmitChanges();
                }
            }
        }
Esempio n. 9
0
        protected void btnSave_Command(object sender, System.Web.UI.WebControls.CommandEventArgs e)
        {
            if (e.CommandName == "Save")
            {
                ShippingOptionType option     = ShippingOptionType.TotalAmount;
                ShippingOptionType optionRush = ShippingOptionType.TotalAmount;

                if (pnlOrderVal.Visible)
                {
                    option = ShippingOptionType.TotalAmount;
                    if (this.rptItems.Items.Count > 0)
                    {
                        using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection())
                               )
                        {
                            foreach (RepeaterItem lst in rptItems.Items)
                            {
                                if ((lst.ItemType == ListItemType.Item) ||
                                    (lst.ItemType == ListItemType.AlternatingItem))
                                {
                                    int                Id          = Convert.ToInt32(((Label)lst.FindControl("lblShippingId")).Text);
                                    TextBox            txtOrderVal = (TextBox)lst.FindControl("txtOrderItem");
                                    TextBox            txtCostVal  = (TextBox)lst.FindControl("txtCostItem");
                                    ShippingOrderValue order       =
                                        context.ShippingOrderValues.Single(p => p.ShippingId == Id);
                                    order.OrderTotal = Convert.ToDecimal(txtOrderVal.Text);
                                    order.Cost       = Convert.ToDecimal(txtCostVal.Text);
                                    context.SubmitChanges();
                                }
                            }
                        }
                    }
                } //end if for Shipping OrderValue

                if (pnlWeight.Visible)
                {
                    option = ShippingOptionType.Weight;
                    if (this.rptOrderWeight.Items.Count > 0)
                    {
                        using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection())
                               )
                        {
                            foreach (RepeaterItem lst in rptOrderWeight.Items)
                            {
                                if ((lst.ItemType == ListItemType.Item) ||
                                    (lst.ItemType == ListItemType.AlternatingItem))
                                {
                                    int                Id          = Convert.ToInt32(((Label)lst.FindControl("lblShippingId")).Text);
                                    TextBox            txtOrderVal = (TextBox)lst.FindControl("txtOrderItem");
                                    TextBox            txtCostVal  = (TextBox)lst.FindControl("txtCostItem");
                                    ShippingOrderValue order       =
                                        context.ShippingOrderValues.Single(p => p.ShippingId == Id);
                                    order.OrderTotal = Convert.ToDecimal(txtOrderVal.Text);
                                    order.Cost       = Convert.ToDecimal(txtCostVal.Text);
                                    context.SubmitChanges();
                                }
                            }
                        }
                    }
                } //end if for Shipping OrderWeight

                if (pnlSkuItem.Visible)
                {
                    option = ShippingOptionType.SkuBased;
                    if (this.rptSkuItem.Items.Count > 0)
                    {
                        using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection())
                               )
                        {
                            foreach (RepeaterItem lst in rptSkuItem.Items)
                            {
                                if ((lst.ItemType == ListItemType.Item) ||
                                    (lst.ItemType == ListItemType.AlternatingItem))
                                {
                                    int         Id         = Convert.ToInt32(((Label)lst.FindControl("lblSkuId")).Text);
                                    TextBox     txtCostVal = (TextBox)lst.FindControl("txtPercentage");
                                    SkuShipping order      =
                                        context.SkuShippings.FirstOrDefault(
                                            p => (p.SkuId == Id) && (p.IncludeRushShipping == false) && (p.PrefId == 1));
                                    if (order != null)
                                    {
                                        order.Cost = Convert.ToDecimal(txtCostVal.Text);
                                        context.SubmitChanges();
                                    }
                                    else
                                    {
                                        SkuShipping item = new SkuShipping();
                                        item.SkuId = Id;
                                        item.Cost  = Convert.ToDecimal(txtCostVal.Text);
                                        item.IncludeRushShipping = false;
                                        item.PrefId = 1;
                                        context.SkuShippings.InsertOnSubmit(item);
                                        context.SubmitChanges();
                                    }
                                }
                            }
                        }
                    }
                } //end if for Shipping SkuItem level

                if (pnlFlat.Visible)
                {
                    option = ShippingOptionType.Flat;
                }

                if (cbRushShippingOption.Checked)
                {
                    if (pnlRushOrderTotal.Visible)
                    {
                        optionRush = ShippingOptionType.TotalAmount;
                        if (this.rptRushOrderTotal.Items.Count > 0)
                        {
                            using (
                                CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection())
                                )
                            {
                                foreach (RepeaterItem lst in rptRushOrderTotal.Items)
                                {
                                    if ((lst.ItemType == ListItemType.Item) ||
                                        (lst.ItemType == ListItemType.AlternatingItem))
                                    {
                                        int                Id          = Convert.ToInt32(((Label)lst.FindControl("lblShippingId")).Text);
                                        TextBox            txtOrderVal = (TextBox)lst.FindControl("txtOrderItem");
                                        TextBox            txtCostVal  = (TextBox)lst.FindControl("txtCostItem");
                                        ShippingOrderValue order       =
                                            context.ShippingOrderValues.Single(p => p.ShippingId == Id);
                                        order.OrderTotal = Convert.ToDecimal(txtOrderVal.Text);
                                        order.Cost       = Convert.ToDecimal(txtCostVal.Text);
                                        context.SubmitChanges();
                                    }
                                }
                            }
                        }
                    }

                    if (pnlRushOrderweight.Visible)
                    {
                        optionRush = ShippingOptionType.Weight;
                        if (this.rptRushOrderWeight.Items.Count > 0)
                        {
                            using (
                                CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection())
                                )
                            {
                                foreach (RepeaterItem lst in rptRushOrderWeight.Items)
                                {
                                    if ((lst.ItemType == ListItemType.Item) ||
                                        (lst.ItemType == ListItemType.AlternatingItem))
                                    {
                                        int                Id          = Convert.ToInt32(((Label)lst.FindControl("lblShippingId")).Text);
                                        TextBox            txtOrderVal = (TextBox)lst.FindControl("txtOrderItem");
                                        TextBox            txtCostVal  = (TextBox)lst.FindControl("txtCostItem");
                                        ShippingOrderValue order       =
                                            context.ShippingOrderValues.Single(p => p.ShippingId == Id);
                                        order.OrderTotal = Convert.ToDecimal(txtOrderVal.Text);
                                        order.Cost       = Convert.ToDecimal(txtCostVal.Text);
                                        context.SubmitChanges();
                                    }
                                }
                            }
                        }
                    }

                    if (pnlRushSkuItem.Visible)
                    {
                        optionRush = ShippingOptionType.SkuBased;
                        if (this.rptRushSkuItem.Items.Count > 0)
                        {
                            using (
                                CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection())
                                )
                            {
                                foreach (RepeaterItem lst in rptRushSkuItem.Items)
                                {
                                    if ((lst.ItemType == ListItemType.Item) ||
                                        (lst.ItemType == ListItemType.AlternatingItem))
                                    {
                                        int         Id         = Convert.ToInt32(((Label)lst.FindControl("lblSkuId")).Text);
                                        TextBox     txtCostVal = (TextBox)lst.FindControl("txtPercentage");
                                        SkuShipping order      =
                                            context.SkuShippings.FirstOrDefault(
                                                p =>
                                                (p.SkuId == Id) && (p.IncludeRushShipping == true) && (p.PrefId == 1));
                                        if (order != null)
                                        {
                                            order.Cost = Convert.ToDecimal(txtCostVal.Text);
                                            context.SubmitChanges();
                                        }
                                        else
                                        {
                                            SkuShipping item = new SkuShipping();
                                            item.SkuId = Id;
                                            item.Cost  = Convert.ToDecimal(txtCostVal.Text);
                                            item.IncludeRushShipping = true;
                                            item.PrefId = 1;
                                            context.SkuShippings.InsertOnSubmit(item);
                                            context.SubmitChanges();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (pnlRushFlat.Visible)
                {
                    optionRush = ShippingOptionType.Flat;
                }


                using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
                {
                    ShippingPref Val = context.ShippingPrefs.FirstOrDefault(x => x.PrefId == DefaultSitePrefereceId);
                    if (Val != null)
                    {
                        if (pnlFlat.Visible)
                        {
                            Val.flatShipping = Convert.ToDecimal(txtFlat.Text);
                        }
                        if (pnlRushFlat.Visible)
                        {
                            Val.RushShippingCost = Convert.ToDecimal(txtRushFlat.Text);
                        }
                        if (cbRushShippingOption.Checked)
                        {
                            Val.RushOptionId = (int)optionRush;
                        }
                        Val.OptionId = (int)option;

                        Val.InCludeRushShipping = cbRushShippingOption.Checked;
                        context.SubmitChanges();
                    }
                }

                // save additional charges
                if (this.rptShippingCharges.Items.Count > 0)
                {
                    List <int> deleteList = new List <int>();

                    using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
                    {
                        foreach (RepeaterItem lst in rptShippingCharges.Items)
                        {
                            if ((lst.ItemType == ListItemType.Item) || (lst.ItemType == ListItemType.AlternatingItem))
                            {
                                int      id        = Convert.ToInt32(((HiddenField)lst.FindControl("hidShippingChargeId")).Value);
                                CheckBox chkDelete = (CheckBox)lst.FindControl("chkDelete");

                                if (chkDelete.Checked)
                                {
                                    deleteList.Add(id);
                                }
                                else
                                {
                                    TextBox txtKey   = (TextBox)lst.FindControl("txtKey");
                                    TextBox txtCost  = (TextBox)lst.FindControl("txtCost");
                                    TextBox txtLabel = (TextBox)lst.FindControl("txtLabel");

                                    ShippingCharge shippingCharge =
                                        context.ShippingCharges.Single(p => p.ShippingChargeId == id);

                                    shippingCharge.Key           = txtKey.Text;
                                    shippingCharge.Cost          = Convert.ToDecimal(txtCost.Text);
                                    shippingCharge.FriendlyLabel = txtLabel.Text;
                                    context.SubmitChanges();
                                }
                            }
                        }
                    }

                    if (deleteList.Count > 0)
                    {
                        foreach (int id in deleteList)
                        {
                            CSBusiness.Shipping.ShippingManager.RemoveShippingCharge(id);
                        }
                    }
                }
                lblCancel.Visible  = false;
                lblSuccess.Visible = true;
            } //end of Save Command
            else
            {
                PopulateControls();
                lblCancel.Visible  = true;
                lblSuccess.Visible = false;
            }

            // Response.Redirect("Main.aspx");
        }
        /// <summary>
        /// Save Command Operation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Command(object sender, System.Web.UI.WebControls.CommandEventArgs e)
        {
            if (e.CommandName == "Save")
            {
                ShippingOptionType option     = ShippingOptionType.SiteLevelPref;
                ShippingOptionType optionRush = ShippingOptionType.SiteLevelPref;
                int?stateId = null;
                int countryId;
                if (DropDownListState.SelectedItem.Value.Length > 0)
                {
                    stateId = Convert.ToInt32(DropDownListState.SelectedItem.Value);
                }
                countryId = Convert.ToInt32(DropDownListCountry.SelectedItem.Value);

                if (PrefId == 0) //New Region Defined in the system
                {
                    //Check User Creating same Custom Shipping again or not
                    if (!ShippingDAL.IsValidShippingRegion(countryId, stateId))
                    {
                        using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
                        {
                            ShippingPref item = new ShippingPref
                            {
                                flatShipping        = (pnlFlat.Visible) ? Convert.ToDecimal(txtFlat.Text) : 0,
                                RushShippingCost    = (pnlRushFlat.Visible) ? Convert.ToDecimal(txtRushFlat.Text) : 0,
                                RushOptionId        = (int)optionRush,
                                OptionId            = (int)option,
                                InCludeRushShipping = cbRushShippingOption.Checked,
                                IsCustomized        = true
                            };

                            context.ShippingPrefs.InsertOnSubmit(item);
                            context.SubmitChanges();

                            PrefId = item.PrefId;


                            //Associate PrefId to Region Table
                            ShippingRegion newRegion = new ShippingRegion
                            {
                                CountryId = countryId,
                                StateId   = stateId,
                                PrefId    = PrefId
                            };
                            context.ShippingRegions.InsertOnSubmit(newRegion);
                            context.SubmitChanges();
                        }
                    }
                    else
                    {
                        //fire Existing Item Message
                    }
                }

                if (PrefId > 0)
                {
                    if (pnlOrderVal.Visible)
                    {
                        option = ShippingOptionType.TotalAmount;
                        if (this.rptItems.Items.Count > 0)
                        {
                            using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
                            {
                                foreach (RepeaterItem lst in rptItems.Items)
                                {
                                    if ((lst.ItemType == ListItemType.Item) || (lst.ItemType == ListItemType.AlternatingItem))
                                    {
                                        int                Id          = Convert.ToInt32(((Label)lst.FindControl("lblShippingId")).Text);
                                        TextBox            txtOrderVal = (TextBox)lst.FindControl("txtOrderItem");
                                        TextBox            txtCostVal  = (TextBox)lst.FindControl("txtCostItem");
                                        ShippingOrderValue order       = context.ShippingOrderValues.Single(p => p.ShippingId == Id);
                                        if (order != null)
                                        {
                                            order.OrderTotal = Convert.ToDecimal(txtOrderVal.Text);
                                            order.Cost       = Convert.ToDecimal(txtCostVal.Text);
                                            order.PrefId     = PrefId;
                                            context.SubmitChanges();
                                        }
                                    }
                                }
                            }
                        }
                    } //end if for Shipping OrderValue

                    if (pnlWeight.Visible)
                    {
                        option = ShippingOptionType.Weight;
                        if (this.rptOrderWeight.Items.Count > 0)
                        {
                            using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
                            {
                                foreach (RepeaterItem lst in rptOrderWeight.Items)
                                {
                                    if ((lst.ItemType == ListItemType.Item) || (lst.ItemType == ListItemType.AlternatingItem))
                                    {
                                        int                Id          = Convert.ToInt32(((Label)lst.FindControl("lblShippingId")).Text);
                                        TextBox            txtOrderVal = (TextBox)lst.FindControl("txtOrderItem");
                                        TextBox            txtCostVal  = (TextBox)lst.FindControl("txtCostItem");
                                        ShippingOrderValue order       = context.ShippingOrderValues.Single(p => p.ShippingId == Id);
                                        if (order != null)
                                        {
                                            order.OrderTotal = Convert.ToDecimal(txtOrderVal.Text);
                                            order.Cost       = Convert.ToDecimal(txtCostVal.Text);
                                            order.PrefId     = PrefId;
                                            context.SubmitChanges();
                                        }
                                    }
                                }
                            }
                        }
                    }//end if for Shipping OrderWeight

                    if (pnlSkuItem.Visible)
                    {
                        option = ShippingOptionType.SkuBased;
                        if (this.rptSkuItem.Items.Count > 0)
                        {
                            using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
                            {
                                foreach (RepeaterItem lst in rptSkuItem.Items)
                                {
                                    if ((lst.ItemType == ListItemType.Item) || (lst.ItemType == ListItemType.AlternatingItem))
                                    {
                                        int         Id         = Convert.ToInt32(((Label)lst.FindControl("lblSkuId")).Text);
                                        TextBox     txtCostVal = (TextBox)lst.FindControl("txtPercentage");
                                        SkuShipping order      = context.SkuShippings.FirstOrDefault(p => (p.SkuId == Id) && (p.IncludeRushShipping == false) && (p.PrefId == PrefId));
                                        if (order != null)
                                        {
                                            order.Cost = Convert.ToDecimal(txtCostVal.Text);
                                            context.SubmitChanges();
                                        }
                                        else
                                        {
                                            SkuShipping item = new SkuShipping();
                                            item.SkuId = Id;
                                            item.Cost  = Convert.ToDecimal(txtCostVal.Text);
                                            item.IncludeRushShipping = false;
                                            item.PrefId = PrefId;
                                            context.SkuShippings.InsertOnSubmit(item);
                                            context.SubmitChanges();
                                        }
                                    }
                                }
                            }
                        }
                    }//end if for Shipping SkuItem level

                    if (pnlFlat.Visible)
                    {
                        option = ShippingOptionType.Flat;
                    }

                    if (cbSitePref.Checked)
                    {
                        option = ShippingOptionType.SiteLevelPref;
                    }

                    if (cbRushShippingOption.Checked)
                    {
                        if (pnlRushOrderTotal.Visible)
                        {
                            optionRush = ShippingOptionType.TotalAmount;
                            if (this.rptRushOrderTotal.Items.Count > 0)
                            {
                                using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
                                {
                                    foreach (RepeaterItem lst in rptRushOrderTotal.Items)
                                    {
                                        if ((lst.ItemType == ListItemType.Item) || (lst.ItemType == ListItemType.AlternatingItem))
                                        {
                                            int                Id          = Convert.ToInt32(((Label)lst.FindControl("lblShippingId")).Text);
                                            TextBox            txtOrderVal = (TextBox)lst.FindControl("txtOrderItem");
                                            TextBox            txtCostVal  = (TextBox)lst.FindControl("txtCostItem");
                                            ShippingOrderValue order       = context.ShippingOrderValues.Single(p => p.ShippingId == Id);
                                            if (order != null)
                                            {
                                                order.OrderTotal = Convert.ToDecimal(txtOrderVal.Text);
                                                order.Cost       = Convert.ToDecimal(txtCostVal.Text);
                                                order.PrefId     = PrefId;
                                                context.SubmitChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        if (pnlRushOrderweight.Visible)
                        {
                            optionRush = ShippingOptionType.Weight;
                            if (this.rptRushOrderWeight.Items.Count > 0)
                            {
                                using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
                                {
                                    foreach (RepeaterItem lst in rptRushOrderWeight.Items)
                                    {
                                        if ((lst.ItemType == ListItemType.Item) || (lst.ItemType == ListItemType.AlternatingItem))
                                        {
                                            int                Id          = Convert.ToInt32(((Label)lst.FindControl("lblShippingId")).Text);
                                            TextBox            txtOrderVal = (TextBox)lst.FindControl("txtOrderItem");
                                            TextBox            txtCostVal  = (TextBox)lst.FindControl("txtCostItem");
                                            ShippingOrderValue order       = context.ShippingOrderValues.Single(p => p.ShippingId == Id);
                                            if (order != null)
                                            {
                                                order.OrderTotal = Convert.ToDecimal(txtOrderVal.Text);
                                                order.Cost       = Convert.ToDecimal(txtCostVal.Text);
                                                order.PrefId     = PrefId;
                                                context.SubmitChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        if (pnlRushSkuItem.Visible)
                        {
                            optionRush = ShippingOptionType.SkuBased;
                            if (this.rptRushSkuItem.Items.Count > 0)
                            {
                                using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
                                {
                                    foreach (RepeaterItem lst in rptRushSkuItem.Items)
                                    {
                                        if ((lst.ItemType == ListItemType.Item) || (lst.ItemType == ListItemType.AlternatingItem))
                                        {
                                            int         Id         = Convert.ToInt32(((Label)lst.FindControl("lblSkuId")).Text);
                                            TextBox     txtCostVal = (TextBox)lst.FindControl("txtPercentage");
                                            SkuShipping order      = context.SkuShippings.FirstOrDefault(p => (p.SkuId == Id) && (p.IncludeRushShipping == true) && (p.PrefId == PrefId));
                                            if (order != null)
                                            {
                                                order.Cost = Convert.ToDecimal(txtCostVal.Text);
                                                context.SubmitChanges();
                                            }
                                            else
                                            {
                                                SkuShipping item = new SkuShipping();
                                                item.SkuId = Id;
                                                item.Cost  = Convert.ToDecimal(txtCostVal.Text);
                                                item.IncludeRushShipping = true;
                                                item.PrefId = PrefId;
                                                context.SkuShippings.InsertOnSubmit(item);
                                                context.SubmitChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (pnlRushFlat.Visible)
                    {
                        optionRush = ShippingOptionType.Flat;
                    }

                    if (cbRushSitePref.Checked)
                    {
                        optionRush = ShippingOptionType.SiteLevelPref;
                    }

                    using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
                    {
                        ShippingPref Val = context.ShippingPrefs.FirstOrDefault(x => x.PrefId == PrefId);
                        if (Val != null)
                        {
                            if (pnlFlat.Visible)
                            {
                                Val.flatShipping = Convert.ToDecimal(txtFlat.Text);
                            }
                            if (pnlRushFlat.Visible)
                            {
                                Val.RushShippingCost = Convert.ToDecimal(txtRushFlat.Text);
                            }
                            if (cbRushShippingOption.Checked)
                            {
                                Val.RushOptionId = (int)optionRush;
                            }
                            Val.OptionId = (int)option;

                            Val.InCludeRushShipping = cbRushShippingOption.Checked;
                            context.SubmitChanges();
                        }
                    }
                }// prefId check

                // save additional charges
                if (this.rptShippingCharges.Items.Count > 0)
                {
                    List <int> deleteList = new List <int>();

                    using (CSCommerceDataContext context = new CSCommerceDataContext(ConfigHelper.GetDBConnection()))
                    {
                        foreach (RepeaterItem lst in rptShippingCharges.Items)
                        {
                            if ((lst.ItemType == ListItemType.Item) || (lst.ItemType == ListItemType.AlternatingItem))
                            {
                                int      id        = Convert.ToInt32(((HiddenField)lst.FindControl("hidShippingChargeId")).Value);
                                CheckBox chkDelete = (CheckBox)lst.FindControl("chkDelete");

                                if (chkDelete.Checked)
                                {
                                    deleteList.Add(id);
                                }
                                else
                                {
                                    TextBox txtKey   = (TextBox)lst.FindControl("txtKey");
                                    TextBox txtCost  = (TextBox)lst.FindControl("txtCost");
                                    TextBox txtLabel = (TextBox)lst.FindControl("txtLabel");

                                    ShippingCharge shippingCharge = context.ShippingCharges.Single(p => p.ShippingChargeId == id);

                                    shippingCharge.Key           = txtKey.Text;
                                    shippingCharge.Cost          = Convert.ToDecimal(txtCost.Text);
                                    shippingCharge.FriendlyLabel = txtLabel.Text;
                                    context.SubmitChanges();
                                }
                            }
                        }
                    }

                    if (deleteList.Count > 0)
                    {
                        foreach (int id in deleteList)
                        {
                            CSBusiness.Shipping.ShippingManager.RemoveShippingCharge(id);
                        }
                    }
                }
            }//end of save

            Response.Redirect("CustomShippingList.aspx");
        }