Example #1
0
        private void ShowPMItems()
        {
            try
            {
                pmsched                = new clsPMSchedService();
                pmsched.iOrgId         = OrgId;
                pmsched.iInspectItemId = ItemId;
                dsPMSchedServices      = pmsched.GetPMSchedPMServicesList();
                dsPMSchedServices.Relations.Add(new DataRelation("Schedules_Services", dsPMSchedServices.Tables["Table"].Columns["Id"], dsPMSchedServices.Tables["Table1"].Columns["PMSchedId"]));

                ddlPMSchedules.DataSource = dsPMSchedServices;
                ddlPMSchedules.DataMember = "Table";
                ddlPMSchedules.DataBind();

                ddlPMServices.DataSource = dsPMSchedServices;
                ddlPMServices.DataMember = "Table1";
                ddlPMServices.DataBind();

                ListLink.Enabled = true;
                ListLink.DataBind();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if (pmsched != null)
                {
                    pmsched.Dispose();
                }
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if (!IsPostBack)
                {
                    pmitems                  = new clsPMSchedService();
                    pmitems.iOrgId           = OrgId;
                    dgPMSchedules.DataSource = pmitems.GetPMSchedulesList();
                    dgPMSchedules.DataBind();
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = ParentPageURL;
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (pmitems != null)
                {
                    pmitems.Dispose();
                }
            }
        }
 private void btnAddSchedule_Click(object sender, System.EventArgs e)
 {
     try
     {
         pmitems              = new clsPMSchedService();
         pmitems.cAction      = "U";
         pmitems.iOrgId       = OrgId;
         pmitems.iPMSchedId   = 0;
         pmitems.sPMSchedName = tbScheduleName.Text;
         pmitems.PMScheduleDetails();
         dgPMSchedules.EditItemIndex = -1;
         dgPMSchedules.DataSource    = pmitems.GetPMSchedulesList();
         dgPMSchedules.DataBind();
         tbScheduleName.Text = "";
     }
     catch (Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"]     = "admin_pmschedules.aspx";
         Session["error"]        = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if (pmitems != null)
         {
             pmitems.Dispose();
         }
     }
 }
 private void dgPMSchedules_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     try
     {
         dgPMSchedules.EditItemIndex = e.Item.ItemIndex;
         pmitems                  = new clsPMSchedService();
         pmitems.iOrgId           = OrgId;
         dgPMSchedules.DataSource = pmitems.GetPMSchedulesList();
         dgPMSchedules.DataBind();
     }
     catch (Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"]     = "admin_pmschedules.aspx";
         Session["error"]        = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if (pmitems != null)
         {
             pmitems.Dispose();
         }
     }
 }
Example #5
0
 private void btnAddPMItem_Click(object sender, System.EventArgs e)
 {
     try
     {
         pmitems                = new clsPMSchedService();
         pmitems.cAction        = "U";
         pmitems.iOrgId         = OrgId;
         pmitems.iPMServiceId   = 0;
         pmitems.iRepairCatId   = Convert.ToInt32(ddlCategory.SelectedValue);
         pmitems.sPMServiceName = tbItemName.Text;
         pmitems.PMServiceDetails();
         dgPMItems.DataSource = pmitems.GetPMServicesList();
         dgPMItems.DataBind();
         tbItemName.Text = "";
     }
     catch (Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"]     = "admin_pmitems.aspx";
         Session["error"]        = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if (pmitems != null)
         {
             pmitems.Dispose();
         }
     }
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
            if (Request.QueryString["id"] == null)
            {
                Session["lastpage"] = "admin_pmschedules.aspx";
                Session["error"]    = _functions.ErrorMessage(104);
                Response.Redirect("error.aspx", false);
                return;
            }
            try
            {
                PMSchedId = Convert.ToInt32(Request.QueryString["id"]);
            }
            catch (FormatException fex)
            {
                Session["lastpage"] = "admin_pmschedules.aspx";
                Session["error"]    = _functions.ErrorMessage(105);
                Response.Redirect("error.aspx", false);
                return;
            }

            try
            {
                if (!IsPostBack)
                {
                    pmitems            = new clsPMSchedService();
                    pmitems.cAction    = "S";
                    pmitems.iOrgId     = OrgId;
                    pmitems.iPMSchedId = PMSchedId;
                    if (pmitems.PMScheduleDetails() == -1)
                    {
                        Header.ErrorMessage = _functions.ErrorMessage(169);
                        return;
                    }
                    lblPMScheduleName.Text     = pmitems.sPMSchedName.Value;
                    hlAddPMService.NavigateUrl = "admin_pmschedule_detail_edit.aspx?id=" + PMSchedId.ToString() + "&detailid=0";
                    lblBack.Text = "<input type=button value=\" Back \" onclick=\"document.location='" + this.ParentPageURL + "'\">";
                    dgPMSchedDetails.DataSource = pmitems.GetPMServicesListForSchedule();
                    dgPMSchedDetails.DataBind();
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = ParentPageURL;
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (pmitems != null)
                {
                    pmitems.Dispose();
                }
            }
        }
        private void dgPMSchedules_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            try
            {
                pmitems            = new clsPMSchedService();
                pmitems.cAction    = "D";
                pmitems.iOrgId     = OrgId;
                pmitems.iPMSchedId = Convert.ToInt32(e.CommandArgument);
                switch (pmitems.PMScheduleDetails())
                {
                case -1:
                    Header.ErrorMessage = _functions.ErrorMessage(169);
                    return;

                case -2:
                    Header.ErrorMessage = _functions.ErrorMessage(170);
                    return;

                case -3:
                    Header.ErrorMessage = _functions.ErrorMessage(171);
                    return;

                default:
                    break;
                }
                dgPMSchedules.EditItemIndex = -1;
                dgPMSchedules.DataSource    = pmitems.GetPMSchedulesList();
                dgPMSchedules.DataBind();
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = "admin_pmschedules.aspx";
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (pmitems != null)
                {
                    pmitems.Dispose();
                }
            }
        }
