private void Page_Load(object sender, System.EventArgs e) { try { OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); if(Request.QueryString["id"] == null) { Session["lastpage"] = "wo_default.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { OrderId = Convert.ToInt32(Request.QueryString["id"]); } catch(FormatException fex) { Session["lastpage"] = "wo_default.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } Header.AddJavaScriptFile("/OpenWindows.js"); // if the coming was from order detail screen or for the past work order creating if(Request.QueryString["back"] != null) { if(Request.QueryString["back"] == "past") { IsPast = true; tblMain.Rows[4].Visible = true; tblMain.Rows[5].Visible = false; m_sBackUrl = "wo_addInspections.aspx?back=past&id=" + OrderId.ToString(); m_sLastPage = "wo_editAddInfo.aspx?back=past&id=" + OrderId.ToString() + "&equipid=0"; NextBackControl.BackPage = m_sLastPage; } else { tblMain.Rows[4].Visible = false; tblMain.Rows[5].Visible = true; m_sBackUrl = "wo_addInspections.aspx?id=" + OrderId.ToString() + "&back=view"; m_sLastPage = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString(); // getting the Bread Crumbs from Cookie and add last item if (Request.Cookies.Count > 0 && Request.Cookies["bfp_navigate"] != null) Header.BrdCrumbsSerialization = Request.Cookies["bfp_navigate"].Value; Header.AddBreadCrumb("Work Order Detail", "/wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#Issues"); SaveCancelControl.ParentPageURL = this.ParentPageURL; SaveCancelControl.ButtonText = " Save "; } } else { // the coming was usual from previous wizard screen is the Add Preventive Maintenance tblMain.Rows[4].Visible = true; tblMain.Rows[5].Visible = false; m_sBackUrl = "wo_addInspections.aspx?id=" + OrderId.ToString(); m_sLastPage = "wo_addPreventiveMaintenance.aspx?id=" + OrderId.ToString() + "&back=inspect"; NextBackControl.BackPage = "wo_addPreventiveMaintenance.aspx?id=" + OrderId.ToString() + "&back=inspect"; } // reloading if coming from the Inspection History screen if(Session["reload"] != null) { if((bool)Session["reload"] == true) { Session["reload"] = null; Response.Redirect(m_sBackUrl, false); return; } } if(!IsPostBack) { order = new clsWorkOrders(); order.iOrgId = OrgId; order.iId = OrderId; if(order.GetWorkOrderId() == -1) { Session["lastpage"] = m_sLastPage; Session["error"] = _functions.ErrorMessage(120); Response.Redirect("error.aspx", false); } ViewState["WorkOrderCreatedDate"] = order.daCreated.Value; ViewState["WorkOrderNumber"] = order.iWorkOrderNumber.Value; if(IsPast) order.daCurrentDate = order.daCreated; else order.daCurrentDate = DateTime.Now; dgInspections.DataSource = new DataView(order.GetInspectionsListForWorkOrder()); dgInspections.DataBind(); dtFutureInspections = order.GetFutureInspections(); if(dtFutureInspections.Rows.Count > 0) { dgFutureInspections.DataSource = new DataView(dtFutureInspections); dgFutureInspections.DataBind(); } else { tblMain.Rows[2].Visible = false; tblMain.Rows[3].Visible = false; } } } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = m_sLastPage; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(order != null) order.Dispose(); } }
private void dgFutureInspections_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { try { int FutureOrderId; if(e.CommandName == "Assign") { order = new clsWorkOrders(); order.iId = OrderId; order.iOrgId = OrgId; order.iWOInspectionId = Convert.ToInt32(e.Item.Cells[0].Text); // move inspection from future work order if(order.SetFutureInspection() == -1) { Session["lastpage"] = m_sBackUrl; Session["error"] = _functions.ErrorMessage(124); Response.Redirect("error.aspx", false); } // delete future empty work order if(order.DeleteFutureWorkOrder() == -1) { Session["lastpage"] = m_sBackUrl; Session["error"] = _functions.ErrorMessage(120); Response.Redirect("error.aspx", false); } order.iId = OrderId; dgInspections.DataSource = new DataView(order.GetInspectionsListForWorkOrder()); dgInspections.DataBind(); dtFutureInspections = order.GetFutureInspections(); if(dtFutureInspections.Rows.Count > 0) { dgFutureInspections.DataSource = new DataView(dtFutureInspections); dgFutureInspections.DataBind(); } else { tblMain.Rows[2].Visible = false; tblMain.Rows[3].Visible = false; } } } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = m_sBackUrl; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(order != null) order.Dispose(); } }