Ejemplo n.º 1
0
        public EmployeeList()
        {
            InitializeComponent();

            //Abro el cliente
            ServiceEmployeesClient cliente = new ServiceEmployeesClient();

            List <Employee> aux1 = cliente.GetAllEmployees().ToList();

            foreach (var e in aux1)
            {
                if (e is FullTimeEmployee)
                {
                    var aux = (FullTimeEmployee)e;

                    lstEmp.Items.Add(new ListViewItem(new string[] { Convert.ToString(aux.Id), Convert.ToString(aux.Name), Convert.ToString(aux.StartDate), "Full Time Employee" }));
                }
                else
                {
                    var aux = (PartTimeEmployee)e;

                    lstEmp.Items.Add(new ListViewItem(new string[] { Convert.ToString(aux.Id), Convert.ToString(aux.Name), Convert.ToString(aux.StartDate), "Part Time Employee" }));
                }
            }
        }
Ejemplo n.º 2
0
        private void EmployeeList_Load(object sender, EventArgs e)
        {
            //BLEmployees businessLayer = new BLEmployees(new DALEmployeesEF());
            ServiceEmployeesClient client = new ServiceEmployeesClient();
            List <Employee>        list   = new List <Employee>();

            list.AddRange(client.GetAllEmployees());
            //Obtener empleados, recorrerlos y agregarlos
            int i = 0;

            foreach (Employee emp in list)
            {
                ListViewItem item = new ListViewItem(emp.Id.ToString(), i);
                item.SubItems.Add(emp.Name);
                item.SubItems.Add(emp.StartDate.ToString());
                //ListViewItem item = new ListViewItem(new[] { emp.Id.ToString(), emp.Name, emp.StartDate.ToString() });
                if (emp.GetType() == typeof(FullTimeEmployee))
                {
                    item.SubItems.Add("Full time");
                }
                else
                {
                    item.SubItems.Add("Part time");
                }
                listEmp.Items.Add(item);
                i++;
            }
        }
Ejemplo n.º 3
0
        private void btnNuevo_Click(object sender, EventArgs e)
        {
            //BLEmployees businessLayer = new BLEmployees(new DALEmployeesEF());
            ServiceEmployeesClient client = new ServiceEmployeesClient();

            if (radioButton1.Checked)
            {
                PartTimeEmployee employee = new PartTimeEmployee();
                employee.Name       = textBox1.Text;
                employee.StartDate  = DateTime.Now;
                employee.Id         = client.GetAllEmployees().Count() + 1;
                employee.HourlyRate = Int32.Parse(textBox3.Text);
                client.AddEmployee(employee);
            }
            else
            {
                FullTimeEmployee employee = new FullTimeEmployee();
                employee.Name      = textBox1.Text;
                employee.StartDate = DateTime.Now;
                employee.Id        = client.GetAllEmployees().Count() + 1;
                employee.Salary    = Int32.Parse(textBox4.Text);
                client.AddEmployee(employee);
            }
        }
Ejemplo n.º 4
0
        public ActionResult getAllEmployee()
        {
            try
            {
                // TODO: Add insert logic here
                ServiceEmployeesClient client = new ServiceEmployeesClient();

                Employee[] listEmployee = client.GetAllEmployees();

                List <Model> ret = new List <Model>();
                foreach (Employee e in listEmployee)
                {
                    Model newEmployee = new Model();
                    newEmployee.Id        = e.Id;
                    newEmployee.Name      = e.Name;
                    newEmployee.StartDate = e.StartDate.ToString();
                    if (e.GetType() == typeof(FullTimeEmployee))
                    {
                        newEmployee.isFullTime = true;
                        newEmployee.Salary     = ((FullTimeEmployee)e).Salary;
                        newEmployee.Hourly     = 0;
                    }
                    else
                    {
                        newEmployee.isFullTime = false;
                        newEmployee.Hourly     = ((PartTimeEmployee)e).HourlyRate;
                        newEmployee.Salary     = 0;
                    }
                    ret.Add(newEmployee);
                }

                return(Json(ret, JsonRequestBehavior.AllowGet));
                //return RedirectToAction("Index", "Home");
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred: '{0}'", e);
                return(Json(new { success = false, responseText = "User wrong!" }, JsonRequestBehavior.AllowGet));
            }
        }