Пример #1
0
        public async Task <IActionResult> OnPostEditAsync()
        {
            Debug = 0;
            var check = 0;

            if (FoodSetEdit.FoodSetcoManul == null)
            {
                check = 1;
                ModelState.AddModelError("FoodSetEdit.FoodSetcoManul", "The FoodSetcoManul field is required.");
            }
            if (FoodSetEdit.NameSet == null)
            {
                check = 1;
                ModelState.AddModelError("FoodSetEdit.NameSet", "The NameSet field is required.");
            }
            if (FoodSetEdit.Price <= 0)
            {
                check = 1;
                ModelState.AddModelError("FoodSetEdit.Price", "The Price field is required.");
            }


            if (check == 1)
            {
                Debug = 2;
                await OnLode(FoodSetEdit.Canteen_CanteenID);

                return(Page());
            }



            if (FoodSetEdit.NameSet.Equals("No"))
            {
                ModelState.AddModelError("FoodSetEdit.NameSet", "The NameSet must not be 'No'");
                await OnLode(FoodSetEdit.Canteen_CanteenID);

                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FoodSetExists(FoodSetEdit.FoodSetID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./FoodSet", new { id = FoodSetEdit.Canteen_CanteenID }));
        }
Пример #2
0
        public async Task <IActionResult> OnPostEditAsync()
        {
            Debug = 0;
            var check = 0;

            if (CanteenEdit.Name == null)
            {
                check = 1;
                ModelState.AddModelError("CanteenEdit.Name", "The NameCar field is required.");
            }
            if (CanteenEdit.Email == null)
            {
                check = 1;
                ModelState.AddModelError("CanteenEdit.Email", "The Seat field is required.");
            }
            if (CanteenEdit.Line == null)
            {
                check = 1;
                ModelState.AddModelError("CanteenEdit.Line", "The Line field is required.");
            }
            if (CanteenEdit.Call == null)
            {
                check = 1;
                ModelState.AddModelError("CanteenEdit.Call", "The Call field is required.");
            }

            if (check == 1)
            {
                Debug = 2;
                await Lode();

                return(Page());
            }



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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CanteenExists(CanteenEdit.CanteenID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            await Lode();

            return(RedirectToPage("./ManageCanteen"));
        }
Пример #3
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LoginExists(Login.LoginID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Пример #4
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            Employee = HttpContext.Session.GetLogin(_context.Employee);
            _context.Attach(CarQueue).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarQueueExists(CarQueue.CarQueueID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Пример #5
0
        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 }));
        }
Пример #6
0
        public async Task <IActionResult> OnPostEditAsync()
        {
            if (!ModelState.IsValid)
            {
                Debug = 2;
                await Onlode();

                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LineTokenExists(LineToken.LineTokenID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            await Onlode();

            return(RedirectToPage("./LineToken"));
        }
Пример #7
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OTExists(OTs.OTID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Page());
        }
Пример #8
0
        public async Task <IActionResult> OnPostAsync(int?id, int?Did)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            OTs = await _context.OT.FirstOrDefaultAsync(o => o.OTID == Did);

            OTs.TypStatus = "Manage Car";
            _context.Attach(OTs).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OTExists(OTs.OTID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }



            return(RedirectToPage("./../listOTs/ConfirmShuttle", new { id = id, Did = Did }));
        }
Пример #9
0
        public async Task <IActionResult> OnPostEditAsync()
        {
            Debug = 0;
            var check = 0;

            if (CarTypeEdit.NameCar == null)
            {
                check = 1;
                ModelState.AddModelError("CarTypeEdit.NameCar", "The NameCar field is required.");
            }
            if (CarTypeEdit.Seat == 0)
            {
                check = 1;
                ModelState.AddModelError("CarTypeEdit.Seat", "The Seat field is required.");
            }

            if (check == 1)
            {
                Debug = 2;
                await OnLode(CarTypeEdit.CarType_CompanyCarID);

                return(Page());
            }


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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarTypeExists(CarTypeEdit.CarTypeID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./CarType", new { id = CarTypeEdit.CarType_CompanyCarID }));
        }
Пример #10
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());
        }
Пример #11
0
        public async Task <IActionResult> OnPostRemoveAsync(int id)
        {
            var DetailOTs = await _context.DetailOT
                            .FirstOrDefaultAsync(e => e.DetailOTID == id);

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

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

            try
            {
                await OnLoad(DetailOTs.OT_OTID);
            }
            catch (Exception)
            {
                return(RedirectToPage("./index"));
            }



            return(Page());
        }
