private void DeleteButton_OnClick(object sender, RoutedEventArgs e) { //throw new NotImplementedException(); using (var patientRoomDao = new PatientRoomDao()) { patientRoomDao.DeletePatientRoom(Datalist[ListView1.SelectedIndex].Id); RefreshData(); } }
private void ListViewCPatientRoom_OnLoaded(object sender, RoutedEventArgs e) { #region refresh data list try { using (var patientRoomDao = new PatientRoomDao()) { Datalist.Clear(); var condition = new Dictionary <string, object>(); var list = patientRoomDao.SelectPatientRoom(condition); foreach (var pa in list) { var patientRoomData = new PatientRoomData(); patientRoomData.Id = pa.Id; patientRoomData.Name = pa.Name; { using (var patientAreaDao = new PatientAreaDao()) { condition.Clear(); condition["ID"] = pa.PatientAreaId; var arealist = patientAreaDao.SelectPatientArea(condition); if (arealist.Count == 1) { patientRoomData.PatientArea = arealist[0].Name; } } } { using (var infectTypeDao = new InfectTypeDao()) { condition.Clear(); condition["ID"] = pa.InfectTypeId; var arealist = infectTypeDao.SelectInfectType(condition); if (arealist.Count == 1) { patientRoomData.InfectType = arealist[0].Name; } } } patientRoomData.Description = pa.Description; Datalist.Add(patientRoomData); } } } catch (Exception ex) { MainWindow.Log.WriteInfoConsole("In CPatientRoom.xaml.cs:ListViewCPatientRoom_OnLoaded 3 exception messsage: " + ex.Message); } #endregion }
private void AddButton_OnClick(object sender, RoutedEventArgs e) { //throw new NotImplementedException(); try { using (var patientRoomDao = new PatientRoomDao()) { var patientRoom = new PatientRoom(); patientRoom.Name = this.NameTextBox.Text; var condition = new Dictionary <string, object>(); using (var patientAreaDao = new PatientAreaDao()) { condition.Clear(); condition["Name"] = ComboBoxPatientArea.Text; var arealist = patientAreaDao.SelectPatientArea(condition); if (arealist.Count == 1) { patientRoom.PatientAreaId = arealist[0].Id; } } using (var infectTypeDao = new InfectTypeDao()) { condition.Clear(); condition["Name"] = ComboBoxInfectType.Text; var arealist = infectTypeDao.SelectInfectType(condition); if (arealist.Count == 1) { patientRoom.InfectTypeId = arealist[0].Id; } } patientRoom.Description = this.DescriptionTextBox.Text; int lastInsertId = -1; patientRoomDao.InsertPatientRoom(patientRoom, ref lastInsertId); //UI PatientRoomData patientRoomData = new PatientRoomData(); patientRoomData.Id = patientRoom.Id; patientRoomData.Name = patientRoom.Name; patientRoomData.PatientArea = ComboBoxPatientArea.Text; patientRoomData.InfectType = ComboBoxInfectType.Text; patientRoomData.Description = patientRoom.Description; Datalist.Add(patientRoomData); } } catch (Exception ex) { MainWindow.Log.WriteInfoConsole("In CPatientRoom.xaml.cs:AddButton_OnClick exception messsage: " + ex.Message); } }
private void RefreshData() { try { using (var patientRoomDao = new PatientRoomDao()) { Datalist.Clear(); Dictionary <string, object> condition = new Dictionary <string, object>(); var list = patientRoomDao.SelectPatientRoom(condition); foreach (PatientRoom pa in list) { var patientRoomData = new PatientRoomData(); patientRoomData.Id = pa.Id; patientRoomData.Name = pa.Name; { using (var patientAreaDao = new PatientAreaDao()) { condition.Clear(); condition["ID"] = pa.PatientAreaId; var arealist = patientAreaDao.SelectPatientArea(condition); if (arealist.Count == 1) { patientRoomData.PatientArea = arealist[0].Name; } } } { using (var infectTypeDao = new InfectTypeDao()) { condition.Clear(); condition["ID"] = pa.InfectTypeId; var arealist = infectTypeDao.SelectInfectType(condition); if (arealist.Count == 1) { patientRoomData.InfectType = arealist[0].Name; } } } patientRoomData.Description = pa.Description; Datalist.Add(patientRoomData); } } } catch (Exception ex) { MainWindow.Log.WriteInfoConsole("In CPatientArea.xaml.cs:AddButton_OnClick exception messsage: " + ex.Message); } }
private void UpdateButton_OnClick(object sender, RoutedEventArgs e) { //throw new NotImplementedException(); using (var patientRoomDao = new PatientRoomDao()) { var condition = new Dictionary <string, object>(); condition["ID"] = Datalist[ListView1.SelectedIndex].Id; var fileds = new Dictionary <string, object>(); fileds["NAME"] = NameTextBox.Text; var condition2 = new Dictionary <string, object>(); using (var patientAreaDao = new PatientAreaDao()) { condition2.Clear(); condition2["Name"] = ComboBoxPatientArea.Text; var arealist = patientAreaDao.SelectPatientArea(condition2); if (arealist.Count == 1) { fileds["PATIENTAREAID"] = arealist[0].Id; } } using (var infectTypeDao = new InfectTypeDao()) { condition2.Clear(); condition2["Name"] = ComboBoxInfectType.Text; var arealist = infectTypeDao.SelectInfectType(condition2); if (arealist.Count == 1) { fileds["INFECTTYPEID"] = arealist[0].Id; } } fileds["DESCRIPTION"] = DescriptionTextBox.Text; patientRoomDao.UpdatePatientRoom(fileds, condition); RefreshData(); } }