示例#1
0
        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();
                }
            }
        }
示例#2
0
 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;
     }
 }
示例#3
0
 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;
 }
示例#4
0
        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;
            }
        }