private void thanhToanTile_Click(object sender, EventArgs e) { DialogResult dialog = MetroMessageBox.Show(this, "Bạn muốn thanh toán hóa đơn cho bàn " + (selectedIndex + 1) + " ?", "Pay", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { metroTileList[selectedIndex].Style = MetroColorStyle.Green; tableList[selectedIndex].TinhTrang = "Còn trống"; TableBUS.UpdateStatus(tableList[selectedIndex]); thanhToanTile.Visible = false; themMonTile.Visible = false; tongTienLabel.Visible = false; label.Visible = false; dgv.DataSource = BillDetailBUS.LoadAll(0); BillBUS.UpdateInvoicingTime(currentBill); Refresh(); DialogResult dialog2 = MetroMessageBox.Show(this, "Thanh toán thành công, bạn có muốn in hóa đơn ?", "Print receipt", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialog2 == DialogResult.Yes) { frmThanhToan form = new frmThanhToan(currentBill.MaHoaDon, selectedIndex + 1, login.MaNhanVien); form.Show(); } } }
private void dgv3_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { dgv4.DataSource = BillDetailBUS.LoadAll((int)dgv3.CurrentRow.Cells[0].Value); dgv4.Columns[0].Visible = false; dgv4.Columns[1].HeaderText = "Tên món"; dgv4.Columns[2].HeaderText = "Số lượng"; dgv4.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgv4.Columns[3].HeaderText = "Thành tiền"; dgv4.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } }
public frmDatBan(DangNhap input) { InitializeComponent(); login = input; tableList = TableBUS.LoadAll(); selected = new List <DataTable>(tableList.Count); dgv.DataSource = BillDetailBUS.LoadAll(0); dgv.Columns[0].Visible = false; dgv.Columns[1].HeaderText = "Tên món"; dgv.Columns[2].HeaderText = "Số lượng"; dgv.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgv.Columns[3].HeaderText = "Thành tiền"; dgv.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; }
public Manage() { InitializeComponent(); sorter = new ListViewColumnSorter(); lvCatalog.ListViewItemSorter = sorter; lvCombo.ListViewItemSorter = sorter; lvProduct.ListViewItemSorter = sorter; lvBill.ListViewItemSorter = sorter; accountBUS = new AccountBUS(); billBUS = new BillBUS(); billDetailBUS = new BillDetailBUS(); catalogBUS = new CatalogBUS(); comboBUS = new ComboBUS(); comboDetailBUS = new ComboDetailBUS(); productBUS = new ProductBUS(); }
private void themMonTile_Click(object sender, EventArgs e) { using (frmChonMon form = new frmChonMon(selectedIndex + 1)) { if (form.ShowDialog() == DialogResult.OK) { selected[selectedIndex] = form.Selected; int tongTien = 0; foreach (DataRow row in selected[selectedIndex].Rows) { string tenMon = row["Tên món"].ToString(); int donGia = (int)row["Đơn giá"]; int soLuong = (int)row["Số lượng"]; int thanhTien = donGia * soLuong; tongTien += thanhTien; ChiTietHoaDon detail = new ChiTietHoaDon(currentBill.MaHoaDon, tenMon, soLuong, thanhTien); ChiTietHoaDon existedDetail = BillDetailBUS.GetBillDetail(detail); if (existedDetail != null) { detail.SoLuong += existedDetail.SoLuong; detail.ThanhTien += existedDetail.ThanhTien; BillDetailBUS.Update(detail); } else { BillDetailBUS.Insert(detail); } } currentBill.TongTien += tongTien + tongTien / 10; BillBUS.UpdateTotalPrice(currentBill); metroTileList[selectedIndex].PerformClick(); } } }
private void frmThanhToan_Load(object sender, EventArgs e) { DataTable billDetail = BillDetailBUS.LoadAllExtendedBillDetails(billID); billDetail.Columns[0].ColumnName = "ProductName"; billDetail.Columns[1].ColumnName = "UnitPrice"; billDetail.Columns[2].ColumnName = "Quantity"; billDetail.Columns[3].ColumnName = "Total"; HoaDon bill = BillBUS.GetBill(billID); ReportParameter[] parameters = new ReportParameter[] { new ReportParameter("pThoiGianLap", bill.ThoiGianLap.ToString()), new ReportParameter("pMaHoaDon", bill.MaHoaDon.ToString()), new ReportParameter("pMaBan", tableID.ToString()), new ReportParameter("pHoTen", employeeName) }; reportViewer.LocalReport.SetParameters(parameters); reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", billDetail)); reportViewer.RefreshReport(); }
private void Tile_Click(object sender, EventArgs e) { int index = metroTileList.IndexOf((MetroTile)sender); if (tableList[index].TinhTrang == "Còn trống") { using (frmChonMon form = new frmChonMon(index + 1)) { if (form.ShowDialog() == DialogResult.OK) { selected[index] = form.Selected; metroTileList[index].Style = MetroColorStyle.Red; tableList[index].TinhTrang = "Đã được đặt"; TableBUS.UpdateStatus(tableList[index]); int tongTien = 0; currentBill = new HoaDon { MaBan = tableList[index].MaBan, MaNhanVien = login.MaNhanVien, }; BillBUS.Insert(currentBill); currentBill = BillBUS.GetLastBill(tableList[index].MaBan); foreach (DataRow row in selected[index].Rows) { string tenMon = row["Tên món"].ToString(); int donGia = (int)row["Đơn giá"]; int soLuong = (int)row["Số lượng"]; int thanhTien = donGia * soLuong; tongTien += thanhTien; ChiTietHoaDon detail = new ChiTietHoaDon(currentBill.MaHoaDon, tenMon, soLuong, thanhTien); ChiTietHoaDon existedDetail = BillDetailBUS.GetBillDetail(detail); if (existedDetail != null) { detail.SoLuong += existedDetail.SoLuong; detail.ThanhTien += existedDetail.ThanhTien; BillDetailBUS.Update(detail); } else { BillDetailBUS.Insert(detail); } } currentBill.TongTien = tongTien + tongTien / 10; BillBUS.UpdateTotalPrice(currentBill); } } } else { currentBill = BillBUS.GetLastBill(tableList[index].MaBan); dgv.DataSource = BillDetailBUS.LoadAll(currentBill.MaHoaDon); selectedIndex = index; thanhToanTile.Visible = true; themMonTile.Visible = true; tongTienLabel.Visible = true; tongTienLabel.Text = currentBill.TongTien.ToString("N0"); label.Visible = true; } }