Пример #1
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;
        }
Пример #2
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;
        }
Пример #3
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;
        }
Пример #4
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;
        }
Пример #5
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;
        }
Пример #6
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;
        }
Пример #7
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;
        }
Пример #8
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;
        }
Пример #9
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;
        }
Пример #10
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;
        }
Пример #11
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;
        }
Пример #12
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;
        }
Пример #13
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;
        }
Пример #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 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;
        }
Пример #16
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;
        }
Пример #17
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;
        }
Пример #18
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;
        }
Пример #19
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;
        }