Beispiel #1
0
 public DepartmentModel GetModel(Guid id)
 {
     using (DataProvider dp = new DataProvider())
     {
         return(Mapper.Map <DepartmentModel>(data.GetDepById(dp, id)));
     }
 }
        ////////////////////////////////////////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());
        }
Beispiel #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());
        }
Beispiel #4
0
        public JsonResult ChangeCollectingPoint(string cp)
        {
            Employee   emp = EmployeeData.FindByUserName((string)Session["username"]);
            Department dep = DepartmentData.GetDepById(emp.department.Id);

            DepartmentData.SetColPoint(dep.Id, cp);

            object new_amount = new { cp = cp };

            return(Json(new_amount, JsonRequestBehavior.AllowGet));
        }
        ////////////////////////////////////////Manage Representative
        public ActionResult ManageRep()
        {
            Employee u   = EmployeeData.FindByUserName((string)Session["username"]);
            int      uId = u.Id;
            int      dId = u.department.Id;

            Department dep = DepartmentData.GetDepById(dId);


            List <Employee> lemp = DepartmentData.GetAllEmpByDepId(u.department.Id);

            ViewBag.listemp = lemp;

            ViewBag.dep = dep;

            return(View());
        }
Beispiel #6
0
        // GET: DepRep
        public ActionResult PendingDisbursmentList()
        {
            Dictionary <int, int> signinglist = new Dictionary <int, int>();

            signinglist            = loadsigninglist();
            ViewBag.Rlist          = signinglist;
            Session["signinglist"] = signinglist;

            string user = (string)Session["username"];


            bool dele = EmployeeData.GetDelegateStatusByUserName(user);

            if (dele)
            {
                Session["sessionRole"] = "DeleManager";
            }
            ViewBag.delestatus = dele;

            ViewBag.dep = DepartmentData.GetDepById(EmployeeData.FindDepIdByUsername(user));

            return(View());
        }
Beispiel #7
0
        ///////////////////////Manage Collecting Point
        public ActionResult ManageCollectingPoint()
        {
            List <string> listCP = new List <string>()
            {
                "Stationery Store-Administration Building(9:30am)", "Management School(11:00am)", "Medical School(9:30am)", "Engineering School(11:00am)", "Science School(9:30am)", "University Hospital(11:00am)"
            };
            Employee   emp = EmployeeData.FindByUserName((string)Session["username"]);
            Department dep = DepartmentData.GetDepById(emp.department.Id);

            ViewBag.currentDep = dep;
            ViewBag.listCP     = listCP;

            string user = (string)Session["username"];
            bool   dele = EmployeeData.GetDelegateStatusByUserName(user);

            if (dele)
            {
                Session["sessionRole"] = "DeleManager";
            }
            ViewBag.delestatus = dele;

            return(View());
        }
        public JsonResult setRep(int empId)
        {
            object status;
            int    userid = EmployeeData.GetId((string)Session["username"]);

            if (userid == empId)
            {
                status = new { status = false };

                return(Json(status, JsonRequestBehavior.AllowGet));
            }
            Department dep        = DepartmentData.GetDepById(EmployeeData.FindEmpById(userid).department.Id);
            Employee   currentRep = EmployeeData.FindEmpById(dep.DepRepId);
            Employee   newRep     = EmployeeData.FindEmpById(empId);

            EmployeeData.SetRoleToEmp(currentRep.Id);
            EmployeeData.SetRoleToRep(newRep.Id);
            DepartmentData.SetRep(EmployeeData.FindEmpById(userid).department.Id, empId);

            status = new { status = true };

            return(Json(status, JsonRequestBehavior.AllowGet));
        }
Beispiel #9
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));
        }