public IList <Horario> BuscarHorario(Int32 Id_Empleado, string Dia)
        {
            DataAccessLayer accesoDatos = new DataAccessLayer();

            try
            {
                accesoDatos.setearComandoText("SELECT ID_HORARIO,ID_EMPLEADO,HORA_DESDE,HORA_HASTA,DIAS FROM HORA_IE  where ID_EMPLEADO= " + Id_Empleado + " and DIAS LIKE '%" + Dia + "%'");
                accesoDatos.abrirConexion();
                accesoDatos.ejecutarQuery();

                IList <Horario> lista = new List <Horario>();

                while (accesoDatos.Lector.Read())
                {
                    Horario hora = new Horario();
                    hora.ID_Horario1  = accesoDatos.Lector.GetInt32(0);
                    hora.ID_Empleado1 = accesoDatos.Lector.GetInt32(1);
                    hora.Desde1       = accesoDatos.Lector.GetTimeSpan(2);
                    hora.Hasta1       = accesoDatos.Lector.GetTimeSpan(3);
                    hora.Dia1         = accesoDatos.Lector.GetString(4);
                    lista.Add(hora);
                }
                return(lista);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                accesoDatos.cerrarConexion();
            }
        }
        public void GuerdarHorarios(Horario nuevo)
        {
            SqlConnection cn = new SqlConnection();
            SqlCommand    cm = new SqlCommand();

            try
            {
                cn.ConnectionString = "Data Source=LOCAL\\SQLEXPRESS;Initial Catalog=CLINICA_TOLOZA;Integrated Security=True";
                cm.CommandType      = System.Data.CommandType.StoredProcedure;
                cm.Connection       = cn;
                cm.CommandText      = "SP_HORARIO_MEDICO";
                cm.Parameters.Clear();
                cm.Parameters.AddWithValue("ID_EMPLEADO", nuevo.ID_Empleado1);
                cm.Parameters.AddWithValue("@HORA_D", nuevo.Desde1);
                cm.Parameters.AddWithValue("@HORA_H", nuevo.Hasta1);
                cm.Parameters.AddWithValue("@DIAS", nuevo.Dia1);

                cn.Open();
                cm.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                cn.Close();
                cn.Dispose();
                cm.Dispose();
            }
        }
        public IList <Horario> TraerHorarios()
        {
            DataAccessLayer accesoDatos = new DataAccessLayer();
            IList <Horario> lista       = new List <Horario>();

            try
            {
                accesoDatos.setearComandoText("SELECT ID_HORARIO,ID_EMPLEADO,HORA_DESDE,HORA_HASTA,DIAS FROM HORA_IE");
                accesoDatos.abrirConexion();
                accesoDatos.ejecutarQuery();
                while (accesoDatos.Lector.Read())
                {
                    Horario HorarioM = new Horario();
                    HorarioM.ID_Horario1  = accesoDatos.Lector.GetInt32(0);
                    HorarioM.ID_Empleado1 = accesoDatos.Lector.GetInt32(1);
                    HorarioM.Desde1       = accesoDatos.Lector.GetTimeSpan(2);
                    HorarioM.Hasta1       = accesoDatos.Lector.GetTimeSpan(3);
                    HorarioM.Dia1         = accesoDatos.Lector.GetString(4);
                    lista.Add(HorarioM);
                }
                return(lista);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                accesoDatos.cerrarConexion();
            }
        }
