protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int rowIndex = e.RowIndex; Company company = new Company(); company.Company_id = Convert.ToInt32(this.GridView1.DataKeys[rowIndex].Value); CompanyProvider provider = new CompanyProvider(); if (provider.Delete(company)) { this.Alert("删除成功!!!"); if (this.txt_Name.Text == "") { this.ListPager1.RecordCount = this.ListPager1.RecordCount - 1; this.BindSource(null); } else { this.ListPager1.RecordCount = this.ListPager1.RecordCount - 1; this.BindSource("%" + this.txt_Name.Text + "%"); } } }
/// <summary> /// 删除公司信息 /// </summary> /// <returns></returns> public ActionResult Delete() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); CompanyProvider provider = new CompanyProvider(); int line = provider.Delete(CompanyID); DataResult dataResult = new DataResult(); if (line > 0) { dataResult.Code = (int)EResponseCode.Success; dataResult.Message = "删除成功"; } else { dataResult.Code = (int)EResponseCode.Success; dataResult.Message = "删除失败"; } return(Content(JsonHelper.SerializeObject(dataResult))); }
public ResponseModel Delete(int id) { try { CompanyProvider companyProvider = new CompanyProvider(_context); companyProvider.Delete(id); ResponseModel objResponseModel = new ResponseModel { Message = "Successfully Deleted Company", StatusCode = 1 }; return(objResponseModel); } catch (Exception ex) { ResponseModel objResponseModel = new ResponseModel { Message = ex.Message, StatusCode = 0 }; return(objResponseModel); } }
protected void GridView_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e) { switch (e.Parameters) { case "CloneRow": HttpContext.Current.Session["isCloneRow_Com"] = true; GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString()); break; case "DetailRow": HttpContext.Current.Session["isDetailRow_Com"] = true; GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString()); break; case "Actived": if (GridView.FocusedRowIndex >= 0) { var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString(); CompanyProvider.SetActived(itemID, true, User.Identity.Name); GridView.DataBind(); UpdateNavBarName(); } GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString()); break; case "InActived": if (GridView.FocusedRowIndex >= 0) { var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString(); CompanyProvider.SetActived(itemID, false, User.Identity.Name); GridView.DataBind(); UpdateNavBarName(); } GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString()); break; case "Blocked": if (GridView.FocusedRowIndex >= 0) { var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString(); CompanyProvider.SetBlocked(itemID, true, User.Identity.Name); GridView.DataBind(); UpdateNavBarName(); } GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString()); break; case "UnBlocked": if (GridView.FocusedRowIndex >= 0) { var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString(); CompanyProvider.SetBlocked(itemID, false, User.Identity.Name); GridView.DataBind(); UpdateNavBarName(); } GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString()); break; case "InActivedBlocked": if (GridView.FocusedRowIndex >= 0) { var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString(); CompanyProvider.SetActivedBlocked(itemID, false, true, User.Identity.Name); GridView.DataBind(); UpdateNavBarName(); } GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString()); break; case "ActivedUnBlocked": if (GridView.FocusedRowIndex >= 0) { var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString(); CompanyProvider.SetActivedBlocked(itemID, true, false, User.Identity.Name); GridView.DataBind(); UpdateNavBarName(); } GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString()); break; case "Delete": if (GridView.FocusedRowIndex >= 0) { var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString(); CompanyProvider.Delete(itemID); //CompanyProvider.Delete(itemID); GridView.DataBind(); UpdateNavBarName(); } GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString()); break; //case "Delete": //List<int> selectedIds = GridView.GetSelectedFieldValues("Id").ConvertAll(id => (int)id); //foreach (var item in selectedIds) //{ // CompanyProvider.DeleteSuit(item, false); // HttpContext.Current.Session["isActBloChanged_Com"] = true; //} //GridView.DataBind(); //GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString()); //break; } GridView.JSProperties["cpParameters"] = e.Parameters; }