Exemplo n.º 1
0
        public static List <NhanVienDTO> LayToanBoNhanVien()
        {
            List <NhanVienDTO> lst = new List <NhanVienDTO>();
            DataProvider       p   = new DataProvider();

            p.Connect();
            SqlDataReader r  = p.GetReader("sp_LayTatCaNhanVien", CommandType.StoredProcedure);
            NhanVienDTO   nv = null;

            while ((r.Read()))
            {
                nv            = new NhanVienDTO();
                nv.MaNhanVien = Convert.ToInt32(r[0]);
                nv.HoTen      = r[1].ToString();
                nv.ChucVu     = r[2].ToString();
                nv.DiaChi     = r[3].ToString();
                nv.Email      = r[4].ToString();
                nv.DienThoai  = r[5].ToString();
                nv.DiDong     = r[6].ToString();
                // kiểm tra xem có dữ liệu không?
                if (r[7].ToString() != null)
                {
                    nv.BoPhan = Convert.ToInt32(r[7]);
                }
                if (r[8].ToString() != null)
                {
                    nv.QuanLy = Convert.ToInt32(r[8]);
                }
                nv.ConQuanLy = Convert.ToBoolean(r[9]);
                lst.Add(nv);
            }
            p.Disconnect();
            return(lst);
        }
Exemplo n.º 2
0
        public static List <HangHoaDTO> _LayTatCaHangHoa()
        {
            List <HangHoaDTO> lst = new List <HangHoaDTO>();

            DataProvider p = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("LayTatCaHangHoa", CommandType.StoredProcedure);

            HangHoaDTO hh = null;

            while ((r.Read()))
            {
                hh                = new HangHoaDTO();
                hh.MaHangHoa      = Convert.ToInt32(r[0]);
                hh.TenHangHoa     = r[1].ToString();
                hh.LoaiHangHoa    = Convert.ToInt32(r[2]);
                hh.KhoMacDinh     = Convert.ToInt32(r[3]);
                hh.PhanLoai       = Convert.ToInt32(r[4]);
                hh.DonVi          = Convert.ToInt32(r[5]);
                hh.XuatXu         = r[6].ToString();
                hh.TonKhoToiThieu = Convert.ToInt32(r[7]);
                hh.TonKho         = Convert.ToInt32(r[8]);
                hh.NhaCungCap     = Convert.ToInt32(r[9]);
                hh.GiaMua         = Convert.ToDouble(r[10]);
                hh.GiaBan         = Convert.ToDouble(r[11]);
                hh.ConQuanLy      = Convert.ToBoolean(r[12]);

                lst.Add(hh);
            }
            p.Disconnect();
            return(lst);
        }
Exemplo n.º 3
0
        public static List <BoPhanDTO> LayToanBoBoPhan()
        {
            List <BoPhanDTO> lst = new List <BoPhanDTO>();

            DataProvider p = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("sp_LayTatCaBoPhan", CommandType.StoredProcedure);

            BoPhanDTO bp;

            while (r.Read())
            {
                bp           = new BoPhanDTO();
                bp.MaBoPhan  = Convert.ToInt32(r[0]);
                bp.TenBoPhan = r[1].ToString();
                bp.GhiChu    = r[2].ToString();
                bp.ConQuanLy = Convert.ToBoolean(r[3]);

                lst.Add(bp);
            }

            p.Disconnect();
            return(lst);
        }
Exemplo n.º 4
0
        public static HangHoaDTO LayThongTinHangHoaCanMuaTheoMa(int MaHangHoa)
        {
            HangHoaDTO hh = new HangHoaDTO();

            DataProvider p = new DataProvider();

            p.Connect();

            SqlParameter p1 = new SqlParameter("@MaHangHoa", SqlDbType.Int)
            {
                Value = MaHangHoa
            };
            SqlDataReader r = p.GetReader("sp_LayThongTinHangHoaCanMuaTheoMa", CommandType.StoredProcedure, p1);

            while ((r.Read()))
            {
                hh.MaHangHoa  = Convert.ToInt32(r[0]);
                hh.TenHangHoa = r[1].ToString();
                hh.DonVi      = Convert.ToInt32(r[2]);
                hh.GiaMua     = float.Parse(r[3].ToString());
            }

            p.Disconnect();
            return(hh);
        }
Exemplo n.º 5
0
        public static List <TaiKhoan_DTO> LayHetNguoiDung()
        {
            List <TaiKhoan_DTO> lst = new List <TaiKhoan_DTO>();

            DataProvider p = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("sp_LayHetNguoiDung", CommandType.StoredProcedure);

            TaiKhoan_DTO nd = null;

            while ((r.Read()))
            {
                nd             = new TaiKhoan_DTO();
                nd.MaNguoiDung = Convert.ToInt32(r[0]);
                nd.Ten         = r[1].ToString();
                nd.TaiKhoan    = r[2].ToString();
                nd.MatKhau     = r[3].ToString();
                nd.XacNhan     = r[4].ToString();
                nd.MaVaiTro    = Convert.ToInt32(r[5]);
                nd.GhiChu      = r[6].ToString();
                lst.Add(nd);
            }
            p.Disconnect();
            return(lst);
        }
