internal static List <Pages> Get_Remaining_Pages(int Emp_Id)
        {
            int i;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                List <Pages> pers = new List <Pages>();

                SqlCommand com = new SqlCommand("Permissions_InsertUpdateDeleteSelect", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Emp_ID", Emp_Id);

                com.Parameters.AddWithValue("@Action", "Get_Remaining_Pages");
                SQL_Utility.Stored_Procedure(ref com);
                // i = com.ExecuteNonQuery();
                SqlDataReader rdr = com.ExecuteReader();
                while (rdr.Read())
                {
                    pers.Add(new Pages
                    {
                        Page_Name   = rdr["Page_Name"].ToString(),
                        Id          = Convert.ToInt32(rdr["Id"]),
                        Group_Name  = rdr["Group_Name"].ToString(),
                        Description = rdr["Description"].ToString(),
                    });
                }
                return(pers);
            }
            return(null);
        }
        public static Pages Get_Page_By_Id(int Page_ID)
        {
            int i;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                SqlCommand com = new SqlCommand("Permissions_InsertUpdateDeleteSelect", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Page_ID", Page_ID);

                com.Parameters.AddWithValue("@Action", "Get_Page_By_Id");
                SQL_Utility.Stored_Procedure(ref com);
                //i = com.ExecuteNonQuery();
                SqlDataReader rdr = com.ExecuteReader();
                while (rdr.Read())
                {
                    Pages p = new Pages
                    {
                        Page_Name   = rdr["Page_Name"].ToString(),
                        Id          = Convert.ToInt32(rdr["Id"]),
                        Group_Name  = rdr["Group_Name"].ToString(),
                        Description = rdr["Description"].ToString(),
                    };
                    return(p);
                }
            }
            return(null);
        }
        public static List <Permissions> Get_Permissions_Of_Emp(int Emp_Id)
        {
            int i;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                List <Permissions> pers = new List <Permissions>();

                SqlCommand com = new SqlCommand("Permissions_InsertUpdateDeleteSelect", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Emp_ID", Emp_Id);

                com.Parameters.AddWithValue("@Action", "Get_Permissions_Of_Emp");
                SQL_Utility.Stored_Procedure(ref com);

                // i = com.ExecuteNonQuery();
                SqlDataReader rdr = com.ExecuteReader();
                while (rdr.Read())
                {
                    pers.Add(new Permissions
                    {
                        Id        = Convert.ToInt32(rdr["Id"]),
                        Emp_ID    = Convert.ToInt32(rdr["Emp_ID"]),
                        Page_ID   = Convert.ToInt32(rdr["Page_ID"]),
                        Emp_Name  = Employeescrud.select_no_department(Convert.ToInt32(rdr["Emp_ID"])).Name,
                        Page_Name = Get_Page_By_Id(Convert.ToInt32(rdr["Page_ID"])).Page_Name,
                    });
                }
                return(pers);
            }
            return(null);
        }
        internal static int Remove_Role(int permission_id)
        {
            int i;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                SqlCommand com = new SqlCommand("Permissions_InsertUpdateDeleteSelect", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Id", permission_id);

                com.Parameters.AddWithValue("@Action", "Remove_Role");

                SQL_Utility.Stored_Procedure(ref com);
                i = com.ExecuteNonQuery();
            }
            return(0);
        }
        private static int delete_existing_roles(int emp_Id)
        {
            int i;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                SqlCommand com = new SqlCommand("Permissions_InsertUpdateDeleteSelect", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Emp_ID", emp_Id);

                com.Parameters.AddWithValue("@Action", "delete_existing_roles");

                SQL_Utility.Stored_Procedure(ref com);
                i = com.ExecuteNonQuery();
            }
            return(0);
        }
 public static int Get_PageID(string page_name)
 {
     using (SqlConnection con = new SqlConnection(cs))
     {
         con.Open();
         SqlCommand com = new SqlCommand("Permissions_InsertUpdateDeleteSelect", con);
         com.CommandType = CommandType.StoredProcedure;
         com.Parameters.AddWithValue("@Page_Name", page_name);
         com.Parameters.AddWithValue("@Action", "Get_PageID");
         SQL_Utility.Stored_Procedure(ref com);
         SqlDataReader rdr = com.ExecuteReader();
         while (rdr.Read())
         {
             return(Convert.ToInt32(rdr[0]));
         }
         return(0);
     }
 }
        public static int Add_Role(int Emp_Id, int Page_ID)
        {
            int i;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                SqlCommand com = new SqlCommand("Permissions_InsertUpdateDeleteSelect", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Emp_ID", Emp_Id);
                com.Parameters.AddWithValue("@Page_ID", Page_ID);

                com.Parameters.AddWithValue("@Action", "Add_Role");
                SQL_Utility.Stored_Procedure(ref com);
                i = com.ExecuteNonQuery();
            }
            return(i);
        }
        private static bool See_If_Can_Access(int Emp_Id, string Page_Name)
        {
            int Page_ID = Get_PageID(Page_Name);

            int i;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                SqlCommand com = new SqlCommand("Permissions_InsertUpdateDeleteSelect", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Emp_ID", Emp_Id);
                com.Parameters.AddWithValue("@Page_ID", Page_ID);

                com.Parameters.AddWithValue("@Action", "See_If_Can_Access");
                SQL_Utility.Stored_Procedure(ref com);
                SqlDataReader rdr = com.ExecuteReader();
                while (rdr.Read())
                {
                    return(true);
                }
            }
            return(false);
        }