Пример #1
0
        public List <NguoiDung> LayDanhSachNguoiDung(int action, int id_nguoidung, string tendangnhap, string tenhienthi, string id_phongban, string email, bool dangsudung, bool quanly, bool admin, bool quanlykho, bool quanlymuahang, string matkhau, bool domain)
        {
            if (string.IsNullOrEmpty(matkhau) == false)
            {
                matkhau = LibEncrypt.Encrypt(matkhau, true);
            }
            DAC kn = new DAC();
            List <NguoiDung> nguoidungs = new List <NguoiDung>();
            SqlParameter     pm         = new SqlParameter("@action", action);
            SqlParameter     pm2        = new SqlParameter("@id_nguoidung", id_nguoidung);
            SqlParameter     pm3        = new SqlParameter("@tendangnhap", tendangnhap);
            SqlParameter     pm4        = new SqlParameter("@tenhienthi", tenhienthi);
            SqlParameter     pm5        = new SqlParameter("@id_phongban", id_phongban);
            SqlParameter     pm6        = new SqlParameter("@email", email);
            SqlParameter     pm7        = new SqlParameter("@dangsudung", dangsudung);
            SqlParameter     pm8        = new SqlParameter("@quanly", quanly);
            SqlParameter     pm9        = new SqlParameter("@admin", admin);
            SqlParameter     pm10       = new SqlParameter("@quanlykho", quanlykho);
            SqlParameter     pm11       = new SqlParameter("@quanlymuahang", quanlymuahang);
            SqlParameter     pm12       = new SqlParameter("@matkhau", matkhau);
            SqlParameter     pm13       = new SqlParameter("@domain", domain);

            SqlParameter[] param = new SqlParameter[13] {
                pm, pm2, pm3, pm4, pm5, pm6, pm7, pm8, pm9, pm10, pm11, pm12, pm13
            };
            DataTable tb = kn.get_by_procedure("proc_Action_NguoiDung", param);

            if (tb != null)
            {
                foreach (DataRow row in tb.Rows)
                {
                    NguoiDung nguoidung = new NguoiDung();
                    nguoidung.Admin            = Convert.ToBoolean(row["Admin"]);
                    nguoidung.Dang_Nhap_Domain = Convert.ToBoolean(row["DangNhapDomain"]);
                    nguoidung.Dang_Su_Dung     = Convert.ToBoolean(row["DangSuDung"]);
                    nguoidung.Email            = row["Email"].ToString();
                    nguoidung.ID_NguoiDung     = Convert.ToInt16(row["ID"]);
                    nguoidung.ID_Phong_Ban     = Convert.ToInt32(row["ID_PhongBan"]);
                    nguoidung.Phong_Ban        = row["PhongBan"].ToString();
                    nguoidung.Ngay_Tao         = Convert.ToDateTime(row["NgayTao"]);
                    nguoidung.Quan_Ly          = Convert.ToBoolean(row["QuanLy"]);
                    nguoidung.Ten_Dang_Nhap    = row["TenDangNhap"].ToString();
                    nguoidung.Ten_Hien_Thi     = row["TenHienThi"].ToString();
                    nguoidung.Mat_Khau         = row["Password"].ToString();
                    nguoidung.Quan_Ly_Kho      = Convert.ToBoolean(row["QuanLyKho"]);
                    nguoidung.Quan_Ly_Mua_Hang = Convert.ToBoolean(row["QuanLyMuaHang"]);
                    nguoidung.Mat_Khau         = row["Password"].ToString();
                    nguoidungs.Add(nguoidung);
                }
            }
            return(nguoidungs);
        }
Пример #2
0
        public bool CheckLogin(string TenDangNhap, string MatKhau, ref string userData, ref string MessageError)
        {
            bool isOk = false;

            try
            {
                NguoiDung nguoidung = new NguoiDung().LayThongTinNguoiDung(TenDangNhap);


                if (!string.IsNullOrEmpty(TenDangNhap) && !string.IsNullOrEmpty(MatKhau))
                {
                    if (nguoidung.Dang_Su_Dung == true)
                    {
                        if (nguoidung.Dang_Nhap_Domain == false)
                        {
                            string mk = LibEncrypt.Encrypt(MatKhau, true);

                            //code xem ma hoa mat khau
                            //string mk2 = LibEncrypt.Decrypt(nguoidung.Mat_Khau, true);
                            //Response.Write("Mat khau da ma hoa : " + mk2);

                            if (mk == nguoidung.Mat_Khau)
                            {
                                userData = LibEncrypt.Encrypt(nguoidung.ID_NguoiDung + "," + nguoidung.Ten_Dang_Nhap + "," + nguoidung.Email + "," + nguoidung.Ten_Hien_Thi, true);
                                isOk     = true;
                            }
                        }
                        else
                        {
                            isOk = LDAP.AuthenticateUser("", TenDangNhap, MatKhau);
                            if (isOk)
                            {
                                userData = LibEncrypt.Encrypt(nguoidung.ID_NguoiDung + "," + nguoidung.Ten_Dang_Nhap + "," + nguoidung.Email + "," + nguoidung.Ten_Hien_Thi, true);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lbError.Text = "<span class=\"error\">Hệ thống đang bảo trì</span>";
            }
            return(isOk);
        }