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"] = "main.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { OrderId = Convert.ToInt32(Request.QueryString["id"]); } catch(FormatException fex) { Session["lastpage"] = "main.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } // 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()); SaveCancelControl.ParentPageURL = this.ParentPageURL; SaveCancelControl.ButtonText = " Close & Sign "; if(!IsPostBack) { order = new clsWorkOrders(); user = new clsUsers(); order.cAction = "S"; order.iOrgId = OrgId; order.iId = OrderId; if(order.WorkOrderDetails() == -1) { Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();; Session["error"] = _functions.ErrorMessage(120); Response.Redirect("error.aspx", false); return; } if(!user.IsTechnician(_functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true))) { Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString(); Session["error"] = _functions.ErrorMessage(131); Response.Redirect("error.aspx", false); return; } if(order.iTechId.Value == 0) { Signature.sError = _functions.ErrorMessage(143); SaveCancelControl.EnableSave = false; } if(order.GetCompleteAbleOrder() != 1) { Signature.sError = _functions.ErrorMessage(142); SaveCancelControl.EnableSave = false; } lblWorkOrderId.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString(); lblEquipId.Text = order.sEquipId.Value; lblSpareEquipId.Text = order.sSpareEquipId.Value; lblTech.Text = order.sTechName.Value; lblOperator.Text = order.sOperatorName.Value; tbCleanliness.Text = order.sCleanliness.Value; if(order.daClosed.IsNull) adtClosed.Date = DateTime.Now; else adtClosed.Date = order.daClosed.Value; if(order.iStatusId.Value == (int)WorkOrderStatus.Closed || order.iStatusId.Value == (int)WorkOrderStatus.Scheduled) { tbCleanliness.Enabled = false; tbTechNote.Enabled = false; tbCheckOutNote.Enabled = false; Signature.Enabled = false; SaveCancelControl.EnableSave = false; Signature.sError = _functions.ErrorMessage(141); } // show notes order.iItemId = OrderId; order.iNoteTypeId = (int)NoteTypes.TechnicianNote; repTechNotes.DataSource = new DataView(order.GetNotesList()); repTechNotes.DataBind(); order.iNoteId = 0; order.iNoteTypeId = (int)NoteTypes.CheckOutNote; if(order.NoteDetails() != -1) { tbCheckOutNote.Text = order.sNote.Value; } ShowCustomFields(); } } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString(); Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(user != null) user.Dispose(); if(order != null) order.Dispose(); } }
private void Page_Load(object sender, System.EventArgs e) { try { 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"]); OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); } catch(FormatException fex) { Session["lastpage"] = "wo_default.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } if(Request.QueryString["repairid"] != null) RepairId = Convert.ToInt32(Request.QueryString["repairid"]); else RepairId = 0; html_btnBack.Attributes.Add("onclick", "document.location='wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "&#TimeLog';"); 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()); dtNow = DateTime.Now; if(!IsPostBack) { rdiStartTime.SelectedDate = dtNow; rdiStopTime.SelectedDate = dtNow; order = new clsWorkOrders(); user = new clsUsers(); order.cAction = "S"; order.iOrgId = OrgId; order.iId = OrderId; user.iOrgId = OrgId; user.iOrderId = OrderId; user.iTypeId = (int)UserTypes.Technician; DataTable dtTechList = user.GetUserListByType(); dtTechList.Rows[0].Delete(); ddlTechnicians.DataSource = new DataView(dtTechList); ddlTechnicians.DataBind(); DataTable dtRepairList = order.GetRepairsShortList(); dtRepairList.Rows[0].Delete(); ddlRepairs.DataSource = new DataView(dtRepairList); ddlRepairs.DataBind(); if(order.WorkOrderDetails() == -1) { Session["lastpage"] = this.ParentPageURL; Session["error"] = _functions.ErrorMessage(120); Response.Redirect("error.aspx", false); return; } if(!user.IsTechnician(_functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true))) { Session["lastpage"] = this.ParentPageURL; Session["error"] = _functions.ErrorMessage(131); Response.Redirect("error.aspx", false); return; } lblWorkOrderId.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString(); lblEquipId.Text = order.sEquipId.Value; lblOperator.Text = order.sOperatorName.Value; lblTech.Text = order.sTechName.Value; if(user.GetTechnicianInfo() != -1) { tbHourlyRate.Text = user.dmHourlyRate.Value.ToString("F"); if(!user.bTechCanViewHourlyRate.Value) { ViewState["HourlyRate"] = user.dmHourlyRate.Value; html_tblMain.Rows[12].Visible = false; html_trTotalCosts.Visible = false; } else { ViewState["HourlyRate"] = null; html_tblMain.Rows[12].Visible = true; html_trTotalCosts.Visible = true; } } else { html_trTotalCosts.Visible = true; html_tblMain.Rows[12].Visible = true; tbHourlyRate.Text = "0.0"; ViewState["HourlyRate"] = null; } if(ddlTechnicians.Items.FindByValue(order.iTechId.Value.ToString()) != null) { ddlTechnicians.SelectedValue = order.iTechId.Value.ToString(); } else { ddlTechnicians.SelectedIndex = 0; } if(ddlRepairs.Items.FindByValue(RepairId.ToString()) != null) { ddlRepairs.SelectedValue = RepairId.ToString(); } else { ddlRepairs.SelectedIndex = 0; } order.iTechId = 0; dtTimeLog = order.GetTimeLogList(); if(dtTimeLog.Rows.Count > 0) { repTimeLog.DataSource = new DataView(dtTimeLog); repTimeLog.DataBind(); html_tblNoneTimeLog.Visible = false; lblTotalHours.Text = order.sReportDesc.Value; lblTotalCosts.Text = order.sDecs.Value; } else { html_tblNoneTimeLog.Visible = true; repTimeLog.Visible = false; html_trTotalHours.Visible = false; html_trTotalCosts.Visible = false; } } } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = this.ParentPageURL; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(user != null) user.Dispose(); if(order != null) order.Dispose(); } }
private void Page_Load(object sender, System.EventArgs e) { string sDomenName, sReportPath; try { OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); if(Session["reload"] != null) { if((bool)Session["reload"] == true) { Session["reload"] = null; Response.Redirect((string)Session["RedirectPath"], false); Session["RedirectPath"] = null; return; } } if(Request.QueryString["id"] == null || Request.QueryString["inspectid"] == null) { Session["lastpage"] = "main.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { OrderId = Convert.ToInt32(Request.QueryString["id"]); InspectId = Convert.ToInt32(Request.QueryString["inspectid"]); } catch(FormatException fex) { Session["lastpage"] = "main.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } // 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()); SaveCancelControl.ParentPageURL = ParentPageURL; SaveCancelControl.EnableSave = true; SaveCancelControl.ButtonText = " Complete/Sign "; SaveCancelControl.CancelText = " Back "; if(!IsPostBack) { sReportPath = _functions.GetValueFromConfig("SQLRS.Folder"); hlPrintInspectRequest.NavigateUrl = "ReportViewer.aspx?Report=" + sReportPath + "%2fInspectionRequest&OrgId=" + OrgId.ToString() + "&OrderId=" + OrderId.ToString() + "&InspectId=" + InspectId.ToString(); hlPrintCompletedInstect.NavigateUrl = "ReportViewer.aspx?Report=" + sReportPath + "%2fCompletedInspection&OrgId=" + OrgId.ToString() + "&OrderId=" + OrderId.ToString() + "&InspectId=" + InspectId.ToString(); user = new clsUsers(); order = new clsWorkOrders(); order.iOrgId = OrgId; order.iId = OrderId; order.iInspectionId = InspectId; order.iTechId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true); switch(order.GetInfoForInspection()) { case 1: tableMain.Rows[19].Visible = false; tableMain.Rows[20].Visible = false; tableMain.Rows[21].Visible = false; tableMain.Rows[22].Visible = true; tableMain.Rows[23].Visible = true; tableMain.Rows[24].Visible = false; tableMain.Rows[25].Visible = false; SaveCancelControl.EnableSave = false; order.iDocumentId = InspectId; order.iDocumentTypeId = (int)DocumentTypes.InspectionCompleted; if(order.GetSignedDocument() != -1) { hlPrintInspectRequest.Enabled = false; hlPrintCompletedInstect.Enabled = true; lblSign.Text = order.sUserName.Value; lblSignDate.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString(); } else { hlPrintInspectRequest.Enabled = true; hlPrintCompletedInstect.Enabled = false; lblSign.Text = " "; } break; case -1: Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString(); Session["error"] = _functions.ErrorMessage(124); Response.Redirect("error.aspx", false); return; default: hlPrintCompletedInstect.Enabled = false; adtInspection.Date = DateTime.Now; tableMain.Rows[22].Visible = false; break; } if(!user.IsTechnician(_functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true))) { SaveCancelControl.EnableSave = false; } ViewState["EquipId"] = order.iEquipId.Value; ViewState["InspectSchedDetailId"] = order.iInspectSchedDetailId.Value; lblInspectName.Text = order.sInspectionName.Value; lblInspectSchedule.Text = order.sInspectSchedule.Value; lblTargetDaysOut.Text = order.iInspectTargetDays.Value.ToString() + " days"; lblEquipId.Text = order.sEquipId.Value; lblEquipMake.Text = order.sEquipMake.Value; lblEquipModel.Text = order.sEquipModel.Value; repInspectItems.DataSource = new DataView(order.GetWorkOrderInspectItems()); repInspectItems.DataBind(); } } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString(); Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(user != null) user.Dispose(); if(order != null) order.Dispose(); } }