public async Task <IActionResult> OnPostAddAllAsync(int id, int Did)
        {
            await OnLoad(id);

            List <DetailOT> newDetailOTs = DetailOT.Where(n => n.OT_OTID == Did).ToList();

            foreach (var item in newDetailOTs)
            {
                DetailOT newDetailOT = item;
                newDetailOT.Status = "Allow";

                _context.Attach(newDetailOT).State = EntityState.Modified;

                try
                {
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DetailOTExists(newDetailOT.DetailOTID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }



            return(RedirectToPage("./../listOTs/listEmpOT", new { id = Employee.EmployeeID }));
        }
Beispiel #2
0
        private async Task onLoad(int?id, int?Did)
        {
            Department = await _context.Department.ToListAsync();

            Employee = await _context.Employee
                       .Include(e => e.Company)
                       .Include(e => e.Department)
                       .Include(e => e.EmployeeType)
                       .Include(e => e.Location)
                       .Include(e => e.Position).FirstOrDefaultAsync(m => m.EmployeeID == id);

            OT = await _context.OT.FirstOrDefaultAsync(m => m.OTID == Did);

            DetailOT = await _context.DetailOT
                       .Include(d => d.Employee)
                       .Include(d => d.FoodSet)
                       .Include(d => d.OT)
                       .Include(d => d.Part).ToListAsync();

            DetailOT = DetailOT.Where(d => d.OT_OTID == Did && d.Status.Equals("Allow")).ToList();
            Part     = await _context.Part.ToListAsync();

            FoodSet = await _context.FoodSet.ToListAsync();

            CarType = await _context.CarType.ToListAsync();



            CarType = CarType.OrderByDescending(o => o.Seat).ToList();
        }
Beispiel #3
0
        public async Task <IActionResult> OnGetAsync(int?id, int?Did)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Employee = await _context.Employee

                       .Include(e => e.Department)
                       .Include(e => e.EmployeeType)
                       .Include(e => e.Location)
                       .Include(e => e.Position).FirstOrDefaultAsync(e => e.EmployeeID == id);

            DetailOT = await _context.DetailOT

                       .Include(d => d.Employee)
                       .Include(d => d.FoodSet)
                       .Include(d => d.OT)
                       .Include(d => d.Part).Where(d => d.OT_OTID == Did).ToListAsync();

            DetailOT = DetailOT.Where(d => d.Employee.Employee_DepartmentID == Employee.Employee_DepartmentID).ToList();

            if (DetailOT == null)
            {
                return(NotFound());
            }

            return(Page());
        }
Beispiel #4
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Employee = await _context.Employee
                       .Include(e => e.Company)
                       .Include(e => e.Department)
                       .Include(e => e.EmployeeType)
                       .Include(e => e.Location)
                       .Include(e => e.Position).FirstOrDefaultAsync(m => m.EmployeeID == id);

            if (Employee == null)
            {
                return(NotFound());
            }
            ViewData["Company_CompanyID"]           = new SelectList(_context.Company, "CompanyID", "CompanyID");
            ViewData["Department_DepartmentID"]     = new SelectList(_context.Department, "DepartmentID", "DepartmentID");
            ViewData["EmployeeType_EmployeeTypeID"] = new SelectList(_context.EmployeeType, "EmployeeTypeID", "EmployeeTypeID");
            ViewData["Location_LocationID"]         = new SelectList(_context.Location, "LocationID", "LocationID");
            ViewData["Position_PositionID"]         = new SelectList(_context.Position, "PositionID", "PositionID");

            DetailOT = await _context.DetailOT
                       .Include(d => d.CarType)
                       .Include(d => d.Employee)
                       .Include(d => d.FoodSet)
                       .Include(d => d.OT)
                       .Include(d => d.Part).ToListAsync();


            DetailOT = DetailOT.Where(e => e.Employee_EmpID == id).ToList();

            return(Page());
        }
Beispiel #5
0
        public async Task<IActionResult> OnGetAsync(int? Did)
        {

            try
            {
                await onLoad(Did);
            }
            catch (Exception)
            {
                return RedirectToPage("./index");
            }
            
            if (OT == null)
            {
                return NotFound();
            }
            if (Employee == null)
            {
                return NotFound();
            }
                    
            OTs = ListOTDetail(Did);


            
            Depasments = OTDetailOTList();


            IList<DetailOT> mDetailOTnew;
            if (OT.TypeOT.Equals("Saturday") || OT.TypeOT.Equals("Sunday"))
            {
                mDetailOTnew = DetailOT.Where(d => (d.Type.Equals("Go") || d.Type.Equals("Go and Back"))&& d.TimeStart.Hour==8 && d.TimeStart.Minute == 0).ToList();
                Round_8 = ManageCar(mDetailOTnew);
                mDetailOTnew = DetailOT.Where(d => (d.Type.Equals("Back") || d.Type.Equals("Go and Back")) && d.TimeEnd.Hour == 17 && d.TimeEnd.Minute == 0).ToList();
                Round_17 = ManageCar(mDetailOTnew);
                mDetailOTnew = DetailOT.Where(d => (d.Type.Equals("Back") || d.Type.Equals("Go and Back")) && d.TimeEnd.Hour == 20 && d.TimeEnd.Minute == 0).ToList();
                Round_20 = ManageCar(mDetailOTnew);
            }
            else
            {
                mDetailOTnew = DetailOT.Where(d => d.Type.Equals("Back") && d.TimeEnd.Hour == 20 && d.TimeEnd.Minute == 0).ToList();
                Round_20 = ManageCar(mDetailOTnew);
            }
            return Page();
        }