Exemplo n.º 6
0
        public static List <KhoHangDTO> LayDanhSachKhoHang()
        {
            List <KhoHangDTO> lst = new List <KhoHangDTO>();

            DataProvider p = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("sp_LayTatCaKhoHang", CommandType.StoredProcedure);

            KhoHangDTO kh = null;

            while ((r.Read()))
            {
                kh             = new KhoHangDTO();
                kh.MaKho       = Convert.ToInt32(r[0]);
                kh.TenKho      = r[1].ToString();
                kh.NVQuanLy    = Convert.ToInt32(r[2]);
                kh.NguoiLienHe = r[3].ToString();
                kh.DiaChi      = r[4].ToString();
                kh.DienThoai   = r[5].ToString();
                kh.Fax         = r[6].ToString();
                kh.Email       = r[7].ToString();
                kh.DienGiai    = r[8].ToString();
                kh.ConQuanLy   = Convert.ToBoolean(r[9]);
                lst.Add(kh);
            }

            p.Disconnect();
            return(lst);
        }
Exemplo n.º 7
0
        public static VaiTroDTO LayVaiTroTheoTaiKhoan(string TaiKhoan)
        {
            DataProvider p = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("sp_LayVaiTroTheoTaiKhoan", CommandType.StoredProcedure, new SqlParameter("@TaiKhoan", SqlDbType.VarChar, 50)
            {
                Value = TaiKhoan
            });

            VaiTroDTO vt = new VaiTroDTO();

            while ((r.Read()))
            {
                vt.MaVaiTro      = Convert.ToInt32(r[0]);
                vt.Ten           = r[1].ToString();
                vt.PhanQuyen     = Convert.ToBoolean(r[2]);
                vt.DoiMatKhau    = Convert.ToBoolean(r[3]);
                vt.NhatKyHeThong = Convert.ToBoolean(r[4]);
                vt.SaoLuu        = Convert.ToBoolean(r[5]);
                vt.PhucHoi       = Convert.ToBoolean(r[6]);
                vt.KhuVuc        = Convert.ToBoolean(r[7]);
                vt.KhachHang     = Convert.ToBoolean(r[8]);
                vt.NhaCungCap    = Convert.ToBoolean(r[9]);
                vt.KhoHang       = Convert.ToBoolean(r[10]);
                vt.DonViTinh     = Convert.ToBoolean(r[11]);
                vt.NhomHang      = Convert.ToBoolean(r[12]);
                vt.HangHoa       = Convert.ToBoolean(r[13]);
                vt.TyGia         = Convert.ToBoolean(r[14]);
                vt.BoPhan        = Convert.ToBoolean(r[15]);
                vt.NhanVien      = Convert.ToBoolean(r[16]);
                vt.MuaHang       = Convert.ToBoolean(r[17]);
                vt.BanHang       = Convert.ToBoolean(r[18]);
                vt.TonKho        = Convert.ToBoolean(r[19]);
                vt.ChuyenKho     = Convert.ToBoolean(r[20]);
                vt.ThuTien       = Convert.ToBoolean(r[21]);
                vt.TraTien       = Convert.ToBoolean(r[22]);
                vt.BaoCaoKhoHang = Convert.ToBoolean(r[23]);
                vt.BaoCaoBanHang = Convert.ToBoolean(r[24]);
            }
            p.Disconnect();
            return(vt);
        }
