public bool LuuChiTietPhieuDat(int mapd, int mama, int dongia, int soluong)
        {
            try
            {
                using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
                {
                    ChiTietPD ct = new ChiTietPD()
                    {
                        MaPD    = mapd,
                        MaMA    = mama,
                        DonGia  = dongia,
                        SoLuong = soluong
                    };
                    context.ChiTietPDs.InsertOnSubmit(ct);
                    context.SubmitChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
        public bool SuaChiTietPhieuDat(int mapdsua, int mama, int dongia, int soluong)
        {
            try
            {
                using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
                {
                    ChiTietPD ct = context.ChiTietPDs.FirstOrDefault(x => x.MaPD == mapdsua);



                    ct.MaMA    = mama;
                    ct.DonGia  = dongia;
                    ct.SoLuong = soluong;


                    context.SubmitChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
        public bool TaoHoaDon(int mahd, DateTime ngaynhap, int manv, int mapd)
        {
            using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
            {
                try
                {
                    HoaDonThanhToan hd = new HoaDonThanhToan()
                    {
                        MaHD     = mahd,
                        NgayNhap = ngaynhap,
                        MaNV     = manv,
                        MaPD     = mapd
                    };
                    context.HoaDonThanhToans.InsertOnSubmit(hd);
                    context.SubmitChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);

                    throw;
                }
            }
        }
        public bool ThemPhieuDatBan(int mapd, DateTime ngaylap, int tongtien, int manv, int maban, int makh)
        {
            try
            {
                using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
                {
                    PhieuDatBanAn pd = new PhieuDatBanAn();
                    pd.MaPD     = mapd;
                    pd.NgayLap  = ngaylap;
                    pd.TongTien = tongtien;
                    pd.MaNV     = manv;
                    pd.MaBan    = maban;
                    pd.MaKH     = makh;
                    context.PhieuDatBanAns.InsertOnSubmit(pd);
                    context.SubmitChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
        public bool SuaPhieuDatBan(int mapdsua, DateTime ngaylap, int tongtien, int manv, int maban, int makh)
        {
            try
            {
                using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
                {
                    PhieuDatBanAn pd = context.PhieuDatBanAns.FirstOrDefault(x => x.MaPD == mapdsua);

                    pd.NgayLap  = ngaylap;
                    pd.TongTien = tongtien;
                    pd.MaNV     = manv;
                    pd.MaBan    = maban;
                    pd.MaKH     = makh;

                    context.SubmitChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
        public bool LuuMonAn(int mama, string tenmonan, int dongia, int maloai)
        {
            try
            {
                using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
                {
                    MonAn ma = new MonAn
                    {
                        MaMA     = mama,
                        TenMonAn = tenmonan,
                        DonGia   = dongia,
                        MaLoai   = maloai,
                    };
                    context.MonAns.InsertOnSubmit(ma);
                    context.SubmitChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
 public List <DanhSachHoaDonResult> DSHoaDon()
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <DanhSachHoaDonResult> list = context.DanhSachHoaDon().ToList();
         return(list);
     }
 }
 public List <DanhSchPhieuDatChuaThanhToanResult> DSPDChuaThanhToan()
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <DanhSchPhieuDatChuaThanhToanResult> list = context.DanhSchPhieuDatChuaThanhToan().ToList();
         return(list);
     }
 }
 public List <DSBanAnCoLoaiMonAnResult> LayToanBoMonAn1()
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <DSBanAnCoLoaiMonAnResult> list = context.DSBanAnCoLoaiMonAn().ToList();
         return(list);
     }
 }
 public int LaymaHDMax()
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <HoaDonThanhToan> list = context.HoaDonThanhToans.OrderByDescending(x => x.MaHD).ToList();
         HoaDonThanhToan[]      hd   = list.ToArray();
         return(hd[0].MaHD);
     }
 }
Exemplo n.º 11
0
 public BanAn LayDSBanAn(int maban)
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         BanAn ba = context.BanAns.FirstOrDefault(x => x.MaBan == maban);
         if (ba != null)
         {
             ba.PhieuDatBanAns.Clear();
         }
         return(ba);
     }
 }
Exemplo n.º 12
0
 public List <BanAn> LayDSBanAn()
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <BanAn> list = context.BanAns.ToList();
         foreach (BanAn b in list)
         {
             b.PhieuDatBanAns.Clear();
         }
         return(list);
     }
 }
Exemplo n.º 13
0
 public List <LoaiMonAn> DSLoaiMonAn()
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <LoaiMonAn> list = context.LoaiMonAns.ToList();
         foreach (LoaiMonAn l in list)
         {
             l.MonAns.Clear();
         }
         return(list);
     }
 }
Exemplo n.º 14
0
 public List <KhachHang> DSKH()
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <KhachHang> list = context.KhachHangs.ToList();
         foreach (KhachHang kh in list)
         {
             kh.PhieuDatBanAns.Clear();
         }
         return(list);
     }
 }
Exemplo n.º 15
0
 public List <BanAn> LayDSBanAn2(int trangthai, int socho)
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <BanAn> ba = context.BanAns.Where(x => (x.SoChoNgoi == socho && x.TrangThai == trangthai)).ToList();
         foreach (BanAn b in ba)
         {
             b.PhieuDatBanAns.Clear();
         }
         return(ba);
     }
 }
Exemplo n.º 16
0
 public List <BanAn> LayDSBanAn1(int trangthai)
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <BanAn> ba = context.BanAns.Where(x => x.TrangThai == trangthai).ToList();
         foreach (BanAn b in ba)
         {
             b.PhieuDatBanAns.Clear();
         }
         return(ba);
     }
 }
