private void btnAddInspection_Click(object sender, System.EventArgs e) { try { inspect = new clsInspections(); inspect.iOrgId = OrgId; inspect.iId = 0; inspect.cAction = "U"; inspect.sInspectionName = tbInspectionName.Text; tbInspectionName.Text = ""; if(inspect.InspectionDetails() == -1) { Session["lastpage"] = "admin_inspections.aspx"; Session["error"] = _functions.ErrorMessage(124); Response.Redirect("error.aspx", false); return; } ShowInspections(); } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "admin_inspections.aspx"; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(inspect != null) inspect.Dispose(); } }
private void dgInspections_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { try { inspect = new clsInspections(); inspect.iOrgId = OrgId; inspect.iId = Convert.ToInt32(e.Item.Cells[0].Text); switch(e.CommandName) { case "Delete": inspect.cAction = "D"; switch(inspect.InspectionDetails()) { case -1: Session["lastpage"] = "admin_inspections.aspx"; Session["error"] = _functions.ErrorMessage(124); Response.Redirect("error.aspx", false); return; case 1: Header.ErrorMessage = _functions.ErrorMessage(154); break; case 2: Header.ErrorMessage = _functions.ErrorMessage(155); break; case 0: dgInspections.EditItemIndex = -1; ShowInspections(); break; default: break; } break; case "Cancel": dgInspections.EditItemIndex = -1; ShowInspections(); break; case "Edit": dgInspections.EditItemIndex = e.Item.ItemIndex; ShowInspections(); break; case "Update": inspect.cAction = "U"; inspect.sInspectionName = ((TextBox)e.Item.FindControl("tbNameEdit")).Text; if(inspect.InspectionDetails() == -1) { Session["lastpage"] = "admin_inspections.aspx"; Session["error"] = _functions.ErrorMessage(124); Response.Redirect("error.aspx", false); return; } dgInspections.EditItemIndex = -1; ShowInspections(); break; default: break; } } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "admin_inspections.aspx"; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(inspect != null) inspect.Dispose(); } }