示例#1
0
        public bool KtMatKhau(int id, string MKcu)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            KhachHang kh = db.KhachHangs.SingleOrDefault(p => p.MaKhachHang == id);

            if (kh == null) 
                return false;

            if (MKcu == kh.MatKhau)
                return true;
            return false;
        }
示例#2
0
        public bool DoiMatKhau(int id, string matkhaucu, string matkhaumoi)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            KhachHang kh = db.KhachHangs.SingleOrDefault(p => p.MaKhachHang == id);

            if (kh != null)
                kh.MatKhau = matkhaumoi;
            else
                return false;

            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#3
0
        public List<MatHang1> XuatMatHang()
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            var query = from c in db.MatHangs
                        select new MatHang1()
                        {
                           GiaHienHanh = c.GiaHienHanh,
                           LoaiMatHang = c.LoaiMatHang,
                           MaMatHang = c.MaMatHang,
                           NgaySanXuat = c.NgaySanXuat,
                           NhaSanXuat = c.NhaSanXuat,
                           SoLuongMHTrenKe = c.SoLuongMHTrenKe,
                           SoLuongMHTrenKho = c.SoLuongMHTrenKho,
                           TenMatHang = c.TenMatHang,                           
                        };
            return query.ToList(); 
        }
示例#4
0
        public List<KhachHang1> XuatKhachHang()
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            var query = from c in db.KhachHangs
                        select new KhachHang1()
                    {
                        CMND = c.CMND,
                        DiaChi = c.DiaChi,
                        DiemTichLuy = c.DiemTichLuy,
                        Email = c.Email,
                        HoTen = c.HoTen,
                        MaKhachHang = c.MaKhachHang,
                        MatKhau = c.MatKhau,
                        SDT = c.SDT,
                        TenDN = c.TenDN,                        
                    };
            return query.ToList();
        }
示例#5
0
        public bool UpdateLoaiMH(int id, string ten)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            LoaiMH ob = db.LoaiMHs.SingleOrDefault(p => p.MaLoaiMH == id);

            if (ob == null)
                return false; 
            
            ob.TenLoaiMH = ten;

            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#6
0
        public bool UpdateNSX(int id, string ten)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            NSX ob = db.NSXes.SingleOrDefault(p => p.MaNSX == id);
            if (ob == null)
                return false;

            ob.TenNSX = ten;            

            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#7
0
        public bool XoaNSX(int id)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            NSX ob = db.NSXes.SingleOrDefault(p => p.MaNSX == id);
            if (ob == null)
                return false;
            db.NSXes.Remove(ob);

            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#8
0
        public bool XoaMatHang(int id)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            MatHang ob = db.MatHangs.SingleOrDefault(p => p.MaMatHang == id);
            if (ob == null)
                return false;
            db.MatHangs.Remove(ob);

            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#9
0
 public List<NhanVien1> XuatNhanVien()
 {
     QL_NhaSachEntities db = new QL_NhaSachEntities();
     var query = from c in db.NhanViens
                 select new NhanVien1()
                 {
                     CMND = c.CMND,
                     DiaChi = c.DiaChi,
                     Email = c.Email,
                     HoTen = c.HoTen,
                     MaNguoiQL = c.MaNguoiQL,
                     MaNhanVien = c.MaNhanVien,
                     MatKhau = c.MatKhau,
                     SDT = c.SDT,
                     TenDN = c.TenDN,
                 };
     return query.ToList(); 
 }
示例#10
0
        public bool XoaLoaiMH(int id)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            LoaiMH ob = db.LoaiMHs.SingleOrDefault(p => p.MaLoaiMH == id);
            if (ob == null)
                return false;
            db.LoaiMHs.Remove(ob);

            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#11
0
        public bool UpdateKhachHang(int id, string TenDN, string MatKhau, string Hoten, string Email, string DiaChi, string SDT, string CMND, double DiemTichLuy)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            KhachHang ob = db.KhachHangs.SingleOrDefault(p => p.MaKhachHang == id);
            if (ob == null)
                return false; 
            
            ob.TenDN = TenDN;
            ob.MatKhau = MatKhau;
            ob.HoTen = Hoten;
            ob.Email = Email;
            ob.DiaChi = DiaChi;
            ob.SDT = SDT;
            ob.CMND = CMND;
            ob.DiemTichLuy = DiemTichLuy;            

            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#12
0
        public bool ThemNSX(string ten)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();
            int index = 1;
            if ((db.NSXes.ToList()).Count != 0)
            {
                index = db.NSXes.Max(p => p.MaNSX);
                index += 1;
            }

            NSX ob = new NSX()
            {
                MaNSX = index,
                TenNSX = ten,
            };

            db.NSXes.Add(ob);
            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#13
