Exemple #1
0
        public async Task <IActionResult> RejectOrder(string rejectReason)
        {
            if (String.IsNullOrEmpty(rejectReason))
            {
                TempData["NoText"] = "Please key in the reason for rejection.";
                return(RedirectToAction(nameof(Details), new { id = rrid }));
            }
            else
            {
                EmployeeRequestRecord e1 = context.EmployeeRequestRecord.Where(x => x.Rrid == rrid).First();
                e1.Status = "Rejected";
                e1.Remark = rejectReason.ToString();
                DateTime today = DateTime.Now.Date;
                e1.CompleteDate = today;
                context.SaveChanges();
                userid = e1.DepEmpId;

                //send rejection email to staff
                var    rejectedstaff = context.User.Where(x => x.UserId == userid).First();
                string email         = rejectedstaff.EmailAddress;
                await _emailSender.SendEmailAsync("Hello", "Rejection of New Request", "Dear,<br>Your submitted stationery request has been rejected.");

                return(RedirectToAction(nameof(Index)));
            }
        }
        public async Task <IActionResult> Index(string[] itemSubmitted)
        {
            ADTeam5User user = await _userManager.GetUserAsync(HttpContext.User);

            List <string> identity = userCheck.checkUserIdentityAsync(user);
            int           userID   = user.WorkID;

            dept = identity[0];
            role = identity[1];

            if (itemSubmitted.Length != 0)
            {
                rrid = b.IDGenerator(dept);
                foreach (var item in tempNewRequests)
                {
                    if (Array.Exists(itemSubmitted, i => i == item.ItemNumber.ToString()))
                    {
                        //add items to request
                        RecordDetails r = new RecordDetails();
                        r.Rrid              = rrid;
                        r.ItemNumber        = item.ItemNumber;
                        r.Quantity          = item.Quantity;
                        r.QuantityDelivered = 0;
                        _context.RecordDetails.Add(r);
                        _context.SaveChanges();
                    }
                }

                //check if item exists in record details
                var record = _context.RecordDetails.FirstOrDefault(x => x.Rrid == rrid);
                if (record != null)
                {
                    // Make new EmployeeRequestRecord
                    EmployeeRequestRecord e = new EmployeeRequestRecord();
                    DateTime requestDate    = DateTime.Now.Date;
                    int      empId          = userid;
                    var      findHeadId     = _context.Department.Where(x => x.DepartmentCode == dept).First();
                    int      headId         = findHeadId.HeadId;
                    string   deptCode       = dept;
                    string   status         = "Pending Approval";
                    e.Rrid        = rrid;
                    e.RequestDate = requestDate;
                    e.DepEmpId    = empId;
                    e.DepHeadId   = headId;
                    e.DepCode     = deptCode;
                    e.Status      = status;
                    _context.EmployeeRequestRecord.Add(e);
                    _context.SaveChanges();

                    TempData["Submitted"] = "New request has been created successfully!";
                }
            }

            tempNewRequests = new List <TempNewRequest>();
            List <RecordDetails> rdList = _context.RecordDetails.Where(x => x.Rrid == rrid).ToList();

            //return RedirectToAction("Details", new { id = rrid });
            return(Json(new { redirecturl = "NewRequest/Details/" + rrid }));
        }
Exemple #3
0
        public EmployeeRequestRecord searchEmployeeRequestByRRID(string rrid)
        {
            var q1 = _context.EmployeeRequestRecord.Where(x => x.Rrid == rrid).First();
            EmployeeRequestRecord e1 = new EmployeeRequestRecord();

            e1 = q1;
            return(e1);
        }
