private void grdShippingRates_ItemCommand(object source, DataGridCommandEventArgs e) { // Add the new item to the database. if (e.CommandName == "Add" && Page.IsValid) { DataGridItem item = e.Item; TextBox txtNewDescription = (TextBox)item.FindControl("txtNewDescription"); string description = txtNewDescription.Text; TextBox txtNewMinWeight = (TextBox)item.FindControl("txtNewMinWeight"); Decimal newMinWeight = Decimal.Parse(txtNewMinWeight.Text); TextBox txtNewMaxWeight = (TextBox)item.FindControl("txtNewMaxWeight"); Decimal newMaxWeight = Decimal.Parse(txtNewMaxWeight.Text); TextBox txtNewCost = (TextBox)item.FindControl("txtNewCost"); Decimal newCost = Decimal.Parse(txtNewCost.Text); ShippingInfo newShippingInfo = new ShippingInfo { Description = description, MinWeight = newMinWeight, MaxWeight = newMaxWeight, Cost = newCost, ApplyTaxRate = cbApplyTaxRate.Checked }; _controller.AddShippingRate(PortalId, newShippingInfo); BindShippingRates(); } }
private void btnSaveShippingFee_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } bool applyTaxRate = cbApplyTaxRate.Checked; // Loop through the items in the datagrid. foreach (DataGridItem di in grdShippingRates.Items) { // Make sure this is an item and not the header or footer. if (di.ItemType == ListItemType.Item || di.ItemType == ListItemType.AlternatingItem) { // Get the current row for update or delete operations later. int ID = (int)grdShippingRates.DataKeys[di.ItemIndex]; // Check if this one needs to be deleted. if (((CheckBox)di.FindControl("chkDelete")).Checked) { _controller.DeleteShippingRate(ID); } else { // Verify values TextBox txtDescription = (TextBox)di.FindControl("txtDescription"); string description = txtDescription.Text; TextBox txtMinWeight = (TextBox)di.FindControl("txtMinWeight"); Decimal minWeight = Decimal.Parse(txtMinWeight.Text); TextBox txtMaxWeight = (TextBox)di.FindControl("txtMaxWeight"); Decimal maxWeight = Decimal.Parse(txtMaxWeight.Text); TextBox txtCost = (TextBox)di.FindControl("txtCost"); Decimal cost = Decimal.Parse(txtCost.Text); // Update the row ShippingInfo shippingInfo = new ShippingInfo { ID = ID, Description = description, MinWeight = minWeight, MaxWeight = maxWeight, Cost = cost, ApplyTaxRate = applyTaxRate }; _controller.UpdateShippingRate(shippingInfo); } } } BindShippingRates(); InvokeEditComplete(); }
public void AddShippingRate(int portalID, ShippingInfo shippingInfo) { DataProvider.Instance().ExecuteNonQuery("Store_ShippingRates_AddShippingRate", portalID, shippingInfo.Description, shippingInfo.MinWeight, shippingInfo.MaxWeight, shippingInfo.Cost, shippingInfo.ApplyTaxRate); }
public void UpdateShippingRate(ShippingInfo shippingInfo) { DataProvider.Instance().ExecuteNonQuery("Store_ShippingRates_UpdateShippingRate", shippingInfo.ID, shippingInfo.Description, shippingInfo.MinWeight, shippingInfo.MaxWeight, shippingInfo.Cost, shippingInfo.ApplyTaxRate); }
private void btnSaveShippingFee_Click(object sender, EventArgs e) { // Loop through the items in the datagrid. ShippingController controller = new ShippingController(); ExpandShippingAdmin(); foreach (DataGridItem di in grdShippingRates.Items) { // Make sure this is an item and not the header or footer. if (di.ItemType == ListItemType.Item || di.ItemType == ListItemType.AlternatingItem) { // Get the current row for update or delete operations later. int ID = (int)grdShippingRates.DataKeys[di.ItemIndex]; // See if this one needs to be deleted. if (((CheckBox)di.FindControl("chkDelete")).Checked) { controller.DeleteShippingRate(ID); } else { // Update the row instead. ShippingInfo shippingInfo = new ShippingInfo(); shippingInfo.ID = ID; // Ajouté : Localisation des messages d'erreur if (((TextBox)di.FindControl("lblDescription")).Text.Length == 0) { ShowError(Localization.GetString("ErrorRateDescription", this.LocalResourceFile), ((TextBox)di.FindControl("lblDescription"))); return; } shippingInfo.Description = ((TextBox)di.FindControl("lblDescription")).Text; ClearError(((TextBox)di.FindControl("lblDescription"))); try { shippingInfo.MinWeight = Decimal.Parse(((TextBox)di.FindControl("lblMinWeight")).Text); ClearError(((TextBox)di.FindControl("lblMinWeight"))); } catch (Exception) { ShowError(Localization.GetString("ErrorMinWeight", this.LocalResourceFile), ((TextBox)di.FindControl("lblMinWeight"))); return; } try { shippingInfo.MaxWeight = Decimal.Parse(((TextBox)di.FindControl("lblMaxWeight")).Text); ClearError(((TextBox)di.FindControl("lblMaxWeight"))); } catch (Exception) { ShowError(Localization.GetString("ErrorMaxWeight", this.LocalResourceFile), ((TextBox)di.FindControl("lblMaxWeight"))); return; } try { shippingInfo.Cost = Decimal.Parse(((TextBox)di.FindControl("lblCost")).Text); ClearError(((TextBox)di.FindControl("lblCost"))); } catch (Exception) { ShowError(Localization.GetString("ErrorCost", this.LocalResourceFile), ((TextBox)di.FindControl("lblCost"))); return; } controller.UpdateShippingRate(shippingInfo); } } } BindShippingRates(); lblError.Visible = false; }
private void grdShippingRates_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { // Add the new item to the dataset. I use an array here for efficiency. if (e.CommandName == "Add") { // Ajouté : Localisation des messages d'erreur ExpandShippingAdmin(); ShippingInfo newShippingInfo = new ShippingInfo(); if (((TextBox)e.Item.FindControl("txtNewDescription")).Text.Length == 0) { ShowError(Localization.GetString("ErrorRateDescription", this.LocalResourceFile), ((TextBox)e.Item.FindControl("txtNewDescription"))); return; } newShippingInfo.Description = ((TextBox)e.Item.FindControl("txtNewDescription")).Text; ClearError(((TextBox)e.Item.FindControl("txtNewDescription"))); try { newShippingInfo.MinWeight = Decimal.Parse(((TextBox)e.Item.FindControl("txtNewMinWeight")).Text); ClearError(((TextBox)e.Item.FindControl("txtNewMinWeight"))); } catch (Exception) { ShowError(Localization.GetString("ErrorMinWeight", this.LocalResourceFile), ((TextBox)e.Item.FindControl("txtNewMinWeight"))); return; } try { newShippingInfo.MaxWeight = Decimal.Parse(((TextBox)e.Item.FindControl("txtNewMaxWeight")).Text); ClearError(((TextBox)e.Item.FindControl("txtNewMaxWeight"))); } catch (Exception) { ShowError(Localization.GetString("ErrorMaxWeight", this.LocalResourceFile), ((TextBox)e.Item.FindControl("txtNewMaxWeight"))); return; } try { newShippingInfo.Cost = Decimal.Parse(((TextBox)e.Item.FindControl("txtNewCost")).Text); ClearError(((TextBox)e.Item.FindControl("txtNewCost"))); } catch (Exception) { ShowError(Localization.GetString("ErrorCost", this.LocalResourceFile), ((TextBox)e.Item.FindControl("txtNewCost"))); return; } ShippingController controller = new ShippingController(); controller.AddShippingRate(PortalId, newShippingInfo); BindShippingRates(); lblError.Visible = false; } }
public void UpdateShippingRate(ShippingInfo shippingInfo) { DataProvider.Instance().UpdateShippingRate(shippingInfo.ID, shippingInfo.Description, shippingInfo.MinWeight, shippingInfo.MaxWeight, shippingInfo.Cost); }
public void AddShippingRate(int portalID, ShippingInfo shippingInfo) { DataProvider.Instance().AddShippingRate(portalID, shippingInfo.Description, shippingInfo.MinWeight, shippingInfo.MaxWeight, shippingInfo.Cost); }