Exemplo n.º 8
0
        public static List <VaiTroDTO> LayHetVaiTro()
        {
            List <VaiTroDTO> lst = new List <VaiTroDTO>();
            DataProvider     p   = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("sp_LayHetVaiTro", CommandType.StoredProcedure);

            VaiTroDTO vt = null;

            while ((r.Read()))
            {
                vt               = new VaiTroDTO();
                vt.MaVaiTro      = Convert.ToInt32(r[0]);
                vt.Ten           = r[1].ToString();
                vt.PhanQuyen     = Convert.ToBoolean(r[2]);
                vt.DoiMatKhau    = Convert.ToBoolean(r[3]);
                vt.NhatKyHeThong = Convert.ToBoolean(r[4]);
                vt.SaoLuu        = Convert.ToBoolean(r[5]);
                vt.PhucHoi       = Convert.ToBoolean(r[6]);
                vt.KhuVuc        = Convert.ToBoolean(r[7]);
                vt.KhachHang     = Convert.ToBoolean(r[8]);
                vt.NhaCungCap    = Convert.ToBoolean(r[9]);
                vt.KhoHang       = Convert.ToBoolean(r[10]);
                vt.DonViTinh     = Convert.ToBoolean(r[11]);
                vt.NhomHang      = Convert.ToBoolean(r[12]);
                vt.HangHoa       = Convert.ToBoolean(r[13]);
                vt.TyGia         = Convert.ToBoolean(r[14]);
                vt.BoPhan        = Convert.ToBoolean(r[15]);
                vt.NhanVien      = Convert.ToBoolean(r[16]);
                vt.MuaHang       = Convert.ToBoolean(r[17]);
                vt.BanHang       = Convert.ToBoolean(r[18]);
                vt.TonKho        = Convert.ToBoolean(r[19]);
                vt.ChuyenKho     = Convert.ToBoolean(r[20]);
                vt.ThuTien       = Convert.ToBoolean(r[21]);
                vt.TraTien       = Convert.ToBoolean(r[22]);
                vt.BaoCaoKhoHang = Convert.ToBoolean(r[23]);
                vt.BaoCaoBanHang = Convert.ToBoolean(r[24]);
                lst.Add(vt);
            }
            p.Disconnect();
            return(lst);
        }
Exemplo n.º 9
0
        public static List <LoaiHangDTO> LayTatCaLoaiHangHoa()
        {
            List <LoaiHangDTO> lst = new List <LoaiHangDTO>();

            DataProvider p = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("sp_LayTatCaLoaiHang", CommandType.StoredProcedure);

            LoaiHangDTO hh = null;

            while ((r.Read()))
            {
                hh           = new LoaiHangDTO();
                hh.MaLoaiHH  = Convert.ToInt32(r[0]);
                hh.TenLoaiHH = r[1].ToString();
                lst.Add(hh);
            }
            p.Disconnect();
            return(lst);
        }
Exemplo n.º 10
0
        public static List <TyGiaDTO> LoadTatCaTyGia()
        {
            List <TyGiaDTO> ltg = new List <TyGiaDTO>();
            TyGiaDTO        tg  = null;
            DataProvider    p   = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("sp_LayTatCaTyGia", CommandType.StoredProcedure);

            while (r.Read())
            {
                tg             = new TyGiaDTO();
                tg.MaTyGia     = Convert.ToInt32(r[0]);
                tg.TenTyGia    = r[1].ToString();
                tg.TyGiaQuyDoi = Convert.ToDouble(r[2]);
                tg.ConQuanLy   = Convert.ToBoolean(r[3]);
                ltg.Add(tg);
            }
            p.Disconnect();
            return(ltg);
        }
Exemplo n.º 11
0
        public static List <NhomHangDTO> LoadNhomHang()
        {
            List <NhomHangDTO> lnh = new List <NhomHangDTO>();
            NhomHangDTO        nh  = default(NhomHangDTO);
            DataProvider       p   = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("sp_LayTatCaNhomHang", CommandType.StoredProcedure);

            while (r.Read())
            {
                nh             = new NhomHangDTO();
                nh.MaNhomHang  = Convert.ToInt32(r[0]);
                nh.TenNhomHang = Convert.ToString(r[1].ToString());
                nh.GhiChu      = Convert.ToString(r[2].ToString());
                nh.ConQuanLy   = Convert.ToBoolean(r[3]);
                lnh.Add(nh);
            }
            p.Disconnect();
            return(lnh);
        }
Exemplo n.º 12
0
        public static List <Log_DTO> LoadNhatKyHoatDong()
        {
            DataProvider p = new DataProvider();

            p.Connect();
            List <Log_DTO> lnk = new List <Log_DTO>();
            Log_DTO        nk  = null;
            SqlDataReader  r   = p.GetReader("sp_LoadLog", CommandType.StoredProcedure);

            while (r.Read())
            {
                nk          = new Log_DTO();
                nk.Ma       = Convert.ToInt32(r[0]);
                nk.TenND    = r[1].ToString();
                nk.ChucNang = r[2].ToString();
                nk.HanhDong = r[3].ToString();
                nk.ThoiGian = r[4].ToString();
                lnk.Add(nk);
            }
            p.Disconnect();
            return(lnk);
        }
