private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtScreenName.Text == "")
         {
             MessageBox.Show("You Must Enter Screen Name");
             return;
         }
         DALLayer.Screen s = screen.Add(new DALLayer.Screen()
         {
             Screen_Code = int.Parse(txtScreenCode.Text), Screen_Name = txtScreenName.Text
         });
         AddScreenPermissions(s);
         btnSave.Enabled    = false;
         btnAddNew.Enabled  = btnDelete.Enabled = btnModify.Enabled = true;
         txtScreenCode.Text = txtScreenName.Text = "";
         MessageBox.Show("New Screen Successfully Added");
         FRM_Screen_Load(null, null);
         btnLast_Click(null, null);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void btnModify_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtScreenName.Text == "")
         {
             MessageBox.Show("You Must Enter Screen Name");
             return;
         }
         DALLayer.Screen sc = screen.Get(int.Parse(txtScreenCode.Text));
         sc.Screen_Name = txtScreenName.Text;
         perinscreen.DeleteMulti(sc.PermissionsInScreen);
         AddScreenPermissions(sc);
         screen.Update(sc);
         int ModifiedRowIndex = RowFocusedIndex;
         MessageBox.Show("Selected Screen Successfully Modified");
         FRM_Screen_Load(null, null);
         GetFocusedRowData(ModifiedRowIndex);
         ScreenView.FocusedRowHandle = ModifiedRowIndex;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void AddScreenPermissions(DALLayer.Screen s)
 {
     for (int i = 0; i < dgvPermissions.Rows.Count; i++)
     {
         if (bool.Parse(dgvPermissions.Rows[i].Cells[check.Name].Value.ToString()) == true)
         {
             perinscreen.Add(new PermissionsInScreen()
             {
                 Screen_Code     = s.Screen_Code,
                 Permission_Code = int.Parse(dgvPermissions.Rows[i].Cells[PerCode.Name].Value.ToString())
             });
         }
     }
 }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         DALLayer.Screen sc = screen.Get(int.Parse(txtScreenCode.Text));
         perinscreen.DeleteMulti(sc.PermissionsInScreen);
         screen.Delete(sc);
         MessageBox.Show("Selected Screen Successfully Deleted");
         FRM_Screen_Load(null, null);
         RowFocusedIndex = 0;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }