예제 #1
0
        static public Entidades.Empleado buscarEmpleado(string id)
        {
            Entidades.Empleado c = new Entidades.Empleado();
            Conexion.OpenConnection();

            string       query   = "Select* from empleado Where cedula = @cedula";
            MySqlCommand comando = new MySqlCommand(query, Conexion.Connection);

            comando.Parameters.AddWithValue("@cedula", id);
            comando.Prepare();

            MySqlDataReader reader = comando.ExecuteReader();

            while (reader.Read())
            {
                c.Celuda            = reader.GetString("cedula");
                c.Nombre            = reader.GetString("nombre");
                c.Apellido          = reader.GetString("apellido");
                c.Apellido2         = reader.GetString("apellido2");
                c.Telefono          = reader.GetString("telefono");
                c.Puesto            = reader.GetString("puesto");
                c.FechaContratacion = reader.GetDateTime("fechaContratacion");
                Conexion.CloseConnection();
                return(c);
            }
            //retorna valores nulos en caso de no encontrar coincidencias
            Conexion.CloseConnection();
            return(c);
        }
예제 #2
0
        public static List<Empleado> GetAll()
        {
            Acceso ac = new Acceso();

            List<Empleado> empleados = new List<Empleado>();

            string sql = "SELECT * FROM CONSULTAR_EMPLEADO order by apellido asc, nombre asc";

            SqlCommand cmd = new SqlCommand();
            SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

            try
            {
                conexion.Open();

                cmd.Connection = conexion;
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;

                SqlDataReader dr = cmd.ExecuteReader();

                Empleado em;
                Estado e;

                while (dr.Read())
                {
                    em  = new Empleado ();
                    e = new Estado();

                    e.idEstado = Convert.ToInt32(dr["idEstado"]);
                    e.Nombre = dr["estado"].ToString();
                    em.estado = e;
                    em.Nombre = dr["nombre"].ToString();
                    em.Apellido = dr["apellido"].ToString();
                    em.fechaAlta = Convert.ToDateTime(dr["fechaAlta"]);
                    em.idEmpleado = Convert.ToInt32(dr["idEmpleado"]);
                    em.fechaNac = Convert.ToDateTime(dr["fechaNac"]);
                    em.telefono = dr["telefonoContacto"].ToString();
                    em.edad  = Convert.ToInt32(dr["edad"]);
                    empleados.Add(em );

                }

            }
            catch (InvalidOperationException ex)
            {
                throw new ApplicationException(ex.Message);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Error en BD:" + ex.Message);
            }
            finally
            {
                conexion.Close();
            }

            return empleados;
        }
예제 #3
0
        static public void eliminar(Entidades.Empleado c)
        {
            Conexion.OpenConnection();

            string       query   = "DELETE from empleado WHERE cedula = @cedula";
            MySqlCommand comando = new MySqlCommand(query, Conexion.Connection);

            comando.Parameters.AddWithValue("@cedula", c.Celuda);
            comando.Prepare();

            comando.ExecuteNonQuery();

            Conexion.CloseConnection();
        }
예제 #4
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            Empleado empleado = new Entidades.Empleado(txbNombre.Text, txbApellido.Text, int.Parse(txbDni.Text), txbUsuario.Text, txbContraseña.Text);

            if (KwikEMart.listaDePersonas + empleado)
            {
                MessageBox.Show("Empleado agregado exitosamente");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("Error");
            }
        }
예제 #5
0
        public void InsertaEmpleado(Empleado emp)
        {
            using (var conexion = new SqlConnection(CadenaConexion))
            {

                using (var comando = new SqlCommand("spInsertaEmpleado", conexion))
                {
                    comando.CommandType = CommandType.StoredProcedure;
                    comando.Parameters.Add("@Nombre", SqlDbType.NVarChar).Value = emp.Nombre;
                    comando.Parameters.Add("@Titulo", SqlDbType.NVarChar).Value = emp.Titulo;
                    comando.Parameters.Add("@FechaNacimiento", SqlDbType.NVarChar).Value = emp.FechaNacimiento;

                    conexion.Open();
                    comando.ExecuteNonQuery();
                }
            }
        }