Beispiel #6
0
        public async Task <IActionResult> OnPostRemoveAsync(int id, int Did)
        {
            DetailOTs = await _context.DetailOT

                        .Include(d => d.Employee)
                        .Include(d => d.FoodSet)
                        .Include(d => d.OT)
                        .Include(d => d.Part).FirstOrDefaultAsync(e => e.DetailOTID == Did);

            DetailOTs.Status = "Disallow";
            _context.Attach(DetailOTs).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DetailOTExists(DetailOTs.DetailOTID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            Employee = await _context.Employee
                       .Include(e => e.Department)
                       .Include(e => e.EmployeeType)
                       .Include(e => e.Location)
                       .Include(e => e.Position).FirstOrDefaultAsync(e => e.EmployeeID == id);

            DetailOT = await _context.DetailOT

                       .Include(d => d.Employee)
                       .Include(d => d.FoodSet)
                       .Include(d => d.OT)
                       .Include(d => d.Part).Where(d => d.OT_OTID == DetailOTs.OT_OTID).ToListAsync();

            DetailOT = DetailOT.Where(d => d.Employee.Employee_DepartmentID == Employee.Employee_DepartmentID).ToList();

            return(Page());
        }
        private async Task OnLoad(int?id)
        {
            Employee = await _context.Employee
                       .Include(e => e.Company)
                       .Include(e => e.Department)
                       .Include(e => e.EmployeeType)
                       .Include(e => e.Location)
                       .Include(e => e.Position).FirstOrDefaultAsync(m => m.EmployeeID == id);

            DetailOT = await _context.DetailOT

                       .Include(d => d.Employee)
                       .Include(d => d.FoodSet)
                       .Include(d => d.OT)
                       .Include(d => d.Part).ToListAsync();

            DetailOT = DetailOT.Where(d => d.Employee.Employee_DepartmentID == Employee.Employee_DepartmentID).ToList();
            DetailOT = DetailOT.Where(d => d.Status.Equals("Pending for approval")).ToList();
            OT       = await _context.OT.ToListAsync();

            OT = OT.Where(o => o.TypStatus.Equals("Manage Car")).ToList();
        }
        private OTs ListOTDetail(int?Did)
        {
            OTs OTsnew = new OTs();


            DetailOTnew     = DetailOT.Where(d => d.OT_OTID == Did && d.Status.Equals("Allow")).ToList();
            OTsnew.countEmp = DetailOTnew.Count;

            foreach (var i in DetailOTnew)
            {
                if (i.FoodSet.NameSet.Equals("No"))
                {
                    OTsnew.countFood = OTsnew.countFood + 1;
                }
                if (!i.Type.Equals("No"))
                {
                    OTsnew.countCar = OTsnew.countCar + 1;
                }
            }

            return(OTsnew);
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }



            DetailOT = await _context.DetailOT

                       .Include(d => d.Employee)
                       .Include(d => d.FoodSet)
                       .Include(d => d.OT)
                       .Include(d => d.Part).ToListAsync();

            DetailOT    = DetailOT.Where(d => d.Employee_EmpID.Equals(id)).ToList();
            DetailOT    = DetailOT.Where(d => d.Status.Equals("Approved")).ToList();
            countHourOT = new TimeSpan();
            foreach (var item in DetailOT)
            {
                countHourOT = countHourOT + item.Hour;
            }



            Employee = await _context.Employee
                       .Include(e => e.Company)
                       .Include(e => e.Department)
                       .Include(e => e.EmployeeType)
                       .Include(e => e.Location)
                       .Include(e => e.Position).FirstOrDefaultAsync(m => m.EmployeeID == id);

            if (Employee == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Beispiel #10
0
        private OTs ListOTDetail(int?Did)
        {
            OTs OTsnew = new OTs();


            DetailOTnew      = DetailOT.Where(d => d.OT_OTID == Did && d.Status.Equals("Allow")).ToList();
            OTsnew.countEmp  = DetailOTnew.Count;
            OTsnew.countCar  = DetailCarQueue.Count;
            OTsnew.countFood = DetailOTnew.Where(e => !e.FoodSet.NameSet.Equals("No")).ToList().Count;
            //foreach (var i in DetailOTnew)
            //{
            //    if (i.FoodSet.NameSet.Equals("No"))
            //    {
            //        OTsnew.countFood = OTsnew.countFood + 1;
            //    }
            //    if (!i.Type.Equals("No"))
            //    {
            //        OTsnew.countCar = OTsnew.countCar + 1;
            //    }

            //}

            return(OTsnew);
        }