public IHttpActionResult PostBuscarColaborador(EmpleadoIn empleado)
        {
            var model = new RegistrosNegocio();
            List <EmpleadosOut> empleados = new List <EmpleadosOut>();

            empleados = model.BuscarColaborador(empleado);

            return(Json(empleados));
        }
Exemplo n.º 2
0
        public List <EmpleadosOut> BuscarColaborador(EmpleadoIn empleado)
        {
            try
            {
                List <EmpleadosOut> empleados = new List <EmpleadosOut>();

                using (SqlConnection conn = Conexion())
                {
                    DataTable  dt  = new DataTable();
                    SqlCommand cmd = new SqlCommand("saati_BuscarEmpleado", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@No", empleado.No);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(dt);
                    foreach (DataRow dr in dt.Rows)
                    {
                        EmpleadosOut emp = new EmpleadosOut();
                        emp.Nombre    = dr["Nombre"].ToString();
                        emp.ApellidoP = dr["ApellidoP"].ToString();
                        emp.ApellidoM = dr["ApellidoM"].ToString();
                        emp.Cedis     = dr["DenominacionS"].ToString();

                        empleados.Add(emp);
                    }

                    conn.Close();
                }

                return(empleados);
            }
            catch (Exception e)
            {
                throw;
            }
        }