Esempio n. 1
0
 private void SaveRecord()
 {
     try
     {
         FormHelpers.CursorWait(true);
         mgridRights.CommitEdit(DataGridViewDataErrorContexts.Commit);
         if (IsValid())
         {
             var strmsg = "";
             var blnsuccess = false;
             AssignRecord(true);
             if (MyState == FormState.Add)
             {
                 strmsg = "Saving Failed!";
                 if (usrgrpbal.Save(usrgrp))
                 {
                     strmsg = "Saving Successful!";
                     blnsuccess = true;
                 }                 
             }
             if (MyState == FormState.Edit)
             {
                 strmsg = "Updating Failed!";
                 if (usrgrpbal.Update(usrgrp))
                 {
                     strmsg = "Updating Successful!";
                     blnsuccess = true;
                 }                        
             }                    
             if (blnsuccess)
             {
                 MessageHelpers.ShowInfo(strmsg);
                 MyCaller.RefreshGrid();
                 MyCaller.Focus();
                 this.Close();
             }
             else
             {
                 MessageHelpers.ShowWarning(strmsg);
             }
             
         }
     }
     catch (Exception ex)
     {
         MessageHelpers.ShowError(ex.Message);
     }
     finally
     {
         FormHelpers.CursorWait(false);
     }
 }