Пример #1
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)
        {
            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();
            }
        }
Пример #3
0
        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;
                    dgPMItems.DataSource = pmitems.GetPMServicesList();
                    dgPMItems.DataBind();
                    dtCats = pmitems.GetRepairCatsList();
                    ddlCategory.DataSource = dtCats;
                    ddlCategory.DataBind();
                    ViewState["Categories"] = dtCats;
                }
            }
            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();
            }
        }
Пример #4
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();
     }
 }
Пример #5
0
        private void dgPMItems_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            try
            {
                dgPMItems.EditItemIndex = e.Item.ItemIndex;
                pmitems = new clsPMSchedService();
                pmitems.iOrgId = OrgId;
                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();
            }
        }
Пример #6
0
 private void dgPMItems_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     try
     {
         pmitems = new clsPMSchedService();
         pmitems.cAction = "D";
         pmitems.iOrgId = OrgId;
         pmitems.iPMServiceId = Convert.ToInt32(e.CommandArgument);
         switch(pmitems.PMServiceDetails())
         {
             case -1:
                 Header.ErrorMessage = _functions.ErrorMessage(172);
                 return;
             case -2:
                 Header.ErrorMessage = _functions.ErrorMessage(173);
                 return;
             default:
                 break;
         }
         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();
     }
 }