public static List<Listado4> Listado4(int semestre, int ano) { List<Listado4> listaListado4 = new List<Listado4>(); List<SqlParameter> ListaParametros = new List<SqlParameter>(); ListaParametros.Add(new SqlParameter("@ano", (decimal)ano)); if (semestre == 1) { string query =@"SELECT TOP 5 Nombre, Apellido, Documento, [1], [2], [3], [4], [5], [6], Total_Primer_Semestre FROM mario_killers.listado_4_view WHERE Anio = @ano ORDER BY Total_Primer_Semestre DESC "; SqlDataReader lector = Clases.BaseDeDatosSQL.ObtenerDataReader(query, "T", ListaParametros); if (lector.HasRows) { while (lector.Read()) { Listado4 unRegistro = new Listado4(); unRegistro.Nombre = (string)lector["Nombre"]; unRegistro.Apellido = (string)lector["Apellido"]; unRegistro.CantBonos = (int)lector["Total_Primer_Semestre"]; unRegistro.CantBonos1 = (int)lector["1"]; unRegistro.CantBonos2 = (int)lector["2"]; unRegistro.CantBonos3 = (int)lector["3"]; unRegistro.CantBonos4 = (int)lector["4"]; unRegistro.CantBonos5 = (int)lector["5"]; unRegistro.CantBonos6 = (int)lector["6"]; unRegistro.Documento = (int)(decimal)lector["Documento"]; unRegistro.ano = ano; listaListado4.Add(unRegistro); } } return listaListado4; } else { string query = @"SELECT TOP 5 Nombre, Apellido, Documento, [7], [8], [9], [10], [11], [12], Total_Segundo_Semestre FROM mario_killers.listado_4_view WHERE Anio = @ano ORDER BY Total_Segundo_Semestre DESC"; SqlDataReader lector = Clases.BaseDeDatosSQL.ObtenerDataReader(query, "T", ListaParametros); if (lector.HasRows) { while (lector.Read()) { Listado4 unRegistro = new Listado4(); unRegistro.Nombre = (string)lector["Nombre"]; unRegistro.Apellido = (string)lector["Apellido"]; unRegistro.CantBonos = (int)lector["Total_Segundo_Semestre"]; unRegistro.CantBonos1 = (int)lector["7"]; unRegistro.CantBonos2 = (int)lector["8"]; unRegistro.CantBonos3 = (int)lector["9"]; unRegistro.CantBonos4 = (int)lector["10"]; unRegistro.CantBonos5 = (int)lector["11"]; unRegistro.CantBonos6 = (int)lector["12"]; unRegistro.Documento = (int)(decimal)lector["Documento"]; unRegistro.ano = ano; listaListado4.Add(unRegistro); } } return listaListado4; } }
public static List <Listado4> Listado4(int semestre, int ano) { List <Listado4> listaListado4 = new List <Listado4>(); List <SqlParameter> ListaParametros = new List <SqlParameter>(); ListaParametros.Add(new SqlParameter("@ano", (decimal)ano)); if (semestre == 1) { string query = @"SELECT TOP 5 Nombre, Apellido, Documento, [1], [2], [3], [4], [5], [6], Total_Primer_Semestre FROM mario_killers.listado_4_view WHERE Anio = @ano ORDER BY Total_Primer_Semestre DESC "; SqlDataReader lector = Clases.BaseDeDatosSQL.ObtenerDataReader(query, "T", ListaParametros); if (lector.HasRows) { while (lector.Read()) { Listado4 unRegistro = new Listado4(); unRegistro.Nombre = (string)lector["Nombre"]; unRegistro.Apellido = (string)lector["Apellido"]; unRegistro.CantBonos = (int)lector["Total_Primer_Semestre"]; unRegistro.CantBonos1 = (int)lector["1"]; unRegistro.CantBonos2 = (int)lector["2"]; unRegistro.CantBonos3 = (int)lector["3"]; unRegistro.CantBonos4 = (int)lector["4"]; unRegistro.CantBonos5 = (int)lector["5"]; unRegistro.CantBonos6 = (int)lector["6"]; unRegistro.Documento = (int)(decimal)lector["Documento"]; unRegistro.ano = ano; listaListado4.Add(unRegistro); } } return(listaListado4); } else { string query = @"SELECT TOP 5 Nombre, Apellido, Documento, [7], [8], [9], [10], [11], [12], Total_Segundo_Semestre FROM mario_killers.listado_4_view WHERE Anio = @ano ORDER BY Total_Segundo_Semestre DESC"; SqlDataReader lector = Clases.BaseDeDatosSQL.ObtenerDataReader(query, "T", ListaParametros); if (lector.HasRows) { while (lector.Read()) { Listado4 unRegistro = new Listado4(); unRegistro.Nombre = (string)lector["Nombre"]; unRegistro.Apellido = (string)lector["Apellido"]; unRegistro.CantBonos = (int)lector["Total_Segundo_Semestre"]; unRegistro.CantBonos1 = (int)lector["7"]; unRegistro.CantBonos2 = (int)lector["8"]; unRegistro.CantBonos3 = (int)lector["9"]; unRegistro.CantBonos4 = (int)lector["10"]; unRegistro.CantBonos5 = (int)lector["11"]; unRegistro.CantBonos6 = (int)lector["12"]; unRegistro.Documento = (int)(decimal)lector["Documento"]; unRegistro.ano = ano; listaListado4.Add(unRegistro); } } return(listaListado4); } }