Exemplo n.º 13
0
        public static List <NhaCungCapDTO> LayDanhSachNhaCungCap()
        {
            List <NhaCungCapDTO> lst = new List <NhaCungCapDTO>();

            DataProvider p = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("sp_LayDuLieuNhaCungCap", CommandType.StoredProcedure);

            NhaCungCapDTO ncc = null;

            while ((r.Read()))
            {
                ncc = new NhaCungCapDTO();
                ncc.MaNhaCungCap   = Convert.ToInt32(r[0]);
                ncc.TenNhaPhanPhoi = r[1].ToString();
                ncc.DiaChi         = r[2].ToString();
                ncc.MaSoThue       = r[3].ToString();
                ncc.SoDiDong       = r[4].ToString();
                ncc.SoDienThoaiBan = r[5].ToString();
                ncc.Email          = r[6].ToString();
                ncc.Fax            = r[7].ToString();
                ncc.Website        = r[8].ToString();
                ncc.SoTaiKhoan     = r[9].ToString();
                ncc.NganHang       = r[10].ToString();
                ncc.GioiHanNo      = Convert.ToDouble(r[11]);
                ncc.ChietKhau      = Convert.ToDouble(r[12]);
                ncc.NguoiLienHe    = r[13].ToString();
                ncc.ChucVu         = r[14].ToString();
                ncc.NoHienTai      = Convert.ToDouble(r[15]);
                ncc.KhuVuc         = Convert.ToInt32(r[16]);
                ncc.ConQuanLy      = Convert.ToBoolean(r[17]);
                lst.Add(ncc);
            }

            p.Disconnect();
            return(lst);
        }
Exemplo n.º 14
0
        public static List <DonViTinhDTO> LayToanBoDonVi()
        {
            List <DonViTinhDTO> lst = new List <DonViTinhDTO>();

            DataProvider p = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("sp_LayTatCaDonVi", CommandType.StoredProcedure);

            DonViTinhDTO dv = null;

            while ((r.Read()))
            {
                dv           = new DonViTinhDTO();
                dv.MaDV      = Convert.ToInt32(r[0]);
                dv.TenDonVi  = r[1].ToString();
                dv.GhiChu    = r[2].ToString();
                dv.ConQuanLy = Convert.ToBoolean(r[3]);
                lst.Add(dv);
            }
            p.Disconnect();
            return(lst);
        }
Exemplo n.º 15
0
        public static List <KhachHangDTO> LayDanhSachKhachHang()
        {
            List <KhachHangDTO> lKH = new List <KhachHangDTO>();
            DataProvider        p   = new DataProvider();

            p.Connect();
            SqlDataReader dr = p.GetReader("sp_ChonKhachHang", CommandType.StoredProcedure);
            KhachHangDTO  kh = null;

            while (dr.Read())
            {
                kh                = new KhachHangDTO();
                kh.MaKH           = Convert.ToInt32(dr[0]);
                kh.HoTen          = dr[1].ToString().TrimEnd();
                kh.DiaChi         = dr[2].ToString().TrimEnd();
                kh.MaSoThue       = dr[3].ToString().TrimEnd();
                kh.SoDiDong       = dr[4].ToString().TrimEnd();
                kh.SoDienThoaiBan = dr[5].ToString().TrimEnd();
                kh.Email          = dr[6].ToString().TrimEnd();
                kh.Fax            = dr[7].ToString().TrimEnd();
                kh.Website        = dr[8].ToString().TrimEnd();
                kh.SoTaiKhoan     = dr[9].ToString().TrimEnd();
                kh.NganHang       = dr[10].ToString().TrimEnd();
                kh.GioiHanNo      = Convert.ToDouble(dr[11]);
                kh.ChietKhau      = Convert.ToDouble(dr[12]);
                kh.NguoiLienHe    = dr[13].ToString().TrimEnd();
                kh.NoHienTai      = Convert.ToDouble(dr[14]);
                kh.NickYahoo      = dr[15].ToString().TrimEnd();
                kh.LoaiKhachHang  = Convert.ToInt32(dr[16]);
                kh.KhuVuc         = Convert.ToInt32(dr[17]);
                kh.NickSkype      = dr[18].ToString().TrimEnd();
                kh.ConQuanLy      = Convert.ToBoolean(dr[19]);
                lKH.Add(kh);
            }
            p.Disconnect();
            return(lKH);
        }
Exemplo n.º 16
0
        public static List <KhuVucDTO> LayToanBoKhuVuc()
        {
            List <KhuVucDTO> lst = new List <KhuVucDTO>();

            DataProvider p = new DataProvider();

            p.Connect();
            SqlDataReader r = p.GetReader("sp_LayTatCaKhuVuc", CommandType.StoredProcedure);

            KhuVucDTO kv = null;

            while ((r.Read()))
            {
                kv           = new KhuVucDTO();
                kv.MaKhuVuc  = Convert.ToInt32(r[0]);
                kv.TenKhuVuc = r[1].ToString();
                kv.GhiChu    = r[2].ToString();
                kv.ConQuanLy = Convert.ToBoolean(r[3]);
                lst.Add(kv);
            }

            p.Disconnect();
            return(lst);
        }