private void simpleButton2_Click(object sender, EventArgs e) { int BillID = hoaDon.LayHoaDonChuaThanhToan(Global.BanID); string TenSanPham = lbTenSenPham.Text; int SanPhamID = sanPham.LayIdSanPham(TenSanPham); hoaDon.AddChiTietHoaDon(BillID, SanPhamID, -100); if (!ban.KiemTraBanConMonKhong(Global.BanID)) { ban.Update_Ban1(Global.BanID); hoaDon.XoaHoaDon(BillID); } this.loadBill(Global.BanID); this.loadTable(); Close(); }
private void btnThanhToan_Click(object sender, EventArgs e) { if (BanID == 0) { XtraMessageBox.Show("Xin hãy chọn bàn để thanh toán!"); return; } int HoaDonID = hoaDon.LayHoaDonChuaThanhToan(BanID); var quer = (from chitiethoadon in Global.context.ChiTietHoaDons join sanpham in Global.context.SanPhams on chitiethoadon.SanPhamID equals sanpham.SanPhamId where chitiethoadon.HoaDonID == HoaDonID select new { TenMon = sanpham.TenSanPham, chitiethoadon.SoLuong, sanpham.DonGia, ThanhTien = chitiethoadon.SoLuong * sanpham.DonGia }).ToList(); // double totalPrice = hoadon.TinhTien(context, HoaD onID); int discount = (int)spDiscount.Value; double totalPrice = Convert.ToDouble(txtThanhTien.Text.Split(',')[0]) * 1000; double finalPrice = totalPrice - (totalPrice / 100) * discount; if (HoaDonID != 0) { if (XtraMessageBox.Show(string.Format("Bạn có chắc thanh toán hóa đơn cho bàn {0} chứ?", BanID), "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK) { XtraReport report = new XtraReport(); report.DataSource = quer; report.Parameters["TableName"].Value = BanID; report.Parameters["Discount"].Value = discount; report.Parameters["CreateDate"].Value = DateTime.Now; report.Parameters["TotalPrice"].Value = finalPrice; ReportPrintTool tool = new ReportPrintTool(report); tool.ShowPreview(); hoaDon.CapNhatTrangThaiHoaDon(HoaDonID, Global.context, finalPrice); ban.Update_Ban1(BanID); Load_Table(); } } ShowBill(BanID); }