Beispiel #1
0
 public ActionResult EditSupplier([Bind(Include = "SupplierId,SupplierName,GSTRegNo,ContactName,FaxNo,PhNo,Address")] Supplier supplier)
 {
     if (ModelState.IsValid)
     {
         db.Entry(supplier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("SupplierList"));
     }
     return(View(supplier));
 }
 public ActionResult EditProduct([Bind(Include = "ProductId,Category,Description,Bin,Unit,Qty,ReorderLevel,ReorderQty")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ProductDetails", new { category = product.Category }));
     }
     return(View(product));
 }
Beispiel #3
0
        public void SaveDisbursement(int id, string status, string[] receivedQtys, string[] remarks, int storestaffId)
        {
            using (db = new LogicEntities())
            {
                var result = from d in db.Disbursement
                             where d.DisId == id
                             select d;
                Disbursement dis = result.First();
                dis.Status       = status;
                dis.StoreStaffId = storestaffId;

                var resultSet = from dd in db.DisbursementDetail
                                where dd.DisId == id
                                select dd;

                List <DisbursementDetail> disbursementDetails = resultSet.ToList();
                int x = 0;
                foreach (DisbursementDetail disd in disbursementDetails)
                {
                    disd.ReceivedQty = Convert.ToInt32(receivedQtys[x]);
                    disd.Remarks     = remarks[x];
                    x++;
                }
                dis.DisbursementDetails = disbursementDetails;
                db.Entry(dis).State     = EntityState.Modified;
                db.SaveChanges();
            }
        }
        public ActionResult SetDisbursementList(int id, string status, string deptId)
        {
            string[] productIds    = Request.Form.GetValues("productId");
            string[] requestedQtys = Request.Form.GetValues("requestedQty");
            string[] receivedQtys  = Request.Form.GetValues("receivedQty");
            string[] remarks       = Request.Form.GetValues("remarks");
            int      storeStaffId  = Convert.ToInt32(Request.Form.Get("creatorId"));

            //Update the item quantities && Set Disburesment status to delivered
            disbursementDAO.SaveDisbursement(id, status, receivedQtys, remarks, storeStaffId);
            DepartmentStaff rep = departmentStaffDAO.getDeptRep(deptId);

            //Set all the orders status to Delivered. Not DAO-ed
            using (db = new LogicEntities())
            {
                var resultSet = from r in db.Request
                                where r.DeptId == deptId
                                select r;
                List <Request> requests = resultSet.ToList();
                foreach (Request req in requests)
                {
                    req.Status          = "Delivered";
                    db.Entry(req).State = EntityState.Modified;
                    db.SaveChanges();
                }
                //if Qty received < Qty Requested, Generate outstanding order in requests

                Request outstanding = new Request
                {
                    DeptId  = deptId,
                    ReqDate = DateTime.Now,
                    Remark  = "Outstanding Order, " + DateTime.Now.Date.ToString("d"),
                    Status  = "Outstanding",
                    StaffId = rep.StaffId
                };
                List <RequestDetail> outstandingDetails = new List <RequestDetail>();
                for (int x = 0; x < requestedQtys.Length; x++)
                {
                    if (requestedQtys[x] != receivedQtys[x])
                    {
                        RequestDetail rd = new RequestDetail
                        {
                            ProductId   = productIds[x],
                            RequestId   = outstanding.RequestId,
                            ReqQty      = Convert.ToInt32(requestedQtys[x]) - Convert.ToInt32(receivedQtys[x]),
                            ReceivedQty = 0, //Shouldn't be needed...
                        };
                        outstandingDetails.Add(rd);
                    }
                }
                if (outstandingDetails.Count != 0)
                {
                    db.Request.Add(outstanding);
                    db.RequestDetail.AddRange(outstandingDetails);
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("FindDisbursementList"));
        }
Beispiel #5
0
 public void UpdateItemQty(string productId, int qty)
 {
     using (db = new LogicEntities())
     {
         Product p = db.Product.Find(productId);
         p.Qty             = p.Qty + qty;
         db.Entry(p).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Beispiel #6
0
 public ActionResult Edit([Bind(Include = "DeptId,DeptName,ContactName,PhNo,FaxNo,EmailAddr,HeadId,CollectionPt,RepId")] Department department)
 {
     if (ModelState.IsValid)
     {
         db.Entry(department).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CollectionPt = new SelectList(db.CollectionPoint, "CollectionPtId", "CollectionPt", department.CollectionPt);
     return(View(department));
 }
        public void SetPOStatus(string status, string remarks, int id)
        {
            using (db = new LogicEntities())
            {
                var result = from po in db.PurchaseOrder
                             where po.OrderId == id
                             select po;

                PurchaseOrder p = result.First();
                p.Status          = status;
                p.ApprovedDate    = DateTime.Now;
                p.Remarks         = remarks; //Additional remarks column for po needed, must be able to be null
                db.Entry(p).State = EntityState.Modified;
                db.SaveChanges();
            }
        }
Beispiel #8
0
 public void UpdateItemQty(string[] productIds, string[] qtys, bool isAdd)
 {
     using (db = new LogicEntities())
     {
         for (int x = 0; x < productIds.Length; x++)
         {
             Product p = db.Product.Find(productIds[x]);
             if (isAdd)
             {
                 p.Qty = p.Qty + Convert.ToInt32(qtys[x]);
             }
             else
             {
                 p.Qty = p.Qty - Convert.ToInt32(qtys[x]);
             }
             db.Entry(p).State = EntityState.Modified;
         }
         db.SaveChanges();
     }
 }