protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteRegion") { RegionService.DeleteRegion(SQLDataHelper.GetInt(e.CommandArgument)); } if (e.CommandName == "AddRegion") { GridViewRow footer = grid.FooterRow; if (string.IsNullOrEmpty(((TextBox)footer.FindControl("txtNewName")).Text)) { grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ffcccc"); return; } RegionService.InsertRegion(new Region { Name = ((TextBox)footer.FindControl("txtNewName")).Text, RegionCode = ((TextBox)footer.FindControl("txtNewRegionCode")).Text, SortOrder = ((TextBox)footer.FindControl("txtNewSort")).Text.TryParseInt(), CountryID = CountryId }); grid.ShowFooter = false; } if (e.CommandName == "CancelAdd") { grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ccffcc"); grid.ShowFooter = false; } }
public ActionResult RegionDelete([DataSourceRequest] DataSourceRequest request, RegionItem regionItem) { if (regionItem != null) { service.DeleteRegion(regionItem); } return(Json(new[] { regionItem }.ToDataSourceResult(request, ModelState))); }
protected void GvShowRegion_RowDeleting(object sender, GridViewDeleteEventArgs e) { string regionID = GvShowRegion.DataKeys[e.RowIndex].Value.ToString(); var region = new Region() { Id = Convert.ToInt32(regionID) }; var regionService = new RegionService(); regionService.DeleteRegion(region); //var countryService = new CountryService(); //countryService.DeleteCountry(region); Response.Write("<script>alert('删除成功')</script>"); BindCountry(); }
protected void lbDeleteSelected_Click(object sender, EventArgs e) { if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { if (!_inverseSelection) { foreach (var id in _selectionFilter.Values) { RegionService.DeleteRegion(SQLDataHelper.GetInt(id)); } } else { var itemsIds = _paging.ItemsIds <int>("RegionID as ID"); foreach (var id in itemsIds.Where(id => !_selectionFilter.Values.Contains(id.ToString(CultureInfo.InvariantCulture)))) { RegionService.DeleteRegion(id); } } } }
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteRegion") { RegionService.DeleteRegion(Convert.ToInt32(e.CommandArgument)); } if (e.CommandName == "AddRegion") { GridViewRow footer = grid.FooterRow; if ( string.IsNullOrEmpty(((TextBox)footer.FindControl("txtNewName")).Text) || string.IsNullOrEmpty(((TextBox)footer.FindControl("txtNewNumber")).Text) ) { grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ffcccc"); return; } int temp; int.TryParse(((TextBox)footer.FindControl("txtNewSort")).Text, out temp); var region = new Region { Name = ((TextBox)footer.FindControl("txtNewName")).Text, RegionCode = ((TextBox)footer.FindControl("txtNewNumber")).Text, SortOrder = temp, CountryID = CountryID }; RegionService.InsertRegion(region); grid.ShowFooter = false; } if (e.CommandName == "CancelAdd") { grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ccffcc"); grid.ShowFooter = false; } }
public async Task <bool> DeleteRegion(string id) { return(await regionService.DeleteRegion(id)); }
public string DeleteRegion([FromRoute] int id) { return(RegionService.DeleteRegion(id, dbConn)); }