private void EditRoom() { SelectedRoom.Capacity = Int32.Parse(Capacity); SelectedRoom.Description_ = Description; DataProvider.Ins.DB.SaveChanges(); var temp = SelectedRoom; int length = ListRoom.Count(); for (int i = 0; i < length; i++) { if (ListRoom[i].RoomID == SelectedRoom.RoomID) { ListRoom.RemoveAt(i); ListRoom.Insert(i, temp); break; } } SelectedRoom = temp; }
private void DeleteRoom() { // check if not used anymore first if (IsNotUsing()) { SelectedRoom.Status_ = "Không còn sử dụng"; DataProvider.Ins.DB.SaveChanges(); var temp = SelectedRoom; for (int i = 0; i < ListRoom.Count(); i++) { if (ListRoom[i].RoomID == SelectedRoom.RoomID) { ListRoom.RemoveAt(i); ListRoom.Insert(i, temp); break; } } } else { MessageBox.Show("Phong dang duoc su dung"); } }