Пример #1
0
        public string getMaSP(string tensp)
        {
            db = new QLCafeDataContext();
            SanPham l = db.SanPhams.Where(o => o.tenSP == tensp).FirstOrDefault();

            return(l.maSP);
        }
Пример #2
0
        public decimal getDonGia(string tensp)
        {
            db = new QLCafeDataContext();
            SanPham l = db.SanPhams.Where(o => o.tenSP == tensp).FirstOrDefault();

            return(l.dongia);
        }
Пример #3
0
        public List <KhachHang> getKhachHangByTen(string tenKH)
        {
            da = new QLCafeDataContext();
            List <KhachHang> lstKH = da.KhachHangs.Where(o => o.tenKH == tenKH).ToList();

            return(lstKH);
        }
Пример #4
0
        public List <HoaDon> getHdayMa(string mahd)
        {
            da = new QLCafeDataContext();
            List <HoaDon> lst = da.HoaDons.Where(o => o.maHD == mahd).ToList();

            return(lst);
        }
Пример #5
0
        public List <KhachHang> getKhachHangByMa(string maKH)
        {
            da = new QLCafeDataContext();
            List <KhachHang> lstKH = da.KhachHangs.Where(o => o.maKH == maKH).ToList();

            return(lstKH);
        }
Пример #6
0
        public List <HoaDon> getAllHDThu()
        {
            da = new QLCafeDataContext();
            List <HoaDon> lst = da.HoaDons.Where(o => o.loaiHD == true).ToList();

            return(lst);
        }
Пример #7
0
        public string getKhachHangByName(string tenKH)
        {
            da = new QLCafeDataContext();
            KhachHang lstKH = da.KhachHangs.Where(o => o.tenKH == tenKH).FirstOrDefault();

            return(lstKH.maKH);
        }
Пример #8
0
        public List <KhachHang> getAllKhachHang()
        {
            da = new QLCafeDataContext();
            List <KhachHang> lstKH = da.KhachHangs.ToList();

            return(lstKH);
        }
Пример #9
0
        public string getDVTinh(string tenNL)
        {
            db = new QLCafeDataContext();
            NguyenLieu lst = new NguyenLieu();

            lst = db.NguyenLieus.Where(o => o.tenNL == tenNL).FirstOrDefault();
            return(lst.dvtinh);
        }
Пример #10
0
        public List <LoaiSP> GetAllSP2Grid()
        {
            db = new QLCafeDataContext();
            List <LoaiSP> lst = new List <LoaiSP>();

            lst = db.LoaiSPs.ToList();
            return(lst);
        }
Пример #11
0
        public List <NhanVien> GetAllNhanVien()
        {
            db = new QLCafeDataContext();

            List <NhanVien> lst = new List <NhanVien>();

            lst = db.NhanViens.ToList();
            return(lst);
        }
Пример #12
0
        public List <SanPham> GetAllSP()
        {
            db = new QLCafeDataContext();

            List <SanPham> lst = new List <SanPham>();

            lst = db.SanPhams.ToList();
            return(lst);
        }
Пример #13
0
        public List <NguyenLieu> GetAllNguyenLieu()
        {
            db = new QLCafeDataContext();

            List <NguyenLieu> lst = new List <NguyenLieu>();

            lst = db.NguyenLieus.ToList();
            return(lst);
        }
Пример #14
0
 public bool addHDThu(HoaDon hdthu)
 {
     try
     {
         da = new QLCafeDataContext();
         da.HoaDons.InsertOnSubmit(hdthu);
         da.SubmitChanges();
         return(true);
     }
     catch { throw new Exception("Thêm Hóa đơn thất bại"); }
 }
Пример #15
0
 public bool addCTHDThu(CT_HoaDonThu cthdThu)
 {
     try
     {
         da = new QLCafeDataContext();
         da.CT_HoaDonThus.InsertOnSubmit(cthdThu);
         da.SubmitChanges();
         return(true);
     }
     catch (Exception ex) { throw new Exception(ex.Message); }
 }
Пример #16
0
        public List <clsCTHD> getCTHdayMa(string mahd)
        {
            da = new QLCafeDataContext();
            var qr = da.CT_HoaDonThus.Where(hd => hd.maHDT == mahd).Join(da.SanPhams, hd => hd.maSP, sp => sp.maSP, (hd, sp) => new clsCTHD
            {
                TenSP   = sp.tenSP,
                Soluong = hd.soluong,
                Dongia  = decimal.Parse(hd.dongia.ToString())
            });
            List <clsCTHD> lst = qr.ToList();

            return(lst);
        }
