Exemple #1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "list.aspx";
                    Session["error"]    = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    EquipId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch (FormatException fex)
                {
                    Session["lastpage"] = "list.aspx";
                    Session["error"]    = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                string [,] arrBrdCrumbs = new string [3, 2];
                arrBrdCrumbs[0, 0]      = "main.aspx";
                arrBrdCrumbs[0, 1]      = "Home";
                arrBrdCrumbs[1, 0]      = "list.aspx";
                arrBrdCrumbs[1, 1]      = "Equipment List";
                arrBrdCrumbs[2, 0]      = "view.aspx?id=" + EquipId + "";
                arrBrdCrumbs[2, 1]      = "Equipment Detail";
                PageTitle        = "Equipment-Edit Alt";
                Header.BrdCrumbs = ParseBreadCrumbs(arrBrdCrumbs, PageTitle);
                Header.PageTitle = PageTitle;

                SaveCancelControl.ParentPageURL = ParentPageURL;

                if (!IsPostBack)
                {
                    equip         = new clsEquipment();
                    pm            = new clsPMSchedService();
                    inspec        = new clsInspections();
                    equip.cAction = "S";
                    equip.iOrgId  = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                    equip.iId     = EquipId;
                    pm.iOrgId     = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                    inspec.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                    ddStatusId.DataTextField  = "vchName";
                    ddStatusId.DataValueField = "Id";
                    ddStatusId.DataSource     = new DataView(equip.GetEquipStatusList());
                    ddStatusId.DataBind();

                    ddPMScheduleId.DataTextField  = "vchName";
                    ddPMScheduleId.DataValueField = "Id";
                    ddPMScheduleId.DataSource     = new DataView(pm.GetPMSchedulesList());
                    ddPMScheduleId.DataBind();
                    ddPMScheduleId.Items.Insert(0, new ListItem("", "0"));

                    ddInspectionId.DataTextField  = "vchName";
                    ddInspectionId.DataValueField = "Id";
                    ddInspectionId.DataSource     = new DataView(inspec.GetInspectionsList());
                    ddInspectionId.DataBind();
                    ddInspectionId.Items.Insert(0, new ListItem("", "0"));

                    // getting equipment's data
                    if (equip.EquipmentDetail() != -1)
                    {
                        ddStatusId.SelectedValue     = Convert.ToString(equip.iStatusId);
                        ddPMScheduleId.SelectedValue = Convert.ToString(equip.iPMSched);
                        ddInspectionId.SelectedValue = Convert.ToString(equip.iInspectId);
                        tbCurrentUnits.Text          = Convert.ToString(equip.iCurrentUnits);
                    }
                    else
                    {
                        Session["lastpage"] = ParentPageURL;
                        Session["error"]    = _functions.ErrorMessage(102);
                        Response.Redirect("error.aspx", false);
                    }
                }
            }
            catch (Exception ex)
            {
                _functions.Log("Application error: \n" + ex.ToString());
                Session["lastpage"]     = ParentPageURL;
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (inspec != null)
                {
                    inspec.Dispose();
                }
                if (pm != null)
                {
                    pm.Dispose();
                }
                if (equip != null)
                {
                    equip.Dispose();
                }
            }
        }