private void cbNumberTable_SelectionChanged(object sender, SelectionChangedEventArgs e) { Model.Table itemTable = (Model.Table)cbTable.SelectedItem; if (itemTable != null) { if (itemTable.IsBusy) { cbTable.SelectedItem = null; MessageBox.Show("Стол занят"); } } }
private void btnSaveZakaz_Click(object sender, RoutedEventArgs e) { double itogSum = 0; bool proverka = true; registrationZakaza.DateOpen = DateTime.Now; foreach (var item in db.ZakaznBludaNew) { if (item.IdZakaza == idNewZakaz) { itogSum += (double)item.Price; } } registrationZakaza.Total = (int)itogSum; if (cbEmployee.SelectedItem != null) { registrationZakaza.EmployeeId = ((Employees)cbEmployee.SelectedItem).id; } else { MessageBox.Show("Поле Сотрудник не заполнено"); proverka = false; } if (cbTable.SelectedItem != null) { registrationZakaza.NumberTable = ((Model.Table)cbTable.SelectedItem).Id; registrationZakaza.ZakazZakrit = false; Model.Table itemTable = db.Table.Where(i => i.NumberTable == ((Model.Table)cbTable.SelectedItem).NumberTable).FirstOrDefault(); itemTable.IsBusy = true; } else { MessageBox.Show("Поле Стол не заполнено"); proverka = false; } if (proverka != false) { db.RegistrationZakaza.Add(registrationZakaza); db.SaveChanges(); idNewZakaz = registrationZakaza.Id; Close(); } }