/// <summary>
 /// Update the Category information and positions of items
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btSave_FormSubmit(object sender, EventArgs e)
 {
     int Position, NewPosition;
     try
     {
         inspect = new clsInspections();
         inspect.cAction = "U";
         inspect.iOrgId = OrgId;
         inspect.iId = InspectionId;
         inspect.iCategoryId = CategoryId;
         inspect.sCategoryName = tbCategory.Text;
         inspect.iCatPosition = Convert.ToInt32(ddlOrder.SelectedValue);
         if(inspect.InspectCatDetails() == -1)
         {
             Session["lastpage"] = sCurrentPage;
             Session["error"] = _functions.ErrorMessage(156);
             Response.Redirect("error.aspx", false);
             return;
         }
         foreach(DataGridItem Item in dgInspectItems.Items)
         {
             Position = Convert.ToInt32(((Label)Item.FindControl("lblCatId")).Text);
             NewPosition = Convert.ToInt32(Request.Params["FormPosition" + Item.ItemIndex.ToString()]);
             if(Position != NewPosition)
             {
                 inspect.iInspectItemId = Convert.ToInt32(Item.Cells[0].Text);
                 inspect.iItemPosition = NewPosition;
                 inspect.UpdatePosInspectItem();
             }
         }
         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(inspect != null)
             inspect.Dispose();
     }
 }
 private void dgInspectSchedules_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     try
     {
         inspect = new clsInspections();
         inspect.iOrgId = OrgId;
         inspect.iInspectScheduleId = Convert.ToInt32(e.Item.Cells[0].Text);
         switch(e.CommandName)
         {
             case "Delete":
                 inspect.cAction = "D";
                 switch(inspect.InspectScheduleDetails())
                 {
                     case -1:
                         Session["lastpage"] = "admin_inspectschedules.aspx";
                         Session["error"] = _functions.ErrorMessage(159);
                         Response.Redirect("error.aspx", false);
                         return;
                     case -2:
                         Header.ErrorMessage = _functions.ErrorMessage(160);
                         break;
                     case -3:
                         Header.ErrorMessage = _functions.ErrorMessage(161);
                         break;
                     case 0:
                         dgInspectSchedules.EditItemIndex = -1;
                         ShowInspectSchedules();
                         break;
                     default:
                         break;
                 }
                 break;
             case "Cancel":
                 dgInspectSchedules.EditItemIndex = -1;
                 ShowInspectSchedules();
                 break;
             case "Edit":
                 dgInspectSchedules.EditItemIndex = e.Item.ItemIndex;
                 ShowInspectSchedules();
                 break;
             case "Update":
                 inspect.cAction = "U";
                 inspect.sInspectScheduleName = ((TextBox)e.Item.FindControl("tbNameEdit")).Text;
                 if(inspect.InspectScheduleDetails() == -1)
                 {
                     Session["lastpage"] = "admin_inspectschedules.aspx";
                     Session["error"] = _functions.ErrorMessage(159);
                     Response.Redirect("error.aspx", false);
                     return;
                 }
                 dgInspectSchedules.EditItemIndex = -1;
                 ShowInspectSchedules();
                 break;
             default:
                 break;
         }
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "admin_inspectschedules.aspx";
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(inspect != null)
             inspect.Dispose();
     }
 }
 private void btnDelete_Click(object sender, System.EventArgs e)
 {
     try
     {
         inspect = new clsInspections();
         inspect.cAction = "D";
         inspect.iOrgId = OrgId;
         inspect.iId = InspectionId;
         inspect.iCategoryId = CategoryId;
         if(inspect.InspectCatDetails() == -1)
         {
             Session["lastpage"] = sCurrentPage;
             Session["error"] = _functions.ErrorMessage(156);
             Response.Redirect("error.aspx", false);
             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(inspect != null)
             inspect.Dispose();
     }
 }
 private void btnAddSchedule_Click(object sender, System.EventArgs e)
 {
     try
     {
         inspect = new clsInspections();
         inspect.cAction = "U";
         inspect.iOrgId = OrgId;
         inspect.iInspectScheduleId = 0;
         inspect.sInspectScheduleName= tbScheduleName.Text;
         tbScheduleName.Text = "";
         inspect.InspectScheduleDetails();
         ShowInspectSchedules();
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "admin_inspectschedules.aspx";
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(inspect != null)
             inspect.Dispose();
     }
 }
        private void dgPMItems_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            try
            {
                inspect = new clsInspections();
                inspect.cAction = "D";
                inspect.iOrgId = OrgId;
                inspect.iInspectItemId = ItemId;
                inspect.iInspectItemPMItemId = Convert.ToInt32(e.Item.Cells[0].Text);

                inspect.InspectItemPMItemDetails();

                dgPMItems.DataSource = new DataView(inspect.GetPMServicesByInspectionItem());
                dgPMItems.DataBind();
                if(dgPMItems.Items.Count == 0)
                    dgPMItems.Visible = false;

                ShowPMItems();
            }
            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(inspect != null)
                    inspect.Dispose();
            }
        }
        private void btnLink_Click(object sender, System.EventArgs e)
        {
            try
            {
                inspect = new clsInspections();
                inspect.cAction = "I";
                inspect.iOrgId = OrgId;
                inspect.iInspectItemId = ItemId;
                inspect.iPMSchedDetailId = Convert.ToInt32(ddlPMServices.SelectedValue);

                inspect.InspectItemPMItemDetails();

                dgPMItems.DataSource = new DataView(inspect.GetPMServicesByInspectionItem());
                dgPMItems.DataBind();
                dgPMItems.Visible = true;

                ShowPMItems();
            }
            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(inspect != null)
                    inspect.Dispose();
            }
        }
Ejemplo n.º 7
0
 private void dgHolidays_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     try
     {
         dgHolidays.EditItemIndex = e.Item.ItemIndex;
         inspect = new clsInspections();
         inspect.iOrgId = OrgId;
         ShowHolidays();
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "admin_holidays.aspx";
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(inspect != null)
             inspect.Dispose();
     }
 }
Ejemplo n.º 8
0
 private void dgHolidays_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     try
     {
         inspect = new clsInspections();
         inspect.cAction = "D";
         inspect.iOrgId = OrgId;
         inspect.iHolidayId = Convert.ToInt32(e.Item.Cells[0].Text);
         if(inspect.HolidayDetail() == -1)
         {
             Session["lastpage"] = "admin_holidays.aspx";
             Session["error"] = _functions.ErrorMessage(153);
             Response.Redirect("error.aspx", false);
             return;
         }
         ShowHolidays();
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "admin_holidays.aspx";
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(inspect != null)
             inspect.Dispose();
     }
 }