private void UpdateSoba() { SelektovanaSoba.Sifra = Convert.ToInt32(SifraTb.Text); SelektovanaSoba.Kapacitet = Convert.ToInt32(KapacitetTb.Text); SelektovanaSoba.Zauzetost = Convert.ToInt32(ZauzetostTb.Text); SelektovanaSoba.Pocetak = (DateTime)PocetakTb.SelectedDate; SelektovanaSoba.Tip = (TypeOfUsage)TipCb.SelectedItem; SelektovanaSoba.Kraj = (DateTime)KrajTb.SelectedDate; RoomController roomController = new RoomController(); RenovationPeriodController renovationPeriodController = new RenovationPeriodController(); RenovationPeriod p = new RenovationPeriod(); Room room = new Room(); room.Capacity = SelektovanaSoba.Kapacitet; room.Number = SelektovanaSoba.Sifra; room.Occupation = SelektovanaSoba.Zauzetost; if (SelektovanaSoba.Pocetak == DateTime.Today && SelektovanaSoba.Kraj == DateTime.Today) { room.Renovation = false; renovationPeriodController.CancelRenovation(room.Number); } else if (SelektovanaSoba.Pocetak == DateTime.MinValue && SelektovanaSoba.Kraj == DateTime.MinValue) { room.Renovation = false; renovationPeriodController.CancelRenovation(room.Number); } else { if (renovationPeriodController.ViewRenovationByRoomNumber(room.Number) != null) { room.Renovation = true; p.room = room; p.BeginDate = SelektovanaSoba.Pocetak; p.EndDate = SelektovanaSoba.Kraj; renovationPeriodController.EditRenovation(p); } else { room.Renovation = true; p.room = room; p.BeginDate = SelektovanaSoba.Pocetak; p.EndDate = SelektovanaSoba.Kraj; renovationPeriodController.ScheduleRenovation(p); } } roomController.EditRoom(room); }
public RoomView() { InitializeComponent(); txtNameToSearch.Focus(); rooms.AddRange(roomController.ViewRooms()); foreach (Room r in rooms) { if (r.Usage != TypeOfUsage.Soba_za_lezanje) { RoomDTO roomDTO = new RoomDTO(); roomDTO.NumberOfRoom = r.Number.ToString(); roomDTO.isRenovate = r.Renovation; if (r.Usage == TypeOfUsage.Soba_za_pregled) { roomDTO.Purpose = "Soba za pregled"; } else { roomDTO.Purpose = "Operaciona sala"; } renovationPeriod = periodController.ViewRenovationByRoomNumber(r.Number); if (renovationPeriod != null) { roomDTO.StartRenovationDate = renovationPeriod.BeginDate.ToShortDateString(); roomDTO.EndRenovationDate = renovationPeriod.EndDate.ToShortDateString(); } else { roomDTO.StartRenovationDate = "-"; roomDTO.EndRenovationDate = "-"; } roomsDTO.Add(roomDTO); } } dgRooms.ItemsSource = roomsDTO; }
private void Button_Click_9(object sender, RoutedEventArgs e) { string s1 = dataOd.SelectedDate.ToString(); string[] lines1 = s1.Split(' '); string datumOd = lines1[0]; if (String.IsNullOrEmpty(datumOd)) { MessageBox.Show("Morate izabrati datum početka ležanja.", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning); dataOd.Focus(); return; } else if (String.IsNullOrEmpty(comboSoba.Text)) { MessageBox.Show("Morate izabrati sobu u koju želite smjesiti pacijenta.", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning); comboSoba.Focus(); return; } else if (String.IsNullOrEmpty(comboKrevet.Text)) { MessageBox.Show("Morate izabrati krevet u koji želite smjesiti pacijenta.", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning); comboKrevet.Focus(); return; } else if (comboKrevet.Text.Contains("zauzet")) { MessageBox.Show("Ne možete smjestiti pacijenta u krevet koji je zauzet.", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning); comboKrevet.Focus(); return; } string[] t1 = datumOd.Split('/'); string s2 = dataDo.SelectedDate.ToString(); string[] lines2 = s2.Split(' '); string datumDo = lines2[0]; if (String.IsNullOrEmpty(datumDo)) { MessageBox.Show("Morate izabrati datum kraja ležanja.", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning); dataDo.Focus(); return; } string[] t2 = datumDo.Split('/'); int god1 = Int32.Parse(t1[2]); int god2 = Int32.Parse(t2[2]); int mj1 = Int32.Parse(t1[0]); int mj2 = Int32.Parse(t2[0]); int dan1 = Int32.Parse(t1[1]); int dan2 = Int32.Parse(t2[1]); if (god2 < god1) { MessageBox.Show("Greška! Krajnji datum je stariji od početnog.", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning); dataOd.Focus(); return; } else if (god1 == god2 && mj1 > mj2) { MessageBox.Show("Greška! Krajnji datum je stariji od početnog.", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning); dataOd.Focus(); return; } else if (god1 == god2 && mj1 == mj2 && dan1 > dan2) { MessageBox.Show("Greška! Krajnji datum je stariji od početnog.", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning); dataOd.Focus(); return; } Room r = roomPlacment; r.Occupation = r.Occupation + 1; rc.EditRoom(r); List <Examination> examinations = ec.ViewExaminationsByRoom(r.Number); foreach (Examination exm in examinations) { exm.room = r; ec.EditExamination(exm); } RenovationPeriod period = rpc.ViewRenovationByRoomNumber(r.Number); period.room = r; rpc.EditRenovation(period); PlacemetnInARoom placement = new PlacemetnInARoom(); int idPlacement = prc.getLastId(); placement.Id = ++idPlacement; placement.DateOfPlacement = (DateTime)dataOd.SelectedDate; placement.DateOfDismison = (DateTime)dataDo.SelectedDate; placement.room = r; placement.patientCard = patientCard; prc.PlaceInRoom(placement); var p = new PlaceInSickRoom(); p.Show(); }