Ejemplo n.º 1
0
        public ActionResult ConfirmDelete(string soHdb, string maHanghoa)
        {
            ChiTietBan ctb = db.ChiTietBans.Find(soHdb, maHanghoa);

            db.ChiTietBans.Remove(ctb);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        int HienThiHoaDon(int idtable)
        {
            DataTable data = ChiTietBan.HienThiHoaDon(idtable);

            dgvChiTietNhapMain.DataSource = data;
            TongTien((int)HoaDonBanDAO.LayHoaDonTheoBan(idtable));
            return(data.Rows.Count);
        }
Ejemplo n.º 3
0
        void TongTien(int mahdb)
        {
            double tongtien = ChiTietBan.TongTien(mahdb);

            CultureInfo culture = new CultureInfo("vi-VN");

            //Thread.CurrentThread.CurrentCulture = culture;

            txbTongTien.Text = tongtien.ToString("c", culture);
        }
Ejemplo n.º 4
0
 public ActionResult Edit(ChiTietBan ctb)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ctb).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ctb));
 }
Ejemplo n.º 5
0
 public ActionResult Create(ChiTietBan ctb)
 {
     if (ModelState.IsValid)
     {
         db.ChiTietBans.Add(ctb);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Ejemplo n.º 6
0
        private void btnTraMon_Click(object sender, EventArgs e)
        {
            int idtable = (int)dgvChiTietNhapMain.Tag;
            int mahdb   = (int)HoaDonBanDAO.LayHoaDonTheoBan(idtable);
            int mamh    = (int)cboDanhSachMatHang.SelectedValue;
            int soluong = (int)SpinEditSoLuong.Value;

            try
            {
                mamh = (int)dgvChiTietNhap.GetFocusedRowCellValue("MAMH");
            }
            catch
            {
                MessageBox.Show("Hóa đơn đang trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (mahdb == -1)
            {
                MessageBox.Show("Không có món, không thể trả món", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                ChiTietBan.TraMon(mahdb, mamh, soluong);
            }

            QuanLyQuanCafeDBContext db = new QuanLyQuanCafeDBContext();
            int cnt = (
                from hd in db.HOADONBANs.Where(p => p.MABA == idtable && p.STATUS == 0).ToList()
                from ctb in db.CHITIETBANs.Where(p => p.MAHDB == hd.MAHDB).ToList()
                from mh in db.MATHANGs.Where(p => p.MAMH == ctb.MAMH).ToList()
                select new
            {
                MatHang = mh.TENMH,
                SoLuong = ctb.SOLUONG,
                DonGia = mh.DONGIA,
                ThanhTien = ctb.THANHTIEN
            })
                      .ToList()
                      .Count;

            if (cnt == 0)
            {
                db.BANANs.Where(p => p.MABA == idtable).FirstOrDefault().TRANGTHAI = 0;
                db.SaveChanges();
                LoadDanhSachBanAn();
            }

            HienThiHoaDon(idtable);
            TongTien(mahdb);
        }
Ejemplo n.º 7
0
 private void btnThanhToan_Click(object sender, EventArgs e)
 {
     try
     {
         int idtable = (int)dgvChiTietNhapMain.Tag;
         int mahdb   = (int)HoaDonBanDAO.LayHoaDonTheoBan(idtable);
         ChiTietBan.DeleteChiTietBan(mahdb);
         HoaDonBanDAO.DeleteHoaDonBan(idtable);
         MessageBox.Show("Thanh toán thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         HienThiHoaDon(idtable);
         TongTien(mahdb);
         ChangeImageTable(idtable, 0);
     }
     catch
     {
     }
 }
Ejemplo n.º 8
0
        private void btnDatMon_Click(object sender, EventArgs e)
        {
            int idtable;

            try
            {
                idtable = (int)dgvChiTietNhapMain.Tag;
            }
            catch
            {
                MessageBox.Show("Bạn cần phải lựa chọn bàn ăn trước khi thêm món", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            int mamh    = (int)cboDanhSachMatHang.SelectedValue;
            int soluong = (int)SpinEditSoLuong.Value;

            int mahdb = HoaDonBanDAO.LayHoaDonTheoBan(idtable);

            if (MatHangDAO.CheckHangTonKho(mamh, soluong) == 1)
            {
                if (mahdb == -1)
                {
                    HoaDonBanDAO.InsertHoaDonBan(idtable);
                    ChiTietBan.InsertChiTietBan(HoaDonBanDAO.LayHoaDonBanMax(), mamh, soluong);
                    mahdb = HoaDonBanDAO.LayHoaDonTheoBan(idtable);
                    ChangeImageTable(idtable, 1);
                }
                else
                {
                    ChiTietBan.InsertChiTietBan(mahdb, mamh, soluong);
                }
            }
            else
            {
                MessageBox.Show("Không đủ hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            HienThiHoaDon(idtable);
            TongTien(mahdb);
        }
Ejemplo n.º 9
0
        private void btnTraMon_Click(object sender, EventArgs e)
        {
            int idtable = (int)dgvChiTietNhapMain.Tag;
            int mahdb   = (int)HoaDonBanDAO.LayHoaDonTheoBan(idtable);
            int mamh    = (int)cboDanhSachMatHang.SelectedValue;
            int soluong = (int)SpinEditSoLuong.Value;

            if (mahdb == -1)
            {
                MessageBox.Show("Không có món, không thể trả món", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                ChiTietBan.TraMon(mahdb, mamh, soluong);
            }
            if (HienThiHoaDon(idtable) == 0)
            {
                HoaDonBanDAO.DeleteHoaDonBan(idtable);
                ChangeImageTable(idtable, 0);
            }
            TongTien(mahdb);
        }
Ejemplo n.º 10
0
        private void btnDatMon_Click(object sender, EventArgs e)
        {
            int idtable = (int)dgvChiTietNhapMain.Tag;
            int mamh    = (int)cboDanhSachMatHang.SelectedValue;
            int soluong = (int)SpinEditSoLuong.Value;

            int mahdb = HoaDonBanDAO.LayHoaDonTheoBan(idtable);

            if (mahdb == -1)
            {
                HoaDonBanDAO.InsertHoaDonBan(idtable);
                ChiTietBan.InsertChiTietBan(HoaDonBanDAO.LayHoaDonBanMax(), mamh, soluong);
                mahdb = HoaDonBanDAO.LayHoaDonTheoBan(idtable);
                ChangeImageTable(idtable, 1);
            }
            else
            {
                ChiTietBan.InsertChiTietBan(mahdb, mamh, soluong);
            }
            HienThiHoaDon(idtable);
            TongTien(mahdb);
        }
Ejemplo n.º 11
0
        public ActionResult Delete(string soHdb, string maHanghoa)
        {
            ChiTietBan ctb = db.ChiTietBans.Find(soHdb, maHanghoa);

            return(View(ctb));
        }