Esempio n. 1
0
        public KhachHang LayThongTinKhachHang(string uname)
        {
            DAO_KhachHang daoKH = new DAO_KhachHang();

            daoKH.Open();
            string        qry    = "select * from KhachHang where TenDangNhap = '" + uname + "'";
            SqlCommand    cmd    = new SqlCommand(qry, daoKH.cnn);
            SqlDataReader reader = cmd.ExecuteReader();
            KhachHang     kh     = new KhachHang();

            if (reader.HasRows)
            {
                reader.Read();
                kh.MAKH        = reader.GetInt32(0);
                kh.TENDANGNHAP = uname;
                kh.HOTEN       = reader.GetValue(3).ToString();
                kh.GIOITINH    = reader.GetInt32(4);
                kh.DIACHI      = reader.GetValue(5).ToString();
                kh.EMAIL       = reader.GetValue(6).ToString();
                kh.SODIENTHOAI = reader.GetValue(7).ToString();
                kh.LAADMIN     = (bool)reader.GetValue(8);
            }


            reader.Dispose();
            cmd.Dispose();
            daoKH.Close();

            return(kh);
        }
Esempio n. 2
0
        public int LaDangNhapThanhCong(string Username, string Password)
        {
            int           flag = -1;
            DAO_KhachHang dao  = new DAO_KhachHang();

            dao.Open();
            string        qry    = "SELECT * FROM KHACHHANG WHERE TENDANGNHAP = '" + Username + "' AND MATKHAU ='" + Password + "'";
            SqlCommand    cmd    = new SqlCommand(qry, dao.cnn);
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                bool isAdmin = reader.GetBoolean(8);
                if (isAdmin == true)
                {
                    flag = 1;
                }
                else
                {
                    flag = 0;
                }
            }
            cmd.Dispose();
            reader.Dispose();
            dao.Close();
            return(flag);
        }
Esempio n. 3
0
        public int LayMaKH(string username)
        {
            DAO_KhachHang dao = new DAO_KhachHang();

            dao.Open();
            string        qry    = "SELECT MaKH FROM KHACHHANG WHERE TENDANGNHAP = '" + username + "'";
            SqlCommand    cmd    = new SqlCommand(qry, dao.cnn);
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Read();
                int makh = int.Parse(reader.GetValue(0).ToString());
                cmd.Dispose();
                reader.Dispose();
                dao.Close();
                return(makh);
            }
            else
            {
                cmd.Dispose();
                reader.Dispose();
                dao.Close();
                return(-1);
            }
        }
Esempio n. 4
0
        public void GhiThongTinKhachHang(KhachHang kh)
        {
            DAO_KhachHang dao = new DAO_KhachHang();

            dao.Open();
            string     qry = "insert into khachhang(TenDangNhap,MatKhau,HoTen,GioiTinh,DiaChi,Email,SoDienThoai,LaAdmin) values('" + kh.TENDANGNHAP + "','" + kh.MATKHAU + "','" + kh.HOTEN + "'," + kh.GIOITINH + ",'" + kh.DIACHI + "','" + kh.EMAIL + "','" + kh.SODIENTHOAI + "','False')";
            SqlCommand cmd = new SqlCommand(qry, dao.cnn);

            cmd.ExecuteNonQuery();
            cmd.Dispose();
            dao.Close();
        }
Esempio n. 5
0
        public void CapNhatThongTinKH(KhachHang kh)
        {
            DAO_KhachHang daoKH = new DAO_KhachHang();

            daoKH.Open();
            string qry = "Update KhachHang set HoTen = '" + kh.HOTEN + "', GioiTinh = " + kh.GIOITINH +
                         ", DiaChi = '" + kh.DIACHI + "', Email = '" + kh.EMAIL + "',SoDienThoai ='" + kh.SODIENTHOAI + "'" +
                         "where MaKH = " + kh.MAKH;
            SqlCommand cmd = new SqlCommand(qry, daoKH.cnn);

            cmd.ExecuteNonQuery();
            daoKH.Close();
        }
Esempio n. 6
0
        public DataTable DanhSachKhachHang()
        {
            DataTable     ds    = new DataTable();
            DAO_KhachHang daoKH = new DAO_KhachHang();

            daoKH.Open();
            string        qry    = "select * from KhachHang";
            SqlCommand    cmd    = new SqlCommand(qry, daoKH.cnn);
            SqlDataReader reader = cmd.ExecuteReader();

            ds.Load(reader);
            daoKH.Close();
            return(ds);
        }
Esempio n. 7
0
        public int LaTrungTenDangNhap(string TenDangNhap)
        {
            DAO_KhachHang dao = new DAO_KhachHang();

            dao.Open();
            string        qry    = "SELECT * FROM KHACHHANG WHERE TENDANGNHAP = '" + TenDangNhap + "'";
            SqlCommand    cmd    = new SqlCommand(qry, dao.cnn);
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                return(1);
            }
            return(0);
        }
Esempio n. 8
0
        public void XoaKhachHang(int MaKH)
        {
            DAO_KhachHang daoKH = new DAO_KhachHang();

            daoKH.Open();
            string     qry = "XOAKH";
            SqlCommand cmd = new SqlCommand(qry, daoKH.cnn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MaKH", SqlDbType.Int).Value = MaKH;
            cmd.ExecuteNonQuery();

            cmd.Dispose();

            daoKH.Close();
        }
Esempio n. 9
0
        public DataTable LoadTopKhachHang(int num)
        {
            DAO_KhachHang daoKH = new DAO_KhachHang();

            daoKH.Open();
            string        qry    = "select top " + num + " with ties B.HoTen,B.SoDienThoai , SUM(SoLuong*DonGia) as DoanhThu from HoaDon A,KhachHang B,ChiTiet_HoaDon C where A.MaHD = C.MaHD and B.MaKH = A.MaKH group by B.MaKH,B.HoTen,B.SoDienThoai order by SUM(SoLuong*DonGia) desc";
            SqlCommand    cmd    = new SqlCommand(qry, daoKH.cnn);
            SqlDataReader reader = cmd.ExecuteReader();
            DataTable     dt     = new DataTable();

            dt.Load(reader);

            reader.Dispose();
            cmd.Dispose();
            daoKH.Close();

            return(dt);
        }
Esempio n. 10
0
        public int LaTrungEmail(string Email)
        {
            int           flag = 0;
            DAO_KhachHang dao  = new DAO_KhachHang();

            dao.Open();
            string        qry    = "SELECT * FROM KHACHHANG WHERE Email = '" + Email + "'";
            SqlCommand    cmd    = new SqlCommand(qry, dao.cnn);
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                flag = 1;
            }
            cmd.Dispose();
            reader.Dispose();
            dao.Close();
            return(flag);
        }
Esempio n. 11
0
        public void CapNhatKhachHang(KhachHang kh)
        {
            DAO_KhachHang daoKH = new DAO_KhachHang();

            daoKH.CapNhatKhachHang(kh);
        }
Esempio n. 12
0
        public int LayMaKH(string username)
        {
            DAO_KhachHang dao = new DAO_KhachHang();

            return(dao.LayMaKH(username));
        }
Esempio n. 13
0
        public DataTable LoadTopKhachHang(int num)
        {
            DAO_KhachHang dao = new DAO_KhachHang();

            return(dao.LoadTopKhachHang(num));
        }
Esempio n. 14
0
        public void XoaKhachHang(int MaKH)
        {
            DAO_KhachHang daoKH = new DAO_KhachHang();

            daoKH.XoaKhachHang(MaKH);
        }
Esempio n. 15
0
        public void CapNhatThongTinKH(KhachHang kh)
        {
            DAO_KhachHang dao = new DAO_KhachHang();

            dao.CapNhatThongTinKH(kh);
        }
Esempio n. 16
0
        public int LaTrungTenDangNhap(string TenDangNhap)
        {
            DAO_KhachHang dao = new DAO_KhachHang();

            return(dao.LaTrungTenDangNhap(TenDangNhap));
        }
Esempio n. 17
0
        public int LaTrungEmail(string Email)
        {
            DAO_KhachHang dao = new DAO_KhachHang();

            return(dao.LaTrungEmail(Email));
        }
Esempio n. 18
0
        public int LaDangNhapThanhCong(string Username, string Password)
        {
            DAO_KhachHang dao = new DAO_KhachHang();

            return(dao.LaDangNhapThanhCong(Username, Password));
        }
Esempio n. 19
0
        public DataTable DanhSachKhachHang()
        {
            DAO_KhachHang daoKH = new DAO_KhachHang();

            return(daoKH.DanhSachKhachHang());
        }
Esempio n. 20
0
        public void GhiThongTinKhachHang(KhachHang kh)
        {
            DAO_KhachHang dao = new DAO_KhachHang();

            dao.GhiThongTinKhachHang(kh);
        }
Esempio n. 21
0
        public KhachHang LayThongTinKhachHang(string uname)
        {
            DAO_KhachHang daoKH = new DAO_KhachHang();

            return(daoKH.LayThongTinKhachHang(uname));
        }