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"] = "ok_selectWorkOrder.aspx";
                    Session["error"]    = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrderId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch (FormatException fex)
                {
                    Session["lastpage"] = "ok_selectWorkOrder.aspx";
                    Session["error"]    = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                if (Request.UrlReferrer != null)
                {
                    m_sBack = Request.UrlReferrer.AbsoluteUri;
                    m_sBack = m_sBack.Remove(0, m_sBack.LastIndexOf("/") + 1);
                }
                else
                {
                    m_sBack = "ok_viewNotes.aspx?id=" + OrderId.ToString();
                }

                NextBackControl.BackText  = "<< Back";
                NextBackControl.BackPage  = m_sBack;
                NextBackControl.NextText  = "  Finish  ";
                NextBackControl.sCSSClass = "ok_input_button";

                op = new OperatorInfo(Request.Cookies["bfp_operator"].Value);

                if (!IsPostBack)
                {
                    lblFirstName.Text = op.FirstName;
                    order             = new clsWorkOrders();
                    order.iOrgId      = OrgId;
                    order.iId         = OrderId;
                    if (order.GetEquipInfo() != -1)
                    {
                        lblEquipId.Text   = order.sEquipId.Value;
                        lblEquipType.Text = order.sEquipTypeName.Value;

                        dtInstructions = order.GetInstructionByCheckOut();
                        if (!order.daScheduled.IsNull)
                        {
                            DataRow newRow = dtInstructions.NewRow();
                            newRow["vchNote"] = "Please be aware that the next date of inspection will be " + order.daScheduled.Value.ToShortDateString() + " " + order.daScheduled.Value.ToShortTimeString();
                            dtInstructions.Rows.Add(newRow);
                        }
                        repInstructions.DataSource = new DataView(dtInstructions);
                        repInstructions.DataBind();
                    }
                    else
                    {
                        Session["lastpage"] = m_sBack;
                        Session["error"]    = _functions.ErrorMessage(102);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = m_sBack;
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (order != null)
                {
                    order.Dispose();
                }
            }
        }