예제 #6
0
        public DataSet ConsultaEmpleados(Empleado emp)
        {
            var ds = new DataSet();
            using (var conexion = new SqlConnection(CadenaConexion))
            {
                using (var comando = new SqlCommand("spConsultaEmpleado", conexion))
                {
                    comando.CommandType = CommandType.StoredProcedure;
                    comando.Parameters.Add("@Empleado", SqlDbType.Int).Value = emp.EmpleadoId;

                    var da = new SqlDataAdapter {SelectCommand = comando};

                    conexion.Open();
                    comando.ExecuteNonQuery();
                    da.Fill(ds);
                }
            }
            return ds;
        }
예제 #7
0
        static public void insertar(Entidades.Empleado c)
        {
            Conexion.OpenConnection();

            string       query   = "insert into Empleado (cedula, nombre, apellido, apellido2, telefono, fechaContratacion, puesto) values(@cedula, @nombre, @apellido, @apellido2, @telefono, @fechaContratacion, @puesto)";
            MySqlCommand comando = new MySqlCommand(query, Conexion.Connection);


            comando.Parameters.AddWithValue("@cedula", c.Celuda);
            comando.Parameters.AddWithValue("@nombre", c.Nombre);
            comando.Parameters.AddWithValue("@apellido", c.Apellido);
            comando.Parameters.AddWithValue("@apellido2", c.Apellido2);
            comando.Parameters.AddWithValue("@telefono", c.Telefono);
            comando.Parameters.AddWithValue("@fechaContratacion", c.FechaContratacion);
            comando.Parameters.AddWithValue("@puesto", c.Puesto);
            comando.Prepare();
            comando.ExecuteNonQuery();

            Conexion.CloseConnection();
        }
예제 #8
0
        static public void modificar(Entidades.Empleado c)
        {
            Conexion.OpenConnection();

            string       query   = "UPDATE empleado set nombre = @nombre, apellido = @apellido, apellido2 = @apellido2, telefono = @telefono, fechaContratacion = @fechaContratacion, puesto =  @puesto WHERE cedula = @cedula";
            MySqlCommand comando = new MySqlCommand(query, Conexion.Connection);

            comando.Parameters.AddWithValue("@cedula", c.Celuda);
            comando.Parameters.AddWithValue("@nombre", c.Nombre);
            comando.Parameters.AddWithValue("@apellido", c.Apellido);
            comando.Parameters.AddWithValue("@apellido2", c.Apellido2);
            comando.Parameters.AddWithValue("@telefono", c.Telefono);
            comando.Parameters.AddWithValue("@fechaContratacion", c.FechaContratacion);
            comando.Parameters.AddWithValue("@puesto", c.Puesto);

            comando.Prepare();
            comando.ExecuteNonQuery();

            Conexion.CloseConnection();
        }
예제 #9
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         //Verifico usuario
         Entidades.Empleado unUsuario = Logica.LogEmpleado.Logueo(txtUsuario.Text.Trim(), txtContresena.Text.Trim());
         if (unUsuario != null)
         {
             //Si entra aca es valido
             Session["Usuario"] = unUsuario;
             Response.Redirect("MenuPrincipal.aspx");
         }
         else
         {
             lblError.Text = "Datos Incorrectos";
         }
     }
     catch (Exception ex)
     {
         lblError.Text = ex.Message;
     }
 }
