Esempio n. 1
0
 /// <summary>
 /// Function to insert values to Privilege Table
 /// </summary>
 /// <param name="privilegeinfo"></param>
 public void PrivilegeAdd(PrivilegeInfo privilegeinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PrivilegeAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@formName", SqlDbType.VarChar);
         sprmparam.Value = privilegeinfo.FormName;
         sprmparam       = sccmd.Parameters.Add("@action", SqlDbType.VarChar);
         sprmparam.Value = privilegeinfo.Action;
         sprmparam       = sccmd.Parameters.Add("@roleId", SqlDbType.Decimal);
         sprmparam.Value = privilegeinfo.RoleId;
         sprmparam       = sccmd.Parameters.Add("@exatra1", SqlDbType.VarChar);
         sprmparam.Value = privilegeinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = privilegeinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Function to get particular values from Privilege Table based on the parameter
        /// </summary>
        /// <param name="decRoleId"></param>
        /// <returns></returns>
        public PrivilegeInfo PrivilegeView(decimal decRoleId)
        {
            PrivilegeInfo privilegeinfo = new PrivilegeInfo();
            SqlDataReader sdrreader     = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("PrivilegeView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@roleId", SqlDbType.Decimal);
                sprmparam.Value = decRoleId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    privilegeinfo.PrivilegeId = decimal.Parse(sdrreader[0].ToString());
                    privilegeinfo.FormName    = sdrreader[1].ToString();
                    privilegeinfo.Action      = sdrreader[2].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(privilegeinfo);
        }