Ejemplo n.º 1
0
        private void Btn_delete_Click(object sender, EventArgs e)
        {
            if (!layerAccess.IsCanDelete(_frmMain.userID))
               {
               clsWin.WarningMessage("You dont have permition to access this form, please contact your administrator", "Access Denied");

               return;
               }
               //BomContext db = new BomContext();
               PartGroupModel Pg;
               try
               {
               if (clsWin.QuestionMessage("Are you sure want to Delete this record?", "Confirm Delete"))
               {

                   {
                       Pg = new PartGroupModel
                       {
                           Deleted = true,
                           Comp = clsWin.GetComputerName(),
                           UserName = _frmMain.activeuser,
                           LastUpdate = DateTime.Now,
                       };
                       layerGroup.DeleteGroup(Pg, id);
                   }

                  // db.SaveChanges();
                   clsWin.SuccessMessage("Group has been Delete", "Success");
                   Btn_refresh.PerformClick();
               }

               }
               catch (DbEntityValidationException ex)
               {
               var errorMessages = ex.EntityValidationErrors
                   .SelectMany(x => x.ValidationErrors)
                   .Select(x => x.ErrorMessage);
               var exceptionMessage = string.Concat(errorMessages);
               clsWin.ClearWindowsObJect(panelEx1);
               clsWin.ErrorMessage((exceptionMessage).ToString(), "Oops");

               Btn_refresh.PerformClick();
               }
        }
Ejemplo n.º 2
0
        private void Btn_Save_Click(object sender, EventArgs e)
        {
            //BomContext db = new BomContext();
               PartGroupModel um;
               try
               {

               if (layerGroup.GetGroupCD((Txt_Group_CD.Text), id))
               {
                   var exceptionMessage = "Brand Code already exist";
                   // clsWin.ClearWindowsObJect(panelEx1);
                   clsWin.ErrorMessage((exceptionMessage).ToString(), "Oops");
                   Txt_Group_CD.Focus();
                   return;
               }

               if (clsWin.QuestionMessage("Are you sure want to save", "Save Group"))
               {
                   if (StatusEdit)
                   {
                       um = new PartGroupModel
                       {
                           GroupCD = Txt_Group_CD.Text,
                           GroupName = txt_Group_Name.Text,
                           Comp = clsWin.GetComputerName(),
                           UserName = _frmMain.activeuser,
                           LastUpdate = DateTime.Now,
                       };
                       layerGroup.UpdatetGroup(um, id);
                   }
                   else
                   {
                       um = new PartGroupModel()
                       {
                           pgGUID = Guid.NewGuid().ToString(),
                           GroupCD = Txt_Group_CD.Text.ToString(),
                           GroupName = txt_Group_Name.Text.ToString(),
                           Comp = clsWin.GetComputerName(),
                           UserName = _frmMain.activeuser,
                           LastUpdate = DateTime.Now
                       };
                       layerGroup.InSertGroup(um);
                   }

                   clsWin.SuccessMessage("Group has been saved", "Success");
                   Btn_refresh.PerformClick();
               }

               }
               catch (DbEntityValidationException ex)
               {
               var errorMessages = ex.EntityValidationErrors
                   .SelectMany(x => x.ValidationErrors)
                   .Select(x => x.ErrorMessage);
               var exceptionMessage = string.Concat(errorMessages);
               clsWin.ClearWindowsObJect(panelEx1);
               clsWin.ErrorMessage((exceptionMessage).ToString(), "Oops");

               Btn_refresh.PerformClick();
               }
        }