public async Task <IActionResult> Edit(string id, [Bind("shipmentLineId,shipmentId,branchId,warehouseId,productId,qty,qtyShipment,qtyInventory,createdAt")] ShipmentLine shipmentLine) { if (id != shipmentLine.shipmentLineId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(shipmentLine); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShipmentLineExists(shipmentLine.shipmentLineId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["branchId"] = new SelectList(_context.Branch, "branchId", "branchId", shipmentLine.branchId); ViewData["productId"] = new SelectList(_context.Product, "productId", "productId", shipmentLine.productId); ViewData["shipmentId"] = new SelectList(_context.Shipment, "shipmentId", "shipmentId", shipmentLine.shipmentId); ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseId", shipmentLine.warehouseId); return(View(shipmentLine)); }
/// <summary> /// Saves the OpCo shipment line. /// </summary> /// <param name="shipmentLine">The shipment line.</param> /// <returns></returns> public static int SaveLine(ShipmentLine shipmentLine) { try { // Make sure the shipment line is valid if (shipmentLine.IsValid) { // Save the shipment line to the db shipmentLine.Id = DataAccessProvider.Instance().SaveOpCoShipmentLine(shipmentLine); // Get the checksum for the entity FrameworkController.GetChecksum(shipmentLine); } else { // Entity is not valid throw new InValidBusinessObjectException(shipmentLine); } } catch (Exception ex) { // Log an throw if configured to do so if (ExceptionPolicy.HandleException(ex, "Business Logic")) { throw; } // Failed! return(-1); } // Done return(shipmentLine.Id); }
public async Task <IActionResult> Create([Bind("shipmentLineId,shipmentId,branchId,warehouseId,productId,qty,qtyShipment,qtyInventory,createdAt")] ShipmentLine shipmentLine) { if (ModelState.IsValid) { _context.Add(shipmentLine); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["branchId"] = new SelectList(_context.Branch, "branchId", "branchId", shipmentLine.branchId); ViewData["productId"] = new SelectList(_context.Product, "productId", "productId", shipmentLine.productId); ViewData["shipmentId"] = new SelectList(_context.Shipment, "shipmentId", "shipmentId", shipmentLine.shipmentId); ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseId", shipmentLine.warehouseId); return(View(shipmentLine)); }
public ShipmentLine CreateShipmentLine(ShipmentLineInsert shipmentline) { using (SqlConnection connection = new SqlConnection(DefaultConnection)) { DynamicParameters p = new DynamicParameters(); p.Add("shipmentid", shipmentline.ShipmentID); p.Add("itemid", shipmentline.ItemID); p.Add("quantity", shipmentline.Quantity); p.Add("unitprice", shipmentline.UnitPrice); ShipmentLine result = connection.Query <ShipmentLine>("spCreateShipmentLine", p, commandType: CommandType.StoredProcedure).Single(); return(result); } }
// GET: ShipmentLine/Create public IActionResult Create(string masterid, string id) { var check = _context.ShipmentLine.SingleOrDefault(m => m.shipmentLineId == id); var selected = _context.Shipment.SingleOrDefault(m => m.shipmentId == masterid); ViewData["branchId"] = new SelectList(_context.Branch, "branchId", "branchId"); ViewData["productId"] = new SelectList(_context.Product, "productId", "productId"); ViewData["shipmentId"] = new SelectList(_context.Shipment, "shipmentId", "shipmentId"); ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseId"); if (check == null) { ShipmentLine objline = new ShipmentLine(); objline.shipment = selected; objline.shipmentId = masterid; return(View(objline)); } else { return(View(check)); } }
public async Task <IActionResult> PostShipmentLine([FromBody] ShipmentLine shipmentLine) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (shipmentLine.shipmentLineId == string.Empty) { shipmentLine.shipmentLineId = Guid.NewGuid().ToString(); _context.ShipmentLine.Add(shipmentLine); await _context.SaveChangesAsync(); return(Json(new { success = true, message = "Η Προσθήκη στοιχείου αποστολής, έγινε με επιτυχία." })); } else { _context.Update(shipmentLine); await _context.SaveChangesAsync(); return(Json(new { success = true, message = "Η Επεξεργασία στοιχείου αποστολής, έγινε με επιτυχία." })); } }
public async Task <IActionResult> PostShipmentLine([FromBody] ShipmentLine shipmentLine) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (shipmentLine.shipmentLineId == string.Empty) { shipmentLine.shipmentLineId = Guid.NewGuid().ToString(); _context.ShipmentLine.Add(shipmentLine); await _context.SaveChangesAsync(); return(Json(new { success = true, message = "Add new data success." })); } else { _context.Update(shipmentLine); await _context.SaveChangesAsync(); return(Json(new { success = true, message = "Edit data success." })); } }
public async Task <IActionResult> Create([Bind("shipmentId,salesOrderId,shipmentNumber,shipmentDate,customerId,customerPO,invoice,branchId,warehouseId,expeditionType,expeditionMode,HasChild,createdAt")] Shipment shipment) { if (shipment.salesOrderId == "0" || shipment.warehouseId == "0") { TempData["StatusMessage"] = "Error. Sales order or warehouse is not valid. Please select valid sales order and warehouse"; return(RedirectToAction(nameof(Create))); } if (ModelState.IsValid) { //check sales order Shipment check = await _context.Shipment .Include(x => x.salesOrder) .SingleOrDefaultAsync(x => x.salesOrderId.Equals(shipment.salesOrderId)); if (check != null) { ViewData["StatusMessage"] = "Error. Sales order already shipped. " + check.shipmentNumber; ViewData["branchId"] = new SelectList(_context.Branch, "branchId", "branchName"); ViewData["customerId"] = new SelectList(_context.Customer, "customerId", "customerName"); ViewData["salesOrderId"] = new SelectList(_context.SalesOrder, "salesOrderId", "salesOrderNumber"); ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseName"); return(View(shipment)); } //check stock bool isStockOK = true; string productList = ""; List <SalesOrderLine> stocklines = new List <SalesOrderLine>(); stocklines = _context.SalesOrderLine .Include(x => x.product) .Where(x => x.salesOrderId.Equals(shipment.salesOrderId)).ToList(); foreach (var item in stocklines) { VMStock stock = _netcoreService.GetStockByProductAndWarehouse(item.productId, shipment.warehouseId); if (stock != null) { if (stock.QtyOnhand < item.qty) { isStockOK = false; productList = productList + " [" + item.product.productCode + "] "; } } else { isStockOK = false; } } if (!isStockOK) { TempData["StatusMessage"] = "Error. Stock quantity problem, please check your on hand stock. " + productList; return(RedirectToAction(nameof(Create))); } shipment.warehouse = await _context.Warehouse.Include(x => x.branch).SingleOrDefaultAsync(x => x.warehouseId.Equals(shipment.warehouseId)); shipment.branch = shipment.warehouse.branch; shipment.salesOrder = await _context.SalesOrder.Include(x => x.customer).SingleOrDefaultAsync(x => x.salesOrderId.Equals(shipment.salesOrderId)); shipment.customer = shipment.salesOrder.customer; //change status of salesorder shipment.salesOrder.salesOrderStatus = SalesOrderStatus.Completed; _context.Update(shipment.salesOrder); _context.Add(shipment); await _context.SaveChangesAsync(); //auto create shipment line, full shipment List <SalesOrderLine> solines = new List <SalesOrderLine>(); solines = _context.SalesOrderLine.Include(x => x.product).Where(x => x.salesOrderId.Equals(shipment.salesOrderId)).ToList(); foreach (var item in solines) { ShipmentLine line = new ShipmentLine(); line.shipment = shipment; line.product = item.product; line.qty = item.qty; line.qtyShipment = item.qty; line.qtyInventory = line.qtyShipment * -1; line.branchId = shipment.branchId; line.warehouseId = shipment.warehouseId; _context.ShipmentLine.Add(line); await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Details), new { id = shipment.shipmentId })); } ViewData["branchId"] = new SelectList(_context.Branch, "branchId", "branchName", shipment.branchId); ViewData["customerId"] = new SelectList(_context.Customer, "customerId", "customerName", shipment.customerId); ViewData["salesOrderId"] = new SelectList(_context.SalesOrder, "salesOrderId", "salesOrderNumber", shipment.salesOrderId); ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseName", shipment.warehouseId); return(View(shipment)); }
public async Task <IActionResult> Create([Bind("shipmentId,HasChild,branchId,createdAt,customerId,customerPO,expeditionMode,expeditionType,invoiceNumber,salesOrderId,shipmentDate,shipmentNumber,warehouseId,EmployeeId")] Shipment shipment) { if (shipment.salesOrderId == "0" || shipment.warehouseId == "0") { TempData["StatusMessage"] = "Σφάλμα. Η εντολή πώλησης ή η αποθήκη δεν είναι έγκυρη. Επιλέξτε έγκυρη παραγγελία και αποθήκη πωλήσεων"; return(RedirectToAction(nameof(Create))); } if (ModelState.IsValid) { //check sales order Shipment check = await _context.Shipment .Include(x => x.salesOrder) .Include(x => x.Employee) .SingleOrDefaultAsync(x => x.salesOrderId.Equals(shipment.salesOrderId)); if (check != null) { ViewData["salesOrderId"] = new SelectList(_context.SalesOrder.Where(x => x.salesOrderStatus == SalesOrderStatus.Open), "salesOrderId", "SalesOrderName"); ViewData["StatusMessage"] = "Σφάλμα. Η εντολή πώλησης έχει ήδη αποσταλεί. " + check.shipmentNumber; ViewData["branchId"] = new SelectList(_context.Branch, "branchId", "branchName"); ViewData["customerId"] = new SelectList(_context.Customer, "customerId", "customerName"); ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseName"); ViewData["employeeId"] = new SelectList(_context.Employee, "EmployeeId", "DisplayName"); return(View(shipment)); } //check stock bool isStockOK = true; string productList = ""; List <SalesOrderLine> stocklines = new List <SalesOrderLine>(); stocklines = _context.SalesOrderLine .Include(x => x.Product) .Where(x => x.SalesOrderId.Equals(shipment.salesOrderId)).ToList(); foreach (var item in stocklines) { VMStock stock = _netcoreService.GetStockByProductAndWarehouse(item.ProductId, shipment.warehouseId); if (stock != null) { if (stock.QtyOnhand < item.Qty) { isStockOK = false; productList = productList + " [" + item.Product.productCode + "] "; } } else { isStockOK = false; } } if (!isStockOK) { TempData["StatusMessage"] = "Σφάλμα. Υπάρχει πρόβλημα στην ποσότητα αποθεμάτων, ελέγξτε το απόθεμά σας. " + productList; return(RedirectToAction(nameof(Create))); } shipment.warehouse = await _context.Warehouse.Include(x => x.branch).SingleOrDefaultAsync(x => x.warehouseId.Equals(shipment.warehouseId)); shipment.branch = shipment.warehouse.branch; shipment.salesOrder = await _context.SalesOrder.Include(x => x.customer).SingleOrDefaultAsync(x => x.salesOrderId.Equals(shipment.salesOrderId)); shipment.customer = shipment.salesOrder.customer; //change status of salesorder shipment.salesOrder.salesOrderStatus = SalesOrderStatus.Completed; _context.Update(shipment.salesOrder); shipment.shipmentNumber = _numberSequence.GetNumberSequence("ΔΑ"); _context.Add(shipment); await _context.SaveChangesAsync(); //auto create shipment line, full shipment List <SalesOrderLine> solines = new List <SalesOrderLine>(); solines = _context.SalesOrderLine.Include(x => x.Product).Where(x => x.SalesOrderId.Equals(shipment.salesOrderId)).ToList(); foreach (var item in solines) { ShipmentLine line = new ShipmentLine(); line.shipment = shipment; line.product = item.Product; line.qty = item.Qty; line.qtyShipment = item.Qty; line.qtyInventory = line.qtyShipment * -1; line.branchId = shipment.branchId; line.warehouseId = shipment.warehouseId; _context.ShipmentLine.Add(line); await _context.SaveChangesAsync(); } TempData["TransMessage"] = "Η Δημιουργία της Αποστολής " + shipment.shipmentNumber + " έγινε με Επιτυχία"; return(RedirectToAction(nameof(Details), new { id = shipment.shipmentId })); } ViewData["branchId"] = new SelectList(_context.Branch, "branchId", "branchName", shipment.branchId); ViewData["customerId"] = new SelectList(_context.Customer, "customerId", "customerName", shipment.customerId); ViewData["salesOrderId"] = new SelectList(_context.SalesOrder.Where(x => x.salesOrderStatus == SalesOrderStatus.Open), "salesOrderId", "SalesOrderName", shipment.salesOrderId); ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseName", shipment.warehouseId); ViewData["employeeId"] = new SelectList(_context.Employee, "EmployeeId", "DisplayName", shipment.EmployeeId); return(View(shipment)); }
public ShipmentDetail CreateShipmentDetail(ShipmentDetailInsert shipmentdetail) { using (SqlConnection connection = new SqlConnection(DefaultConnection)) { connection.Open(); SqlTransaction transaction = connection.BeginTransaction(); ShipmentDetail shipmentDetail = new ShipmentDetail(); DynamicParameters p = new DynamicParameters(); p.Add("businessid", shipmentdetail.Shipment.BusinessID); p.Add("shipperid", shipmentdetail.Shipment.ShipperID); p.Add("customerid", shipmentdetail.Shipment.CustomerID); p.Add("originffw", shipmentdetail.Shipment.OriginFFW); p.Add("origin3pl", shipmentdetail.Shipment.Origin3PL); p.Add("destinationffw", shipmentdetail.Shipment.DestinationFFW); p.Add("destination3pl", shipmentdetail.Shipment.Destination3PL); p.Add("hblnumber", shipmentdetail.Shipment.HBLNumber); p.Add("mblnumber", shipmentdetail.Shipment.MBLNumber); p.Add("containernumber", shipmentdetail.Shipment.ContainerNumber); p.Add("etd", shipmentdetail.Shipment.ETD); p.Add("eta", shipmentdetail.Shipment.ETA); p.Add("txl", shipmentdetail.Shipment.TXL); p.Add("isffiled", shipmentdetail.Shipment.ISFFiled); p.Add("deliverylocationid", shipmentdetail.Shipment.DeliveryLocationID); p.Add("status", shipmentdetail.Shipment.Status); p.Add("memo", shipmentdetail.Shipment.Memo); p.Add("shipperreference", shipmentdetail.Shipment.ShipperReference); p.Add("createdby", shipmentdetail.Shipment.CreatedBy); Shipment shipment = connection.Query <Shipment>("spCreateShipment", p, transaction, commandType: CommandType.StoredProcedure).Single(); shipmentDetail.Shipment = shipment; foreach (ShipmentLineInsert _ShipmentLine in shipmentdetail.ShipmentLines) { DynamicParameters p2 = new DynamicParameters(); p2.Add("shipmentid", shipment.ShipmentID); ShipmentLine shipmentLine = connection.Query <ShipmentLine>("spCreateShipmentLine", p2, transaction, commandType: CommandType.StoredProcedure).Single(); shipmentDetail.ShipmentLines.Add(shipmentLine); } foreach (ShipmentPackageInsert _ShipmentPackage in shipmentdetail.ShipmentPackages) { DynamicParameters p2 = new DynamicParameters(); p2.Add("shipmentid", shipment.ShipmentID); ShipmentPackage shipmentPackge = connection.Query <ShipmentPackage>("spCreateShipmentPackage", p2, transaction, commandType: CommandType.StoredProcedure).Single(); shipmentDetail.ShipmentPackages.Add(shipmentPackge); } foreach (ShipmentFeeInsert _ShipmentFee in shipmentdetail.ShipmentFees) { DynamicParameters p2 = new DynamicParameters(); p2.Add("shipmentid", shipment.ShipmentID); ShipmentFee shipmentFee = connection.Query <ShipmentFee>("spCreateShipmentFee", p2, transaction, commandType: CommandType.StoredProcedure).Single(); shipmentDetail.ShipmentFees.Add(shipmentFee); } foreach (ShipmentContactInsert _ShipmentContact in shipmentdetail.ShipmentContacts) { DynamicParameters p2 = new DynamicParameters(); p2.Add("shipmentid", shipment.ShipmentID); ShipmentContact shipmentContact = connection.Query <ShipmentContact>("spCreateShipmentContact", p2, transaction, commandType: CommandType.StoredProcedure).Single(); shipmentDetail.ShipmentContacts.Add(shipmentContact); } transaction.Commit(); return(shipmentDetail); } }