private void LoadFeautureVisits(int id) { SqlConnection connection = new SqlConnection(MyProject.Properties.Settings.Default.Connection); try { connection.Open(); } finally { string select1 = $"select * FROM DOCTOR INNER JOIN (SELECT * FROM VISIT INNER JOIN PACIENT ON VISIT.IDPACIENT=PACIENT.PACIENTID WHERE PACIENT.PACIENTID={id} AND VISIT.DATE > CONVERT (date, SYSDATETIME())) VISITS ON VISITS.IDDOCTOR=DOCTOR.DOCTORID"; SqlCommand command = new SqlCommand(select1, connection); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { User FutureVisits = new User(); FutureVisits.DocName = reader.GetString(2); FutureVisits.DateVisit = reader.GetDateTime(9); FutureVisits.TimeVisit = reader.GetTimeSpan(10); FutureVisits.Room = reader.GetInt32(5); VISIT.Add(FutureVisits); } connection.Close(); if (VISIT.Count > 0) { FutureVisits = VISIT[0]; } } } }
private void LoadVisits(int id) { SqlConnection connection = new SqlConnection(MyProject.Properties.Settings.Default.Connection); try { connection.Open(); } finally { string select1 = $"select * FROM PACIENT INNER JOIN (SELECT * FROM VISIT INNER JOIN DOCTOR ON VISIT.IDDOCTOR=DOCTOR.DOCTORID WHERE DOCTOR.DOCTORID={id} AND VISIT.DATE >= CONVERT (date, SYSDATETIME()) ) VISITS ON VISITS.IDPACIENT=PACIENT.PACIENTID"; SqlCommand command = new SqlCommand(select1, connection); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Doctor doctor = new Doctor(); doctor.IdVisit = reader.GetInt32(8); doctor.PacientName = reader.GetString(3); doctor.Surname = reader.GetString(4); doctor.DataVisit = reader.GetDateTime(11); doctor.TimeVisit = reader.GetTimeSpan(12); if (!reader.IsDBNull(13)) { doctor.Diagnose = reader.GetString(13); } if (!reader.IsDBNull(14)) { doctor.Treatment = reader.GetString(14); } VISIT.Add(doctor); } } connection.Close(); } }