Example #8
0
 /// <summary>
 /// Update the PM Schedule Detail info
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btSave_FormSubmit(object sender, EventArgs e)
 {
     try
     {
         pmitem                  = new clsPMSchedService();
         pmitem.cAction          = "U";
         pmitem.iOrgId           = OrgId;
         pmitem.iPMSchedDetailId = DetailId;
         pmitem.iPMSchedId       = PMSchedId;
         pmitem.iPMServiceId     = Convert.ToInt32(ddlPMServices.SelectedValue);
         pmitem.iUnitMeasureId   = Convert.ToInt32(ddlMeasures.SelectedValue);
         pmitem.iDays            = tbDays.Text.Length > 0?Convert.ToInt32(tbDays.Text):SqlInt32.Null;
         pmitem.dmUnits          = tbUnits.Text.Length > 0?Convert.ToDecimal(tbUnits.Text):SqlDecimal.Null;
         if (pmitem.PMSchedServiceDetails() == -1)
         {
             Header.ErrorMessage = _functions.ErrorMessage(174);
             return;
         }
         Response.Redirect(sLastPage, false);
     }
     catch (FormatException fex)
     {
         Header.ErrorMessage = _functions.ErrorMessage(108);
     }
     catch (Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"]     = sCurrentPage;
         Session["error"]        = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if (pmitem != null)
         {
             pmitem.Dispose();
         }
     }
 }
Example #9
0
 private void dgPMItems_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     try
     {
         pmitems                = new clsPMSchedService();
         pmitems.cAction        = "U";
         pmitems.iOrgId         = OrgId;
         pmitems.iPMServiceId   = Convert.ToInt32(e.CommandArgument);
         pmitems.sPMServiceName = ((TextBox)e.Item.FindControl("tbPMServiceName")).Text;
         pmitems.iRepairCatId   = Convert.ToInt32(((DropDownList)e.Item.FindControl("dg_ddlCategories")).SelectedValue);
         if (pmitems.PMServiceDetails() == -1)
         {
             Header.ErrorMessage = _functions.ErrorMessage(172);
         }
         else
         {
             dgPMItems.EditItemIndex = -1;
             dgPMItems.DataSource    = pmitems.GetPMServicesList();
             dgPMItems.DataBind();
         }
     }
     catch (Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"]     = "admin_pmitems.aspx";
         Session["error"]        = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if (pmitems != null)
         {
             pmitems.Dispose();
         }
     }
 }
Example #10
0
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            try
            {
                pmitem                  = new clsPMSchedService();
                pmitem.cAction          = "D";
                pmitem.iOrgId           = OrgId;
                pmitem.iPMSchedDetailId = DetailId;
                switch (pmitem.PMSchedServiceDetails())
                {
                case -1:
                    Header.ErrorMessage = _functions.ErrorMessage(174);
                    return;

                case -2:
                    Header.ErrorMessage = _functions.ErrorMessage(175);
                    return;
                }
                Response.Redirect(sLastPage, false);
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = sCurrentPage;
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (pmitem != null)
                {
                    pmitem.Dispose();
                }
            }
        }
