private void FillDoctorListView() { lvDoc.Items.Clear(); using (var client = new HaServiceClient()) { var appoinments = client.GetAppoinmentsByDate(DateTime.Today).Where(id => id.Doctor.DoctorId.Equals(_doctor.DoctorId)); if (appoinments.Count() < 1) { return; } foreach (var item in appoinments) { ListViewItem lvItem = new ListViewItem(item.Patient.FirstName); lvItem.SubItems.Add(item.Patient.SecondName); lvItem.SubItems.Add(item.Patient.LastName); lvItem.SubItems.Add(item.Patient.HistoryBook.BookNumber.ToString()); //lvItem.SubItems.Add(item.Patient.HistoryBook.BookNumber.ToString()); lvItem.SubItems.Add(item.Room.RoomNumber.ToString()); lvItem.SubItems.Add(item.Time); lvDoc.Items.Add(lvItem); } } }
private void btAddAppointment_Click(object sender, EventArgs e) { Appoinment appoinment = new Appoinment(); appoinment.Date = mcThisMonth.SelectionRange.Start.Date; //DateTime.Now; //new DateTime(2017, 4, 5);//mcThisMonth.SelectionRange.Start.Date; appoinment.Patient = _currentUser; appoinment.Doctor = _doctor; string time = "0"; if (rb1000.Checked == true) { time = "10:00"; } if (rb1020.Checked == true) { time = "10:20"; } if (rb1040.Checked == true) { time = "10:40"; } if (rb1100.Checked == true) { time = "11:00"; } if (rb1200.Checked == true) { time = "12:00"; } using (var client = new HaServiceClient()) { var rooms = client.GetRooms(); List <int> roomNum = rooms.Select(room => room.RoomNumber).ToList(); if (time != "0") { foreach ( var item in client.GetAppoinmentsByDate(mcThisMonth.SelectionRange.Start) .Where(t => t.Time.Equals(time))) { foreach (var room in rooms) { if (room.RoomNumber == item.Room.RoomNumber) { roomNum.Remove(room.RoomNumber); } } } } else { return; } if (roomNum.Count != 0) { appoinment.Room = client.GetRoomByNumber(roomNum.First()); var room = client.GetRoomByNumber(roomNum.First()); appoinment.RecordNumber = 1; appoinment.Time = time; //client.AddAppointment(appoinment); client.AddAppointmentOnContext(_doctor.DoctorId, _currentUser.PatientId, room.RoomId, appoinment); Refresh(); } else { return; } } //appoinment.Room }
private void mcThisMonth_DateSelected(object sender, DateRangeEventArgs e) { ResetRadioButtons(); RadioButtonsEnabledFalse(); tbSelectedData.Text = mcThisMonth.SelectionRange.Start.ToShortDateString(); List <string> times = new List <string>(); if (_doctor.DaysOfReceiving.TimeOfReceiving.T10_00 == true) { times.Add("10:00"); } if (_doctor.DaysOfReceiving.TimeOfReceiving.T10_20 == true) { times.Add("10:20"); } if (_doctor.DaysOfReceiving.TimeOfReceiving.T10_40 == true) { times.Add("10:40"); } if (_doctor.DaysOfReceiving.TimeOfReceiving.T11_00 == true) { times.Add("11:00"); } if (_doctor.DaysOfReceiving.TimeOfReceiving.T12_00 == true) { times.Add("12:00"); } List <string> freeTimeForDate = new List <string>(); freeTimeForDate = times; List <string> myAppTimeForToday = new List <string>(); using (var client = new HaServiceClient()) { foreach (var item in client.GetAppoinmentsByDate(mcThisMonth.SelectionRange.Start.Date).Where(pId => pId.Patient.PatientId.Equals(_currentUser.PatientId))) { freeTimeForDate.Remove(item.Time); } } using (var client = new HaServiceClient()) { var appByDoc = client.GetAppoinmentsByDate(mcThisMonth.SelectionRange.Start).Where(d => d.Doctor.DoctorId.Equals(_doctor.DoctorId)); foreach (var app in appByDoc) { foreach (var time in times) { if (app.Time == time) { freeTimeForDate.Remove(time); } } } if (freeTimeForDate.Count == 0) { return; } var rooms = client.GetRooms(); List <int> roomNum = new List <int>(); foreach (var time in freeTimeForDate) { foreach (var room in rooms) { roomNum.Add(room.RoomNumber); } foreach (var item in client.GetAppoinmentsByDate(mcThisMonth.SelectionRange.Start).Where(t => t.Time.Equals(time))) { foreach (var room in rooms) { if (room.RoomNumber == item.Room.RoomNumber) { roomNum.Remove(room.RoomNumber); } } } if (roomNum.Count != 0) { switch (time) { case "10:00": rb1000.Enabled = true; break; case "10:20": rb1020.Enabled = true; break; case "10:40": rb1040.Enabled = true; break; case "11:00": rb1100.Enabled = true; break; case "12:00": rb1200.Enabled = true; break; } } } /*foreach (var item in client.GetAppoinmentsByDate(mcThisMonth.SelectionRange.Start)) * { * if (item.Time == "10:00") rb1000.Enabled = false; * if (item.Time == "10:20") rb1020.Enabled = false; * if (item.Time == "10:40") rb1040.Enabled = false; * if (item.Time == "11:00") rb1100.Enabled = false; * if (item.Time == "12:00") rb1200.Enabled = false; * * //cbChoseSpesialty.Items.Add(item.SpecialtyName); * }*/ } }