Example #1
0
        public static bool Create(AlumnoGrado alumnoGrado)
        {
            using (SqlConnection connection = DBConfig.GetInstance().GetConnection())
            {
                try
                {
                    SqlCommand query = new SqlCommand("spAlumnoGradoCreate", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    query.Parameters.AddWithValue("@alumnoID", alumnoGrado.AlumnoID);
                    query.Parameters.AddWithValue("@gradoID", alumnoGrado.GradoID);
                    query.Parameters.AddWithValue("@seccion", alumnoGrado.Seccion);

                    int rowsAffected = query.ExecuteNonQuery();

                    if (rowsAffected == 1)
                    {
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(false);
        }
Example #2
0
        public static bool Delete(int id)
        {
            using (SqlConnection connection = DBConfig.GetInstance().GetConnection())
            {
                try
                {
                    SqlCommand query = new SqlCommand("spAlumnoGradoDeleteByID", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    query.Parameters.AddWithValue("@id", id);

                    int rowsAffected = query.ExecuteNonQuery();

                    if (rowsAffected == 1)
                    {
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(false);
        }
Example #3
0
        public static List <AlumnoGrado> GetAll()
        {
            List <AlumnoGrado> alumnosGrados = new List <AlumnoGrado>();

            using (SqlConnection connection = DBConfig.GetInstance().GetConnection())
            {
                try
                {
                    SqlCommand query = new SqlCommand("spAlumnoGradoGetAll", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    SqlDataReader reader = query.ExecuteReader();

                    while (reader.Read())
                    {
                        AlumnoGrado alumnoGrado = new AlumnoGrado
                        {
                            ID       = Convert.ToInt32(reader["id"]),
                            AlumnoID = Convert.ToInt32(reader["alumnoID"]),
                            GradoID  = Convert.ToInt32(reader["gradoID"]),
                            Seccion  = Convert.ToString(reader["seccion"])
                        };
                        alumnosGrados.Add(alumnoGrado);
                    }
                } catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(alumnosGrados);
        }
Example #4
0
        public static bool Create(Profesor profesor)
        {
            using (SqlConnection connection = DBConfig.GetInstance().GetConnection())
            {
                try
                {
                    SqlCommand query = new SqlCommand("spProfesorCreate", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    query.Parameters.AddWithValue("@nombre", profesor.Nombre);
                    query.Parameters.AddWithValue("@apellidos", profesor.Apellidos);
                    query.Parameters.AddWithValue("@genero", profesor.Genero);

                    int rowsAffected = query.ExecuteNonQuery();

                    if (rowsAffected == 1)
                    {
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(false);
        }
Example #5
0
        public static AlumnoGrado GetByID(int id)
        {
            AlumnoGrado alumnoGrado = null;

            using (SqlConnection connection = DBConfig.GetInstance().GetConnection())
            {
                try
                {
                    SqlCommand query = new SqlCommand("spAlumnoGradoGetByID", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    query.Parameters.AddWithValue("@id", id);

                    SqlDataReader reader = query.ExecuteReader();

                    while (reader.Read())
                    {
                        alumnoGrado = new AlumnoGrado
                        {
                            ID       = Convert.ToInt32(reader["id"]),
                            AlumnoID = Convert.ToInt32(reader["alumnoID"]),
                            GradoID  = Convert.ToInt32(reader["gradoID"]),
                            Seccion  = Convert.ToString(reader["seccion"])
                        };
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(alumnoGrado);
        }
Example #6
0
        public static Profesor GetByID(int id)
        {
            Profesor profesor = null;

            using (SqlConnection connection = DBConfig.GetInstance().GetConnection())
            {
                try
                {
                    SqlCommand query = new SqlCommand("spProfesorGetByID", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    query.Parameters.AddWithValue("@id", id);

                    SqlDataReader reader = query.ExecuteReader();

                    while (reader.Read())
                    {
                        profesor = new Profesor
                        {
                            ID        = Convert.ToInt32(reader["id"]),
                            Nombre    = Convert.ToString(reader["nombre"]),
                            Apellidos = Convert.ToString(reader["apellidos"]),
                            Genero    = Convert.ToString(reader["genero"])
                        };
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(profesor);
        }
Example #7
0
        public static List <Profesor> GetAll()
        {
            List <Profesor> profesores = new List <Profesor>();

            using (SqlConnection connection = DBConfig.GetInstance().GetConnection())
            {
                try
                {
                    SqlCommand query = new SqlCommand("spProfesorGetAll", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    SqlDataReader reader = query.ExecuteReader();

                    while (reader.Read())
                    {
                        Profesor profesor = new Profesor
                        {
                            ID        = Convert.ToInt32(reader["id"]),
                            Nombre    = Convert.ToString(reader["nombre"]),
                            Apellidos = Convert.ToString(reader["apellidos"]),
                            Genero    = Convert.ToString(reader["genero"]),
                        };
                        profesores.Add(profesor);
                    }
                } catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(profesores);
        }
Example #8
0
        public static List <Alumno> GetAll()
        {
            List <Alumno> alumnos = new List <Alumno>();

            using (SqlConnection connection = DBConfig.GetInstance().GetConnection())
            {
                try
                {
                    SqlCommand query = new SqlCommand("spAlumnoGetAll", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    SqlDataReader reader = query.ExecuteReader();

                    while (reader.Read())
                    {
                        Alumno alumno = new Alumno
                        {
                            ID                = Convert.ToInt32(reader["id"]),
                            Nombre            = Convert.ToString(reader["nombre"]),
                            Apellidos         = Convert.ToString(reader["apellidos"]),
                            Genero            = Convert.ToString(reader["genero"]),
                            FechaDeNacimiento = Convert.ToDateTime(reader["fechaDeNacimiento"])
                        };
                        alumnos.Add(alumno);
                    }
                } catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(alumnos);
        }
Example #9
0
        public static bool Update(Alumno alumno)
        {
            using (SqlConnection connection = DBConfig.GetInstance().GetConnection())
            {
                try
                {
                    SqlCommand query = new SqlCommand("spAlumnoUpdateByID", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    query.Parameters.AddWithValue("@id", alumno.ID);
                    query.Parameters.AddWithValue("@nombre", alumno.Nombre);
                    query.Parameters.AddWithValue("@apellidos", alumno.Apellidos);
                    query.Parameters.AddWithValue("@genero", alumno.Genero);
                    query.Parameters.AddWithValue("@fechaDeNacimiento", alumno.FechaDeNacimiento);

                    int rowsAffected = query.ExecuteNonQuery();

                    if (rowsAffected == 1)
                    {
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(false);
        }
Example #10
0
        public static List <Grado> GetAll()
        {
            List <Grado> grados = new List <Grado>();

            using (SqlConnection connection = DBConfig.GetInstance().GetConnection())
            {
                try
                {
                    SqlCommand query = new SqlCommand("spGradoGetAll", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    SqlDataReader reader = query.ExecuteReader();

                    while (reader.Read())
                    {
                        Grado grado = new Grado
                        {
                            ID         = Convert.ToInt32(reader["id"]),
                            Nombre     = Convert.ToString(reader["nombre"]),
                            ProfesorID = Convert.ToInt32(reader["profesorID"])
                        };
                        grados.Add(grado);
                    }
                } catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(grados);
        }
Example #11
0
        public static Grado GetByID(int id)
        {
            Grado grado = null;

            using (SqlConnection connection = DBConfig.GetInstance().GetConnection())
            {
                try
                {
                    SqlCommand query = new SqlCommand("spGradoGetByID", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    query.Parameters.AddWithValue("@id", id);

                    SqlDataReader reader = query.ExecuteReader();

                    while (reader.Read())
                    {
                        grado = new Grado
                        {
                            ID         = Convert.ToInt32(reader["id"]),
                            Nombre     = Convert.ToString(reader["nombre"]),
                            ProfesorID = Convert.ToInt32(reader["profesorID"])
                        };
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(grado);
        }
Example #12
0
        public static bool Update(Grado grado)
        {
            using (SqlConnection connection = DBConfig.GetInstance().GetConnection())
            {
                try
                {
                    SqlCommand query = new SqlCommand("spGradoUpdateByID", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    query.Parameters.AddWithValue("@id", grado.ID);
                    query.Parameters.AddWithValue("@nombre", grado.Nombre);
                    query.Parameters.AddWithValue("@profesorID", grado.ProfesorID);

                    int rowsAffected = query.ExecuteNonQuery();

                    if (rowsAffected == 1)
                    {
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(false);
        }