public async Task <IActionResult> Edit(string id, [Bind("transferOrderLineId,transferOrderId,productId,qty,createdAt")] TransferOrderLine transferOrderLine) { if (id != transferOrderLine.transferOrderLineId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(transferOrderLine); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TransferOrderLineExists(transferOrderLine.transferOrderLineId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["productId"] = new SelectList(_context.Product, "productId", "productCode", transferOrderLine.productId); ViewData["transferOrderId"] = new SelectList(_context.TransferOrder, "transferOrderId", "transferOrderNumber", transferOrderLine.transferOrderId); return(View(transferOrderLine)); }
public async Task <IActionResult> Create([Bind("transferOrderLineId,transferOrderId,productId,qty,createdAt")] TransferOrderLine transferOrderLine) { if (ModelState.IsValid) { _context.Add(transferOrderLine); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["productId"] = new SelectList(_context.Product, "productId", "productCode", transferOrderLine.productId); ViewData["transferOrderId"] = new SelectList(_context.TransferOrder, "transferOrderId", "transferOrderNumber", transferOrderLine.transferOrderId); return(View(transferOrderLine)); }
// GET: TransferOrderLine/Create public IActionResult Create(string masterid, string id) { var check = _context.TransferOrderLine.SingleOrDefault(m => m.transferOrderLineId == id); var selected = _context.TransferOrder.SingleOrDefault(m => m.transferOrderId == masterid); ViewData["productId"] = new SelectList(_context.Product, "productId", "productCode"); ViewData["transferOrderId"] = new SelectList(_context.TransferOrder, "transferOrderId", "transferOrderNumber"); if (check == null) { TransferOrderLine objline = new TransferOrderLine(); objline.transferOrder = selected; objline.transferOrderId = masterid; return(View(objline)); } else { return(View(check)); } }
public async Task <IActionResult> PostTransferOrderLine([FromBody] TransferOrderLine transferOrderLine) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TransferOrder transferOrder = await _context.TransferOrder.Where(x => x.transferOrderId.Equals(transferOrderLine.transferOrderId)).FirstOrDefaultAsync(); if (transferOrder.transferOrderStatus == TransferOrderStatus.Completed) { return(Json(new { success = false, message = "Lỗi. Không thẻ sửa [Completed]." })); } if (transferOrder.isIssued == true) { return(Json(new { success = false, message = "Lỗi. Không thể chỉnh sửa đơn hàng [Mở] đã xử lý sự cố hàng hóa" })); } if (transferOrder.isReceived == true) { return(Json(new { success = false, message = "Lỗi. Không thể chỉnh sửa đơn hàng [Mở] đã xử lý hàng hóa nhận được" })); } if (transferOrderLine.transferOrderLineId == string.Empty) { transferOrderLine.transferOrderLineId = Guid.NewGuid().ToString(); _context.TransferOrderLine.Add(transferOrderLine); await _context.SaveChangesAsync(); return(Json(new { success = true, message = "Add new data success." })); } else { _context.Update(transferOrderLine); await _context.SaveChangesAsync(); return(Json(new { success = true, message = "Edit data success." })); } }
public async Task <IActionResult> PostTransferOrderLine([FromBody] TransferOrderLine transferOrderLine) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TransferOrder transferOrder = await _context.TransferOrder.Where(x => x.transferOrderId.Equals(transferOrderLine.transferOrderId)).FirstOrDefaultAsync(); if (transferOrder.transferOrderStatus == TransferOrderStatus.Completed) { return(Json(new { success = false, message = "Σφάλμα. Δεν μπορεί να γίνει Επεξεργασία, Παραγγελίας που είναι [Ολοκληρωμένη]." })); } if (transferOrder.isIssued == true) { return(Json(new { success = false, message = "Σφάλμα. Can not edit [Open] order that already process the goods issue" })); } if (transferOrder.isReceived == true) { return(Json(new { success = false, message = "Σφάλμα. Δεν είναι δυνατή η επεξεργασία παραγγελίας που είναι [Ανοιχτή], και ήδη επεξεργάζεται την παραλαβή των προϊόντων" })); } if (transferOrderLine.transferOrderLineId == string.Empty) { transferOrderLine.transferOrderLineId = Guid.NewGuid().ToString(); _context.TransferOrderLine.Add(transferOrderLine); await _context.SaveChangesAsync(); return(Json(new { success = true, message = "Η Προσθήκη νέου στοιχείου μεταφοράς, έγινε με επιτυχία." })); } else { _context.Update(transferOrderLine); await _context.SaveChangesAsync(); return(Json(new { success = true, message = "Η Επεξεργασία του στοιχείου μεταφοράς, έγινε με επιτυχία." })); } }
public async Task <IActionResult> PostTransferOrderLine([FromBody] TransferOrderLine transferOrderLine) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TransferOrder transferOrder = await _context.TransferOrder.Where(x => x.transferOrderId.Equals(transferOrderLine.transferOrderId)).FirstOrDefaultAsync(); if (transferOrder.transferOrderStatus == TransferOrderStatus.Completed) { return(Json(new { success = false, message = "Error. Can not edit [Completed] order" })); } if (transferOrder.isIssued == true) { return(Json(new { success = false, message = "Error. Can not edit [Open] order that already process the goods issue" })); } if (transferOrder.isReceived == true) { return(Json(new { success = false, message = "Error. Can not edit [Open] order that already process the goods receive" })); } if (transferOrderLine.transferOrderLineId == string.Empty) { transferOrderLine.transferOrderLineId = Guid.NewGuid().ToString(); _context.TransferOrderLine.Add(transferOrderLine); await _context.SaveChangesAsync(); return(Json(new { success = true, message = "Add new data success." })); } else { _context.Update(transferOrderLine); await _context.SaveChangesAsync(); return(Json(new { success = true, message = "Edit data success." })); } }