public void GetTherapyPatient() { DBClass.openConnection(); //) CAST(DateOfBirth AS date), convert(Date, DateOfBirth, 23) //select distinct convert(VARCHAR, DataDiagnosis, 23) , NotesDiagnosis, LastNameTherapist from therapists, diagnosis where(diagnosis.IDPatient = '2') and therapists.LastNameTherapist = (select LastNameTherapist from therapists where IDTherapist = '2') DBClass.sql = "select distinct IDTherapy, convert(VARCHAR, DateTherapy, 23) , TherapyNote, LastNameTherapist " + "from therapists, therapy " + "where (therapy.IDPatient = '" + infoPatientTemp[0] + "') and therapists.LastNameTherapist = (select LastNameTherapist from therapists where IDTherapist = '2')"; DBClass.cmd.CommandType = CommandType.Text; DBClass.cmd.CommandText = DBClass.sql; DBClass.da = new SqlDataAdapter(DBClass.cmd); DBClass.dt = new DataTable(); DBClass.da.Fill(DBClass.dt); // wyciągamy dane int j = 0; TherapyList.Clear(); using (SqlDataReader reader = DBClass.cmd.ExecuteReader()) { while (reader.Read()) { for (j = 0; j <= reader.FieldCount - 1; j++) // Looping throw colums { data[j] = reader.GetValue(j).ToString(); } if (data[7] == null) { data[7] = ""; } TherapyList.Add(new TherapyModel { IDTherapy = (data[0]), DataTherapy = data[1], NotesTherapy = data[2], LastNameTherapist = data[3] }); //Console.WriteLine("IDTherapist - " + data[7] + data[8]); } } }
private void Page1_Load(object sender, EventArgs e) { var therapyList = TherapyList.Instance(); var therapistList = TherapistList.Instance(); foreach (var therapy in therapyList) { dataGridView.Rows.Add(therapy.TherapyId, therapy.TherapyName, ""); var currentTherapyRow = dataGridView.Rows[dataGridView.RowCount - 1]; currentTherapyRow[1].Style.ColSpan = 2; foreach (var therapist in therapistList) { if (therapist.TherapyId == therapy.TherapyId) { dataGridView.Rows.Add(therapist.TherapyId, "", therapist.TherapistName); dataGridView.Rows[dataGridView.RowCount - 1].ParentRow = currentTherapyRow; } } currentTherapyRow.Collapse(); } }