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); }
 }
 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"); }
 }
 public bool AddLoaiSP(LoaiSP s)
 {
     try
     {
         db = new QLCafeDataContext();
         db.LoaiSPs.InsertOnSubmit(s);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #4
0
 public bool AddNhanVien(NhanVien s)
 {
     try
     {
         db = new QLCafeDataContext();
         db.NhanViens.InsertOnSubmit(s);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #5
0
 public bool AddNguyenLieu(NguyenLieu s)
 {
     try
     {
         db = new QLCafeDataContext();
         db.NguyenLieus.InsertOnSubmit(s);
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 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"); }
 }
Exemple #7
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);
     }
 }
 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);
     }
 }
Exemple #9
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);
     }
 }
        public bool deleteCTHDThu(string maHD, string maSP)
        {
            try
            {
                da = new QLCafeDataContext();

                CT_HoaDonThu hd = da.CT_HoaDonThus.Where(o => o.maHDT == maHD && o.maSP == maSP).FirstOrDefault();
                da.CT_HoaDonThus.DeleteOnSubmit(hd);
                da.SubmitChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public bool deleteKhachHang(string maKH)
        {
            try
            {
                da = new QLCafeDataContext();

                KhachHang kh = da.KhachHangs.Where(o => o.maKH == maKH).FirstOrDefault();
                da.KhachHangs.DeleteOnSubmit(kh);
                da.SubmitChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        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!");;
            }
        }
Exemple #13
0
 public bool updateHoaDon(HoaDon HDNew)
 {
     try
     {
         da = new QLCafeDataContext();
         HoaDon hd = da.HoaDons.Where(o => o.maHD == HDNew.maHD).FirstOrDefault();
         if (hd != null)
         {
             hd.tongtien = HDNew.tongtien;
             da.SubmitChanges();
             return(true);
         }
         return(false);
     }
     catch { throw new Exception("Chỉnh sửa Hóa đơn thất bại"); }
 }
 public bool updateKhachHang(KhachHang KHNew)
 {
     try
     {
         da = new QLCafeDataContext();
         KhachHang kh = da.KhachHangs.Where(o => o.maKH == KHNew.maKH).FirstOrDefault();
         if (kh != null)
         {
             kh.tenKH     = KHNew.tenKH;
             kh.thanthiet = KHNew.thanthiet;
             kh.cmnd      = KHNew.cmnd;
             da.SubmitChanges();
             return(true);
         }
         return(false);
     }
     catch { throw new Exception("Chỉnh sửa khách hàng thất bại. Mã khách hàng đã tồn tại"); }
 }
Exemple #15
0
 public bool UpdateNguyenLieu(NguyenLieu l)
 {
     try
     {
         db = new QLCafeDataContext();
         NguyenLieu x = db.NguyenLieus.Where(o => o.maNL == l.maNL).FirstOrDefault();
         if (x != null)
         {
             x.tenNL  = l.tenNL;
             x.dvtinh = l.dvtinh;
             db.SubmitChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
 public bool UpdateLoaiSp(LoaiSP l)
 {
     try
     {
         db = new QLCafeDataContext();
         LoaiSP x = db.LoaiSPs.Where(o => o.maLoai == l.maLoai).FirstOrDefault();
         if (x != null)
         {
             x.maLoai  = l.maLoai;
             x.tenLoai = l.tenLoai;
             db.SubmitChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #17
0
 public bool UpdateSP(SanPham l)
 {
     try
     {
         db = new QLCafeDataContext();
         SanPham x = db.SanPhams.Where(o => o.maSP == l.maSP).FirstOrDefault();
         if (x != null)
         {
             x.tenSP  = l.tenSP;
             x.loaiSP = l.loaiSP;
             x.dongia = l.dongia;
             x.mota   = l.mota;
             db.SubmitChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #18
0
 public bool UpdateNhanVien(NhanVien l)
 {
     try
     {
         db = new QLCafeDataContext();
         NhanVien x = db.NhanViens.Where(o => o.maNV == l.maNV).FirstOrDefault();
         if (x != null)
         {
             x.maNV      = l.maNV;
             x.tenNV     = l.tenNV;
             x.diachi    = l.diachi;
             x.cmnd      = l.cmnd;
             x.matkhauNV = l.matkhauNV;
             x.phai      = l.phai;
             db.SubmitChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }