Beispiel #1
0
        public static Empleado Logueo(int ci, string pass)
        {
            Empleado      resp = null;
            SqlConnection cnn  = new SqlConnection(Conexion.STR);
            SqlCommand    cmd  = new SqlCommand("LogueoJornalero", cnn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@cedula", ci);
            cmd.Parameters.AddWithValue("@pass", pass);

            SqlDataReader lector;

            try
            {
                cnn.Open();
                lector = cmd.ExecuteReader();
                if (lector.Read())
                {
                    resp                    = new Jornalero();
                    resp.CI                 = (int)lector[0];
                    resp.Nombre             = lector[2].ToString();
                    resp.Pass               = pass;
                    ((Jornalero)resp).Horas = (int)lector[4];
                    lector.Close();
                }
            }
            catch (Exception ex)
            { throw ex; }
            finally
            { cnn.Close(); }
            return(resp);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Jornalero        emp01         = new Jornalero(18, "Juan", "Peres", 20);
            Jornalero        emp02         = new Jornalero(26, "Alicia", "Fontes", 15);
            Mensual          emp03         = new Mensual(21, "Alicia", "Fontes", 1000);
            List <IEmpleado> listEmpleados = new List <IEmpleado>()
            {
                emp01, emp02, emp03
            };
            decimal sueldoTotal = 0;

            Jornalero.jornal = 200;
            foreach (var item in listEmpleados)
            {
                sueldoTotal += item.CalcularSueldo();
            }
            Console.WriteLine("----------------sueldo------------------");
            Console.WriteLine("sueldo: " + sueldoTotal.ToString());
            Console.ReadKey();
        }