Example #4
0
        //public static void CarregarGrafoPeloArquivo(IDado[,] matriz)
        //{
        //    for (int i = 0; i < matriz.GetLength(0); i++)
        //    {
        //        Vertice disc = new Vertice(matriz[i, 0]);
        //        Vertice prof = new Vertice(matriz[i, 1]);
        //        Vertice peri = new Vertice(matriz[i, 2]);

        //        grade.AddVertice(disc);
        //        grade.AddVertice(prof);
        //        grade.AddVertice(peri);

        //        grade.AddAresta(new Aresta(disc, prof));
        //        grade.AddAresta(new Aresta(disc, peri));
        //    }
        //}

        public static void CarregarGrafoPeloBanco()
        {
            DataTable disciplinas = (new TDisciplina()).SelectAll();
            DataTable horarios    = (new THorario()).SelectAll();
            DataTable alocacao    = (new TAlocacao()).SelectAll();

            grade = new Grafo();

            foreach (DataRow linha in disciplinas.Rows)
            {
                // DISCIPLINA

                Disciplina d           = new Disciplina(linha[2].ToString(), int.Parse(linha[3].ToString()), int.Parse(linha[1].ToString()));
                Vertice    vDisciplina = new Vertice(d);
                grade.AddVertice(vDisciplina);

                // PERIODO

                Periodo p        = new Periodo(int.Parse(linha[1].ToString()));
                Vertice vPeriodo = grade.GetVerticePorDado(p);

                if (vPeriodo == null)
                {
                    vPeriodo = new Vertice(p);
                    grade.AddVertice(vPeriodo);
                }

                // PROFESSOR

                DataRow linhap = (new TProfessor()).Select(linha[3].ToString()); //uma consulta por inserção de disciplina é muito. Otimizar isso depois

                Professor f          = new Professor(int.Parse(linhap[0].ToString()), int.Parse(linhap[1].ToString()));
                Vertice   vProfessor = grade.GetVerticePorDado(f);

                if (vProfessor == null)
                {
                    vProfessor = new Vertice(f);
                    grade.AddVertice(vProfessor);
                }

                grade.AddAresta(new Aresta(vDisciplina, vPeriodo));
                grade.AddAresta(new Aresta(vDisciplina, vProfessor));
            }

            foreach (DataRow linha in horarios.Rows)
            {
                // HORARIO

                Horario h = new Horario(
                    (DiaSemana)int.Parse(linha[3].ToString()),
                    DateTime.Parse(linha[1].ToString()) == DateTime.Parse("19:00:00") ? Hora._19h00 : Hora._20h50);

                Vertice vHorario = new Vertice(h);

                grade.AddVertice(vHorario);

                foreach (DataRow linhaAloc in alocacao.Rows)
                {
                    if (linhaAloc[2].ToString() == linha[0].ToString())
                    {
                        Disciplina disc = new Disciplina(int.Parse(linhaAloc[1].ToString()));

                        Vertice vDisciplina = grade.GetVerticePorDado(disc);
                        Vertice vPeriodo    = grade.GetVerticePorDado(new Periodo(disc.Periodo));

                        grade.AddAresta(new Aresta(vHorario, vDisciplina));
                        grade.AddAresta(new Aresta(vHorario, vPeriodo));
                    }
                }
            }
        }
