public List <NGUOIDUNGDTO> LayDanhSachGiaoVienQuanLy()
        {
            try
            {
                List <NGUOIDUNGDTO> lstKQ      = new List <NGUOIDUNGDTO>();
                SqlConnection       connection = ConnectDB();
                SqlCommand          cmd        = new SqlCommand("sp_LayDanhSachGiaoVienQuanLy", connection);

                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    NGUOIDUNGDTO d = new NGUOIDUNGDTO();
                    d.HOTEN       = (string)rdr["HOTEN"];
                    d.MAND        = (long)rdr["MAND"];
                    d.TENDANGNHAP = (string)rdr["TENDANGNHAP"];
                    d.MATKHAU     = (string)rdr["MATKHAU"];
                    d.TRANGTHAI   = (bool)rdr["TRANGTHAI"];
                    d.TOANQUYENGV = (bool)rdr["TOANQUYENGV"];
                    d.MALOAI      = (long)rdr["MALOAI"];
                    d.MABM        = (long)rdr["MABM"];
                    if (rdr["MAGVQL"] != DBNull.Value)
                    {
                        d.MAGVQL = (long)rdr["MAGVQL"];
                    }
                    lstKQ.Add(d);
                }
                return(lstKQ);
            }
            catch (Exception e)
            {
                Console.WriteLine("THANG: " + e.ToString());
                throw e;
            }
        }
        public FrmThemNguoiDung(FrmQuanLyNguoiDung frm, long maND)
        {
            InitializeComponent();
            this.maND               = maND;
            this.frmParent          = frm;
            button1.Text            = "Cập nhật";
            this.Text               = "Cập nhật thông tin người dùng";
            cboLoaiND.DataSource    = LOAINGUOIDUNGBUS.LayDanhSachLoaiNguoiDung();
            cboLoaiND.ValueMember   = "MALOAI";
            cboLoaiND.DisplayMember = "TENLOAIND";

            cboTenBM.DataSource    = BOMONBUS.LayDanhSachBoMon();
            cboTenBM.ValueMember   = "MABM";
            cboTenBM.DisplayMember = "TENBM";

            cboTrangThai.Items.Add("Mở");
            cboTrangThai.Items.Add("Khóa");
            cboTrangThai.SelectedIndex = 0;

            NGUOIDUNGDTO d = NGUOIDUNGBUS.LayNguoiDung(this.maND);

            txtHoTen.Text              = d.HOTEN;
            txtTenDangNhap.Text        = d.TENDANGNHAP;
            cbToanQuyen.Checked        = d.TOANQUYENGV;
            cboLoaiND.SelectedValue    = d.MALOAI;
            cboTenBM.SelectedValue     = d.MABM;
            cboTrangThai.SelectedValue = d.TRANGTHAI;

            cboTenGVQL.DataSource    = NGUOIDUNGBUS.LayDanhSachGiaoVienQuanLy();
            cboTenGVQL.ValueMember   = "MaND";
            cboTenGVQL.DisplayMember = "HoTen";
            cboTenGVQL.SelectedValue = d.MAGVQL;
        }
        public List <NGUOIDUNGDTO> LayDanhSachGV(long maGVQL)
        {
            try
            {
                List <NGUOIDUNGDTO> lstKQ      = new List <NGUOIDUNGDTO>();
                SqlConnection       connection = ConnectDB();
                SqlCommand          cmd        = new SqlCommand("sp_LayDanhGV", connection);

                SqlParameter sParam_MaGVQL = cmd.Parameters.Add("@MaGVQL", SqlDbType.BigInt);
                sParam_MaGVQL.Direction = ParameterDirection.Input;
                sParam_MaGVQL.Value     = maGVQL;

                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    NGUOIDUNGDTO d = new NGUOIDUNGDTO();
                    d.HOTEN       = (string)rdr["HOTEN"];
                    d.MAND        = (long)rdr["MAND"];
                    d.TENDANGNHAP = (string)rdr["TENDANGNHAP"];
                    d.MATKHAU     = (string)rdr["MATKHAU"];
                    d.TRANGTHAI   = (bool)rdr["TRANGTHAI"];
                    d.TOANQUYENGV = (bool)rdr["TOANQUYENGV"];
                    d.MALOAI      = (long)rdr["MALOAI"];
                    d.MABM        = (long)rdr["MABM"];
                    if (rdr["MAGVQL"] != DBNull.Value)
                    {
                        d.MAGVQL = (long)rdr["MAGVQL"];
                    }
                    d.TENLOAIND = (string)rdr["TENLOAIND"];
                    d.TENBM     = (string)rdr["TENBM"];
                    //Console.WriteLine(rdr["TENGVQL"]);
                    //if (rdr["TENGVQL"] != DBNull.Value)
                    //    d.TENGVQL = (string)rdr["TENGVQL"];
                    lstKQ.Add(d);
                }
                return(lstKQ);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw e;
            }
        }
        public NGUOIDUNGDTO LayNguoiDung(long maND)
        {
            try
            {
                NGUOIDUNGDTO  d          = new NGUOIDUNGDTO();
                SqlConnection connection = ConnectDB();
                SqlCommand    cmd        = new SqlCommand("sp_LayNguoiDung", connection);

                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter sParam_maND = cmd.Parameters.Add("@MaND", SqlDbType.BigInt);
                sParam_maND.Direction = ParameterDirection.Input;
                sParam_maND.Value     = maND;

                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    d.HOTEN       = (string)rdr["HOTEN"];
                    d.MAND        = (long)rdr["MAND"];
                    d.TENDANGNHAP = (string)rdr["TENDANGNHAP"];
                    d.MATKHAU     = (string)rdr["MATKHAU"];
                    d.TRANGTHAI   = (bool)rdr["TRANGTHAI"];
                    d.TOANQUYENGV = (bool)rdr["TOANQUYENGV"];
                    d.MALOAI      = (long)rdr["MALOAI"];
                    d.MABM        = (long)rdr["MABM"];
                    if (rdr["MAGVQL"] != DBNull.Value)
                    {
                        d.MAGVQL = (long)rdr["MAGVQL"];
                    }
                }
                return(d);
            }
            catch (Exception e)
            {
                throw e;
            }
        }