protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { TaxServices.DeleteTax(int.Parse((string)e.CommandArgument)); } if (e.CommandName == "AddTax") { GridViewRow footer = grid.FooterRow; string name = ((TextBox)footer.FindControl("txtNewName")).Text; string regNumber = ((TextBox)footer.FindControl("txtNewRegNumber")).Text; bool enabled = Convert.ToBoolean(((DropDownList)footer.FindControl("ddlNewEnabled")).SelectedValue); int countryId = Convert.ToInt32(((DropDownList)footer.FindControl("ddlCountry")).SelectedValue); if ((name.Trim().Length != 0) && (regNumber.Trim().Length != 0)) { var tax = new TaxElement { CountryID = countryId, DependsOnAddress = TypeRateDepends.Default, Enabled = enabled, FederalRate = 0.0M, Name = name, Priority = 1, RegNumber = regNumber, ShowInPrice = false, Type = (RateType)1 }; TaxServices.CreateTax(tax); //if (tax.TaxId != 0) // Response.Redirect("Tax.aspx?TaxID=" + tax.TaxId); } grid.ShowFooter = false; } }
//Delete!! protected void lbDeleteSelected_Click(object sender, EventArgs e) { if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { if (!_inverseSelection) { foreach (var id in _selectionFilter.Values) { TaxServices.DeleteTax(Convert.ToInt32(id)); } } else { var itemsIds = _paging.ItemsIds <int>("TaxID as ID"); foreach (int tax in itemsIds.Where(tax => !_selectionFilter.Values.Contains(tax.ToString(CultureInfo.InvariantCulture)))) { TaxServices.DeleteTax(tax); } } } }
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { TaxServices.DeleteTax(int.Parse((string)e.CommandArgument)); } if (e.CommandName == "AddTax") { GridViewRow footer = grid.FooterRow; string name = ((TextBox)footer.FindControl("txtNewName")).Text; float rate = ((TextBox)footer.FindControl("txtNewRate")).Text.TryParseFloat(); bool enabled = SQLDataHelper.GetBoolean(((DropDownList)footer.FindControl("ddlNewEnabled")).SelectedValue); bool showInPrice = SQLDataHelper.GetBoolean(((DropDownList)footer.FindControl("ddlNewShowInPrice")).SelectedValue); if ((name.Trim().Length != 0)) { var tax = new TaxElement { Enabled = enabled, Rate = rate, Name = name, ShowInPrice = showInPrice }; TaxServices.CreateTax(tax); } grid.ShowFooter = false; } }