Exemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "PurchaseOrderId,SuppliedBy")] AssignmentOfTool assignmentOfTool, HttpPostedFileBase FileT, int ContractId, string AditionalInfo, string OrderNumber, double Cost)
        {
            if (ModelState.IsValid)
            {
                assignmentOfTool = db.AssignmentOfTools.Find(assignmentOfTool.PurchaseOrderId);
                assignmentOfTool.AditionalInfo = AditionalInfo;
                assignmentOfTool.OrderNumber   = OrderNumber;
                assignmentOfTool.Cost          = Cost;

                if (FileT != null)
                {
                    var dir = Server.MapPath("~/Documents/PO/" + assignmentOfTool.PurchaseOrderId + "/" + "Tools");
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    string _FileName = System.IO.Path.GetFileName(FileT.FileName);

                    string path = System.IO.Path.Combine(dir, _FileName);
                    FileT.SaveAs(path);

                    assignmentOfTool.FileT = FileT.FileName;
                }


                db.Entry(assignmentOfTool).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "Mobilization"));
            }

            return(View(assignmentOfTool));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "PurchaseOrderId,PO,Commentary,ContractId")] Purchaseorder purchaseorder, HttpPostedFileBase file)
        {
            if (ModelState.IsValid && file != null)
            {
                var dir = Server.MapPath("~/Documents/PO/" + purchaseorder.ContractId);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                string _FileName = System.IO.Path.GetFileName(file.FileName);
                string path      = System.IO.Path.Combine(dir, _FileName);
                file.SaveAs(path);

                purchaseorder.Status = "OPEN";
                purchaseorder.Date   = DateTime.Now;
                purchaseorder.File   = _FileName;
                db.Purchaseorders.Add(purchaseorder);


                AssignmentOfTool ATool = new AssignmentOfTool();

                Truck Truck = new Truck();

                Shipping Shipping = new Shipping();

                ATool.PurchaseOrderId = purchaseorder.PurchaseOrderId;
                ATool.Cost            = 0;

                Truck.PurchaseOrderId = purchaseorder.PurchaseOrderId;
                Truck.Status          = "PENDING ASSIGNMENT";

                Shipping.PurchaseOrderId = purchaseorder.PurchaseOrderId;

                db.AssignmentOfTools.Add(ATool);
                db.Trucks.Add(Truck);
                db.Shippings.Add(Shipping);

                db.SaveChanges();



                return(RedirectToAction("Details", "Contracts", new { id = purchaseorder.ContractId }));
            }


            return(RedirectToAction("Details", "Contracts", new { id = purchaseorder.ContractId }));
        }
Exemplo n.º 3
0
        // GET: ATools/Edit/5
        public ActionResult Edit(int?id, int ContractId)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AssignmentOfTool assignmentOfTool = db.AssignmentOfTools.Find(id);

            if (assignmentOfTool == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PurchaseOrderId = id;
            ViewBag.ContractId      = ContractId;
            return(View(assignmentOfTool));
        }
Exemplo n.º 4
0
        public ActionResult EditJson([Bind(Include = "PurchaseOrderId,SuppliedBy")] AssignmentOfTool assignmentOfTool, int ContractId, string AditionalInfo)
        {
            if (ModelState.IsValid)
            {
                assignmentOfTool.AditionalInfo = AditionalInfo;


                db.Entry(assignmentOfTool).State = EntityState.Modified;
                db.SaveChanges();
                return(new JsonResult()
                {
                    Data = "1"
                });
            }

            return(new JsonResult()
            {
                Data = "0"
            });
        }