예제 #1
0
        public RedirectToRouteResult Approve(String data)
        {
            //update staff req
            using (SSISdbEntities e = new SSISdbEntities()) {
                DAL.StaffRequisitionRepositoryImpl dal = new DAL.StaffRequisitionRepositoryImpl(e);

                StaffRequisitionHeader srh = dal.GetStaffRequisitionHeaderById(Session["ReviewNewRequisitionId"].ToString());
                srh.ApprovalStatus = "Approved";
                srh.Approver       = Session["UserId"].ToString();
                srh.DateProcessed  = System.DateTime.Now;
                srh.Remarks        = data;

                if (srh.NotificationStatus == "Unread")
                {
                    int noUnreadRequests = (int)Session["NoUnreadRequests"];
                    noUnreadRequests--;
                    Session["NoUnreadRequests"] = noUnreadRequests;
                }

                srh.NotificationStatus = "Unread";

                dal.UpdateStaffRequisitionHeader(srh);
                e.SaveChanges();

                Employee req = e.Employees.Where(x => x.EmployeeID == srh.EmployeeID).FirstOrDefault();

                string title   = "[LogicUniversity] Requisition Approved: " + srh.FormID;
                string message = "Your requisition has approved";

                CommonLogic.Email.sendEmail("*****@*****.**", req.EmployeeEmail, title, message);
            }
            return(RedirectToAction("Approval", "Dept"));
        }
예제 #2
0
        public RedirectToRouteResult DiscardSelBackorders(string[] itemCodes, string[] formIds)
        {
            using (SSISdbEntities e = new SSISdbEntities())
            {
                DAL.StaffRequisitionDetailsRepositoryImpl dal       = new DAL.StaffRequisitionDetailsRepositoryImpl(e);
                DAL.StaffRequisitionRepositoryImpl        dalHeader = new DAL.StaffRequisitionRepositoryImpl(e);

                int index = 0;

                foreach (string i in itemCodes)
                {
                    string formId = formIds[index];

                    //update SRD
                    StaffRequisitionDetail srd = new StaffRequisitionDetail();
                    srd = dal.GetStaffRequisitionDetailById(formId, itemCodes[index]);
                    srd.CancelledBackOrdered = srd.QuantityBackOrdered;
                    srd.QuantityBackOrdered  = 0;
                    dal.UpdateStaffRequisitionDetail(srd);

                    //update SRH
                    StaffRequisitionHeader srh = new StaffRequisitionHeader();
                    srh = dalHeader.GetStaffRequisitionHeaderById(formId);
                    string stockRetrievalId = e.StockRetrievalReqForms.Where(x => x.ReqFormID == formId).Select(x => x.StockRetrievalID).FirstOrDefault();
                    byte?  disbursedStatus  = e.StockRetrievalHeaders.Where(x => x.ID == stockRetrievalId).Select(x => x.Disbursed).FirstOrDefault();
                    bool   backOrderStatus  = false;
                    List <StaffRequisitionDetail> reqDetailsList = e.StaffRequisitionDetails.Where(x => x.FormID == formId).ToList();
                    foreach (StaffRequisitionDetail detail in reqDetailsList)
                    {
                        if (detail.QuantityBackOrdered > 0)
                        {
                            backOrderStatus = true;
                        }
                    }

                    switch (backOrderStatus)
                    {
                    case true:     //backorder exists for current SR
                        break;

                    case false:
                        srh.Status = "Cancelled";
                        break;
                    }

                    dalHeader.UpdateStaffRequisitionHeader(srh);

                    index++;
                    e.SaveChanges();
                }
            }

            Session["DeptReqTabIndex"] = "2";
            return(RedirectToAction("Requisition", "Dept"));
        }
예제 #3
0
        public void SubmitNewReqTest()
        {
            using (Models.SSISdbEntities e = new Models.SSISdbEntities())
            {
                Models.Item item1 = e.Items.Where(x => x.Description == "File Separator").FirstOrDefault();
                Models.Item item2 = e.Items.Where(x => x.Description == "Highlighter Blue").FirstOrDefault();
                Models.Item item3 = e.Items.Where(x => x.Description == "Pen Ballpoint Black").FirstOrDefault();

                Models.StaffRequisitionDetail srd1 = new Models.StaffRequisitionDetail();
                srd1.QuantityOrdered = 20;
                Models.StaffRequisitionDetail srd2 = new Models.StaffRequisitionDetail();
                srd2.QuantityOrdered = 10;
                Models.StaffRequisitionDetail srd3 = new Models.StaffRequisitionDetail();
                srd3.QuantityOrdered = 5;

                List <Models.StaffRequisitionDetail> list = new List <Models.StaffRequisitionDetail>();
                var itemCode = new NameValueCollection {
                    { "SelectItemDesc", "F020" }
                };

                HttpContext.Current = SA46Team1_Web_ADProjTests.MockSession.FakeHttpContext();

                var wrapper = new HttpContextWrapper(HttpContext.Current);
                DeptRequisitionController controller = new DeptRequisitionController();
                HttpContext.Current.Session["DepartmentCode"]   = "ZOOL";
                HttpContext.Current.Session["LoginEmployeeID"]  = "E25";
                HttpContext.Current.Session["currentFormId"]    = "SR-1001";
                HttpContext.Current.Session["newReqList"]       = list;
                HttpContext.Current.Session["NoUnreadRequests"] = 10;
                HttpContext.Current.Session["tempList"]         = new List <String>();
                HttpContext.Current.Session["EmpName"]          = "Keith Ho";
                controller.ControllerContext = new ControllerContext(wrapper, new RouteData(), controller);

                var result1 = controller.SubmitNewRequestForm();

                Assert.IsNotNull(result1);

                DAL.StaffRequisitionRepositoryImpl dal = new DAL.StaffRequisitionRepositoryImpl(e);
                Models.StaffRequisitionHeader      srh = dal.GetStaffRequisitionHeaderById("SR-1000");
                string emp      = srh.EmployeeID;
                string deptCode = srh.DepartmentCode;

                Assert.AreEqual(emp, "E25");
                Assert.AreEqual(deptCode, "ZOOL");

                dal.DeleteStaffRequisitionHeader("SR-1001");
                e.SaveChanges();
            }
        }
예제 #4
0
        public RedirectToRouteResult DisplayApprovalDetails(string ReqFormId)
        {
            Session["ReqApprovalPage"]        = "2";
            Session["ReviewNewRequisitionId"] = ReqFormId;

            using (SSISdbEntities e = new SSISdbEntities())
            {
                DAL.StaffRequisitionRepositoryImpl dal = new DAL.StaffRequisitionRepositoryImpl(e);
                StaffRequisitionHeader             srh = dal.GetStaffRequisitionHeaderById(ReqFormId);
                TempData["RequisitionRequstor"] = e.Employees.Where(x => x.EmployeeID == srh.EmployeeID).Select(x => x.EmployeeName).First();
                TempData["RequisitionDateReq"]  = srh.DateRequested;
            }

            return(RedirectToAction("Approval", "Dept"));
        }