private void btnSaveOrder_Click(object sender, EventArgs e) { List <Item> selectedItems = new List <Item>(dgvSelectedItems.DataSource as BindingList <Item>); if (txtTableId.Text == "" || txtNoOfPeople.Text == "" || txtTableIds.Text == "") { MessageBox.Show("Please select a table and input all the information."); } else if (selectedItems == null || selectedItems.Count == 0) { MessageBox.Show("Order should contain at least one item."); } else { Waiter waiter = diningArea.CurrentStaff as Waiter; if (int.Parse(txtOrderId.Text) == -1) { if (MessageBox.Show("Are you sure to create new order?", "Warning!", MessageBoxButtons.OKCancel) == DialogResult.OK) { int flag; flag = waiter.CreateOrder(diningArea.Orders, int.Parse(txtCustomerId.Text), selectedItems, int.Parse(txtNoOfPeople.Text), diningArea.Tables); //if (flag == 1) MessageBox.Show("Success!"); if (flag == 0) { MessageBox.Show("Failed!"); } } } else { if (MessageBox.Show("Are you sure to save order?", "Warning!", MessageBoxButtons.OKCancel) == DialogResult.OK) { int flag; flag = waiter.UpdateOrder(diningArea.Orders, int.Parse(txtOrderId.Text), int.Parse(txtCustomerId.Text), selectedItems, int.Parse(txtNoOfPeople.Text), (OrderStatus)comboBoxOrderStatus.SelectedIndex); //if (flag == 1) MessageBox.Show("Success!"); if (flag == 0) { MessageBox.Show("Failed!"); } } } } }