/// <summary> /// Retrieves latest database data and refreshes all UI elements /// </summary> private void InitUI() { var stringSSNs = Resident.GetAllResidents(dataWrapper).Select(ssn => ssn.ToString("000000000")); var stringRoomNums = Room.GetAllRooms(dataWrapper).Select(rn => rn.ToString()); var stringSectionNames = Section.GetAllSections(dataWrapper); ResidentListBox.Items.Clear(); RoomListBox.Items.Clear(); SectionListBox.Items.Clear(); ResidentListBox.Items.AddRange(stringSSNs.ToArray()); RoomListBox.Items.AddRange(stringRoomNums.ToArray()); SectionListBox.Items.AddRange(stringSectionNames); if (ResidentListBox.Items.Count > 0) { ResidentListBox.SelectedIndex = 0; } if (RoomListBox.Items.Count > 0) { RoomListBox.SelectedIndex = 0; } if (SectionListBox.Items.Count > 0) { SectionListBox.SelectedIndex = 0; } }
private void UpdateSectionUI(Dictionary <string, object> dict) { RASSNComboBox.Items.Clear(); RASSNComboBox.Items.Add("N/A"); var SSNStrings = Resident.GetAllResidents(dataWrapper).Select(ssn => ssn.ToString("000000000")); RASSNComboBox.Items.AddRange(SSNStrings.ToArray()); SectionNameTextBox.Text = ToNonNull <string>(dict["Name"]); SectionPointsNUD.Value = ToNonNull <int>(dict["Points"]); RASSNComboBox.SelectedItem = ToNonNull <int>(dict["RASSN"]).ToString("000000000"); }
private void UpdateRoomUI(Dictionary <string, object> dict) { RoomLeaderSSNComboBox.Items.Clear(); RoomLeaderSSNComboBox.Items.Add("N/A"); RoomSectionComboBox.Items.Clear(); var SSNStrings = Resident.GetAllResidents(dataWrapper).Select(ssn => ssn.ToString("000000000")); RoomLeaderSSNComboBox.Items.AddRange(SSNStrings.ToArray()); RoomSectionComboBox.Items.AddRange(Section.GetAllSections(dataWrapper)); RoomNumberTextBox.Text = ToNonNull <int>(dict["RoomNumber"]).ToString(); RoomChoreSetTextBox.Text = ToNonNull <string>(dict["ChoreSet"]); RoomWorkOrdersTextBox.Text = ToNonNull <string>(dict["WorkOrders"]); RoomMeetingTimeTextBox.Text = ToNonNull <string>(dict["RoomMeetingTime"]); RoomLeaderSSNComboBox.SelectedItem = ToNonNull <int>(dict["RLSSN"]).ToString("000000000"); RoomSectionComboBox.SelectedItem = Room.GetSection(int.Parse(RoomNumberTextBox.Text), dataWrapper); }
private void AddSectionBtn_Click(object sender, EventArgs e) { var form = new CreateSectionForm(Resident.GetAllResidents(dataWrapper)); var result = form.ShowDialog(); var name = form.SectionName; if (result == DialogResult.OK) { try { Section.AddSection(name, form.RASSN, dataWrapper); } catch (Exception ex) { MessageBox.Show("An error occurred when adding a section:\n\n" + ex.Message); } InitUI(); SectionListBox.SelectedItem = name; } }
private void AddRoomBtn_Click(object sender, EventArgs e) { var form = new CreateRoomForm(Resident.GetAllResidents(dataWrapper), Section.GetAllSections(dataWrapper)); var result = form.ShowDialog(); var roomNum = form.RoomNumber; if (result == DialogResult.OK) { try { Room.AddRoom(roomNum, form.ChoreSet, form.RoomMeetingTime, form.RoomLeaderSSN, form.SectionName, dataWrapper); } catch (Exception ex) { MessageBox.Show("An error occurred when adding a room:\n\n" + ex.Message); } InitUI(); RoomListBox.SelectedItem = roomNum.ToString(); } }