예제 #10
0
        private void btn_aplicar_filtro_persona_Click(object sender, EventArgs e)
        {
            Empleado  per = new Empleado();

            if (txt_apellido.Text != "")
            {
                per.Apellido = txt_apellido.Text;
            }
            if (txt_nombre.Text != "")
            {
                per.Nombre = txt_nombre.Text;
            }

            List<Empleado> empleados = null;
            try
            {
                 empleados =  EmpleadoDAO.GetByFiltro(per);
            }
            catch (ApplicationException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
            cargarGrillaFiltrada(empleados );
        }
예제 #11
0
        public static void Update(Empleado  emp)
        {
            Acceso ac = new Acceso();

            SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

            SqlCommand cmd = new SqlCommand("sp_update_empleado", conexion);

            if (!(emp.Nombre == "N/D") && !(emp.Nombre == ""))
            {
                cmd.Parameters.AddWithValue("@nombre", emp.Nombre);
            }

            if (!(emp.Apellido == "N/D") && !(emp.Apellido == ""))
            {
                cmd.Parameters.AddWithValue("@apellido", emp.Apellido);
            }

            if (!(emp.telefono == String.Empty))
            {
                cmd.Parameters.AddWithValue("@tel", emp.telefono);
            }
            cmd.Parameters.AddWithValue("@fechaNac", emp.fechaNac.Date);

            cmd.Parameters.AddWithValue("@fechaAlt", emp.fechaAlta.Date);

            cmd.Parameters.AddWithValue("@idEmpleado", emp.idEmpleado );

            try
            {
                conexion.Open();

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.ExecuteNonQuery();

            }
            catch (ArgumentException ex)
            {
                throw new ApplicationException(ex.Message);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Error en BD: " + ex.Message);
            }
            finally
            {
                conexion.Close();
            }
        }
예제 #12
0
        public static List<OrdenDeTrabajo> GetAllOTHija(int idProd, DateTime fecha, int idPlan)
        {
            Acceso ac = new Acceso();

            List<OrdenDeTrabajo> ordenes = new List<OrdenDeTrabajo>();

            string sql = "SELECT * from CONSULTAR_OT_HIJA where fechaCreacion = @fecha and idPlan = @idPlan and idProducto = @idProd ";
            SqlCommand cmd = new SqlCommand();
            cmd.Parameters.AddWithValue("@fecha", fecha);
            cmd.Parameters.AddWithValue("@idPlan", idPlan);
            cmd.Parameters.AddWithValue("@idProd", idProd);
            SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

            try
            {
                conexion.Open();

                cmd.Connection = conexion;
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;

                SqlDataReader dr = cmd.ExecuteReader();

                Producto pi;
                //Categoria c;
                UnidadMedida u;
                Maquinaria m;
                Estado e;
                OrdenDeTrabajo ot;
                Empleado em;
                while (dr.Read())
                {
                    em = new Empleado();
                    em.idEmpleado = Convert.ToInt32(dr["idEmpleado"]);
                    em.Nombre = dr["nombre"].ToString();
                    em.Apellido = dr["apellido"].ToString();

                    e = new Estado();
                    e.idEstado = Convert.ToInt32(dr["idEstado"]);
                    e.Nombre = dr["estado"].ToString();

                    m = new Maquinaria();
                    m.idMaquinaria  = Convert.ToInt32(dr["idMaquinaria"]);
                    m.Nombre = dr["maquinaria"].ToString();

                    u = new UnidadMedida();
                    u.Nombre = dr["unidad"].ToString();

                    pi = new Producto();
                    pi.idProducto = Convert.ToInt32(dr["idProdIntermedio"]);
                    pi.Nombre = dr["nombreHijo"].ToString();
                    //pi.Categoria = c;
                    pi.Unidad = u;

                    ot = new OrdenDeTrabajo();

                    ot.idOrdenTrabajo = Convert.ToInt32(dr["idOrdenTrabajo"]);
                    ot.idOrdenTrabajoPadre = Convert.ToInt32(dr["idOTPadre"]);
                    //ot.fechaPlan = Convert.ToDateTime(dr["fechaPlan"]);
                    ot.horaInicio = Convert.ToDateTime(dr["horaInicio"]);
                    ot.horaFin = Convert.ToDateTime(dr["horaFin"]);
                    ot.fechaCreacion = Convert.ToDateTime(dr["fechaCreacion"]);
                    ot.estado = e;
                    ot.empleado = em;
                    ot.maquinaria = m;

                    ot.productoIntermedio = pi;
                    ot.cantidad = Convert.ToDouble (dr["cantidad"]);
                    ot.cantidadReal = Convert.ToDouble(dr["cantReal"]);

                    ordenes.Add(ot);

                }

            }

            catch (InvalidOperationException ex)
            {
                throw new ApplicationException(ex.Message);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Error en BD: " + ex.Message);
            }
            finally
            {
                conexion.Close();
            }

            return ordenes;
        }
예제 #13
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            if (_estado == estados.nuevo && validarCampos() == true)
            {
                Empleado emp = new Empleado();

                if (!(txt_telefono.Text == "    -"))
                {
                    emp.telefono  = txt_telefono.Text;
                }
                emp.Nombre = txt_nombre.Text;
                emp.Apellido  = txt_apellido.Text;
                emp.fechaAlta  = dtp_fechaAlta.Value ;
                emp.fechaNac = dtp_fechaNac.Value;

                try
                {
                    EmpleadoDAO.Insert(emp );
                    MessageBox.Show("Registrado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    limpiarCampos();
                    btn_guardar.Enabled = false;

                }
                catch (ApplicationException ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                }

            }
            else
            {
                if (_estado == estados.modificar && validarCampos() == true)
                {
                    Empleado emp = new Empleado();

                    if (!(txt_telefono.Text == "    -"))
                    {
                        emp.telefono = txt_telefono.Text;
                    }
                    emp.Nombre = txt_nombre.Text;
                    emp.Apellido = txt_apellido.Text;
                    emp.fechaAlta = dtp_fechaAlta.Value;
                    emp.fechaNac = dtp_fechaNac.Value;
                    emp.idEmpleado = _empModificar.idEmpleado;

                    try
                    {
                        EmpleadoDAO.Update (emp);
                        MessageBox.Show("Actualizado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        //limpiarCampos();
                        //btn_guardar.Enabled = false;
                        Close();
                        Dispose();
                    }
                    catch (ApplicationException ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    }
                }

            }
        }
예제 #14
0
 public void InsertaEmpleado(Empleado emp)
 {
     new Conexion().InsertaEmpleado(emp);
 }
예제 #15
0
 public DataSet ConsultaEmpleados(Empleado emp)
 {
     DataSet ds = new Conexion().ConsultaEmpleados(emp);
     return ds;
 }
예제 #16
0
        public static List<Empleado> GetByFiltro(Empleado per)
        {
            Acceso ac = new Acceso();

            List<Empleado> empleados = new List<Empleado>();
            SqlCommand cmd = new SqlCommand();

            string sql = "SELECT * from CONSULTAR_EMPLEADO  where 1=1";

            if (per.Nombre != null)
            {
                sql += " and nombre LIKE @nombre";
                cmd.Parameters.AddWithValue("@nombre", "%" + per.Nombre + "%");
            }
            if (per.Apellido != null)
            {
                sql += " and apellido LIKE @apellido";
                cmd.Parameters.AddWithValue("@apellido", "%" + per.Apellido + "%");
            }

            SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

            try
            {
                conexion.Open();

                cmd.Connection = conexion;
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;

                SqlDataReader dr = cmd.ExecuteReader();

                Empleado  em;
                Estado e;

                while (dr.Read())
                {

                    em = new Empleado ();

                    em = new Empleado();
                    e = new Estado();

                    e.idEstado = Convert.ToInt32(dr["idEstado"]);
                    e.Nombre = dr["estado"].ToString();
                    em.estado = e;
                    em.Nombre = dr["nombre"].ToString();
                    em.Apellido = dr["apellido"].ToString();
                    em.fechaAlta = Convert.ToDateTime(dr["fechaAlta"]);
                    em.idEmpleado = Convert.ToInt32(dr["idEmpleado"]);
                    em.fechaNac = Convert.ToDateTime(dr["fechaNac"]);
                    em.telefono = dr["telefonoContacto"].ToString();
                    em.edad = Convert.ToInt32(dr["edad"]);
                    empleados.Add(em);

                }

            }
            catch (InvalidOperationException ex)
            {
                throw new ApplicationException(ex.Message);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Error en BD: " + ex.Message);
            }
            finally
            {
                conexion.Close();
            }

            return empleados;
        }
예제 #17
0
        private void dgv_empleados_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            Gestion_de_Empleado gestion = new Gestion_de_Empleado();

            gestion._estado = estados.modificar;

            Empleado emp = new Empleado()
            {

                Apellido = (string)dgv_empleados.Rows[dgv_empleados.CurrentRow.Index].Cells["apellido"].Value,

                Nombre = (string)dgv_empleados.Rows[dgv_empleados.CurrentRow.Index].Cells["Nombre"].Value,
                telefono = (string)dgv_empleados.Rows[dgv_empleados.CurrentRow.Index].Cells["telefono"].Value,
                fechaNac = Convert.ToDateTime(dgv_empleados.Rows[dgv_empleados.CurrentRow.Index].Cells["fechaNac"].Value),
                idEmpleado = (int)dgv_empleados.Rows[dgv_empleados.CurrentRow.Index].Cells["idEmpleado"].Value
            };

            gestion._empModificar = emp;
            gestion._estado = estados.modificar;
            gestion.ShowDialog();
            cargarGrilla();
        }
예제 #18
0
        public static List<OrdenDeTrabajo> GetAllOTPadre()
        {
            Acceso ac = new Acceso();

            List<OrdenDeTrabajo> ordenes = new List<OrdenDeTrabajo>();

            string sql = "SELECT * from CONSULTAR_OT_Padre order by fechaCreacion desc, horaInicio desc";
            SqlCommand cmd = new SqlCommand();
            SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

            try
            {
                conexion.Open();

                cmd.Connection = conexion;
                cmd.CommandText = sql;
                cmd.CommandType = CommandType.Text;

                SqlDataReader dr = cmd.ExecuteReader();

                Producto p;

                UnidadMedida u;
                Maquinaria m;
                Estado e;
                OrdenDeTrabajo ot;
                Empleado em;
                while (dr.Read())
                {
                    em = new Empleado();
                    em.idEmpleado = Convert.ToInt32(dr["idEmpleado"]);
                    em.Nombre = dr["empleado"].ToString();
                    em.Apellido = dr["apellido"].ToString();

                    e = new Estado();
                    e.idEstado = Convert.ToInt32(dr["idEstado"]);
                    e.Nombre = dr["estado"].ToString();

                    m = new Maquinaria();
                    m.idMaquinaria = Convert.ToInt32(dr["idMaquinaria"]);
                    m.Nombre = dr["maquinaria"].ToString();

                    u = new UnidadMedida();

                    u.Nombre = dr["unidad"].ToString();

                    //c = new Categoria();
                    ////c.IDCategoria = Convert.ToInt32(dr["idCategoria"]);
                    //c.Nombre = dr["categoria"].ToString();

                    p = new Producto();
                    p.idProducto = Convert.ToInt32(dr["idProducto"]);
                    p.Nombre = dr["producto"].ToString();
                    //p.Categoria = c;
                    p.Unidad = u;

                    ot = new OrdenDeTrabajo();

                    ot.idOrdenTrabajo = Convert.ToInt32(dr["idOrdenTrabajo"]);
                    ot.idPlan = Convert.ToInt32(dr["idPlan"]);
                    ot.fechaPlan = Convert.ToDateTime(dr["fechaPlan"]);
                    ot.horaInicio = Convert.ToDateTime(dr["horaInicio"]);
                    ot.horaFin = Convert.ToDateTime(dr["horaFin"]);
                    ot.fechaCreacion = Convert.ToDateTime(dr["fechaCreacion"]);
                    ot.estado = e;
                    ot.empleado = em;
                    ot.maquinaria = m;
                    ot.producto = p;
                    ot.cantidadReal = Convert.ToDouble(dr["cantReal"]);
                    ot.cantidad = Convert.ToDouble(dr["cantidad"]);
                    ordenes.Add(ot);

                }

            }

            catch (InvalidOperationException ex)
            {
                throw new ApplicationException(ex.Message);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Error en BD: " + ex.Message);
            }
            finally
            {
                conexion.Close();
            }

            return ordenes;
        }
예제 #19
0
 public void ActualizaEmpleado(Empleado emp)
 {
     new Conexion().ActualizaEmpleado(emp);
 }
예제 #20
0
        public static List<Empleado> GetAllDisponible(DateTime fecha, DateTime hi, DateTime hf)
        {
            Acceso ac = new Acceso();

            List<Empleado> empleados = new List<Empleado>();

            SqlConnection conexion = new SqlConnection(ac.getCadenaConexion());

            SqlCommand cmd = new SqlCommand("sp_empleados_disponibles", conexion);

            cmd.Parameters.AddWithValue("@fecha", fecha);
            cmd.Parameters.AddWithValue("@hi", hi);
            cmd.Parameters.AddWithValue("@hf", hf);

            try
            {
                conexion.Open();

                cmd.Connection = conexion;

                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataReader dr = cmd.ExecuteReader();

                Empleado em;

                while (dr.Read())
                {

                    em = new Empleado();

                    em.idEmpleado = Convert.ToInt32(dr["idEmpleado"]);
                    em.Nombre = dr["nombre"].ToString();
                    em.Apellido = dr["apellido"].ToString();

                    empleados.Add(em);

                }

            }
            catch (InvalidOperationException ex)
            {
                throw new ApplicationException(ex.Message);
            }
            catch (SqlException ex)
            {
                throw new ApplicationException("Error en BD:" + ex.Message);
            }
            finally
            {
                conexion.Close();
            }

            return empleados;
        }