Пример #12
0
        public async Task <IActionResult> OnPostEditAsync()
        {
            Debug = 0;
            var check = 0;

            if (PartEdit.Name == null)
            {
                check = 1;
                ModelState.AddModelError("PartEdit.Name", "The Name field is required.");
            }
            if (PartEdit.Price <= 0)
            {
                check = 1;
                ModelState.AddModelError("PartEdit.Price", "The Price field is required.");
            }



            if (check == 1)
            {
                Debug = 2;
                await OnLode();

                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PartExists(PartEdit.PartID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Part"));
        }
Пример #13
0
        public async Task <ActionResult> OnPostAsync(int id, int Did)
        {
            OT = await _context.OT.FirstOrDefaultAsync(m => m.OTID == Did);



            if (Round_8.Any())
            {
                int              time         = 8;
                string           type         = "Go";
                IList <CarsPart> managecarNEW = Round_8;

                await createDetailCarQ(Did, time, type, managecarNEW);
            }
            else
            {
                Debug.WriteLine("Round_8 Null");
            }


            if (Round_17.Any())
            {
                int              time         = 17;
                string           type         = "Back";
                IList <CarsPart> managecarNEW = Round_17;

                await createDetailCarQ(Did, time, type, managecarNEW);
            }
            else
            {
                Debug.WriteLine("Round_17 Null");
            }

            if (Round_20.Any())
            {
                int              time         = 20;
                string           type         = "Back";
                IList <CarsPart> managecarNEW = Round_20;

                await createDetailCarQ(Did, time, type, managecarNEW);
            }
            else
            {
                Debug.WriteLine("Round_20 Null");
            }


            //_context.CarsPart.Add(Round_8);


            //Your logic here using Products and statusId

            OT.TypStatus = "Close";
            _context.Attach(OT).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OTExists(OT.OTID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }


            return(RedirectToPage("./../listOTs/ContactCarFood", new { id = id, Did = Did }));
        }
Пример #14
0
        public async Task <IActionResult> OnPostEditAsync()
        {
            var check = 0;

            if (EditDetailOT.Employee_EmpID == 0)
            {
                check = 1;
                ModelState.AddModelError("EditDetailOT.Employee_EmpID", "The Employee field is required.");
            }
            if (EditDetailOT.Point_PointID == 0)
            {
                check = 1;
                ModelState.AddModelError("EditDetailOT.Point_PointID", "The Point field is required.");
            }
            if (EditDetailOT.FoodSet_FoodSetID == 0)
            {
                check = 1;
                ModelState.AddModelError("EditDetailOT.FoodSet_FoodSetID", "The Food Set field is required.");
            }
            if (EditDetailOT.Type == null)
            {
                check = 1;
                ModelState.AddModelError("EditDetailOT.Type", "The Travel Type field is required.");
            }



            if (check == 1)
            {
                try
                {
                    await OnLoad();
                }
                catch (Exception)
                {
                    return(RedirectToPage("./index"));
                }
                Defal = 2;
                return(Page());
            }



            Employee = HttpContext.Session.GetLogin(_context.Employee);

            var OTcheck = await _context.OT.FirstOrDefaultAsync(e => e.OTID == EditDetailOT.OT_OTID);

            DateTime TimeS = OTcheck.date;

            EditDetailOT.TimeStart = new DateTime(TimeS.Year, TimeS.Month, TimeS.Day, EditDetailOT.TimeStart.Hour, EditDetailOT.TimeStart.Minute, EditDetailOT.TimeStart.Second);
            EditDetailOT.TimeEnd   = new DateTime(TimeS.Year, TimeS.Month, TimeS.Day, EditDetailOT.TimeEnd.Hour, EditDetailOT.TimeEnd.Minute, EditDetailOT.TimeEnd.Second);
            TimeSpan hour = EditDetailOT.TimeEnd - EditDetailOT.TimeStart;

            EditDetailOT.Hour = hour;


            check = await CheckTimeEditAsync(OTcheck);

            if (check == 1)
            {
                Defal = 2;
                try
                {
                    await OnLoad();
                }
                catch (Exception)
                {
                    return(RedirectToPage("./index"));
                }
                return(Page());
            }

            Defal = 0;


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

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

            return(RedirectToPage("./../listOTs/addOT"));
        }