/// <summary>
 /// Function to insert values to Role Table
 /// </summary>
 /// <param name="infoRole"></param>
 /// <returns></returns>
 public decimal RoleAdd(RoleInfo infoRole)
 {
     decimal decRoleIdentity = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RoleAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@role", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Role;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Extra2;
         decRoleIdentity = Convert.ToDecimal(sccmd.ExecuteScalar());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decRoleIdentity;
 }
 /// <summary>
 /// Function to Update values in Role Table
 /// </summary>
 /// <param name="infoRole"></param>
 public void RoleEdit(RoleInfo infoRole)
 {
     try
     {
         spRole.RoleEdit(infoRole);
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to insert values to Role Table
 /// </summary>
 /// <param name="infoRole"></param>
 /// <returns></returns>
 public decimal RoleAdd(RoleInfo infoRole)
 {
     decimal decRoleIdentity = 0;
     try
     {
         decRoleIdentity = spRole.RoleAdd(infoRole);
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return decRoleIdentity;
 }
        /// <summary>
        /// Function to get particular values from Role table based on the parameter
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public RoleInfo RoleView(decimal roleId)
        {
            RoleInfo infoRole = new RoleInfo();

            try
            {
                infoRole = spRole.RoleView(roleId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("RL5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return infoRole;
        }
 /// <summary>
 /// Function to get particular values from Role table based on the parameter
 /// </summary>
 /// <param name="roleId"></param>
 /// <returns></returns>
 public RoleInfo RoleView(decimal roleId)
 {
     RoleInfo infoRole = new RoleInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RoleView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@roleId", SqlDbType.Decimal);
         sprmparam.Value = roleId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             infoRole.RoleId = decimal.Parse(sdrreader[0].ToString());
             infoRole.Role = sdrreader[1].ToString();
             infoRole.Narration = sdrreader[2].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return infoRole;
 }
 /// <summary>
 /// Function to Update values in Role Table
 /// </summary>
 /// <param name="infoRole"></param>
 public void RoleEdit(RoleInfo infoRole)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("RoleEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@roleId", SqlDbType.Decimal);
         sprmparam.Value = infoRole.RoleId;
         sprmparam = sccmd.Parameters.Add("@role", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Role;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Narration;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = infoRole.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }