public void SaveInfo() { var shippingMethods = ShippingMethodManager.GetAllShippingMethods(); foreach (GridViewRow row in gvShippingMethodCountryMap.Rows) { foreach (ShippingMethod shippingMethod in shippingMethods) { CheckBox cbRestrict = row.FindControl(String.Format("cbRestrict_{0}", shippingMethod.ShippingMethodId)) as CheckBox; HiddenField hfCountryId = row.FindControl(String.Format("hfCountryId_{0}", shippingMethod.ShippingMethodId)) as HiddenField; if (cbRestrict == null || hfCountryId == null) { return; } int countryId = Int32.Parse(hfCountryId.Value); if (cbRestrict.Checked) { ShippingMethodManager.CreateShippingMethodCountryMapping(shippingMethod.ShippingMethodId, countryId); } else { if (ShippingMethodManager.DoesShippingMethodCountryMappingExist(shippingMethod.ShippingMethodId, countryId)) { ShippingMethodManager.DeleteShippingMethodCountryMapping(shippingMethod.ShippingMethodId, countryId); } } } } }
protected void BuildColumnsDynamically() { gvShippingMethodCountryMap.Columns.Clear(); TemplateField tfAction = new TemplateField(); tfAction.ItemTemplate = new NopGridViewCustomTemplate(DataControlRowType.DataRow, "CountryName", "String"); tfAction.HeaderTemplate = new NopGridViewCustomTemplate(DataControlRowType.Header, GetLocaleResourceString("Admin.ShippingMethodsFilterControl.Grid.CountryName"), "String"); gvShippingMethodCountryMap.Columns.Add(tfAction); StringBuilder scriptBuilder = new StringBuilder(); scriptBuilder.Append("$(document).ready(function() {"); foreach (ShippingMethod shippingMethod in ShippingMethodManager.GetAllShippingMethods()) { TemplateField tf = new TemplateField(); tf.ItemTemplate = new NopGridViewCustomTemplate(DataControlRowType.DataRow, "Restrict", "Checkbox", shippingMethod.ShippingMethodId); tf.HeaderTemplate = new NopGridViewCustomTemplate(DataControlRowType.Header, shippingMethod.Name, "String", shippingMethod.ShippingMethodId); gvShippingMethodCountryMap.Columns.Add(tf); scriptBuilder.AppendFormat("$('.cbSelectAll_{0} input').bind('click', function() {{ $('.cbRestrict_{0} input').each(function() {{ this.checked = $('.cbSelectAll_{0} input')[0].checked; }}) }});", shippingMethod.ShippingMethodId); //scriptBuilder.AppendFormat("$('.cbRestrict_{0} input').bind('click', function() {{ if (this.checked == false) $('.cbSelectAll_{0} input')[0].checked = false; }});", shippingMethod.ShippingMethodId); } scriptBuilder.Append("});"); string script = scriptBuilder.ToString(); Page.ClientScript.RegisterClientScriptBlock(GetType(), script.GetHashCode().ToString(), script, true); }
void BindGrid() { ShippingMethodCollection shippingMethodCollection = ShippingMethodManager.GetAllShippingMethods(); gvShippingMethods.DataSource = shippingMethodCollection; gvShippingMethods.DataBind(); }
public void SaveInfo() { if (Page.IsValid) { try { ShippingMethodCollection shippingMethodCollection = ShippingMethodManager.GetAllShippingMethods(); foreach (GridViewRow row in gvShippingMethodCountryMap.Rows) { foreach (ShippingMethod shippingMethod in shippingMethodCollection) { CheckBox cbRestrict = row.FindControl(String.Format("cbRestrict_{0}", shippingMethod.ShippingMethodId)) as CheckBox; HiddenField hfCountryId = row.FindControl(String.Format("hfCountryId_{0}", shippingMethod.ShippingMethodId)) as HiddenField; int countryId = Int32.Parse(hfCountryId.Value); if (cbRestrict.Checked) { ShippingMethodManager.CreateShippingMethodCountryMapping(shippingMethod.ShippingMethodId, countryId); } else { ShippingMethodManager.DeleteShippingMethodCountryMapping(shippingMethod.ShippingMethodId, countryId); } } } Response.Redirect("ShippingMethods.aspx"); } catch (Exception exc) { ProcessException(exc); } } }
/// <summary> /// Gets available shipping options /// </summary> /// <param name="ShipmentPackage">Shipment package</param> /// <param name="Error">Error</param> /// <returns>Shipping options</returns> public ShippingOptionCollection GetShippingOptions(ShipmentPackage ShipmentPackage, ref string Error) { ShippingOptionCollection shippingOptions = new ShippingOptionCollection(); if (ShipmentPackage == null) { throw new ArgumentNullException("ShipmentPackage"); } if (ShipmentPackage.Items == null) { throw new NopException("No shipment items"); } ShippingMethodCollection shippingMethods = ShippingMethodManager.GetAllShippingMethods(); foreach (ShippingMethod shippingMethod in shippingMethods) { ShippingOption shippingOption = new ShippingOption(); shippingOption.Name = shippingMethod.Name; shippingOption.Description = shippingMethod.Description; shippingOption.Rate = decimal.Zero; shippingOptions.Add(shippingOption); } return(shippingOptions); }
protected void gvShippingByTotals_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ShippingByTotal shippingByTotal = (ShippingByTotal)e.Row.DataItem; Button btnUpdate = e.Row.FindControl("btnUpdate") as Button; if (btnUpdate != null) { btnUpdate.CommandArgument = e.Row.RowIndex.ToString(); } DropDownList ddlShippingMethod = e.Row.FindControl("ddlShippingMethod") as DropDownList; ddlShippingMethod.Items.Clear(); ShippingMethodCollection shippingMethodCollection = ShippingMethodManager.GetAllShippingMethods(); foreach (ShippingMethod shippingMethod in shippingMethodCollection) { ListItem item = new ListItem(shippingMethod.Name, shippingMethod.ShippingMethodID.ToString()); ddlShippingMethod.Items.Add(item); if (shippingByTotal.ShippingMethodID == shippingMethod.ShippingMethodID) { item.Selected = true; } } } }
protected void BindGrid() { var countryCollection = CountryManager.GetAllCountries(); var shippingMethodCollection = ShippingMethodManager.GetAllShippingMethods(); if (countryCollection.Count == 0) { lblMessage.Text = GetLocaleResourceString("Admin.ShippingMethodsFilterControl.NoCountryDefined"); } if (shippingMethodCollection.Count == 0) { lblMessage.Text = GetLocaleResourceString("Admin.ShippingMethodsFilterControl.NoShippingMethodDefined"); } List <ShippingMethodCountryMappingHelperClass> dt = new List <ShippingMethodCountryMappingHelperClass>(); foreach (Country country in countryCollection) { ShippingMethodCountryMappingHelperClass map1 = new ShippingMethodCountryMappingHelperClass(); map1.CountryId = country.CountryId; map1.CountryName = country.Name; map1.Restrict = new Dictionary <int, bool>(); foreach (ShippingMethod shippingMethod in shippingMethodCollection) { map1.Restrict.Add(shippingMethod.ShippingMethodId, ShippingMethodManager.DoesShippingMethodCountryMappingExist(shippingMethod.ShippingMethodId, country.CountryId)); } dt.Add(map1); } gvShippingMethodCountryMap.DataSource = dt; gvShippingMethodCountryMap.DataBind(); }
private void BindData() { ShippingMethod shippingMethod = ShippingMethodManager.GetShippingMethodById(this.ShippingMethodId); if (shippingMethod != null) { this.txtName.Text = shippingMethod.Name; this.txtDescription.Text = shippingMethod.Description; this.txtDisplayOrder.Value = shippingMethod.DisplayOrder; } }
private void FillDropDowns() { ddlShippingMethod.Items.Clear(); ShippingMethodCollection shippingMethodCollection = ShippingMethodManager.GetAllShippingMethods(); foreach (ShippingMethod shippingMethod in shippingMethodCollection) { ListItem item = new ListItem(shippingMethod.Name, shippingMethod.ShippingMethodID.ToString()); ddlShippingMethod.Items.Add(item); } }
protected void DeleteButton_Click(object sender, EventArgs e) { try { ShippingMethodManager.DeleteShippingMethod(this.ShippingMethodId); Response.Redirect("ShippingMethods.aspx"); } catch (Exception exc) { ProcessException(exc); } }
private void BindData() { //TODO add restricted countries [Nop_ShippingMethod_ResrtictedCountries] ShippingMethod shippingMethod = ShippingMethodManager.GetShippingMethodByID(this.ShippingMethodID); if (shippingMethod != null) { this.txtName.Text = shippingMethod.Name; this.txtDescription.Text = shippingMethod.Description; this.txtDisplayOrder.Value = shippingMethod.DisplayOrder; } }
/// <summary> /// Gets available shipping options /// </summary> /// <param name="shipmentPackage">Shipment package</param> /// <param name="error">Error</param> /// <returns>Shipping options</returns> public List <ShippingOption> GetShippingOptions(ShipmentPackage shipmentPackage, ref string error) { var shippingOptions = new List <ShippingOption>(); if (shipmentPackage == null) { throw new ArgumentNullException("shipmentPackage"); } if (shipmentPackage.Items == null) { throw new NopException("No shipment items"); } if (shipmentPackage.ShippingAddress == null) { error = "Shipping address is not set"; return(shippingOptions); } if (shipmentPackage.ShippingAddress.Country == null) { error = "Shipping country is not set"; return(shippingOptions); } decimal subTotal = decimal.Zero; foreach (var shoppingCartItem in shipmentPackage.Items) { if (shoppingCartItem.IsFreeShipping) { continue; } subTotal += PriceHelper.GetSubTotal(shoppingCartItem, shipmentPackage.Customer, true); } decimal weight = ShippingManager.GetShoppingCartTotalWeight(shipmentPackage.Items, shipmentPackage.Customer); var shippingMethods = ShippingMethodManager.GetAllShippingMethods(shipmentPackage.ShippingAddress.CountryId); foreach (var shippingMethod in shippingMethods) { decimal?rate = GetRate(subTotal, weight, shippingMethod.ShippingMethodId); if (rate.HasValue) { var shippingOption = new ShippingOption(); shippingOption.Name = shippingMethod.Name; shippingOption.Description = shippingMethod.Description; shippingOption.Rate = rate.Value; shippingOptions.Add(shippingOption); } } return(shippingOptions); }
/// <summary> /// Gets available shipping options /// </summary> /// <param name="ShipmentPackage">Shipment package</param> /// <param name="Error">Error</param> /// <returns>Shipping options</returns> public ShippingOptionCollection GetShippingOptions(ShipmentPackage ShipmentPackage, ref string Error) { ShippingOptionCollection shippingOptions = new ShippingOptionCollection(); if (ShipmentPackage == null) { throw new ArgumentNullException("ShipmentPackage"); } if (ShipmentPackage.Items == null) { throw new NopException("No shipment items"); } if (ShipmentPackage.ShippingAddress == null) { Error = "Shipping address is not set"; return(shippingOptions); } if (ShipmentPackage.ShippingAddress.Country == null) { Error = "Shipping country is not set"; return(shippingOptions); } decimal subTotal = decimal.Zero; foreach (ShoppingCartItem shoppingCartItem in ShipmentPackage.Items) { if (shoppingCartItem.IsFreeShipping) { continue; } subTotal += PriceHelper.GetSubTotal(shoppingCartItem, ShipmentPackage.Customer, true); } decimal weight = ShippingManager.GetShoppingCartTotalWeigth(ShipmentPackage.Items); ShippingMethodCollection shippingMethods = ShippingMethodManager.GetAllShippingMethods(); foreach (ShippingMethod shippingMethod in shippingMethods) { ShippingOption shippingOption = new ShippingOption(); shippingOption.Name = shippingMethod.Name; shippingOption.Description = shippingMethod.Description; shippingOption.Rate = GetRate(subTotal, weight, shippingMethod.ShippingMethodID, ShipmentPackage.ShippingAddress.Country.CountryID); shippingOptions.Add(shippingOption); } return(shippingOptions); }
public ShippingMethod SaveInfo() { ShippingMethod shippingMethod = ShippingMethodManager.GetShippingMethodById(this.ShippingMethodId); if (shippingMethod != null) { shippingMethod = ShippingMethodManager.UpdateShippingMethod(shippingMethod.ShippingMethodId, txtName.Text, txtDescription.Text, txtDisplayOrder.Value); } else { shippingMethod = ShippingMethodManager.InsertShippingMethod(txtName.Text, txtDescription.Text, txtDisplayOrder.Value); } return(shippingMethod); }
/// <summary> /// Gets available shipping options /// </summary> /// <param name="shipmentPackage">Shipment package</param> /// <param name="error">Error</param> /// <returns>Shipping options</returns> public ShippingOptionCollection GetShippingOptions(ShipmentPackage shipmentPackage, ref string error) { var shippingOptions = new ShippingOptionCollection(); if (shipmentPackage == null) { throw new ArgumentNullException("shipmentPackage"); } if (shipmentPackage.Items == null) { throw new NopException("Нет товаров для доставки. "); } if (shipmentPackage.ShippingAddress == null) { error = "Не указан адрес доставки. "; return(shippingOptions); } if (shipmentPackage.ShippingAddress.Country == null) { error = "Не указана страна доставки. "; return(shippingOptions); } var shippingMethods = ShippingMethodManager.GetAllShippingMethods(shipmentPackage.ShippingAddress.CountryId); foreach (var shippingMethod in shippingMethods) { var shippingOption = new ShippingOption(); shippingOption.Name = shippingMethod.Name; shippingOption.Description = shippingMethod.Description; if (shippingMethod.ShippingMethodId == 4) { shippingOption.Rate = 0; } else { shippingOption.Rate = GetRate(); } shippingOptions.Add(shippingOption); } return(shippingOptions); }
protected void BuildColumnsDynamically() { gvShippingMethodCountryMap.Columns.Clear(); TemplateField tfAction = new TemplateField(); tfAction.ItemTemplate = new NopGridViewCustomTemplate(DataControlRowType.DataRow, "CountryName", "String"); tfAction.HeaderTemplate = new NopGridViewCustomTemplate(DataControlRowType.Header, GetLocaleResourceString("Admin.ShippingMethodsFilterControl.Grid.CountryName"), "String"); gvShippingMethodCountryMap.Columns.Add(tfAction); ShippingMethodCollection shippingMethodCollection = ShippingMethodManager.GetAllShippingMethods(); foreach (ShippingMethod shippingMethod in shippingMethodCollection) { TemplateField tf = new TemplateField(); tf.ItemTemplate = new NopGridViewCustomTemplate(DataControlRowType.DataRow, "Restrict", "Checkbox", shippingMethod.ShippingMethodId); tf.HeaderTemplate = new NopGridViewCustomTemplate(DataControlRowType.Header, shippingMethod.Name, "String"); gvShippingMethodCountryMap.Columns.Add(tf); } }
private void FillDropDowns() { ddlShippingMethod.Items.Clear(); ShippingMethodCollection shippingMethodCollection = ShippingMethodManager.GetAllShippingMethods(); foreach (ShippingMethod shippingMethod in shippingMethodCollection) { ListItem item = new ListItem(shippingMethod.Name, shippingMethod.ShippingMethodID.ToString()); ddlShippingMethod.Items.Add(item); } ddlCountry.Items.Clear(); CountryCollection countryCollection = CountryManager.GetAllCountries(); foreach (Country country in countryCollection) { ListItem item = new ListItem(country.Name, country.CountryID.ToString()); ddlCountry.Items.Add(item); } }
protected void gvShippingByWeightAndCountry_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ShippingByWeightAndCountry shippingByWeightAndCountry = (ShippingByWeightAndCountry)e.Row.DataItem; Button btnUpdate = e.Row.FindControl("btnUpdate") as Button; if (btnUpdate != null) { btnUpdate.CommandArgument = e.Row.RowIndex.ToString(); } DropDownList ddlShippingMethod = e.Row.FindControl("ddlShippingMethod") as DropDownList; ddlShippingMethod.Items.Clear(); ShippingMethodCollection shippingMethodCollection = ShippingMethodManager.GetAllShippingMethods(); foreach (ShippingMethod shippingMethod in shippingMethodCollection) { ListItem item = new ListItem(shippingMethod.Name, shippingMethod.ShippingMethodId.ToString()); ddlShippingMethod.Items.Add(item); if (shippingByWeightAndCountry.ShippingMethodId == shippingMethod.ShippingMethodId) { item.Selected = true; } } DropDownList ddlCountry = e.Row.FindControl("ddlCountry") as DropDownList; ddlCountry.Items.Clear(); CountryCollection countryCollection = CountryManager.GetAllCountries(); foreach (Country country in countryCollection) { ListItem item = new ListItem(country.Name, country.CountryId.ToString()); ddlCountry.Items.Add(item); if (shippingByWeightAndCountry.CountryId == country.CountryId) { item.Selected = true; } } } }
/// <summary> /// Gets available shipping options /// </summary> /// <param name="shipmentPackage">Shipment package</param> /// <param name="error">Error</param> /// <returns>Shipping options</returns> public List <ShippingOption> GetShippingOptions(ShipmentPackage shipmentPackage, ref string error) { var shippingOptions = new List <ShippingOption>(); if (shipmentPackage == null) { throw new ArgumentNullException("shipmentPackage"); } if (shipmentPackage.Items == null) { throw new NopException("No shipment items"); } if (shipmentPackage.ShippingAddress == null) { error = "Shipping address is not set"; return(shippingOptions); } if (shipmentPackage.ShippingAddress.Country == null) { error = "Shipping country is not set"; return(shippingOptions); } var shippingMethods = ShippingMethodManager.GetAllShippingMethods(shipmentPackage.ShippingAddress.CountryId); foreach (var shippingMethod in shippingMethods) { var shippingOption = new ShippingOption(); shippingOption.Name = shippingMethod.Name; shippingOption.Description = shippingMethod.Description; shippingOption.Rate = GetRate(); shippingOptions.Add(shippingOption); } return(shippingOptions); }