Пример #17
0
 public bool AddLoaiSP(LoaiSP s)
 {
     try
     {
         db = new QLCafeDataContext();
         db.LoaiSPs.InsertOnSubmit(s);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #18
0
 public List <SanPham> searchTheoMa(string s)
 {
     try
     {
         List <SanPham> lst = new List <SanPham>();
         db  = new QLCafeDataContext();
         lst = db.SanPhams.Where(o => o.maSP == s).ToList();
         return(lst);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Пример #19
0
 public List <NguyenLieu> searchTheoTen(string s)
 {
     try
     {
         db = new QLCafeDataContext();
         List <NguyenLieu> lst = new List <NguyenLieu>();
         lst = db.NguyenLieus.Where(o => o.tenNL == s).ToList();
         return(lst);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Пример #20
0
 public NhanVien searchTheoMa(string s)
 {
     try
     {
         NhanVien lst = new NhanVien();
         db  = new QLCafeDataContext();
         lst = db.NhanViens.Where(o => o.maNV == s).FirstOrDefault();
         return(lst);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Пример #21
0
        public clsCTHDChi getCTHdayMa(string mahd)
        {
            da = new QLCafeDataContext();
            var qr = da.CT_HoaDonChis.Join(da.NguyenLieus, hd => hd.maNL, sp => sp.maNL, (hd, sp) => new clsCTHDChi
            {
                TenNL   = sp.tenNL,
                DVTinh  = sp.dvtinh,
                Soluong = hd.soluong,
                Ghichu  = hd.ghichu
            });
            clsCTHDChi lst = qr.ToList().FirstOrDefault();

            return(lst);
        }
Пример #22
0
 public bool AddNguyenLieu(NguyenLieu s)
 {
     try
     {
         db = new QLCafeDataContext();
         db.NguyenLieus.InsertOnSubmit(s);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #23
0
 public List <NhanVien> searchTheoMaNhanVien(string s)
 {
     try
     {
         List <NhanVien> lst = new List <NhanVien>();
         db  = new QLCafeDataContext();
         lst = db.NhanViens.Where(o => o.maNV == s).ToList();
         return(lst);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Пример #24
0
 public bool AddNhanVien(NhanVien s)
 {
     try
     {
         db = new QLCafeDataContext();
         db.NhanViens.InsertOnSubmit(s);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #25
0
 public List <LoaiSP> searchTheoTen(string s)
 {
     try
     {
         db = new QLCafeDataContext();
         List <LoaiSP> lst = new List <LoaiSP>();
         lst = db.LoaiSPs.Where(o => o.tenLoai == s).ToList();
         return(lst);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Пример #26
0
 public bool deleteNguyenLieu(string s)
 {
     try
     {
         db = new QLCafeDataContext();
         NguyenLieu l = db.NguyenLieus.Where(o => o.maNL == s).FirstOrDefault();
         db.NguyenLieus.DeleteOnSubmit(l);
         db.SubmitChanges();
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Пример #27
0
 public bool deleteSP(string s)
 {
     try
     {
         db = new QLCafeDataContext();
         SanPham l = db.SanPhams.Where(o => o.maSP == s).FirstOrDefault();
         db.SanPhams.DeleteOnSubmit(l);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #28
0
 public bool addKhachHang(KhachHang kh)
 {
     try
     {
         if (da.KhachHangs.Where(o => o.cmnd == kh.cmnd).FirstOrDefault() == null)
         {
             da = new QLCafeDataContext();
             da.KhachHangs.InsertOnSubmit(kh);
             da.SubmitChanges();
             return(true);
         }
         return(false);
     }
     catch { throw new Exception("Thêm khách hàng thất bại. Mã khách hàng đã tồn tại"); }
 }
Пример #29
0
 public bool deleteLoaiSP(string s)
 {
     try
     {
         db = new QLCafeDataContext();
         LoaiSP l = db.LoaiSPs.Where(o => o.maLoai == s).FirstOrDefault();
         db.LoaiSPs.DeleteOnSubmit(l);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         throw new Exception("Không xóa được vì có sản phẩm đang sử dụng Mã: " + s);
     }
 }
Пример #30
0
        public bool deleteHDThu(string maHD)
        {
            try
            {
                da = new QLCafeDataContext();

                HoaDon hd = da.HoaDons.Where(o => o.maHD == maHD).FirstOrDefault();
                da.HoaDons.DeleteOnSubmit(hd);
                da.SubmitChanges();
                return(true);
            }
            catch
            {
                throw new Exception("Cần xóa hết các chi tiết trong hóa đơn trước khi xóa hóa đơn!");;
            }
        }