/* * 删除餐桌 * 1. 查看选中状态 * 2. 查看餐桌空闲状态,空闲则可删 * 3. 删除 * */ private void DeleteTableButton_Click(object sender, RoutedEventArgs e) { if (TableList.SelectedIndex == -1) { MessageBox.Show("未选中餐桌"); return; } if (((InformationTable3)TableList.SelectedItem).Right_TB.Text == "是") { int DeleteResult = TableInfoConnector.DeleteTable(((InformationTable3)TableList.SelectedItem).Left_TB.Text, HallInfoConnector.GetHallInfoData(((InformationTable3)TableList.SelectedItem).Mid_TB.Text).HId); if (DeleteResult == 1) { MessageBox.Show("删除成功"); ModifyTableName.Text = ""; ModifyHallCombo.SelectedIndex = 0; LoadAllTables(); } } else { MessageBox.Show("非空闲的餐桌无法删除"); return; } }
/* * 删除,判断选中 * 判断餐厅中餐桌的状态 * */ private void DeleteHallButton_Click(object sender, RoutedEventArgs e) { if (HallList.SelectedIndex == -1) { MessageBox.Show("未找到选中项"); return; } ListBoxItem listBoxItem = (ListBoxItem)HallList.SelectedItem; String HTitle = (String)listBoxItem.Content; int DeleteResult = HallInfoConnector.DeleteHall(HTitle); if (DeleteResult == 1) { MessageBox.Show("删除成功"); //AddHallName.Text = ""; LoadAllHalls(); } else if (DeleteResult == -1) { MessageBox.Show("餐厅未空闲"); return; } else { MessageBox.Show("删除失败"); return; } }
/** * 加载所有的大厅 * */ private void LoadAllHalls() { List <HallInfoData> hallInfoDatas = HallInfoConnector.HallInfoDatas(); foreach (HallInfoData hall in hallInfoDatas) { SearchHallCombo.Items.Add(hall.HName); ModifyHallCombo.Items.Add(hall.HName); } SearchHallCombo.SelectedIndex = 0; ModifyHallCombo.SelectedIndex = 0; }
//动态添加房间名的方法 private void AddNewRooms() { List <ListBoxItem> listBoxItems = new List <ListBoxItem>(); hallInfoDatas = HallInfoConnector.HallInfoDatas(); foreach (HallInfoData hall in hallInfoDatas) { ListBoxItem list = new ListBoxItem(); list.Content = hall.HName; listBoxItems.Add(list); } RoomList.ItemsSource = listBoxItems; }
/* * 选中餐桌显示在右侧 * */ private void TableList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (TableList.SelectedIndex == -1) { return; } InformationTable3 informationTable3 = (InformationTable3)(TableList.SelectedItem); ModifyTableName.Text = informationTable3.Left_TB.Text; ModifyHallCombo.SelectedIndex = HallInfoConnector.GetHallInfoData(informationTable3.Mid_TB.Text).HId - 1; if (informationTable3.Right_TB.Text == "是") { FreeRadio.IsChecked = true; } else { NonFreeRadio.IsChecked = true; } }
/* * 添加餐厅的函数 * 1. 判断是否为空 * 2. 判断是否重复 * */ private void AddHallButton_Click(object sender, RoutedEventArgs e) { if (AddHallName.Text == "") { MessageBox.Show("未输入餐厅名"); return; } int InsertResult = HallInfoConnector.InsertHall(AddHallName.Text); if (InsertResult == 1) { MessageBox.Show("插入成功"); AddHallName.Text = ""; LoadAllHalls(); } else { MessageBox.Show("插入失败"); return; } }
/* * 加载全部的大厅 * */ private void LoadAllHalls() { int count = HallList.Items.Count; for (int i = 0; i < count; i++) { HallList.Items.RemoveAt(0); } List <HallInfoData> hallInfoDatas = HallInfoConnector.HallInfoDatas(); foreach (HallInfoData infoData in hallInfoDatas) { ListBoxItem listBoxItem = new ListBoxItem() { Content = infoData.HName, FontSize = 14, Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255)) }; HallList.Items.Add(listBoxItem); } }