Esempio 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"] = "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());

                html_btnNo.Attributes.Add("onclick", "javascript:document.location='wo_viewWorkOrder.aspx?id=" + OrderId.ToString() + "'");

                if (!IsPostBack)
                {
                    order         = new clsWorkOrders();
                    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;
                    }
                    lblEquipId.Text     = order.sEquipId.Value;
                    lblWorkOrderId.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString();
                    lblTech.Text        = order.sTechName.Value;
                    lblOperator.Text    = order.sOperatorName.Value;
                    if ((WorkOrderStatus)order.iStatusId.Value != WorkOrderStatus.Closed)
                    {
                        if (order.GetDeleteAbleOrder() == 1)
                        {
                            btnYes.Enabled = true;
                        }
                        else
                        {
                            btnYes.Enabled      = false;
                            Header.ErrorMessage = _functions.ErrorMessage(146);
                        }
                    }
                    else
                    {
                        btnYes.Enabled      = false;
                        Header.ErrorMessage = _functions.ErrorMessage(145);
                    }
                }
            }
            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 (order != null)
                {
                    order.Dispose();
                }
            }
        }