Example #5
0
        public Empleado BuscarEmpleado(Empleado aux1)
        {
            try
            {
                Empleado             aux            = new Empleado();
                DataAccessLayer      cn             = new DataAccessLayer();
                Horario_service      horarios       = new Horario_service();
                Especialidad_service espec          = new Especialidad_service();
                IList <Horario>      hora           = new List <Horario>();
                IList <Especialidad> ESPECIALIDADES = new List <Especialidad>();

                string consulta = "select E.ID_EMPLEADO,E.ID_CATEGORIA,E.NOMBRE,E.APELLIDO,E.DNI,E.FECHA_NAC,E.DIRECCION,E.IDLOCALIDAD,P.IDPROVINCIA,E.TELEFONO,E.EMAIL,E.SEXO,E.ELIMINADO from empleado AS E INNER JOIN LOCALIDAD AS L ON L.IDLOCALIDAD=E.IDLOCALIDAD INNER JOIN PROVINCIA AS P ON P.IDPROVINCIA=L.IDPROVINCIA where ELIMINADO=0 and ID_EMPLEADO=" + aux1.ID_Empleado1;

                cn.setearComandoText(consulta);
                cn.abrirConexion();
                cn.ejecutarQuery();

                while (cn.Lector.Read())
                {
                    aux.ID_Empleado1  = cn.Lector.GetInt32(0);
                    aux.ID_Categoria1 = cn.Lector.GetInt32(1);
                    aux.Nombre1       = cn.Lector.GetString(2);
                    aux.Apellido1     = cn.Lector.GetString(3);
                    aux.DNI1          = cn.Lector.GetString(4);
                    aux.Fecha_Nac1    = Convert.ToString(cn.Lector.GetDateTime(5));
                    aux.Direccion1    = cn.Lector.GetString(6);
                    aux.Localidad     = new Localidad()
                    {
                        ID_Localidad1 = cn.Lector.GetInt32(7)
                    };
                    aux.Provincia = new Provincia()
                    {
                        ID_Provincia1 = cn.Lector.GetInt32(8)
                    };
                    aux.Telefono1  = cn.Lector.GetString(9);
                    aux.Email1     = cn.Lector.GetString(10);
                    aux.Sexo1      = cn.Lector.GetBoolean(11);
                    aux.Eliminado1 = cn.Lector.GetBoolean(12);
                }
                ESPECIALIDADES = espec.traerEspecialidades(aux1.ID_Empleado1);
                hora           = horarios.BuscarHorario(aux1.ID_Empleado1);
                for (int x = 0; x < hora.Count; x++)
                {
                    Horario h = new Horario();
                    h = hora[x];
                    aux.ListaHorarios.Add(h);
                }
                for (int x = 0; x < ESPECIALIDADES.Count; x++)
                {
                    aux.Lista_Especialidades.Add(ESPECIALIDADES[x]);
                }



                return(aux);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #6
0
        public void GuardarMedico(Empleado Nuevo)
        {
            SqlConnection cn = new SqlConnection();
            SqlCommand    cm = new SqlCommand();

            Horario_service      horarios          = new Horario_service();
            UsuarioService       usuario           = new UsuarioService();
            Horario              h                 = new Horario();
            Especialidad_service EspecialidadX_med = new Especialidad_service();
            EspecialidadXMed     esM               = new EspecialidadXMed();

            try
            {
                cn.ConnectionString = "Data Source=LOCAL\\SQLEXPRESS;Initial Catalog=CLINICA_TOLOZA;Integrated Security=True";
                cm.CommandType      = System.Data.CommandType.StoredProcedure;
                cm.Connection       = cn;
                cm.CommandText      = "SP_AGREGAR_EMPLEADO";
                cm.Parameters.Clear();
                cm.Parameters.AddWithValue("@ID_CATEGORIA", Nuevo.ID_Categoria1);
                cm.Parameters.AddWithValue("@NOMBRE", Nuevo.Nombre1);
                cm.Parameters.AddWithValue("@APELLIDO", Nuevo.Apellido1);
                cm.Parameters.AddWithValue("@DNI", Nuevo.DNI1);
                cm.Parameters.AddWithValue("@FECHA_NAC", Convert.ToDateTime(Nuevo.Fecha_Nac1));
                cm.Parameters.AddWithValue("@DIRECCION", Nuevo.Direccion1);
                cm.Parameters.AddWithValue("@IDLOCALIDAD", Nuevo.Localidad.ID_Localidad1);
                cm.Parameters.AddWithValue("@TELEFONO", Nuevo.Telefono1);
                cm.Parameters.AddWithValue("@EMAIL", Nuevo.Email1);
                cm.Parameters.AddWithValue("@SEXO", Nuevo.Sexo1);
                cm.Parameters.AddWithValue("@ELIMINADO", Nuevo.Eliminado1);

                cn.Open();

                Nuevo.ID_Empleado1       = Convert.ToInt32(cm.ExecuteScalar());
                Nuevo.Usser.ID_Empleado1 = Nuevo.ID_Empleado1;

                for (int i = 0; i < Nuevo.ListaHorarios.Count; i++)
                {
                    Nuevo.ListaHorarios[i].ID_Empleado1 = Nuevo.ID_Empleado1;
                    //horarios.GuerdarHorarios(Nuevo.ListaHorarios);
                }

                for (int j = 0; j < Nuevo.ListaHorarios.Count; j++)
                {
                    h = Nuevo.ListaHorarios[j];
                    string dia = h.Dia1;
                    horarios.GuerdarHorarios(h);
                }
                for (int x = 0; x < Nuevo.Lista_Especialidades.Count; x++)
                {
                    esM.ID_Empleado1     = Nuevo.ID_Empleado1;
                    esM.ID_Especilaidad1 = Nuevo.Lista_Especialidades[x].ID_Especialidad1;
                    esM.Eliminado1       = false;
                    EspecialidadX_med.guardarEspecialidadXMed(esM);
                }
                usuario.guardarUsuario(Nuevo.Usser);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                cn.Close();
                cn.Dispose();
                cm.Dispose();
            }
        }