using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Library_Red_Diamonds
{
    class AccessLevel
    {
        static SqlConnection con = new SqlConnection(Connection.con);
        public static string UserName = string.Empty;

        public static bool books = false;
        public static bool categorys = false;
        public static bool members = false;
        public static bool memberdebits = false;
        public static bool borrowbooks = false;
        public static bool backbooks = false;
        public static bool fines = false;
        public static bool users = false;
        public static bool info = false;
        public static bool backups = false;
        public static bool restores = false;

        public void SetAccess(string userName)
        {
            SqlCommand sqlcmdSet = new SqlCommand();
            sqlcmdSet.CommandText = "select * from accesslevel where usernames=@usernames";
            sqlcmdSet.Parameters.AddWithValue("@usernames",userName);
            sqlcmdSet.Connection = con;
            SqlDataAdapter data = new SqlDataAdapter(sqlcmdSet);
            DataTable dt = new DataTable();
            data.Fill(dt);

            
          books =(bool ) dt.Rows[0][1];
          categorys =(bool ) dt.Rows[0][2];
          members =(bool ) dt.Rows[0][3];
          memberdebits =(bool ) dt.Rows[0][4];
          borrowbooks=(bool ) dt.Rows[0][5];
          backbooks = (bool)dt.Rows[0][6];
          fines = (bool)dt.Rows[0][7];
          users = (bool)dt.Rows[0][8];
          info = (bool)dt.Rows[0][9];
          backups = (bool)dt.Rows[0][10];
          restores = (bool)dt.Rows[0][11];

    
        }


    }
}
