Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        private void btNext_FormSubmit(object sender, EventArgs e)
        {
            try
            {
                order = new clsWorkOrders();

                if(ddlCategory.SelectedIndex != 0 && tbDesc.Text.Length != 0)
                {
                    order.cAction = "U";
                    order.iOrgId = OrgId;
                    order.iReportedIssueId = 0;
                    order.iRepairCatId = Convert.ToInt32(ddlCategory.SelectedValue);
                    order.sReportDesc = tbDesc.Text;
                    order.iId = OrderId;
                    order.iServiceResultId = SqlInt32.Null;
                    order.iServiceCheckId = SqlInt32.Null;
                    order.iRepairMultId = SqlInt32.Null;
                    if(order.WorkOrderReportedIssuesDetail() == -1)
                    {
                        Session["lastpage"] = m_sBackUrl;
                        Session["error"] = _functions.ErrorMessage(121);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                }
                if(m_sBack == "open")
                    Response.Redirect("wo_addPreventiveMaintenance.aspx?id=" + OrderId.ToString(), false);
                else
                {
                    // redirect to finish screen
                    order.iOrgId = OrgId;
                    order.iId = OrderId;

                    if(order.GetWorkOrderId() == -1)
                    {
                        Session["lastpage"] = m_sBackUrl;
                        Session["error"] = _functions.ErrorMessage(102);
                        Response.Redirect("error.aspx", false);
                        return;
                    }

                    BackFinishScreen finish = new BackFinishScreen();
                    finish.sMainText = "The Work Order " + order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString() + " has been created successfully!";

                    finish.bMainMenuVisible = true;
                    finish.sMainMenuText = "[Return to Main Menu]";
                    finish.sMainMenuURL = "main.aspx";

                    finish.bContinueVisible = true;
                    finish.sContinueText = "[Continue to Check-In Equipment by Technician]";
                    finish.sContinueURL = "wo_viewCheckIn.aspx?id=" + OrderId.ToString();

                    finish.bViewVisible = true;
                    finish.sViewText = "[View the Scheduled Work Order]";
                    finish.sViewURL = "wo_viewWorkOrder.aspx?id=" + OrderId.ToString();

                    finish.bAdditionalVisible = true;
                    finish.sAdditionalText = "[Create a New Work Order]";
                    finish.sAdditionalURL = "wo_default.aspx";

                    finish.bPrintVisible = false;

                    Session["BackFinish"] = finish;

                    Response.Redirect("wo_finish.aspx", 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();
            }
        }