예제 #1
0
        // GET: Employees/Details/5
        public ActionResult Details(int id)
        {
            Models.Employee emp = new Models.Employee();
            Employee        e   = _bl.GetEmployee(id);

            if (e.GetType() == typeof(FullTimeEmployee))
            {
                FullTimeEmployee em = (FullTimeEmployee)e;
                emp.Id        = em.Id;
                emp.Name      = em.Name;
                emp.StartDate = em.StartDate;
                emp.Type      = 2;
                emp.Salary    = em.Salary;
            }
            else
            {
                PartTimeEmployee em = (PartTimeEmployee)e;
                emp.Id        = em.Id;
                emp.Name      = em.Name;
                emp.StartDate = em.StartDate;
                emp.Type      = 2;
                emp.Salary    = Convert.ToInt32(em.HourlyRate);
            }
            return(View(emp));
        }
예제 #2
0
        public Employee GetEmployee(int id)
        {
            try
            {
                return(blHandler.GetEmployee(id));
            }
            catch
            {
                throw new Exception("Problemas al traer empleado");
            }

            //throw new NotImplementedException();
        }
예제 #3
0
        // GET api/<controller>/5
        public IHttpActionResult Get(int id)
        {
            var json = JsonConvert.SerializeObject(_bl.GetEmployee(id));

            return(Ok(json));
        }
예제 #4
0
 public Employee GetEmployee(int id)
 {
     return(blHandler.GetEmployee(id));
 }
예제 #5
0
 public Shared.Entities.Employee GetEmployee(int Id)
 {
     return(_bl.GetEmployee(Id));
 }
예제 #6
0
 public Employee GetEmployee(int id)
 {
     //throw new NotImplementedException();
     return(blHandler.GetEmployee(id));
 }
예제 #7
0
        static void Main(string[] args)
        {
            ILog log = LogManager.GetLogger("Logger");

            using (UnityContainer container = new UnityContainer())
            {
                container.LoadConfiguration();
                IBLEmployees blHandler = container.Resolve <IBLEmployees>();

                Employee         e;
                FullTimeEmployee fte;
                PartTimeEmployee p;

                PrintHelp();
                System.Console.Write(">");
                string line = Console.ReadLine();

                log4net.Config.XmlConfigurator.Configure();

                do
                {
                    string[] parameters = line.Split(new string[] { " " }, StringSplitOptions.None);

                    try
                    {
                        switch (parameters[0])
                        {
                        case "help":
                            PrintHelp();
                            break;

                        case "AddFullTimeEmployee":
                            fte = new FullTimeEmployee();
                            foreach (string s in parameters)
                            {
                                System.Console.WriteLine(s);
                            }
                            fte.Name      = parameters[1];
                            fte.StartDate = Convert.ToDateTime(parameters[2]);
                            fte.Salary    = Int32.Parse(parameters[3]);
                            blHandler.AddEmployee(fte);
                            break;

                        case "AddPartTimeEmployee":
                            p            = new PartTimeEmployee();
                            p.Name       = parameters[1];
                            p.StartDate  = Convert.ToDateTime(parameters[2]);
                            p.HourlyDate = Int32.Parse(parameters[3]);
                            blHandler.AddEmployee(p);
                            break;

                        case "DeleteEmployee":
                            blHandler.DeleteEmployee(Int32.Parse(parameters[1]));
                            break;

                        case "UpdateEmployee":
                            Employee emp = blHandler.GetEmployee(Int32.Parse(parameters[1]));
                            if (emp != null)
                            {
                                emp.Id        = Int32.Parse(parameters[1]);
                                emp.Name      = parameters[2];
                                emp.StartDate = Convert.ToDateTime(parameters[3]);
                                int salary = Int32.Parse(parameters[4]);
                                if (emp is FullTimeEmployee)
                                {
                                    ((FullTimeEmployee)emp).Salary = salary;
                                }
                                else
                                {
                                    ((PartTimeEmployee)emp).HourlyDate = salary;
                                }
                                blHandler.UpdateEmployee(emp);
                            }
                            else
                            {
                                throw new Exception("Error: ID empleado no existe.");
                            }
                            break;

                        case "GetAllEmployees":
                            List <Employee> list = blHandler.GetAllEmployees();
                            foreach (Employee l in list)
                            {
                                System.Console.WriteLine(l.ToString());
                            }
                            break;

                        case "GetEmployee":
                            e = blHandler.GetEmployee(Int32.Parse(parameters[1]));
                            System.Console.WriteLine(e.ToString());
                            break;

                        case "SearchEmployees":
                            list = blHandler.SearchEmployees(parameters[1]);
                            foreach (Employee l in list)
                            {
                                System.Console.WriteLine(l.ToString());
                            }
                            break;

                        case "CalcPartTime":
                            int    id    = Int32.Parse(parameters[1]);
                            int    hours = Int32.Parse(parameters[2]);
                            double mount = blHandler.CalcPartTimeEmployeeSalary(id, hours);
                            System.Console.WriteLine(mount);
                            break;

                        default:
                            Console.WriteLine("Invalid Command!");
                            break;
                        }
                    }
                    catch (EmployeeExc exc)
                    {
                        log.Warn(exc.Message, exc);

                        System.Console.WriteLine(exc.Message);
                    }
                    catch (Exception E)
                    {
                        log.Error("Error no controlado:", E);
                    }



                    System.Console.Write(">");
                    line = System.Console.ReadLine();
                } while (!line.Equals("exit"));
            }
        }
예제 #8
0
        private void Editar_Click(object sender, EventArgs e)
        {
            EmployeeAddEdit nuevo = new EmployeeAddEdit(_IBL.GetEmployee(this.id));

            nuevo.Visible = true;
        }
예제 #9
0
 public Employee GetEmployee(int id)
 {
     return(IB.GetEmployee(id));
 }