Example #11
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "e_list.aspx";
                    Session["error"]    = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    OrgId   = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);
                    EquipId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch (FormatException fex)
                {
                    Session["lastpage"] = "e_list.aspx";
                    Session["error"]    = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }

                Header.AddBreadCrumb("Home", "/main.aspx");
                Header.AddBreadCrumb("Equipment List", "/e_list.aspx");
                Header.AddBreadCrumb("Equipment Detail", "/e_view.aspx?id=" + EquipId.ToString());
                Header.LeftBarHtml = "Edit Alternative Information of Equipment";

                SaveCancelControl.ParentPageURL = this.ParentPageURL;

                if (!IsPostBack)
                {
                    equip         = new clsEquipment();
                    pm            = new clsPMSchedService();
                    inspec        = new clsInspections();
                    equip.cAction = "S";
                    equip.iOrgId  = OrgId;
                    equip.iId     = EquipId;
                    pm.iOrgId     = OrgId;
                    inspec.iOrgId = OrgId;

                    ddPMScheduleId.DataTextField  = "vchName";
                    ddPMScheduleId.DataValueField = "Id";
                    ddPMScheduleId.DataSource     = new DataView(pm.GetPMSchedulesList());
                    ddPMScheduleId.DataBind();

                    ddInspectionId.DataTextField  = "vchName";
                    ddInspectionId.DataValueField = "Id";
                    ddInspectionId.DataSource     = new DataView(inspec.GetInspectSchedulesList());
                    ddInspectionId.DataBind();

                    // getting equipment's data
                    if (equip.EquipmentDetail_Alt() != -1)
                    {
                        if (equip.iPMSched.IsNull)
                        {
                            ddPMScheduleId.SelectedValue = "";
                        }
                        else
                        {
                            ddPMScheduleId.SelectedValue = equip.iPMSched.Value.ToString();
                        }
                        if (equip.iInspectScheduleId.IsNull)
                        {
                            ddInspectionId.SelectedValue = "";
                        }
                        else
                        {
                            ddInspectionId.SelectedValue = equip.iInspectScheduleId.Value.ToString();
                        }
                        if (equip.dmCurrentUnits.IsNull)
                        {
                            tbCurrentUnits.Text = "";
                        }
                        else
                        {
                            tbCurrentUnits.Text = Convert.ToDouble(equip.dmCurrentUnits.Value).ToString();
                        }
                    }
                    else
                    {
                        Session["lastpage"] = this.ParentPageURL;
                        Session["error"]    = _functions.ErrorMessage(102);
                        Response.Redirect("error.aspx", false);
                    }
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = this.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();
                }
            }
        }
Example #12
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();
                }
            }
        }
Example #13
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;

                SourcePageName = "edit2.aspx.cs";

                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);

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

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

                    // getting equipment's data
                    if (equip.EquipmentDetail_Alt() != -1)
                    {
                        if (equip.iPMSched.IsNull)
                        {
                            ddPMScheduleId.SelectedValue = "";
                        }
                        else
                        {
                            ddPMScheduleId.SelectedValue = Convert.ToString(equip.iPMSched);
                        }
                        if (equip.iInspectId.IsNull)
                        {
                            ddInspectionId.SelectedValue = "";
                        }
                        else
                        {
                            ddInspectionId.SelectedValue = Convert.ToString(equip.iInspectId);
                        }
                        if (equip.iCurrentUnits.IsNull)
                        {
                            tbCurrentUnits.Text = "";
                        }
                        else
                        {
                            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(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                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();
                }
            }
        }
Example #14
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                SaveCancelControl.ParentPageURL = this.ParentPageURL;
                if (!IsPostBack)
                {
                    loc                     = new clsLocations();
                    dep                     = new clsDepartments();
                    equip                   = new clsEquipment();
                    pm                      = new clsPMSchedService();
                    inspec                  = new clsInspections();
                    equip.iOrgId            = OrgId;
                    ddlTypes.DataValueField = "Id";
                    ddlTypes.DataTextField  = "vchName";
                    ddlTypes.DataSource     = new DataView(equip.GetEquipTypesList());
                    ddlTypes.DataBind();
                    dep.iOrgId = OrgId;
                    ddlDepts.DataValueField = "Id";
                    ddlDepts.DataTextField  = "vchName";
                    ddlDepts.DataSource     = new DataView(dep.GetDepartmentsList());
                    ddlDepts.DataBind();
                    loc.iOrgId             = OrgId;
                    ddlLocs.DataValueField = "Id";
                    ddlLocs.DataTextField  = "vchName";
                    ddlLocs.DataSource     = new DataView(loc.GetLocationsList());
                    ddlLocs.DataBind();
                    mmValue.IsComponent = false;
                    mmValue.TypeId      = Convert.ToInt32(ddlTypes.SelectedValue);
                    mmValue.DataBind();

                    pm.iOrgId     = OrgId;
                    inspec.iOrgId = OrgId;

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

                    ddInspectionId.DataTextField  = "vchName";
                    ddInspectionId.DataValueField = "Id";
                    ddInspectionId.DataSource     = new DataView(inspec.GetInspectSchedulesList());
                    ddInspectionId.DataBind();
                    ddInspectionId.Items.Insert(0, new ListItem("", ""));
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = this.ParentPageURL;
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (pm != null)
                {
                    pm.Dispose();
                }
                if (inspec != null)
                {
                    inspec.Dispose();
                }
                if (loc != null)
                {
                    loc.Dispose();
                }
                if (dep != null)
                {
                    dep.Dispose();
                }
                if (equip != null)
                {
                    equip.Dispose();
                }
            }
        }