public static List <string> AmigosEnMateria(int alumnoId, int materiaId, Dias dia, Turnos turno) { var amigosEnMateria = new List <string>(); using (var conn = new SqlConnection(Program.Configuration["ConnectionStrings:DefaultConnection"])) { conn.Open(); var cmdSelect = new SqlCommand(); cmdSelect.CommandText = @"SELECT A.Nombre FROM MateriaAlumno MA JOIN Alumnos A ON MA.AlumnoId = A.Id JOIN Seguidores S ON MA.AlumnoId = S.SeguidoId JOIN MateriaHorarios MH ON MA.MateriaHorarioId = MH.Id JOIN Horarios H ON MH.HorarioId = H.Id WHERE (S.AlumnoId = @AlumnoId) AND (MH.MateriaId = @MateriaId) AND (H.Dia = @Dia) AND (H.Turno = @Turno) AND (MA.Estado = 0)"; cmdSelect.Parameters.Add(new SqlParameter("AlumnoId", alumnoId)); cmdSelect.Parameters.Add(new SqlParameter("MateriaId", materiaId)); cmdSelect.Parameters.Add(new SqlParameter("Dia", dia.ToString())); cmdSelect.Parameters.Add(new SqlParameter("Turno", turno.ToString())); cmdSelect.Connection = conn; using (var resultSelect = cmdSelect.ExecuteReader()) { while (resultSelect.Read()) { amigosEnMateria.Add((string)resultSelect["Nombre"]); } } } return(amigosEnMateria); }
public static int ObtenerIdMateriaHorario(int idMateria, Dias dia, Turnos turno) { int idMateriaHorario = 0; using (var conn = new SqlConnection(Program.Configuration["ConnectionStrings:DefaultConnection"])) { conn.Open(); var cmdSelect = new SqlCommand(); cmdSelect.CommandText = @"SELECT Id FROM MateriaHorarios WHERE (MateriaId = (SELECT Id FROM Materias WHERE (Id = @IdMateria ))) AND (HorarioId = (SELECT Id FROM Horarios WHERE (Dia = @Dia) AND (Turno = @Turno)))"; cmdSelect.Parameters.Add(new SqlParameter("IdMateria", idMateria)); cmdSelect.Parameters.Add(new SqlParameter("Dia", dia.ToString())); cmdSelect.Parameters.Add(new SqlParameter("Turno", turno.ToString())); cmdSelect.Connection = conn; using (var resultSelect = cmdSelect.ExecuteReader()) { while (resultSelect.Read()) { idMateriaHorario = (int)resultSelect["Id"]; } } } if (idMateriaHorario == 0) { throw new Exception("IdMateriaHorario no encontrado"); } return(idMateriaHorario); }
public static string ValidarHorarioLibre(int idAlumno, Dias dia, Turnos turno) { var nombre = Constantes.Default; using (var conn = new SqlConnection(Program.Configuration["ConnectionStrings:DefaultConnection"])) { conn.Open(); var cmdSelect = new SqlCommand(); cmdSelect.CommandText = @"SELECT M.Nombre FROM Materias M JOIN MateriaHorarios MH ON M.Id = MH.MateriaId JOIN Horarios H ON MH.HorarioId = H.Id JOIN MateriaAlumno MA ON MH.Id = MA.MateriaHorarioId WHERE (MA.AlumnoId = @IdAlumno) AND (H.Dia = @Dia) AND (H.Turno = @Turno) AND (MA.Estado = 0)"; cmdSelect.Parameters.Add(new SqlParameter("IdAlumno", idAlumno)); cmdSelect.Parameters.Add(new SqlParameter("Dia", dia.ToString())); cmdSelect.Parameters.Add(new SqlParameter("Turno", turno.ToString())); cmdSelect.Connection = conn; using (var resultSelect = cmdSelect.ExecuteReader()) { while (resultSelect.Read()) { nombre = resultSelect["Nombre"].ToString(); } } } return(nombre); }
/// <summary> /// Enumeraciones /// 2) Agregar a la enumeración la posibilidad de Imprimir un Texto por cada día de la semana /// </summary> /// <param name="dia"></param> private static void enumeraciones2(Dias dia) { Console.WriteLine(dia.ToString()); }
public string ToShortString() => $"{Anos.ToString("00")}a {Meses.ToString("00")}m {Dias.ToString("00")}d";
public override string ToString() => $"{Anos.ToString("00")}a {Meses.ToString("00")}m {Dias.ToString("00")}d - Total {TotalDeDias.ToString("0000")} dias";