Exemplo n.º 1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (selectedRecordId != 0)
     {
         try
         {
             Cursor = Cursors.WaitCursor;
             DepartmentBAL _objBAL = new DepartmentBAL();
             _objBAL.DeleteUser(selectedRecordId);
             MessageBox.Show("Record has been deleted successfully!");
             FillGrid();
         }
         catch (System.Data.SqlClient.SqlException sqlEx)
         {
             if (sqlEx.Number == 547)
             {
                 MessageBox.Show("You cannot delete this record. Its refference exists in other documents.");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
         finally
         {
             Cursor = Cursors.Default;
             MakeEmpty();
         }
     }
 }