private void btnFiltration_Click(object sender, System.EventArgs e) { try { equip = new clsEquipment(); equip.iOrgId = OrgId; equip.iTypeId = Convert.ToInt32(ddlEquipTypes.SelectedValue); equip.iDeptId = Convert.ToInt32(ddlDepartments.SelectedValue); equip.iLocId = Convert.ToInt32(ddlLocations.SelectedValue); equip.iIsSpare = Convert.ToInt32(ddlSpare.SelectedValue); equip.iUserId = Convert.ToInt32(ddlDrivers.SelectedValue); equip.sEquipId_Filter = _functions.ConvertToSQLFilter(tbEquipId.Text); eFilter = new EquipFilter(); eFilter.iTypeId = equip.iTypeId.Value; eFilter.iDeptId = equip.iDeptId.Value; eFilter.iLocId = equip.iLocId.Value; eFilter.iIsSpare = equip.iIsSpare.Value; eFilter.iOperatorId = equip.iUserId.Value; eFilter.sEquipId = equip.sEquipId_Filter.Value; Session["EquipFilter"] = eFilter; dgInspections.DataSource = new DataView(equip.GetEquipInspectList_Filter()); dgInspections.DataBind(); } catch (Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "wo_showEquipsForInspect.aspx"; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if (equip != null) { equip.Dispose(); } } }
private void Page_Load(object sender, System.EventArgs e) { try { OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); if (!IsPostBack) { equip = new clsEquipment(); loc = new clsLocations(); dep = new clsDepartments(); user = new clsUsers(); equip.iOrgId = OrgId; ddlEquipTypes.DataSource = new DataView(equip.GetEquipTypesList()); ddlEquipTypes.DataBind(); ddlEquipTypes.Items.Insert(0, new ListItem("All", "0")); dep.iOrgId = OrgId; ddlDepartments.DataSource = new DataView(dep.GetDepartmentsList()); ddlDepartments.DataBind(); ddlDepartments.Items.Insert(0, new ListItem("All", "0")); loc.iOrgId = OrgId; ddlLocations.DataSource = new DataView(loc.GetLocationsList()); ddlLocations.DataBind(); ddlLocations.Items.Insert(0, new ListItem("All", "0")); user.iOrgId = OrgId; user.iTypeId = (int)UserTypes.Operator; ddlDrivers.DataSource = new DataView(user.GetUserListByType()); ddlDrivers.DataBind(); ddlDrivers.Items[0].Text = "All"; if (Session["EquipFilter"] == null) { equip.iTypeId = Convert.ToInt32(ddlEquipTypes.SelectedValue); equip.iDeptId = Convert.ToInt32(ddlDepartments.SelectedValue); equip.iLocId = Convert.ToInt32(ddlLocations.SelectedValue); equip.iUserId = Convert.ToInt32(ddlDrivers.SelectedValue); equip.iIsSpare = Convert.ToInt32(ddlSpare.SelectedValue); equip.sEquipId_Filter = _functions.ConvertToSQLFilter(tbEquipId.Text); eFilter = new EquipFilter(); eFilter.iTypeId = equip.iTypeId.Value; eFilter.iDeptId = equip.iDeptId.Value; eFilter.iLocId = equip.iLocId.Value; eFilter.iIsSpare = equip.iIsSpare.Value; eFilter.iOperatorId = equip.iUserId.Value; eFilter.sEquipId = equip.sEquipId_Filter.Value; Session["EquipFilter"] = eFilter; } else { eFilter = (EquipFilter)Session["EquipFilter"]; ddlEquipTypes.Items.FindByValue(eFilter.iTypeId.ToString()).Selected = true; ddlSpare.Items.FindByValue(eFilter.iIsSpare.ToString()).Selected = true; ddlDepartments.Items.FindByValue(eFilter.iDeptId.ToString()).Selected = true; ddlLocations.Items.FindByValue(eFilter.iLocId.ToString()).Selected = true; ddlDrivers.Items.FindByValue(eFilter.iOperatorId.ToString()).Selected = true; tbEquipId.Text = _functions.ConvertFromSQLFilter(eFilter.sEquipId); equip.iTypeId = eFilter.iTypeId; equip.iDeptId = eFilter.iDeptId; equip.iLocId = eFilter.iLocId; equip.iIsSpare = eFilter.iIsSpare; equip.iUserId = eFilter.iOperatorId; equip.sEquipId_Filter = eFilter.sEquipId; } dgInspections.DataSource = new DataView(equip.GetEquipInspectList_Filter()); dgInspections.DataBind(); } } catch (Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "main.aspx"; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if (equip != null) { equip.Dispose(); } if (loc != null) { loc.Dispose(); } if (dep != null) { dep.Dispose(); } if (user != null) { user.Dispose(); } } }