Ejemplo n.º 1
0
        private void buttonDelOrder_Click(object sender, EventArgs e)
        {
            Table table = lsvBill.Tag as Table;


            if (table == null)
            {
                MessageBox.Show("Vui lòng chọn bàn");
                return;
            }

            //int idBill = BillDAO.Instance.GetUncheckBillIDByTableID(table.ID);
            int idBill = billBUS.GetUncheckBillIDByTableID(table.IdTable);

            if (lsvBill.SelectedItems.Count > 0)
            {
                ListViewItem item   = lsvBill.SelectedItems[0];
                int          foodID = Convert.ToInt32(item.SubItems[0].Text);

                // Hiển thị Message xác nhận có đồng ý cancel hay không
                DialogResult result = MessageBox.Show("Bạn có muốn hủy order này " + table.TableName, "Question", MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.ServiceNotification);

                if (result == DialogResult.Yes)
                {
                    billBUS.DelBill(idBill, table.IdTable);
                    textBoxListFoodName.Text = string.Empty;
                }
            }
            else
            {
                if (idBill > -1)
                {
                    // Hiển thị Message xác nhận có đồng ý cancel hay không
                    DialogResult result = MessageBox.Show("Bạn có muốn hủy order này " + table.TableName, "Question", MessageBoxButtons.YesNo,
                                                          MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.ServiceNotification);

                    if (result == DialogResult.Yes)
                    {
                        billBUS.DelBill(idBill, table.IdTable);
                        textBoxListFoodName.Text = string.Empty;
                    }
                }
            }
            LoadTable();
            ShowBill(table.IdTable);
        }