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

                sLastPage    = "admin_pmschedule_detail.aspx?id=" + PMSchedId.ToString();
                sCurrentPage = "admin_pmschedule_detail_edit.aspx?id=" + PMSchedId.ToString() + "&detailid=" + DetailId.ToString();

                Header.AddBreadCrumb("Home", "/selectMode.aspx");
                Header.AddBreadCrumb("Administration", "/admin.aspx");
                Header.AddBreadCrumb("Preventive Maintenances Schedules Manager", "/admin_pmschedules.aspx");
                Header.AddBreadCrumb("Preventive Maintenance Schedule Detail", "/" + sLastPage);
                this.PageTitle     = "PM Schedule Detail Edit";
                Header.LeftBarHtml = "Edit Preventive Maintenance Schedule";

                SaveCancelControl.CancelText    = " Back ";
                SaveCancelControl.ParentPageURL = sLastPage;

                if (!IsPostBack)
                {
                    pmitem                   = new clsPMSchedService();
                    pmitem.cAction           = "S";
                    pmitem.iOrgId            = OrgId;
                    pmitem.iPMSchedId        = PMSchedId;
                    pmitem.iPMSchedDetailId  = DetailId;
                    ddlPMServices.DataSource = pmitem.GetPMServicesList();
                    ddlPMServices.DataBind();
                    ddlMeasures.DataSource = pmitem.GetUnitMeasureList();
                    ddlMeasures.DataBind();
                    if (pmitem.PMScheduleDetails() == -1)
                    {
                        Header.ErrorMessage = _functions.ErrorMessage(169);
                        return;
                    }
                    lblScheduleName.Text = pmitem.sPMSchedName.Value;

                    if (DetailId != 0)
                    {
                        if (pmitem.PMSchedServiceDetails() == -1)
                        {
                            Header.ErrorMessage = _functions.ErrorMessage(174);
                            return;
                        }
                        ddlPMServices.SelectedValue = pmitem.iPMServiceId.Value.ToString();
                        ddlMeasures.SelectedValue   = pmitem.iUnitMeasureId.Value.ToString();
                        tbDays.Text  = pmitem.iDays.IsNull?"":pmitem.iDays.Value.ToString();
                        tbUnits.Text = pmitem.dmUnits.IsNull?"":Convert.ToDouble(pmitem.dmUnits.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 (pmitem != null)
                {
                    pmitem.Dispose();
                }
            }
        }