/// <summary>
 /// Function to fill the Role ComboFill
 /// </summary>
 public void RoleComboFill()
 {
     try
     {
         RoleBll BllRole = new RoleBll();
         List<DataTable> listObjRoleCombo = new List<DataTable>();
         listObjRoleCombo = BllRole.RoleViewAll();
         cmbRole.DataSource = listObjRoleCombo[0];
         cmbRole.ValueMember = "roleId";
         cmbRole.DisplayMember = "role";
         cmbRole.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("UC:1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to the search Role Combo box
 /// </summary>
 public void SearchRoleComboFill()
 {
     try
     {
         RoleBll BllRole = new RoleBll();
         List<DataTable> listObjSearchRoleCombo = new List<DataTable>();
         listObjSearchRoleCombo = BllRole.RoleViewAll();
         DataRow dr = listObjSearchRoleCombo[0].NewRow();
         dr[1] = "All";
         listObjSearchRoleCombo[0].Rows.InsertAt(dr, 0);
         cmbSearchRole.DataSource = listObjSearchRoleCombo[0];
         cmbSearchRole.ValueMember ="roleId";
         cmbSearchRole.DisplayMember = "role";
     }
     catch (Exception ex)
     {
         MessageBox.Show("UC:2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Save function
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         RoleInfo infoRole = new RoleInfo();
         RoleBll BllRole = new RoleBll();
         infoRole.Role = txtRole.Text.Trim();
         infoRole.Narration = txtNarration.Text.Trim();
         infoRole.Extra1 = string.Empty;
         infoRole.Extra2 = string.Empty;
         string strRole = txtRole.Text.Trim();
         if (BllRole.RoleCheckExistence(decRoleId, strRole) == false)
         {
             decRoleId = BllRole.RoleAdd(infoRole);
             Messages.SavedMessage();
             ClearFunction();
         }
         else
         {
             Messages.InformationMessage("Role already exists");
             txtRole.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the grid
 /// </summary>
 public void Gridfill()
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         RoleBll BllRole = new RoleBll();
         listObj = BllRole.RoleViewGridFill();
         dgvRole.DataSource = listObj[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL:1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the Controls for updation
 /// </summary>
 public void FillControls()
 {
     try
     {
         RoleInfo infoRole = new RoleInfo();
         RoleBll BllRole = new RoleBll();
         infoRole = BllRole.RoleView(decRoleId);
         txtRole.Text = infoRole.Role;
         txtNarration.Text = infoRole.Narration;
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL:6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to Update the items
 /// </summary>
 public void EditFunction()
 {
     try
     {
         RoleInfo infoRole = new RoleInfo();
         RoleBll BllRole = new RoleBll();
         infoRole.RoleId = Convert.ToDecimal(dgvRole.CurrentRow.Cells["dgvtxtRoleId"].Value);
         infoRole.Role = txtRole.Text.Trim();
         infoRole.Narration = txtNarration.Text.Trim();
         infoRole.Extra1 = string.Empty;
         infoRole.Extra2 = string.Empty;
         string strRole = txtRole.Text.Trim();
         if (BllRole.RoleCheckExistence(decRoleId, strRole) == false)
         {
             BllRole.RoleEdit(infoRole);
             Messages.UpdatedMessage();
             ClearFunction();
         }
         else
         {
             Messages.InformationMessage("Role already exists");
             txtRole.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Delete Function
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         if (PublicVariables.isMessageDelete)
         {
             if (Messages.DeleteMessage())
             {
                 RoleInfo infoRole = new RoleInfo();
                 RoleBll BllRole = new RoleBll();
                 if ((BllRole.RoleReferenceDelete(decRoleId) == -1))
                 {
                     Messages.ReferenceExistsMessage();
                 }
                 else
                 {
                     Messages.DeletedMessage();
                     btnSave.Text = "Save";
                     btnDelete.Enabled = false;
                     ClearFunction();
                 }
             }
         }
         else
         {
             RoleInfo infoRole = new RoleInfo();
             RoleBll BllRole = new RoleBll();
             if (BllRole.RoleReferenceDelete(decRoleId) == -1)
             {
                 Messages.ReferenceExistsMessage();
             }
             else
             {
                 Messages.DeletedMessage();
                 btnSave.Text = "Save";
                 btnDelete.Enabled = false;
                 ClearFunction();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL:7" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }