示例#1
0
        public ActionResult CollectedDepOrder()
        {
            Dictionary <int, Dictionary <int, int> > plannedlist = new Dictionary <int, Dictionary <int, int> >();

            List <Department> ldep = DepartmentData.GetAllDep();

            //load the collected dep order

            foreach (int depId in ldep.Select(x => x.Id))
            {
                List <DepOrder> listdp = DepOrderData.GetCollectedDepOrderByDepId(depId);

                Dictionary <int, int> dp = new Dictionary <int, int>();
                foreach (int itemId in listdp.Select(x => x.item.Id))
                {
                    dp.Add(itemId, listdp.Where(x => x.item.Id == itemId).FirstOrDefault().collectedquant);
                }
                if (!plannedlist.ContainsKey(depId))
                {
                    plannedlist.Add(depId, dp);
                }
                else
                {
                    plannedlist[depId] = dp;
                }
            }
            Session["plannedlist"] = plannedlist;


            ViewBag.Rlist = plannedlist;
            Session.Remove("collist");
            Session.Remove("plannedlist");

            return(View());
        }
        ////////////////////////////////////////View Monthly Bill
        public ActionResult MonthlyBill()
        {
            Employee u   = EmployeeData.FindByUserName((string)Session["username"]);
            int      uId = u.Id;
            int      dId = u.department.Id;

            Department dep = DepartmentData.GetDepById(dId);

            Dictionary <string, List <DepOrder> > monthlybill = new Dictionary <string, List <DepOrder> >();
            List <DepOrder> listdeporder = DepOrderData.GetDeliveredDepOrderByDepId(dep.Id);

            var iter = from deporder in listdeporder orderby deporder.signindate descending group deporder by new { month = deporder.signindate.Month, year = deporder.signindate.Year } into d select new { dt = string.Format("{0}/{1}", d.Key.month, d.Key.year), detail = d.ToList() };

            foreach (var grp in iter)
            {
                List <DepOrder> mlist = new List <DepOrder>();
                foreach (var dor in grp.detail)
                {
                    mlist.Add(dor);
                }
                monthlybill.Add(grp.dt, mlist);
            }

            ViewBag.dep         = dep;
            ViewBag.monthlybill = monthlybill;
            return(View());
        }
示例#3
0
        public ActionResult GenerateDelOrder()
        {
            Dictionary <int, int> collist = new Dictionary <int, int>();

            if (Session["collist"] != null)
            {
                collist = (Dictionary <int, int>)Session["collist"];
            }
            else
            {
                Session["collist"] = new Dictionary <int, int>();
            }


            List <ReqItem> lri       = ReqItemData.GetAllReqItemApproved();
            var            itemIdset = new HashSet <int>(collist.Keys);
            var            depIdset  = new HashSet <int>(lri.Select(x => x.emp.department.Id).ToList());
            List <ReqItem> slist     = new List <ReqItem>();
            List <ReqItem> xlist     = new List <ReqItem>();
            Dictionary <int, Dictionary <int, int> > list = new Dictionary <int, Dictionary <int, int> >();



            foreach (int depId in depIdset)
            {
                slist = lri.Where(x => x.emp.department.Id == depId).ToList();

                Dictionary <int, int> itemmap = new Dictionary <int, int>();
                foreach (int itemId in itemIdset)
                {
                    xlist = slist.Where(x => x.item.Id == itemId).ToList();
                    int    quant = xlist.Select(x => x.Quant).Sum();
                    double price = StockCardData.GetLatestPriceByItem(ItemData.GetItemById(itemId));
                    if (quant != 0)
                    {
                        itemmap.Add(itemId, quant);
                    }
                    DepOrderData.CreateDepOrder(depId, itemId, quant, price);

                    //Withdraw from stock
                    Item item    = ItemData.GetItemById(itemId);
                    int  balance = StockCardData.GetStockBalanceByItem(item);
                    StockCardData.WithdrawFromStockRecord(item, DateTime.Today, DepartmentData.GetDepById(depId), quant, balance);
                    int stockbalance = StockCardData.GetStockBalanceByItem(item);

                    //if (stockbalance < item.ReorderLevel) Send Notification
                }
                list.Add(depId, itemmap);
            }
            ViewBag.Rlist          = list;
            Session["plannedlist"] = list;



            return(View());
        }
示例#4
0
        public JsonResult ConfirmDelOrder()
        {
            object result;
            Dictionary <int, Dictionary <int, int> > plannedlist = new Dictionary <int, Dictionary <int, int> >();

            if (Session["plannedlist"] != null)
            {
                plannedlist = (Dictionary <int, Dictionary <int, int> >)Session["plannedlist"];
            }

            //Check if the collected quant is tally with deliver plan
            Dictionary <int, int> collist = (Dictionary <int, int>)Session["collist"];

            foreach (int itemId in collist.Keys)
            {
                int itemtotal = 0;
                foreach (int depId in plannedlist.Keys)
                {
                    itemtotal += plannedlist[depId][itemId];
                }
                if (itemtotal != collist[itemId])
                {
                    result = new { status = false };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }

            //Set ItemReq status and Dep Order status
            foreach (int depId in plannedlist.Keys)
            {
                bool notifystatus = false;
                foreach (int itemId in plannedlist[depId].Keys)
                {
                    DepOrderData.SetCollected(depId, itemId, plannedlist[depId][itemId]);


                    foreach (int empId in DepartmentData.GetAllEmpByDepId(depId).Select(x => x.Id))
                    {
                        if (ReqItemData.SetReqItemCollected(empId, itemId) && notifystatus == false)
                        {
                            string emailaddress = EmployeeData.FindEmpById(empId).EmailAdd;
                            Task   task         = Task.Run(() =>
                            {
                                EmailNotification.SendNotificationEmailToEmployee(emailaddress, "Stationary Requisition Status Changed", "Your Stationary Requisition is under delivering");
                            });
                            notifystatus = true;
                        }
                    }
                }
            }
            result = new { status = true };
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        public Dictionary <int, int> loadsigninglist()
        {
            Dictionary <int, int> list = new Dictionary <int, int>();
            Employee        u          = EmployeeData.FindByUserName((string)Session["username"]);
            List <DepOrder> ldo        = new List <DepOrder>();

            ldo = DepOrderData.GetCollectedDepOrderByDepId(u.department.Id);
            if (ldo.Any())
            {
                foreach (int itemId in ldo.Select(x => x.item.Id).ToList())
                {
                    list.Add(itemId, ldo.Where(x => x.item.Id == itemId).FirstOrDefault().collectedquant);
                }
            }
            return(list);
        }
示例#6
0
        public JsonResult ConfirmReceive()
        {
            //load the signinglist
            Dictionary <int, int> signinglist = new Dictionary <int, int>();

            if (Session["signinglist"] != null)
            {
                signinglist = (Dictionary <int, int>)Session["signinglist"];
            }
            else
            {
                throw new Exception("please sign in to confirm receivement");
            }

            int depId;

            if (Session["username"] != null)
            {
                Employee u = EmployeeData.FindByUserName((string)Session["username"]);
                depId = u.department.Id;
            }
            else
            {
                throw new Exception("please sign in to confirm receivement");
            }


            bool notifystatus = false;

            foreach (int itemId in signinglist.Keys)
            {
                // SRequisition sr = new SRequisition();
                //sr.ListItem = new List<ReqItem>();

                foreach (int empId in DepartmentData.GetDepById(depId).Employees.Select(x => x.Id))
                {
                    if (ReqItemData.SetReqItemDeliveredToRep(empId, itemId) && notifystatus == false)
                    {
                        string emailaddress = EmployeeData.FindEmpById(empId).EmailAdd;
                        Task   task         = Task.Run(() =>
                        {
                            EmailNotification.SendNotificationEmailToEmployee(emailaddress, "Stationary Requisition Status Changed", "Your Stationary Requisition has delivered to Department Representative.");
                        });
                        notifystatus = true;
                    }
                }


                //if any discrepancy, create new reqItem to replenish in next delivery.
                int dif = DepOrderData.GetDeliveringOrderByDepAndItem(depId, itemId).quant - signinglist[itemId];

                if (dif > 0)
                {
                    int i = itemId;
                    int j = DepartmentData.GetRepById(depId);
                    ReqItemData.CreatReqItem(itemId, DepartmentData.GetRepById(depId), dif, "approved");
                    /////////////////////////
                }

                //mark this DepOrder to be delivered
                DepOrderData.SetReceived(depId, itemId, signinglist[itemId]);
            }
            Session.Remove("signinglist");



            object new_amount = new { };

            return(Json(new_amount, JsonRequestBehavior.AllowGet));
        }