Exemple #4
0
        public Models.EmployeeRequestRecord findEmployeeRecord(String rrid)
        {
            var q2 = context.EmployeeRequestRecord.Where(x => x.Rrid == rrid).First();
            EmployeeRequestRecord d2 = new EmployeeRequestRecord();

            d2 = q2;
            return(d2);
        }
        public IActionResult ApproveOrder()
        {
            EmployeeRequestRecord e1 = b.findEmployeeRecord(rrid);

            e1.Status = "Approved";
            context.SaveChanges();
            return(RedirectToAction(nameof(Index)));
        }
        public IActionResult RejectOrder(string rejectReason)
        {
            EmployeeRequestRecord e1 = b.findEmployeeRecord(rrid);

            e1.Status = "Reject";
            e1.Remark = rejectReason.ToString();
            context.SaveChanges();
            return(RedirectToAction(nameof(Index)));
        }
        //Approve Outstanding Orders
        public void ApproveRequest(BriefEmpReq briefEmpReq)
        {
            string rrid = briefEmpReq.rrid;

            var q = context.EmployeeRequestRecord.Where(x => x.Rrid == rrid).First();
            EmployeeRequestRecord e = q;

            e.Status = "Approved";
            context.SaveChanges();
        }
        public IActionResult Edit(string id)
        {
            List <Catalogue> categoryList = new List <Catalogue>();
            var q = context.Catalogue.GroupBy(x => new { x.Category }).Select(x => x.FirstOrDefault());

            foreach (var item in q)
            {
                categoryList.Add(item);
            }
            categoryList.Insert(0, new Catalogue {
                ItemNumber = "0", Category = ""
            });
            ViewBag.ListofCategory = categoryList;

            //List<Catalogue> itemNameList = new List<Catalogue>();
            //itemNameList = (from x in context.Catalogue select x).ToList();
            //itemNameList.Insert(0, new Catalogue { ItemNumber = "", ItemName = "---Select Item---" });
            //ViewBag.ListofItemName = itemNameList;

            rrid             = id;
            ViewData["RRID"] = rrid;

            var q1 = context.EmployeeRequestRecord.Where(x => x.Rrid == rrid).First();
            EmployeeRequestRecord e1 = q1;

            ViewData["Status"] = e1.Status;

            var check = context.RecordDetails.Where(x => x.Rrid == rrid);

            if (!check.Any())
            {
                ViewData["CheckRecords"] = null;

                return(View());
            }
            else
            {
                ViewData["CheckRecords"] = "true";

                var q2 = from x in context.RecordDetails
                         join s in context.Catalogue on x.ItemNumber equals s.ItemNumber
                         where x.Rrid == rrid
                         select new ViewRequestDetails
                {
                    rrid     = x.Rrid,
                    itemName = s.ItemName,
                    quantity = x.Quantity
                };
                List <ViewRequestDetails> list = new List <ViewRequestDetails>();
                list = q2.ToList();

                return(View(list));
            }
        }
        //Reject Outstanding Orders
        public void RejectRequest(BriefEmpReq briefEmpReq)
        {
            string rrid   = briefEmpReq.rrid;
            string remark = briefEmpReq.remark;

            var q = context.EmployeeRequestRecord.Where(x => x.Rrid == rrid).First();
            EmployeeRequestRecord e = q;

            e.Status = "Rejected";
            e.Remark = remark;
            context.SaveChanges();
        }
        public async Task <IActionResult> DeleteRequest(string rrid)
        {
            List <RecordDetails> r = context.RecordDetails.Where(x => x.Rrid == rrid).ToList();

            foreach (RecordDetails current in r)
            {
                context.Remove(current);
            }
            EmployeeRequestRecord e = context.EmployeeRequestRecord.Where(x => x.Rrid == rrid).FirstOrDefault();

            context.Remove(e);

            await context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        // GET: OutstandingOrder/Details/id
        public IActionResult Details(string id)
        {
            rrid = id;

            ViewData["RRID"] = rrid;
            var q1 = b.findEmployeeRecord(rrid);
            EmployeeRequestRecord e1 = q1;
            int userid = e1.DepEmpId;

            var    q2       = b.getUser(userid);
            User   u1       = q2;
            string username = u1.Name;

            ViewData["Name"] = username;

            return(View(b.getOutstandingOrdersDetails(rrid)));
        }
Exemple #12
0
        public async Task <IActionResult> ApproveOrder()
        {
            EmployeeRequestRecord e1 = context.EmployeeRequestRecord.Where(x => x.Rrid == rrid).First();

            e1.Status = "Approved";
            DateTime today = DateTime.Now.Date;

            e1.CompleteDate = today;
            context.SaveChanges();
            int userid = e1.DepEmpId;

            //send success email to staff
            var    approvedstaff = context.User.Where(x => x.UserId == userid).First();
            string email         = approvedstaff.EmailAddress;
            await _emailSender.SendEmailAsync(email, "Approval of New Request", "Dear " + approvedstaff.Name + "<br>Your submitted stationery request has been rejected.");

            return(RedirectToAction(nameof(Index)));
        }
        public IActionResult Details(string id)
        {
            rrid = id;

            ViewData["RRID"] = rrid;
            var q1 = context.EmployeeRequestRecord.Where(x => x.Rrid == rrid).First();
            EmployeeRequestRecord e1 = q1;

            if (e1.Status == "Approved")
            {
                return(RedirectToAction("Edit", "ViewRequest", new { id }));
            }
            else
            {
                var q = context.RecordDetails.Where(x => x.Rrid == id);
                return(View(q));
            }
        }
Exemple #14
0
        public IActionResult Details(string id)
        {
            rrid = id;

            ViewData["RRID"] = rrid;
            var q1 = context.EmployeeRequestRecord.Where(x => x.Rrid == rrid).First();
            EmployeeRequestRecord e1 = q1;
            var    q3   = context.User.Where(x => x.UserId == e1.DepEmpId).FirstOrDefault();
            string name = q3.Name;

            DateTime requestDate = e1.RequestDate;

            ViewData["Status"]      = e1.Status;
            ViewData["RequestDate"] = requestDate.ToShortDateString();
            ViewData["Requester"]   = name;

            if (e1.Status == "Pending Approval")
            {
                return(RedirectToAction("Edit", "ViewRequest", new { id }));
            }
            else
            {
                var reject = context.EmployeeRequestRecord.Where(x => x.Rrid == rrid).FirstOrDefault();
                if (reject.Status == "Rejected")
                {
                    ViewData["RejectStatus"] = reject.Remark;
                }

                var q2 = from x in context.RecordDetails
                         join s in context.Catalogue on x.ItemNumber equals s.ItemNumber
                         where x.Rrid == rrid
                         select new ViewRequestDetails
                {
                    itemName = s.ItemName,
                    quantity = x.Quantity
                };
                List <ViewRequestDetails> list = new List <ViewRequestDetails>();
                list = q2.ToList();
                return(View(list));
            }
        }