/// <summary> /// Accesses the database. /// </summary> private void AccessDatabase() { using (SqlConnection connection = new SqlConnection("Data Source=SQL5025.myASP.NET;Initial Catalog=DB_A0ADFA_HPCareDBContext;User Id=DB_A0ADFA_HPCareDBContext_admin;Password=hpcare2016;")) { SqlCommand command = new SqlCommand("SELECT MCDTs.MCDT_ID, MCDTs.MCDT_type, MCDTs.MCDT_date, MCDTs.LabExam_data_in, MCDTs.LabExam_date_out, Users.User_id," + " Users.Name , MCDTs.Discriminator FROM ClinicRegistryManagers INNER JOIN MCDTManagers ON ClinicRegistryManagers.ClinicRegistryManagerId = MCDTManagers.clinicRegistryManager_ClinicRegistryManagerId " + " INNER JOIN MCDTStaffManagers ON MCDTManagers.MCDTStaffManager_MCDTStaffManager_id = MCDTStaffManagers.MCDTStaffManager_id INNER JOIN MCDTs ON " + " MCDTStaffManagers.mcdt_MCDT_ID = MCDTs.MCDT_ID INNER JOIN Patient ON ClinicRegistryManagers.Clinic_patient_User_id = Patient.User_id INNER JOIN " + " Users ON Patient.User_id = Users.User_id and mcdts.labexam_data_in is null and discriminator != '(Undefined)';", connection); command.CommandType = CommandType.Text; command.Connection = connection; connection.Open(); DbDataReader dbDataReader = command.ExecuteReader(); McdtViewModel viewModel; while (dbDataReader.Read()) { viewModel = new McdtViewModel { McdtId = dbDataReader.GetInt32(0), McdtType = dbDataReader.GetInt32(1), McdtDate = GetDateDefault(dbDataReader, 2), LabDateIn = GetDateDefault(dbDataReader, 3), LabDateOut = GetDateDefault(dbDataReader, 4), UserId = dbDataReader.GetInt32(5), UserName = dbDataReader.GetString(6), Discriminator = dbDataReader.GetString(7) }; listMcdtVM.Add(viewModel); } } }
/// <summary> /// Accesses the get patient MCDTS history. /// </summary> /// <param name="idPatient">The identifier patient.</param> private void AccessGetPatientMcdtsHistory(int idPatient) { using (SqlConnection connection = new SqlConnection("Data Source=SQL5025.myASP.NET;Initial Catalog=DB_A0ADFA_HPCareDBContext;User Id=DB_A0ADFA_HPCareDBContext_admin;Password=hpcare2016;")) { SqlCommand command = new SqlCommand("SELECT MCDTs.MCDT_date, MCDTs.Discriminator FROM ClinicRegistryManagers INNER JOIN MCDTManagers ON ClinicRegistryManagers.ClinicRegistryManagerId = MCDTManagers.clinicRegistryManager_ClinicRegistryManagerId " + " INNER JOIN MCDTStaffManagers ON MCDTManagers.MCDTStaffManager_MCDTStaffManager_id = MCDTStaffManagers.MCDTStaffManager_id INNER JOIN MCDTs ON " + " MCDTStaffManagers.mcdt_MCDT_ID = MCDTs.MCDT_ID INNER JOIN Patient ON ClinicRegistryManagers.Clinic_patient_User_id = Patient.User_id INNER JOIN " + " Users ON Patient.User_id = Users.User_id and users.user_id = " + idPatient + ";", connection); command.CommandType = CommandType.Text; command.Connection = connection; connection.Open(); DbDataReader dbDataReader = command.ExecuteReader(); McdtViewModel viewModel; while (dbDataReader.Read()) { viewModel = new McdtViewModel { McdtDate = dbDataReader.GetDateTime(0), Discriminator = dbDataReader.GetString(1) }; patientMcdtHistory.Add(viewModel); } } }