コード例 #1
0
        public List <GastosEmployee> GetGastosEmployee()
        {
            List <GastosEmployee> gastos = new List <GastosEmployee>();

            foreach (Employee employee in GetEmployees())
            {
                GastosEmployee gasto = new GastosEmployee();
                gasto.Name  = employee.Name;
                gasto.Fecha = "";
                double total = 0;

                foreach (Salida salida in GetSalidas())
                {
                    if (employee.Id == salida.Id)
                    {
                        if (total > 0)
                        {
                            gasto.Fecha += ", " + salida.Fecha;
                        }
                        else
                        {
                            gasto.Fecha += salida.Fecha;
                        }

                        total += salida.Monto;
                    }
                }
                gasto.Monto = total;

                gastos.Add(gasto);
            }

            return(gastos);
        }
コード例 #2
0
        public List <GastosEmployee> FilterGastosEmployee(string fechaInicio, string fechaFinal)
        {
            DateTime fechaInicio__date = DateTime.Parse(fechaInicio);
            DateTime fechaFinal__date  = DateTime.Parse(fechaFinal);

            int dayInicio   = fechaInicio__date.Day;
            int monthInicio = fechaInicio__date.Month;
            int yearInicio  = fechaInicio__date.Year;

            int dayFinal   = fechaFinal__date.Day;
            int monthFinal = fechaFinal__date.Month;
            int yearFinal  = fechaFinal__date.Year;

            List <GastosEmployee> gastos = new List <GastosEmployee>();

            foreach (Employee employee in GetEmployees())
            {
                GastosEmployee gasto = null;

                foreach (Salida salida in GetSalidas())
                {
                    //string[] fechaCurrent = salida.Fecha.Split("/");
                    int dayCurrent   = DateTime.Now.Day;
                    int monthCurrent = DateTime.Now.Month;
                    int yearCurrent  = DateTime.Now.Year;


                    if (employee.Id == salida.Id)
                    {
                        if (yearCurrent > yearInicio || yearCurrent < yearFinal)
                        {
                            if (yearCurrent > yearInicio && yearCurrent < yearFinal)
                            {
                                gasto = new GastosEmployee();

                                gasto.Name  = employee.Name;
                                gasto.Monto = salida.Monto;
                                gasto.Fecha = salida.Fecha;

                                gastos.Add(gasto);

                                continue;
                            }
                            else if (yearCurrent >= yearInicio && yearCurrent < yearFinal)
                            {
                                if (monthCurrent >= monthInicio && dayCurrent >= dayInicio)
                                {
                                    gasto = new GastosEmployee();

                                    gasto.Name  = employee.Name;
                                    gasto.Monto = salida.Monto;
                                    gasto.Fecha = salida.Fecha;

                                    gastos.Add(gasto);
                                }

                                continue;
                            }

                            else if (yearCurrent > yearInicio && yearCurrent <= yearFinal)
                            {
                                if (monthCurrent <= monthFinal && dayCurrent <= dayFinal)
                                {
                                    gasto = new GastosEmployee();

                                    gasto.Name  = employee.Name;
                                    gasto.Monto = salida.Monto;
                                    gasto.Fecha = salida.Fecha;

                                    gastos.Add(gasto);
                                }
                            }
                        }
                        if ((monthCurrent >= monthInicio && monthCurrent <= monthFinal) && (yearCurrent == yearInicio && yearCurrent == yearFinal))
                        {
                            if (monthCurrent > monthInicio && monthCurrent < monthFinal)
                            {
                                gasto = new GastosEmployee();

                                gasto.Name  = employee.Name;
                                gasto.Monto = salida.Monto;
                                gasto.Fecha = salida.Fecha;

                                gastos.Add(gasto);

                                continue;
                            }
                            else if (monthCurrent >= monthInicio && monthCurrent < monthFinal)
                            {
                                if (dayCurrent >= dayInicio)
                                {
                                    gasto = new GastosEmployee();

                                    gasto.Name  = employee.Name;
                                    gasto.Monto = salida.Monto;
                                    gasto.Fecha = salida.Fecha;

                                    gastos.Add(gasto);
                                }

                                continue;
                            }
                            else if (monthCurrent > monthInicio && monthCurrent <= monthFinal)
                            {
                                if (dayCurrent <= dayFinal)
                                {
                                    gasto = new GastosEmployee();

                                    gasto.Name  = employee.Name;
                                    gasto.Monto = salida.Monto;
                                    gasto.Fecha = salida.Fecha;

                                    gastos.Add(gasto);
                                }
                            }
                        }
                        if ((dayCurrent >= dayInicio && dayCurrent <= dayFinal) && (monthCurrent == monthInicio && monthCurrent == monthFinal) && (yearCurrent == yearInicio && yearCurrent == yearFinal))
                        {
                            gasto = new GastosEmployee();

                            gasto.Name  = employee.Name;
                            gasto.Monto = salida.Monto;
                            gasto.Fecha = salida.Fecha;

                            gastos.Add(gasto);

                            continue;
                        }
                    }
                }
            }

            return(gastos);
        }