private void ButtonEdit_Click(object sender, EventArgs e) { string newNumberString = textBoxNumber.Text; string phone = textBoxPhone.Text; if (newNumberString == "" || phone == "") { AuxMessages.ShowError(msgNoDataEdit, msgTitle); return; } int newNumber = Int32.Parse(newNumberString); string oldNumberString = dataGridViewRooms.CurrentRow.Cells["Number"].Value.ToString(); int oldNumber = Int32.Parse(oldNumberString); string typeString = comboBoxTypes.SelectedItem.ToString(); bool edited = Controller.GetOnlyInstance().UpdateRoom(oldNumber, newNumber, phone, typeString); if (edited) { AuxMessages.ShowOK(msgEdited, msgTitle); RoomCompleteInfo rci = SearchRoomInList(oldNumber); if (rci != null) { UpdateRoomInList(rci, newNumber, phone, typeString); } } else { AuxMessages.ShowError(msgErrorEdited, msgTitle); } SetDefault(); }
private void ButtonNewClient_Click(object sender, EventArgs e) { string name = textBoxName.Text; string lastName = textBoxLastName.Text; string phone = textBoxPhone.Text; string country = comboBoxCountries.SelectedItem.ToString(); if (name.Length == 0 || lastName.Length == 0 || phone.Length == 0 || country.Length == 0) { AuxMessages.ShowError(msgNoData, msgTitle); } else { Client client = Controller.GetOnlyInstance().CreateClient(name, lastName, phone, country); if (client != null) { AuxMessages.ShowOK(msgCreated, msgTitle); clients.Add(client); } else { AuxMessages.ShowError(msgErrorCreated, msgTitle); } } SetDefault(); }
private void ButtonEdit_Click(object sender, EventArgs e) { string idString = textBoxID.Text; string name = textBoxName.Text; string lastName = textBoxLastName.Text; string phone = textBoxPhone.Text; string country = comboBoxCountries.SelectedItem.ToString(); if (idString == "" || name == "" || lastName == "" || phone == "" || country == "") { AuxMessages.ShowError(msgNoDataEdit, msgTitle); } else { int id = Int32.Parse(idString); bool edited = Controller.GetOnlyInstance().UpdateClient(id, name, lastName, phone, country); if (edited) { AuxMessages.ShowOK(msgEdited, msgTitle); Client client = SearchClient(id); if (client != null) { UpdateClientInList(client, name, lastName, phone, country); } } else { AuxMessages.ShowError(msgErrorEdited, msgTitle); } } SetDefault(); }
private void ButtonNewRoom_Click(object sender, EventArgs e) { string numberString = textBoxNumber.Text; string phone = textBoxPhone.Text; if (numberString == "" || phone == "") { AuxMessages.ShowError(msgNoData, msgTitle); return; } int number = Int32.Parse(numberString); string typeText = comboBoxTypes.SelectedItem.ToString(); int type = 0; bool typeFound = false; int i = 0; while (!typeFound && i < RoomType.RoomTypes.Count) { if (RoomType.RoomTypes[i].Type.Equals(typeText)) { type = RoomType.RoomTypes[i].Id; typeFound = true; } i++; } if (!typeFound) { AuxMessages.ShowError(msgErrorCreated, msgTitle); return; } bool isRoomAvailable = IsRoomAvailable(number); if (!isRoomAvailable) { AuxMessages.ShowError(msgErrorAlreadyCreated, msgTitle); return; } RoomCompleteInfo room = Controller.GetOnlyInstance().CreateRoom(number, phone, type); if (room != null) { AuxMessages.ShowOK(msgCreated, msgTitle); rooms.Add(room); } else { AuxMessages.ShowError(msgErrorCreated, msgTitle); } SetDefault(); }
private void ButtonRemove_Click(object sender, EventArgs e) { string numberString = dataGridViewRooms.CurrentRow.Cells["Number"].Value.ToString(); int number = Int32.Parse(numberString); bool removed = Controller.GetOnlyInstance().RemoveRoom(number); if (removed) { AuxMessages.ShowOK(msgRemoved, msgTitle); RoomCompleteInfo rci = SearchRoomInList(number); RemoveRoomInList(rci); } else { AuxMessages.ShowError(msgErrorRemoved, msgTitle); } SetDefault(); }
private void ButtonRemove_Click(object sender, EventArgs e) { string idString = textBoxID.Text; int id = Int32.Parse(idString); bool removed = Controller.GetOnlyInstance().RemoveClient(id); if (removed) { AuxMessages.ShowOK(msgRemoved, msgTitle); Client client = SearchClient(id); RemoveClientInList(client); } else { AuxMessages.ShowError(msgErrorRemoved, msgTitle); } SetDefault(); }