コード例 #1
0
        public Medico traerMedicosPorEspeciliadad(Int64 idmed)
        {
            SqlCommand            comando  = new SqlCommand();
            SqlConnection         conexion = new SqlConnection();
            SqlDataReader         lector;
            Medico                lista   = new Medico();
            especialidadesNegocio lisEsp  = new especialidadesNegocio();
            horarioServicio       horaser = new horarioServicio();

            try
            {
                conexion.ConnectionString = "data source=(local);initial catalog=medicina_db;integrated security=sspi";
                comando.CommandType       = System.Data.CommandType.Text;
                comando.Connection        = conexion;
                //comando.CommandText = "SELECT p.IDMEDICO,p.IDHORARIO, p.NOMBRE, p.APELLIDO ,p.DNI,p.DIRECCION,p.idlocalidad,l.CP,p.CELULAR,p.TELEFONO,p.EMAIL,p.FECHA_NACIMIENTO,P.SEXO ,p.ACTIVO from MEDICOS  as p inner join LOCALIDADES as l on p.IDLOCALIDAD = l.IDLOCALIDAD inner join HORARIOS as h on h.IDHORARIO =p.IDHORARIO  WHERE p.ACTIVO = 1 and p.idmedico =  " + idmedico ;
                comando.CommandText = "SELECT p.IDMEDICO,p.IDHORARIO, p.NOMBRE, p.APELLIDO ,p.DNI,p.DIRECCION,p.idlocalidad,l.CP,p.CELULAR,p.TELEFONO,p.EMAIL,p.FECHA_NACIMIENTO,P.SEXO ,p.ACTIVO,h.TURNO,h.HORAENTRADA,h.HORASALIDA  from MEDICOS  as p inner join LOCALIDADES as l on p.IDLOCALIDAD = l.IDLOCALIDAD inner join HORARIOS as h on h.IDHORARIO =p.IDHORARIO  WHERE p.ACTIVO = 1 and p.idmedico  = " + idmed;

                conexion.Open();
                lector = comando.ExecuteReader();
                while (lector.Read())
                {
                    Medico nue = new Medico();
                    nue.Idmedico    = lector.GetInt64(0);
                    nue.Idhorario   = lector.GetInt64(1);
                    nue.Nombre      = lector.GetString(2);
                    nue.Apellido    = lector.GetString(3);
                    nue.Dni         = lector.GetInt64(4);
                    nue.Direccion   = lector.GetString(5);
                    nue.Idlocalidad = lector.GetInt64(6);
                    nue.Cp          = lector.GetInt64(7);
                    nue.Celular     = lector.GetInt64(8);
                    nue.Telefono    = lector.GetInt64(9);
                    nue.Email       = lector.GetString(10);
                    nue.FechaNac    = lector.GetDateTime(11);
                    nue.Sexo        = lector.GetString(12);
                    nue.Activo      = lector.GetInt32(13);
                    // nue.ListaEspecialidad = lisEsp.traerEspecialidadPorId(especi);
                    nue.Hora          = new Horarios();
                    nue.Hora.Turno    = lector.GetString(14);
                    nue.Hora.HEntrada = lector.GetInt64(15);
                    nue.Hora.HSalida  = lector.GetInt64(16);


                    lista = nue;
                }
                return(lista);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conexion.Close();
                conexion.Dispose();
                comando.Dispose();
            }
        }
コード例 #2
0
        public IList <MedicoXespecil> traerEspeciXmedico(Int64 idesp)
        {
            SqlCommand             comando  = new SqlCommand();
            SqlConnection          conexion = new SqlConnection();
            SqlDataReader          lector;
            IList <MedicoXespecil> lista   = new List <MedicoXespecil>();
            horarioServicio        horaser = new horarioServicio();

            try
            {
                conexion.ConnectionString = "data source=(local);initial catalog=medicina_db;integrated security=sspi";
                comando.CommandType       = System.Data.CommandType.Text;
                comando.Connection        = conexion;
                comando.CommandText       = " select me.idgeneral,m.apellido,m.idmedico,e.especialidad,e.idespecialidad,me.entrada,me.salida,me.activo from ESPECIALIDADES_X_MEDICO as me inner join MEDICOS as m on me.IDMEDICO=m.IDMEDICO inner join ESPECIALIDADES as e on me.IDESPECIALIDAD=e.IDESPECIALIDAD WHERE me.activo=1 and m.activo=1 AND E.ACTIVO=1 and e.idespecialidad =  " + idesp;

                conexion.Open();
                lector = comando.ExecuteReader();
                while (lector.Read())
                {
                    MedicoXespecil aux = new MedicoXespecil();
                    aux.idgeneral      = lector.GetInt64(0);
                    aux.apellido       = lector.GetString(1);
                    aux.idmedico       = lector.GetInt64(2);
                    aux.especialidad   = lector.GetString(3);
                    aux.idespecialidad = lector.GetInt64(4);
                    aux.entrada        = lector.GetInt64(5);
                    aux.salida         = lector.GetInt64(6);
                    aux.activo         = lector.GetInt32(7);
                    // aux.Hora = horaser.traerHorariosPorMedico(aux.idhorario);

                    lista.Add(aux);
                }
                return(lista);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conexion.Close();
                conexion.Dispose();
                comando.Dispose();
            }
        }