Ejemplo n.º 1
0
        public JsonResult confirmOrder(int companyID, int SelecteditemID, int quantity, int orderID, int UserMasId)
        {
            bool      flag          = false;
            Inventory inventory     = new Inventory();
            Inventory inventoryItem = db.Inventory.SingleOrDefault(x => x.CompanyId == companyID && x.ItemId == SelecteditemID);

            if (inventoryItem == null)
            {
                inventory.CompanyId = companyID;
                inventory.OrderId   = orderID;
                inventory.Quantity  = quantity;
                inventory.ItemId    = SelecteditemID;
                db.Inventory.Add(inventory);
                flag = db.SaveChanges() > 0;
            }
            else
            {
                inventoryItem.Quantity        = inventoryItem.Quantity - quantity;
                db.Entry(inventoryItem).State = EntityState.Modified;
                flag = db.SaveChanges() > 0;
            }



            //db.Inventory.Add(inventory);



            var checkUpdate = 0;

            if (flag)
            {
                checkUpdate = 1;
                var check       = db.SalesOrder.Find(orderID).Status = 1;
                var confirmDate = db.SalesOrder.Find(orderID).ConfirmDate = DateTime.Now;
                db.SaveChanges();
            }

            PurchaseOrdersController purchaseOrdersController = new PurchaseOrdersController();

            purchaseOrdersController.updateBalanceHistory(orderID, UserMasId, "sales");

            return(Json(checkUpdate, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult Create(Payment payment)
        {
            PurchaseOrdersController purchaseOrdersController = new PurchaseOrdersController();

            if (ModelState.IsValid)
            {
                var search = db.CompanyBank.SingleOrDefault(x => x.AccountNo == payment.CompanyAccountNo);

                payment.CompanyBankId    = search.BankId;
                payment.CompanyAccountNo = search.AccountNo;

                if (payment.VendorAccountNo == "0")
                {
                    payment.VendorAccountNo = null;
                }

                if (payment.VendorBankId == 0)
                {
                    payment.VendorBankId = null;
                }

                if (payment.TransactionModeId == 1)
                {
                    payment.Status = 0;
                }
                else
                {
                    payment.Status = 1;
                }

                payment.CreatedOn = DateTime.Now;
                db.Payment.Add(payment);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ViewBag.CompanyId         = new SelectList(db.Company, "Id", "Address", payment.CompanyId);
            ViewBag.TransactionModeId = new SelectList(db.TransactionMode, "Id", "Name");
            ViewBag.UserMasId         = new SelectList(db.UserMas, "Id", "Name", payment.UserMasId);
            ViewBag.VendorBankId      = new SelectList(db.VendorBank, "Id", "Name");
            return(View(payment));
        }
Ejemplo n.º 3
0
 public ActionResult Edit(Payment payment)
 {
     if (ModelState.IsValid)
     {
         payment.CreatedOn       = DateTime.Now;
         db.Entry(payment).State = EntityState.Modified;
         db.SaveChanges();
         PurchaseOrdersController purchaseOrdersController = new PurchaseOrdersController();
         if (payment.TransactionType == 0)
         {
             purchaseOrdersController.updateBalanceHistory(payment.Id, payment.UserMasId, "payment", true, payment.Amount);
         }
         else
         {
             purchaseOrdersController.updateBalanceHistory(payment.Id, payment.UserMasId, "collection", true, payment.Amount);
         }
         return(RedirectToAction("Index"));
     }
     ViewBag.CompanyId         = new SelectList(db.Company, "Id", "Name", payment.CompanyId);
     ViewBag.TransactionModeId = new SelectList(db.TransactionMode, "Id", "Name", payment.TransactionModeId);
     ViewBag.UserMasId         = new SelectList(db.UserMas, "Id", "Name", payment.UserMasId);
     ViewBag.VendorBankId      = new SelectList(db.VendorBank, "Id", "Name", payment.VendorBankId);
     return(View(payment));
 }