0
        public bool ThemKhachHang(string TenDN, string MatKhau, string Hoten, string Email, string DiaChi, string SDT, string CMND)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();
            int kh = 1;
            if ((db.KhachHangs.ToList()).Count != 0)
            {
                kh = db.KhachHangs.Max(p => p.MaKhachHang);
                kh += 1;
            }

            KhachHang KH = new KhachHang()
            {
                MaKhachHang = kh,
                TenDN = TenDN,
                MatKhau = MatKhau,
                HoTen = Hoten,
                Email = Email,
                DiaChi = DiaChi,
                SDT = SDT,
                CMND = CMND,
                DiemTichLuy = 0,
            };

            db.KhachHangs.Add(KH);
            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#14
0
        public bool UpdateNhanVien(int id, string TenDN, string MatKhau, string Hoten, string Email, string DiaChi, string SDT, string CMND, int NguoiQL)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();
            NhanVien ob = db.NhanViens.SingleOrDefault(p => p.MaNhanVien == id);
            if (ob == null)
                return false; 
            
            ob.TenDN = TenDN;
            ob.MatKhau = MatKhau;
            ob.HoTen = Hoten;
            ob.Email = Email;
            ob.DiaChi = DiaChi;
            ob.SDT = SDT;
            ob.CMND = CMND;
            ob.MaNguoiQL = NguoiQL;            

            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#15
0
        public bool ThemNhanVien(string TenDN, string MatKhau, string Hoten, string Email, string DiaChi, string SDT, string CMND, int NguoiQL)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();
            int index = 1;
            if ((db.NhanViens.ToList()).Count != 0)
            {
                index = db.NhanViens.Max(p => p.MaNhanVien);
                index += 1;
            }

            NhanVien ob = new NhanVien()
            {
                MaNhanVien = index,
                TenDN = TenDN,
                MatKhau = MatKhau,
                HoTen = Hoten,
                Email = Email,
                DiaChi = DiaChi,
                SDT = SDT,
                CMND = CMND,
                MaNguoiQL = NguoiQL,
            };

            db.NhanViens.Add(ob);
            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#16
0
 public List<PhieuMuaHang1> XuatPhieuMuaHang()
 {
     QL_NhaSachEntities db = new QL_NhaSachEntities();
     var query = from c in db.PhieuMuaHangs
                 select new PhieuMuaHang1()
                 {
                     MaKhachHang = c.MaKhachHang,
                     MaNhanVien = c.MaNhanVien,
                     MaPhieuMuaHang = c.MaPhieuMuaHang,
                     NgayLap = c.NgayLap,
                     TongTien = c.TongTien,
                 };
     return query.ToList(); 
 }
示例#17
0
        public bool ThemMatHang(string ten, int LoaiMatHang, DateTime NgaySanXuat, double GiaHienHanh, int NhaSanXuat, int SoLuongMHTrenKe, int SoLuongMHTrenKho)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();
            int index = 1;
            if ((db.MatHangs.ToList()).Count != 0)
            {
                index = db.MatHangs.Max(p => p.MaMatHang);
                index += 1;
            }

            MatHang ob = new MatHang()
            {
                MaMatHang = index,
                TenMatHang = ten,
                LoaiMatHang = LoaiMatHang,
                NgaySanXuat = NgaySanXuat,
                GiaHienHanh = GiaHienHanh,
                NhaSanXuat = NhaSanXuat,
                SoLuongMHTrenKe = SoLuongMHTrenKe,
                SoLuongMHTrenKho = SoLuongMHTrenKho,
            };

            db.MatHangs.Add(ob);
            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#18
0
        public bool UpdateMatHang(int id, string ten, int LoaiMatHang, DateTime NgaySanXuat, double GiaHienHanh, int NhaSanXuat, int SoLuongMHTrenKe, int SoLuongMHTrenKho)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            MatHang ob = db.MatHangs.SingleOrDefault(p => p.MaMatHang == id);
            if (ob == null)
                return false; 
            
            ob.TenMatHang = ten;
            ob.LoaiMatHang = LoaiMatHang;
            ob.NgaySanXuat = NgaySanXuat;
            ob.GiaHienHanh = GiaHienHanh;
            ob.NhaSanXuat = NhaSanXuat;
            ob.SoLuongMHTrenKe = SoLuongMHTrenKe;
            ob.SoLuongMHTrenKho = SoLuongMHTrenKho;
            
            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#19
