Example #1
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"));
        }
        public RedirectToRouteResult ExitEditExistingOrderQty(object[] arr, string[] arr1)
        {
            if (arr.Count() == 0 || arr1.Count() == 0)
            {
                return(null);
            }
            else
            {
                try
                {
                    string formId = Session["id"].ToString();

                    Session["existingReqEditMode"] = false;

                    //update details of current req history
                    using (SSISdbEntities m = new SSISdbEntities())
                    {
                        m.Configuration.ProxyCreationEnabled = false;
                        List <RequisitionHistoryDetail>           reqDetailsList = m.RequisitionHistoryDetails.Where(x => x.FormID == formId).ToList <RequisitionHistoryDetail>();
                        DAL.StaffRequisitionDetailsRepositoryImpl dal            = new DAL.StaffRequisitionDetailsRepositoryImpl(m);
                        StaffRequisitionDetail srd = new StaffRequisitionDetail();

                        foreach (RequisitionHistoryDetail rhd in reqDetailsList)
                        {
                            string itemCode = m.Items.Where(x => x.Description == rhd.Description).Select(x => x.ItemCode).FirstOrDefault();
                            srd = m.StaffRequisitionDetails.Where(x => x.FormID == formId && x.ItemCode == itemCode).FirstOrDefault();

                            int index = reqDetailsList.IndexOf(rhd);
                            srd.QuantityOrdered = Int32.Parse(arr1[index]);

                            dal.UpdateStaffRequisitionDetail(srd);
                        }

                        m.SaveChanges();
                    }

                    Session["ReqHistoryPage"] = "2";
                }
                catch (FormatException)
                {
                    TempData["ErrorMsg"] = "Invalid Quantity!";
                    return(null);
                }
                catch (Exception)
                {
                    TempData["ErrorMsg"] = "An unexpected error has occured. Please try again.";
                    return(null);
                }
            }


            return(RedirectToAction("RequisitionHistory", "Dept"));
        }
Example #3
0
        //[Route("NewReq/SubmitNewRequestForm")]
        public RedirectToRouteResult SubmitNewRequestForm()
        {
            string deptCode     = Session["DepartmentCode"].ToString();
            string employeeCode = Session["LoginEmployeeID"].ToString();

            using (SSISdbEntities e = new SSISdbEntities())
            {
                DAL.StaffRequisitionDetailsRepositoryImpl dalDetails = new DAL.StaffRequisitionDetailsRepositoryImpl(e);
                DAL.StaffRequisitionRepositoryImpl        dalHeader  = new DAL.StaffRequisitionRepositoryImpl(e);

                StaffRequisitionHeader srh = new StaffRequisitionHeader();
                srh.FormID             = Session["currentFormId"].ToString();
                srh.DepartmentCode     = deptCode;
                srh.EmployeeID         = employeeCode;
                srh.DateRequested      = System.DateTime.Now;
                srh.Status             = "Open";
                srh.ApprovalStatus     = "Pending";
                srh.DateProcessed      = null;
                srh.Approver           = e.Employees.Where(x => x.EmployeeID == srh.EmployeeID).Select(x => x.ReportsTo).FirstOrDefault();
                srh.NotificationStatus = "Unread";

                dalHeader.InsertStaffRequisitionHeader(srh);

                foreach (StaffRequisitionDetail srd in (List <StaffRequisitionDetail>)Session["newReqList"])
                {
                    srd.Item = null;
                    dalDetails.InsertStaffRequisitionDetail(srd);
                }

                e.SaveChanges();
                Session["newReqList"] = new List <StaffRequisitionDetail>();

                int noUnreadRequests = (int)Session["NoUnreadRequests"];
                noUnreadRequests++;
                Session["NoUnreadRequests"] = noUnreadRequests;

                Employee current = e.Employees.Where(x => x.EmployeeID == employeeCode).FirstOrDefault();
                Employee head    = e.Employees.Where(x => x.EmployeeID == current.ReportsTo).FirstOrDefault();

                string title   = "[LogicUniversity] New Requisition: " + srh.FormID;
                string message = Session["EmpName"].ToString() + " has raised a new requisition.";

                CommonLogic.Email.sendEmail("*****@*****.**", head.EmployeeEmail, title, message);
            }

            Session["tempList"] = new List <String>();

            return(RedirectToAction("Requisition", "Dept"));
        }
        public RedirectToRouteResult DiscardSelReqItems(string data, int index)
        {
            string formId = Session["id"].ToString();

            Session["existingReqEditMode"] = false;

            //update details of current req history
            using (SSISdbEntities m = new SSISdbEntities())
            {
                m.Configuration.ProxyCreationEnabled = false;
                DAL.StaffRequisitionDetailsRepositoryImpl dal = new DAL.StaffRequisitionDetailsRepositoryImpl(m);
                string itemCode = m.Items.Where(x => x.Description == data).Select(x => x.ItemCode).FirstOrDefault();
                dal.DeleteStaffRequisitionDetail(formId, itemCode);

                int noOfItemsInRequest = m.StaffRequisitionDetails.Where(x => x.FormID == formId).ToList().Count();

                if (noOfItemsInRequest == 1)
                {
                    DAL.StaffRequisitionRepositoryImpl dalHeader = new DAL.StaffRequisitionRepositoryImpl(m);
                    StaffRequisitionHeader             srh       = m.StaffRequisitionHeaders.Where(x => x.FormID == formId).FirstOrDefault();
                    srh.Status         = "Withdrawn"; //to add in list of constants
                    srh.ApprovalStatus = "Withdrawn";
                    dalHeader.UpdateStaffRequisitionHeader(srh);

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

                m.SaveChanges();
            }

            Session["ReqHistoryPage"] = "2";

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