コード例 #1
0
        private void Login1()
        {
            FormQLCHBanDT            qldt = new FormQLCHBanDT();
            BaseFunctions <TaiKhoan> tk1  = new BaseFunctions <TaiKhoan>();
            DataTable dt   = tk1.ChucNang();
            string    user = textBoxTenTK.Text;
            string    MK   = textBoxMatKhau.Text;
            int       KQ   = tk.DangNhap(user, MK).Rows.Count;

            if (textBoxTenTK.Text.Length == 0 || textBoxMatKhau.Text.Length == 0)
            {
                MessageBox.Show("Bạn chưa nhập tên hoặc mật khẩu");
            }
            switch (KQ)
            {
            case 0:
                MessageBox.Show("mật khẩu không đúng!");
                break;

            case 1:
                this.Hide();
                TenTaiKhoan         = tk.DangNhap(user, MK).Rows[0][1].ToString();
                Phanquyen           = PhanQuyen(3);
                Matkhau             = PhanQuyen(4);
                Nguoidung           = PhanQuyen(5);
                Dangxuat            = PhanQuyen(6);
                Hoadon              = PhanQuyen(7);
                Xemsanpham          = PhanQuyen(8);
                Baohanh             = PhanQuyen(9);
                Nhaphang            = PhanQuyen(10);
                Trahang             = PhanQuyen(11);
                Khachhang           = PhanQuyen(12);
                Mathang             = PhanQuyen(13);
                Nhanvien            = PhanQuyen(14);
                Banggia             = PhanQuyen(15);
                TKdoanhthu          = PhanQuyen(16);
                TKKhachhang         = PhanQuyen(16);
                TKMathang           = PhanQuyen(18);
                textBoxMatKhau.Text = "";
                TenTaiKhoan         = tk.DangNhap(user, MK).Rows[0][0].ToString();
                qldt.ShowDialog();
                this.Show();
                break;
            }
        }