0
 public List<NSX1> XuatNSX()
 {
     QL_NhaSachEntities db = new QL_NhaSachEntities();
     var query = from c in db.NSXes
                 select new NSX1()
                 {
                     MaNSX = c.MaNSX,
                     TenNSX = c.TenNSX,                             
                 };
     return query.ToList(); 
 }
示例#20
0
        public bool ThemPhieuMuaHang(int MaKhachHang, int MaNhanVien, DateTime NgayLap, double TongTien)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();
            int index = 1;
            if ((db.PhieuMuaHangs.ToList()).Count != 0)
            {
                index = db.PhieuMuaHangs.Max(p => p.MaPhieuMuaHang);
                index += 1;
            }

            PhieuMuaHang ob = new PhieuMuaHang()
            {
                MaPhieuMuaHang = index,
                MaKhachHang=MaKhachHang,
                MaNhanVien=MaNhanVien,
                NgayLap=NgayLap,
                TongTien = TongTien,
            };

            db.PhieuMuaHangs.Add(ob);
            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#21
0
        public bool ThemLoaiMH(string ten)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();
            int index = 1;
            if ((db.LoaiMHs.ToList()).Count != 0)
            {
                index = db.LoaiMHs.Max(p => p.MaLoaiMH);
                index += 1;
            }

            LoaiMH ob = new LoaiMH()
            {
                MaLoaiMH = index,
                TenLoaiMH = ten,                
            };

            db.LoaiMHs.Add(ob);
            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#22
0
        public bool UpdatePhieuMuaHang(int id, int MaKhachHang, int MaNhanVien, DateTime NgayLap, double TongTien)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();
            PhieuMuaHang ob = db.PhieuMuaHangs.SingleOrDefault(p => p.MaPhieuMuaHang == id);
            if (ob == null)
                return false; 
            
            ob.MaKhachHang = MaKhachHang;
            ob.MaNhanVien = MaNhanVien;
            ob.NgayLap = NgayLap;
            ob.TongTien = TongTien;            

            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#23
0
        public bool ThemChiTietPhieuMuaHang(int MaPhieuMuaHang, int MaMatHang, int SoLuong, double DonGia)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();
            
            ChiTietPhieuMuaHang ob = new ChiTietPhieuMuaHang()
            {
                MaPhieuMuaHang = MaPhieuMuaHang,
                MaMatHang = MaMatHang,
                SoLuong = SoLuong,
                DonGia = DonGia,                
            };

            db.ChiTietPhieuMuaHangs.Add(ob);
            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#24
0
        public bool UpdateChiTietPhieuMuaHang(int MaPhieuMuaHang, int MaMatHang, int SoLuong, double DonGia)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            ChiTietPhieuMuaHang ob = db.ChiTietPhieuMuaHangs.SingleOrDefault(p => (p.MaMatHang == MaMatHang && p.MaPhieuMuaHang == MaPhieuMuaHang));
            if (ob == null)
                return false;
                        
            ob.SoLuong = SoLuong;
            ob.DonGia = DonGia;            

            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#25
0
        public bool XoaChiTietPhieuMuaHang(int idMH ,int idPhieuMua)
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            ChiTietPhieuMuaHang ob = db.ChiTietPhieuMuaHangs.SingleOrDefault(p => (p.MaMatHang == idMH && p.MaPhieuMuaHang == idPhieuMua)  );
            if (ob == null)
                return false;
            db.ChiTietPhieuMuaHangs.Remove(ob);

            if (db.SaveChanges() <= 0)
                return false;
            return true;
        }
示例#26
0
        public List<ChiTietPhieuMuaHang1> XuatChiTietPhieuMuaHang()
        {
            QL_NhaSachEntities db = new QL_NhaSachEntities();

            var query = from c in db.ChiTietPhieuMuaHangs 
                    select new ChiTietPhieuMuaHang1() 
                    {
                        DonGia = c.DonGia,
                        MaMatHang = c.MaMatHang,
                        MaPhieuMuaHang = c.MaPhieuMuaHang,
                        SoLuong = c.SoLuong,
                    };
            return query.ToList();
        }
示例#27
0
 public List<LoaiMH1> XuatLoaiMH()
 {
     QL_NhaSachEntities db = new QL_NhaSachEntities();
     var query = from c in db.LoaiMHs
                 select new LoaiMH1()
                 {
                     MaLoaiMH = c.MaLoaiMH,
                     TenLoaiMH = c.TenLoaiMH,                            
                 };
     return query.ToList(); 
 }