Exemplo n.º 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();
                }
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if(Request.QueryString["id"] == null || Request.QueryString["detailid"] == null)
                {
                    Session["lastpage"] = "admin_inspectschedules.aspx";
                    Session["error"] = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    InspectSchedId = Convert.ToInt32(Request.QueryString["id"]);
                    DetailId = Convert.ToInt32(Request.QueryString["detailid"]);
                }
                catch(FormatException fex)
                {
                    Session["lastpage"] = "admin_inspectschedules.aspx";
                    Session["error"] = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                sLastPage = "admin_inspectschedule_detail.aspx?id=" + InspectSchedId.ToString();
                sCurrentPage = "admin_inspectschedule_detail_edit.aspx?id=" + InspectSchedId.ToString() + "&detailid=" + DetailId.ToString();

                Header.AddBreadCrumb("Home", "/selectMode.aspx");
                Header.AddBreadCrumb("Administration", "/admin.aspx");
                Header.AddBreadCrumb("Inspections Manager", "/admin_inspections.aspx");
                Header.AddBreadCrumb("Inspections Schedules Manager", "/admin_inspectschedules.aspx");
                Header.AddBreadCrumb("Inspection Schedule Detail", "/" + sLastPage);
                this.PageTitle = "Inspection Schedule Detail Edit";
                Header.LeftBarHtml = "Edit Inspection Schedule";

                SaveCancelControl.CancelText= " Back ";
                SaveCancelControl.ParentPageURL = sLastPage;
                if(!IsPostBack)
                {
                    inspect = new clsInspections();
                    inspect.cAction = "S";
                    inspect.iOrgId = OrgId;
                    inspect.iInspectSchedDetailId = DetailId;
                    inspect.iInspectScheduleId = InspectSchedId;
                    ddlInspections.DataSource = new DataView(inspect.GetInspectionsList());
                    ddlInspections.DataBind();
                    if(inspect.InspectSchedDetailDetails() == -1)
                    {
                        Session["lastpage"] = sLastPage;
                        Session["error"] = _functions.ErrorMessage(159);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    lblScheduleName.Text = inspect.sInspectScheduleName.Value;
                    if(DetailId != 0)
                    {
                        ddlInspections.SelectedValue = inspect.iId.Value.ToString();
                        ddlInspections.Enabled = false;
                        tbMinDays.Text = inspect.iMinDays.Value.ToString();
                        tbMaxDays.Text = inspect.iMaxDays.Value.ToString();
                        tbTagetDays.Text = inspect.iTargetDays.Value.ToString();
                    }
                    else
                        btnDelete.Visible = false;

                }
            }
            catch(Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"] = sLastPage;
                Session["error"] = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if(inspect != null)
                    inspect.Dispose();
            }
        }