Exemplo n.º 17
0
 public List <NhanVien> ListNV()
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <NhanVien> list = context.NhanViens.ToList();
         foreach (NhanVien nv in list)
         {
             nv.HoaDonThanhToans.Clear();
             nv.PhieuDatBanAns.Clear();
         }
         return(list);
     }
 }
 public List <ChiTietPD> ListPhieuDat()
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <ChiTietPD> list = context.ChiTietPDs.ToList();
         foreach (ChiTietPD ch in list)
         {
             ch.MonAn         = null;
             ch.PhieuDatBanAn = null;
         }
         return(list);
     }
 }
 public List <MonAn> LayToanBoMonAn()
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <MonAn> list = context.MonAns.ToList();
         foreach (MonAn m in list)
         {
             m.LoaiMonAn = null;
             m.ChiTietPDs.Clear();
         }
         return(list);
     }
 }
        public MonAn LayMonAnTheoMa(int id)
        {
            using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
            {
                MonAn list = context.MonAns
                             .FirstOrDefault(x => x.MaMA == id);

                if (list != null)
                {
                    list.LoaiMonAn = null;
                    list.ChiTietPDs.Clear();
                }
                return(list);
            }
        }
 public List <MonAn> LayDanhSachMonAnTheoLoai(int maloai)
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <MonAn> list = context.MonAns
                             .Where(x => x.MaLoai == maloai)
                             .ToList();
         foreach (MonAn m in list)
         {
             m.LoaiMonAn = null;
             m.ChiTietPDs.Clear();
         }
         return(list);
     }
 }
 public List <MonAn> LayDanhSachMonAnTrongDonGia(int dongia1, int dongia2)
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <MonAn> list = context.MonAns
                             .Where(x => x.DonGia >= dongia1 && x.DonGia <= dongia2)
                             .ToList();
         foreach (MonAn m in list)
         {
             m.LoaiMonAn = null;
             m.ChiTietPDs.Clear();
         }
         return(list);
     }
 }
Exemplo n.º 23
0
        public int NVMaMax()
        {
            using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
            {
                List <KhachHang> list = context.KhachHangs.OrderByDescending(x => x.MaKH).ToList();
                foreach (KhachHang kh in list)
                {
                    kh.PhieuDatBanAns.Clear();
                }
                KhachHang[] kh1 = list.ToArray();


                return(kh1[0].MaKH);
            }
        }
 public List <ChiTietPD> ListPhieuDatTheoMaPD(int mapd)
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <ChiTietPD> list = context.ChiTietPDs
                                 .Where(x => x.MaPD == mapd)
                                 .ToList();
         foreach (ChiTietPD ch in list)
         {
             ch.MonAn         = null;
             ch.PhieuDatBanAn = null;
         }
         return(list);
     }
 }
        public List <MonAn> LayMonAnTheoTen(string tenmonan)
        {
            using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
            {
                List <MonAn> list = context.MonAns
                                    .Where(x => x.TenMonAn.Contains(tenmonan))
                                    .ToList();

                foreach (MonAn m in list)
                {
                    m.LoaiMonAn = null;
                    m.ChiTietPDs.Clear();
                }
                return(list);
            }
        }
 public List <DSPhieuDatBanAnResult> ListPhieuDatBan()
 {
     using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
     {
         List <DSPhieuDatBanAnResult> list = context.DSPhieuDatBanAn().ToList();
         //List<PhieuDatBanAn> list = context.PhieuDatBanAns.ToList();
         //foreach (PhieuDatBanAn l in list)
         //{
         //    l.BanAn = null;
         //    l.ChiTietPDs.Clear();
         //    l.HoaDonThanhToan = null;
         //    l.KhachHang = null;
         //    l.NhanVien = null;
         //}
         return(list);
     }
 }
        public bool XoaMonAn(int mamaxoa)
        {
            try
            {
                using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
                {
                    MonAn ma = context.MonAns.FirstOrDefault(x => x.MaMA == mamaxoa);
                    context.MonAns.DeleteOnSubmit(ma);
                    context.SubmitChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
        public int NVMaMax()
        {
            using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
            {
                List <PhieuDatBanAn> list = context.PhieuDatBanAns.OrderByDescending(x => x.MaPD).ToList();
                foreach (PhieuDatBanAn l in list)
                {
                    l.BanAn = null;
                    l.ChiTietPDs.Clear();
                    l.HoaDonThanhToans.Clear();
                    l.KhachHang = null;
                    l.NhanVien  = null;
                }
                PhieuDatBanAn[] kh1 = list.ToArray();


                return(kh1[0].MaPD);
            }
        }
        public bool XoaPhieuDatBan(int mapdxoa)
        {
            try
            {
                using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
                {
                    PhieuDatBanAn pd = context.PhieuDatBanAns.FirstOrDefault(x => x.MaPD == mapdxoa);

                    context.PhieuDatBanAns.DeleteOnSubmit(pd);
                    context.SubmitChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
        public bool XoaChiTietPhieuDat(int mapdxoa)
        {
            try
            {
                using (DatBanAnMonAnDataContext context = new DatBanAnMonAnDataContext())
                {
                    List <ChiTietPD> ct = context.ChiTietPDs.Where(x => x.MaPD == mapdxoa).ToList();

                    context.ChiTietPDs.DeleteAllOnSubmit(ct);
                    context.SubmitChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }