コード例 #1
0
        public async Task <IActionResult> Edit(string id, [Bind("receivingLineId,receivingId,branchId,warehouseId,productId,qty,qtyReceive,qtyInventory,createdAt")] ReceivingLine receivingLine)
        {
            if (id != receivingLine.receivingLineId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(receivingLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReceivingLineExists(receivingLine.receivingLineId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["branchId"]    = new SelectList(_context.Branch, "branchId", "branchName", receivingLine.branchId);
            ViewData["productId"]   = new SelectList(_context.Product, "productId", "productCode", receivingLine.productId);
            ViewData["receivingId"] = new SelectList(_context.Receiving, "receivingId", "receivingNumber", receivingLine.receivingId);
            ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseName", receivingLine.warehouseId);
            return(View(receivingLine));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("receivingLineId,receivingId,branchId,warehouseId,productId,qty,qtyReceive,qtyInventory,createdAt")] ReceivingLine receivingLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(receivingLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["branchId"]    = new SelectList(_context.Branch, "branchId", "branchName", receivingLine.branchId);
            ViewData["productId"]   = new SelectList(_context.Product, "productId", "productCode", receivingLine.productId);
            ViewData["receivingId"] = new SelectList(_context.Receiving, "receivingId", "receivingNumber", receivingLine.receivingId);
            ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseName", receivingLine.warehouseId);
            return(View(receivingLine));
        }
コード例 #3
0
        // GET: ReceivingLine/Create
        public IActionResult Create(string masterid, string id)
        {
            var check    = _context.ReceivingLine.SingleOrDefault(m => m.receivingLineId == id);
            var selected = _context.Receiving.SingleOrDefault(m => m.receivingId == masterid);

            ViewData["branchId"]    = new SelectList(_context.Branch, "branchId", "branchName");
            ViewData["productId"]   = new SelectList(_context.Product, "productId", "productCode");
            ViewData["receivingId"] = new SelectList(_context.Receiving, "receivingId", "receivingNumber");
            ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseName");
            if (check == null)
            {
                ReceivingLine objline = new ReceivingLine();
                objline.receiving   = selected;
                objline.receivingId = masterid;
                return(View(objline));
            }
            else
            {
                return(View(check));
            }
        }
コード例 #4
0
        public async Task <IActionResult> PostReceivingLine([FromBody] ReceivingLine receivingLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (receivingLine.receivingLineId == string.Empty)
            {
                receivingLine.receivingLineId = Guid.NewGuid().ToString();
                _context.ReceivingLine.Add(receivingLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Add new data success." }));
            }
            else
            {
                _context.Update(receivingLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Edit data success." }));
            }
        }
コード例 #5
0
        public async Task <IActionResult> PostReceivingLine([FromBody] ReceivingLine receivingLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (receivingLine.receivingLineId == string.Empty)
            {
                receivingLine.receivingLineId = Guid.NewGuid().ToString();
                _context.ReceivingLine.Add(receivingLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Η Προσθήκη νέου στοιχείου Παραλαβής (GSRN) έγινε με επιτυχία." }));
            }
            else
            {
                _context.Update(receivingLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Η Επεξεργασία του στοιχείου Παραλαβής (GSRN) έγινε με επιτυχία." }));
            }
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("receivingId,purchaseOrderId,receivingNumber,receivingDate,vendorId,vendorDO,vendorInvoice,branchId,warehouseId,HasChild,createdAt")] Receiving receiving)
        {
            if (receiving.purchaseOrderId == "0" || receiving.warehouseId == "0")
            {
                TempData["StatusMessage"] = "Error. Purchase order or warehouse is not valid. Please select valid purchase order and warehouse";
                return(RedirectToAction(nameof(Create)));
            }

            if (ModelState.IsValid)
            {
                //check receiving
                Receiving check = await _context.Receiving.SingleOrDefaultAsync(x => x.purchaseOrderId.Equals(receiving.purchaseOrderId));

                if (check != null)
                {
                    ViewData["StatusMessage"] = "Error. Purchase order already received. " + check.receivingNumber;

                    ViewData["branchId"]        = new SelectList(_context.Branch, "branchId", "branchName");
                    ViewData["purchaseOrderId"] = new SelectList(_context.PurchaseOrder, "purchaseOrderId", "purchaseOrderNumber");
                    ViewData["vendorId"]        = new SelectList(_context.Vendor, "vendorId", "vendorName");
                    ViewData["warehouseId"]     = new SelectList(_context.Warehouse, "warehouseId", "warehouseName");

                    return(View(receiving));
                }
                receiving.warehouse = await _context.Warehouse.Include(x => x.branch).SingleOrDefaultAsync(x => x.warehouseId.Equals(receiving.warehouseId));

                receiving.branch        = receiving.warehouse.branch;
                receiving.purchaseOrder = await _context.PurchaseOrder.Include(x => x.vendor).SingleOrDefaultAsync(x => x.purchaseOrderId.Equals(receiving.purchaseOrderId));

                receiving.vendor = receiving.purchaseOrder.vendor;

                _context.Add(receiving);

                //change status of purchase order to completed
                receiving.purchaseOrder.purchaseOrderStatus = PurchaseOrderStatus.Completed;
                _context.PurchaseOrder.Update(receiving.purchaseOrder);

                await _context.SaveChangesAsync();

                //auto create receiving line, full receive
                List <PurchaseOrderLine> polines = new List <PurchaseOrderLine>();
                polines = _context.PurchaseOrderLine.Include(x => x.product).Where(x => x.purchaseOrderId.Equals(receiving.purchaseOrderId)).ToList();
                foreach (var item in polines)
                {
                    ReceivingLine line = new ReceivingLine();
                    line.receiving    = receiving;
                    line.product      = item.product;
                    line.qty          = item.qty;
                    line.qtyReceive   = item.qty;
                    line.qtyInventory = line.qtyReceive * 1;
                    line.branchId     = receiving.branchId;
                    line.warehouseId  = receiving.warehouseId;

                    _context.ReceivingLine.Add(line);
                    await _context.SaveChangesAsync();
                }

                return(RedirectToAction(nameof(Details), new { id = receiving.receivingId }));
            }
            ViewData["branchId"]        = new SelectList(_context.Branch, "branchId", "branchName", receiving.branchId);
            ViewData["purchaseOrderId"] = new SelectList(_context.PurchaseOrder, "purchaseOrderId", "purchaseOrderNumber", receiving.purchaseOrderId);
            ViewData["vendorId"]        = new SelectList(_context.Vendor, "vendorId", "vendorName", receiving.vendorId);
            ViewData["warehouseId"]     = new SelectList(_context.Warehouse, "warehouseId", "warehouseName", receiving.warehouseId);
            return(View(receiving));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("receivingId,purchaseOrderId,receivingNumber,receivingDate,vendorId,vendorDO,vendorInvoice,branchId,warehouseId,HasChild,createdAt")] Receiving receiving)
        {
            if (receiving.purchaseOrderId == "0" || receiving.warehouseId == "0")
            {
                TempData["StatusMessage"] = "Σφάλμα. Η παραγγελία αγοράς ή η αποθήκη δεν είναι έγκυρη. Επιλέξτε έγκυρη παραγγελία και αποθήκη";
                return(RedirectToAction(nameof(Create)));
            }

            if (ModelState.IsValid)
            {
                //check receiving
                Receiving check = await _context.Receiving.SingleOrDefaultAsync(x => x.purchaseOrderId.Equals(receiving.purchaseOrderId));

                if (check != null)
                {
                    ViewData["StatusMessage"] = "Σφάλμα. Η παραγγελία αγοράς έχει ήδη παραληφθεί. " + check.receivingNumber;

                    ViewData["branchId"]        = new SelectList(_context.Branch, "branchId", "branchName");
                    ViewData["purchaseOrderId"] = new SelectList(_context.PurchaseOrder, "purchaseOrderId", "purchaseOrderNumber");
                    ViewData["vendorId"]        = new SelectList(_context.Vendor, "vendorId", "vendorName");
                    ViewData["warehouseId"]     = new SelectList(_context.Warehouse, "warehouseId", "warehouseName");

                    return(View(receiving));
                }
                receiving.warehouse = await _context.Warehouse.Include(x => x.branch).SingleOrDefaultAsync(x => x.warehouseId.Equals(receiving.warehouseId));

                receiving.branch        = receiving.warehouse.branch;
                receiving.purchaseOrder = await _context.PurchaseOrder.Include(x => x.vendor).SingleOrDefaultAsync(x => x.purchaseOrderId.Equals(receiving.purchaseOrderId));

                receiving.vendor = receiving.purchaseOrder.vendor;

                _context.Add(receiving);

                //change status of purchase order to completed
                receiving.purchaseOrder.purchaseOrderStatus = PurchaseOrderStatus.Completed;
                _context.PurchaseOrder.Update(receiving.purchaseOrder);

                await _context.SaveChangesAsync();

                //auto create receiving line, full receive
                List <PurchaseOrderLine> polines = new List <PurchaseOrderLine>();
                polines = _context.PurchaseOrderLine.Include(x => x.product).Where(x => x.purchaseOrderId.Equals(receiving.purchaseOrderId)).ToList();
                foreach (var item in polines)
                {
                    ReceivingLine line = new ReceivingLine();
                    line.receiving    = receiving;
                    line.product      = item.product;
                    line.qty          = item.qty;
                    line.qtyReceive   = item.qty;
                    line.qtyInventory = line.qtyReceive * 1;
                    line.branchId     = receiving.branchId;
                    line.warehouseId  = receiving.warehouseId;

                    _context.ReceivingLine.Add(line);
                    await _context.SaveChangesAsync();
                }

                TempData["TransMessage"] = "Η Δημιουργία GSRN " + receiving.receivingNumber + " έγινε με επιτυχία";
                return(RedirectToAction(nameof(Details), new { id = receiving.receivingId }));
            }
            ViewData["branchId"]        = new SelectList(_context.Branch, "branchId", "branchName", receiving.branchId);
            ViewData["purchaseOrderId"] = new SelectList(_context.PurchaseOrder, "purchaseOrderId", "purchaseOrderNumber", receiving.purchaseOrderId);
            ViewData["vendorId"]        = new SelectList(_context.Vendor, "vendorId", "vendorName", receiving.vendorId);
            ViewData["warehouseId"]     = new SelectList(_context.Warehouse, "warehouseId", "warehouseName", receiving.warehouseId);
            return(View(receiving));
        }