コード例 #1
0
        public int altaAlumno(Business.Entities.Alumno al)
        {
            string nombre   = al.Nombre;
            string apellido = al.Apellido;
            string dni      = al.Dni;
            string legajo   = al.Legajo;
            string telefono = al.Telefono;
            string mail     = al.Email;
            int    tipo     = (int)al.TipoUsuario;

            try
            {
                Conexion.getInstance().Connect();
                SqlCommand cmd = new SqlCommand("insert into dbo.Persona(nombre,apellido,legajo,dni,telefono,mail)" +
                                                " values('" + nombre + "','"
                                                + apellido + "','" + legajo + "','" + dni + "','" + telefono + "','" + mail + "'); select SCOPE_IDENTITY()", Conexion.getInstance().Conection);
                int idPersona = Convert.ToInt32(cmd.ExecuteScalar());


                Conexion.getInstance().Disconnect();
                return(idPersona);
            }
            catch (Exception e)
            {
                Conexion.getInstance().Disconnect();
                return(-1);
            }
        }
コード例 #2
0
        public Business.Entities.Alumno buscarAlumnoPorId(int id)
        {
            try
            {
                int idper = id;
                Conexion.getInstance().Connect();
                Business.Entities.Alumno al;

                SqlCommand    cmd    = new SqlCommand("select * from dbo.Persona where idPersona='" + idper + "'", Conexion.getInstance().Conection);
                SqlDataReader reader = cmd.ExecuteReader();
                reader.Read();
                string nombre   = reader.GetString(0);
                string apellido = reader.GetString(1);
                string legajo   = reader.GetString(2);
                string dni      = reader.GetString(3);
                string telefono = reader.GetString(4);
                string mail     = reader.GetString(5);
                int    idp      = (int)reader.GetValue(6);
                al           = new Business.Entities.Alumno(nombre, apellido, legajo, dni, mail, telefono);
                al.IDPersona = idp;
                Conexion.getInstance().Disconnect();
                return(al);
            }
            catch (Exception e)
            {
                Conexion.getInstance().Disconnect();
                return(null);
            }
        }
コード例 #3
0
        public Business.Entities.Alumno buscarAlumno(string legajo)
        {
            try
            {
                Conexion.getInstance().Connect();
                Business.Entities.Alumno al;

                SqlCommand    cmd    = new SqlCommand("select * from dbo.Persona where CONVERT(VARCHAR,legajo)='" + legajo + "'", Conexion.getInstance().Conection);
                SqlDataReader reader = cmd.ExecuteReader();

                reader.Read();


                String nombre   = reader.GetString(0);
                String apellido = reader.GetString(1);
                String dni      = reader.GetString(3);
                String telefono = reader.GetString(4);
                String mail     = reader.GetString(5);
                al = new Business.Entities.Alumno(nombre, apellido, legajo, dni, mail, telefono);


                Conexion.getInstance().Disconnect();
                return(al);
            }
            catch (Exception e) {
                Conexion.getInstance().Disconnect();
                return(null);
            }
        }
コード例 #4
0
        public Business.Entities.Alumno buscarAlumno(string legajo)
        {
            try
            {
                Conexion.getInstance().Connect();
                Business.Entities.Alumno al;

                SqlCommand    cmd    = new SqlCommand("select * from dbo.Persona pe inner join dbo.Usuario us on pe.idPersona=us.idPersona where CONVERT(VARCHAR,legajo)='" + legajo + "'", Conexion.getInstance().Conection);
                SqlDataReader reader = cmd.ExecuteReader();

                reader.Read();


                string nombre   = reader.GetString(0);
                string apellido = reader.GetString(1);
                string dni      = reader.GetString(3);
                string telefono = reader.GetString(4);
                string mail     = reader.GetString(5);
                int    id       = (int)reader.GetValue(6);
                string usu      = reader.GetString(7);
                string cont     = reader.GetString(8);
                al = new Business.Entities.Alumno(nombre, apellido, legajo, dni, mail, telefono);
                al.NombreUsuario = usu;
                al.Contraseña    = cont;
                al.IDPersona     = id;


                Conexion.getInstance().Disconnect();
                return(al);
            }
            catch (Exception e) {
                Conexion.getInstance().Disconnect();
                return(null);
            }
        }
コード例 #5
0
 public static int altaAlumno(Business.Entities.Alumno al)
 {
     Business.Entities.Alumno alu = buscarAlumno(al.Legajo);
     if (alu == null)
     {
         return(Data.Database.AlumnoDB.getInstance().altaAlumno(al));
     }
     return(-1);
 }
コード例 #6
0
        public static bool modi(Alumno alu)
        {
            int idP = ABMUsuario.buscarIdpersonaPorUsuario(alu.NombreUsuario);

            if (idP == 0 || idP == alu.IDPersona)
            {
                Business.Entities.Alumno al = buscarAlumno(alu.Legajo);
                if (al == null || al.IDPersona == alu.IDPersona)
                {
                    return(Data.Database.AlumnoDB.getInstance().modi(alu));
                }
            }
            return(false);
        }
コード例 #7
0
        public List <Business.Entities.Alumno> listarAlumnosPorLegajo(string lega)
        {
            try
            {
                Conexion.getInstance().Connect();
                List <Business.Entities.Alumno> alumnos = new List <Business.Entities.Alumno>();
                string        legajo = "%" + lega + "%";
                SqlCommand    cmd    = new SqlCommand("select * from dbo.Persona pe inner join dbo.Usuario us on pe.idPersona=us.idPersona where tipoUsuario=1 AND CONVERT(VARCHAR,legajo) like '" + legajo + "'", Conexion.getInstance().Conection);
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    String nombre               = reader.GetString(0);
                    String apellido             = reader.GetString(1);
                    String legaj                = reader.GetString(2);
                    String dni                  = reader.GetString(3);
                    String telefono             = reader.GetString(4);
                    String mail                 = reader.GetString(5);
                    int    id                   = (int)reader.GetValue(6);
                    String usu                  = reader.GetString(7);
                    String cont                 = reader.GetString(8);
                    Business.Entities.Alumno al = new Business.Entities.Alumno(nombre, apellido, legaj, dni, mail, telefono);
                    al.NombreUsuario = usu;
                    al.Contraseña    = cont;
                    al.IDPersona     = id;
                    alumnos.Add(al);
                }

                Conexion.getInstance().Disconnect();
                return(alumnos);
            }
            catch (Exception e)
            {
                Conexion.getInstance().Disconnect();
                return(null);
            }
        }
コード例 #8
0
 public static int altaAlumno(Business.Entities.Alumno al)
 {
     return(Data.Database.AlumnoDB.getInstance().altaAlumno(al));
 }