public async Task Should_Success_UpdateThenAddMany() { var dbContext = _dbContext(GetCurrentMethod()); DeliveryOrderFacade facade = new DeliveryOrderFacade(dbContext, GetServiceProvider(GetCurrentMethod()).Object); DeliveryOrder model = await _dataUtil(facade, dbContext, GetCurrentMethod()).GetTestData(USERNAME); foreach (var item in model.Items) { foreach (var detail in item.Details) { detail.DOQuantity -= 1; } } var Response = await facade.Update((int)model.Id, model, USERNAME); Assert.NotEqual(0, Response); var newModelForAddItem = await _dataUtil(facade, dbContext, GetCurrentMethod()).GetNewData(USERNAME); DeliveryOrderItem newModelItem = newModelForAddItem.Items.FirstOrDefault(); model.Items.Add(newModelItem); model.Items.Add(newModelItem); var ResponseAddItem = await facade.Update((int)model.Id, model, USERNAME); Assert.NotEqual(0, ResponseAddItem); }
public IActionResult DeleteDeliveryOrderItem(long id) { DeliveryOrderItem DeliveryOrderItem = Deliveryorderitem_repo.Find(id); if (DeliveryOrderItem == null) { return(NotFound()); } Deliveryorderitem_repo.Delete(DeliveryOrderItem); return(Ok()); }
private void wizardFromDOToolStripButton_Click(object sender, EventArgs e) { IList addedPI = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { DeliveryOrderItem pi = (DeliveryOrderItem)itemsDataGrid[GRNNoColumn.Index, i].Tag; if (pi == null) { continue; } addedPI.Add(pi.ID); } using (SearchDOForCussInvoiceForm frm = new SearchDOForCussInvoiceForm( ((Customer)supplierkryptonComboBox.SelectedItem), addedPI, m_mainForm.CurrentUser, dateKryptonDateTimePicker.Value)) { frm.ShowDialog(); IList result = frm.RESULT; foreach (DeliveryOrderItem item in result) { if (item.SO_ITEM.ID > 0) { item.SO_ITEM = r_po.FindSalesOrderItem(item.SO_ITEM.ID); } Part p = item.PART; int row = itemsDataGrid.Rows.Add(); itemsDataGrid[codeColumn.Index, row].Tag = p; itemsDataGrid[GRNNoColumn.Index, row].Tag = item; itemsDataGrid[scanColumn.Index, row].Value = p.BARCODE; itemsDataGrid[GRNNoColumn.Index, row].Value = item.EVENT.CODE; itemsDataGrid[codeColumn.Index, row].Value = p.CODE; itemsDataGrid[nameColumn.Index, row].Value = p.NAME; itemsDataGrid[QtyColumn.Index, row].Value = item.OUTSTANDING_AMOUNT_TO_SR; p.UNIT = (Unit)r_unit.GetById(item.UNIT); itemsDataGrid[unitColumn.Index, row].Value = p.UNIT.ToString(); //itemsDataGrid[unitColumn.Index, row].Value = item.UNIT.ToString(); // if (item.UNIT.ID == item.SO_ITEM.UNIT.ID) //{ //itemsDataGrid[priceColumn.Index, row].Value = item.SO_ITEM != null ? item.SO_ITEM.PRICE : 0d; itemsDataGrid[priceColumn.Index, row].Value = item.SO_ITEM != null ? item.SO_ITEM.PRICE_IN_SMALLEST_UNIT : 0d; itemsDataGrid[discpercentColumn.Index, row].Value = item.SO_ITEM != null ? item.SO_ITEM.DISC_PERCENT : 0; itemsDataGrid[discAmountColumn.Index, row].Value = item.SO_ITEM != null ? item.SO_ITEM.DISC_AMOUNT : 0d; itemsDataGrid[totalDiscColumn.Index, row].Value = item.SO_ITEM != null ? item.SO_ITEM.TOTAL_DISCOUNT : 0d; itemsDataGrid[notesColumn.Index, row].Value = item.SO_ITEM != null ? item.SO_ITEM.NOTES : ""; itemsDataGrid[discabcColumn.Index, row].Value = item.SO_ITEM != null ? item.SO_ITEM.DISC_ABC : ""; itemsDataGrid[totalAmountColumn.Index, row].Value = item.SO_ITEM != null ? item.SO_ITEM.SUBTOTAL : 0d; itemsDataGrid[warehouseColumn.Index, row].Value = r_warehouse.GetById(item.WAREHOUSE).ToString(); // } updateSubtotal(row); } } }
private void AddResult() { for (int i = 0; i < gridData.Rows.Count; i++) { bool check = Convert.ToBoolean(gridData[checkColumn.Index, i].Value); if (!check) { continue; } DeliveryOrderItem pi = (DeliveryOrderItem)gridData.Rows[i].Tag; RESULT.Add(pi); } }
public ActionResult SubmitOrder(long orderId) { Order order = new Order(); try { order = _orderRepository.GetOrderByOrderId(orderId); _orderRepository.UpdateOrder(order); //Generate delivery order string beginSerialNumber = "CK-" + DateTime.Now.ToString("yyyyMMdd"); string maxDeliveryNumberStr = _deliveryOrderRepository.GetMaxDeliveryOrderNumber(beginSerialNumber); DeliveryOrder deliveryOrder = new DeliveryOrder(); deliveryOrder.DeliveryOrderNumber = beginSerialNumber + "-" + maxDeliveryNumberStr; deliveryOrder.DeliveryDate = DateTime.Now; deliveryOrder.TotalRMBInChinese = MathHelper.ConvertToChinese((Double)order.TotalAmount); deliveryOrder.TotalRMBInNumberic = order.TotalAmount.ToString(); deliveryOrder.OrderId = order.Id; long currentDeliveryOrderId = _deliveryOrderRepository.AddDeliveryOrder(deliveryOrder); List <OrderItem> orderItems = order.OrderItems.ToList(); foreach (var item in orderItems) { DeliveryOrderItem deliveryOrderItem = new DeliveryOrderItem(); deliveryOrderItem.ProductName = item.Product.ProductName; deliveryOrderItem.Unit = "件"; deliveryOrderItem.OutNumber = item.Quantity; deliveryOrderItem.PricePerProduct = item.UnitPrice; deliveryOrderItem.TotalPrice = item.Quantity * item.UnitPrice; deliveryOrderItem.DeliveryOrderId = currentDeliveryOrderId; _deliveryOrderItemRepository.AddDeliveryOrderItem(deliveryOrderItem); } //Generate delivery note DeliveryNote deliveryNote = new DeliveryNote(); deliveryNote.DeliveryNoteNumber = "PS-" + DateTime.Now.ToString("yyyyMMdd") + "-" + maxDeliveryNumberStr; //Generate QR Code deliveryNote.QRCodeImgURL = QRCodeHelper.GetQRImage(deliveryNote.DeliveryNoteNumber); deliveryNote.OrderId = order.Id; _deliveryNoteRepository.AddDeliveryNote(deliveryNote); } catch (Exception ex) { } return(View("SubmitOrder", order)); }
private IList getItems() { IList items = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { Part p = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (itemsDataGrid[unitColumn.Index, i].Value == null) { continue; } Unit u = (Unit)Utils.FindEntityInList(itemsDataGrid[unitColumn.Index, i].Value.ToString(), m_units); if ((p == null) || (u == null)) { continue; } POSItem st = (POSItem)itemsDataGrid.Rows[i].Tag; if (st == null) { st = new POSItem(); } itemsDataGrid.Rows[i].Tag = st; st.EVENT = m_si; st.PART = p; st.WAREHOUSE = (Warehouse)Utils.FindEntityInList(itemsDataGrid[warehouseColumn.Index, i].Value.ToString(), m_warehouses); st.QYTAMOUNT = Convert.ToDouble(itemsDataGrid[QtyColumn.Index, i].Value); st.UNIT = u; st.PRICE = Convert.ToDouble(itemsDataGrid[priceColumn.Index, i].Value); st.DISC_PERCENT = Convert.ToDouble(itemsDataGrid[discpercentColumn.Index, i].Value); st.DISC_AMOUNT = Convert.ToDouble(itemsDataGrid[discAmountColumn.Index, i].Value); st.TOTAL_DISCOUNT = Convert.ToDouble(itemsDataGrid[totalDiscColumn.Index, i].Value); st.NOTES = itemsDataGrid[notesColumn.Index, i].Value == null ? "" : itemsDataGrid[notesColumn.Index, i].Value.ToString(); st.DISC_ABC = itemsDataGrid[discabcColumn.Index, i].Value == null ? "" : itemsDataGrid[discabcColumn.Index, i].Value.ToString(); st.DISC_A = splitDiscString(st.DISC_ABC, 0); st.DISC_B = splitDiscString(st.DISC_ABC, 1); st.DISC_C = splitDiscString(st.DISC_ABC, 2); st.SUBTOTAL = Convert.ToDouble(itemsDataGrid[totalAmountColumn.Index, i].Value); DeliveryOrderItem grn = (DeliveryOrderItem)itemsDataGrid[GRNNoColumn.Index, i].Tag; st.DO_ITEM = grn; if (st.QYTAMOUNT == 0) { continue; } items.Add(st); } return(items); }
private void updateReturned() { for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { DeliveryOrderItem st = (DeliveryOrderItem)itemsDataGrid.Rows[i].Tag; if (st == null) { continue; } Part p = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (itemsDataGrid[unitColumn.Index, i].Value == null) { continue; } p.UNIT = (Unit)r_unit.GetById(p.UNIT); itemsDataGrid[returnedColumn.Index, i].Value = r_grn.GetReturned(st.ID); itemsDataGrid[returnedunitColumn.Index, i].Value = p.UNIT.ToString(); } }
private IList getItems() { IList items = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { SalesOrderItem poi = (SalesOrderItem)itemsDataGrid[scanColumn.Index, i].Tag; if (poi == null) { continue; } Part p = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (itemsDataGrid[unitColumn.Index, i].Value == null) { continue; } Unit u = (Unit)Utils.FindEntityInList(itemsDataGrid[unitColumn.Index, i].Value.ToString(), m_units); if ((p == null) || (u == null)) { continue; } DeliveryOrderItem st = (DeliveryOrderItem)itemsDataGrid.Rows[i].Tag; if (st == null) { st = new DeliveryOrderItem(); } itemsDataGrid.Rows[i].Tag = st; st.EVENT = m_do; st.PART = p; st.WAREHOUSE = (Warehouse)Utils.FindEntityInList(itemsDataGrid[warehouseColumn.Index, i].Value.ToString(), m_warehouses); st.QYTAMOUNT = Convert.ToDouble(itemsDataGrid[QtyColumn.Index, i].Value); st.UNIT = u; st.SO_ITEM = poi; st.NOTES = itemsDataGrid[notesColumn.Index, i].Value == null ? "" : itemsDataGrid[notesColumn.Index, i].Value.ToString(); if (st.QYTAMOUNT == 0) { continue; } items.Add(st); } return(items); }
void Post(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (m_prn.POSTED) { r_prn.Revise(m_prn.ID); m_prn.POSTED = false; KryptonMessageBox.Show("Transaction has been UNPOSTED", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { r_prn.Confirm(m_prn.ID); m_prn.POSTED = true; KryptonMessageBox.Show("Transaction has been POSTED", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } setEnableForm(false); setEditMode(EditMode.View); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { DeliveryOrderItem poi = (DeliveryOrderItem)itemsDataGrid[scanColumn.Index, i].Tag; if (poi == null) { continue; } itemsDataGrid[OutstandingPOColumn.Index, i].Value = r_grn.GetReturned(poi.ID); } } catch (Exception x) { KryptonMessageBox.Show(x.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { this.Cursor = Cursors.Default; } }
void dataItemskryptonDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (m_editMode == EditMode.View) { return; } itemsDataGrid.Rows[e.RowIndex].ErrorText = ""; if (!itemsDataGrid[e.ColumnIndex, e.RowIndex].IsInEditMode) { return; } if (e.ColumnIndex == scanColumn.Index) { if (!((DataGridViewTextBoxCell)itemsDataGrid[scanColumn.Index, e.RowIndex]).IsInEditMode) { return; } if (e.FormattedValue.ToString() == "") { return; } IList result = r_part.SearchActivePart(e.FormattedValue.ToString(), true); if (result.Count == 1) { Part p = (Part)result[0]; for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { if (i == e.RowIndex) { continue; } Part pi = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (pi == null) { continue; } if (pi.ID == p.ID) { itemsDataGrid.Rows[e.RowIndex].ErrorText = "Part : " + p.NAME + " already add."; e.Cancel = true; return; } } itemsDataGrid[codeColumn.Index, e.RowIndex].Tag = p; itemsDataGrid[GRNNoColumn.Index, e.RowIndex].Tag = null; itemsDataGrid[GRNNoColumn.Index, e.RowIndex].Value = ""; itemsDataGrid[scanColumn.Index, e.RowIndex].Value = p.BARCODE; itemsDataGrid[codeColumn.Index, e.RowIndex].Value = p.CODE; itemsDataGrid[nameColumn.Index, e.RowIndex].Value = p.NAME; //dataItemskryptonDataGridView[QtyColumn.Index, e.RowIndex].Value = 0; //unitColumn.Items.Clear(); // IList units = r_part.GetAllUnit(p.ID, p.UNIT.ID); //Utils.GetListCode(unitColumn.Items, units); p.UNIT = (Unit)r_unit.GetById(p.UNIT); itemsDataGrid[unitColumn.Index, e.RowIndex].Value = p.UNIT.ToString(); itemsDataGrid[priceColumn.Index, e.RowIndex].Value = r_si.GetTheLatestSIPrice(((Customer)supplierkryptonComboBox.SelectedItem).ID, p.ID, p.UNIT.ID); //dataItemskryptonDataGridView[totalAmountColumn.Index, e.RowIndex].Value = 0; itemsDataGrid[warehouseColumn.Index, e.RowIndex].Value = m_warehouses[0].ToString(); } if ((result.Count == 0) || (result.Count > 1)) { using (SearchPartForm fr = new SearchPartForm(e.FormattedValue.ToString(), result)) { fr.ShowDialog(); Part p = fr.PART; if (p == null) { p = (Part)itemsDataGrid[codeColumn.Index, e.RowIndex].Tag; if (p == null) { e.Cancel = true; return; } } else { for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { if (i == e.RowIndex) { continue; } Part pi = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (pi == null) { continue; } if (pi.ID == p.ID) { itemsDataGrid.Rows[e.RowIndex].ErrorText = "Part : " + p.NAME + " already add."; e.Cancel = true; return; } } itemsDataGrid[codeColumn.Index, e.RowIndex].Tag = p; itemsDataGrid[GRNNoColumn.Index, e.RowIndex].Tag = null; itemsDataGrid[GRNNoColumn.Index, e.RowIndex].Value = ""; itemsDataGrid[scanColumn.Index, e.RowIndex].Value = p.BARCODE; itemsDataGrid[codeColumn.Index, e.RowIndex].Value = p.CODE; itemsDataGrid[nameColumn.Index, e.RowIndex].Value = p.NAME; //dataItemskryptonDataGridView[QtyColumn.Index, e.RowIndex].Value = 0; //unitColumn.Items.Clear(); //IList units = r_part.GetAllUnit(p.ID, p.UNIT.ID); //Utils.GetListCode(unitColumn.Items, units); p.UNIT = (Unit)r_unit.GetById(p.UNIT); itemsDataGrid[unitColumn.Index, e.RowIndex].Value = p.UNIT.ToString(); itemsDataGrid[priceColumn.Index, e.RowIndex].Value = r_si.GetTheLatestSIPrice(((Customer)supplierkryptonComboBox.SelectedItem).ID, p.ID, p.UNIT.ID); // dataItemskryptonDataGridView[totalAmountColumn.Index, e.RowIndex].Value = 0; itemsDataGrid[warehouseColumn.Index, e.RowIndex].Value = m_warehouses[0].ToString(); } } } } if (e.ColumnIndex == discabcColumn.Index) { if (e.FormattedValue.ToString() == "") { return; } else { try { splitDiscString(e.FormattedValue.ToString(), 0); splitDiscString(e.FormattedValue.ToString(), 1); splitDiscString(e.FormattedValue.ToString(), 2); } catch (Exception x) { itemsDataGrid.Rows[e.RowIndex].ErrorText = x.Message; e.Cancel = true; return; } } } if (e.ColumnIndex == QtyColumn.Index || e.ColumnIndex == unitColumn.Index) { DeliveryOrderItem item = (DeliveryOrderItem)itemsDataGrid[GRNNoColumn.Index, e.RowIndex].Tag; if (item != null) { if (item.ID == 0) { return; } e.Cancel = true; itemsDataGrid.Rows[e.RowIndex].ErrorText = "DO Qty / Unit can not change"; } } }
private void loadMovement() { movemntkryptonDataGridView.Rows.Clear(); if (m_part.ID == 0) { return; } IList movs = r_part.GetAllEvents(m_part.ID); foreach (EventItem itm in movs) { int r = movemntkryptonDataGridView.Rows.Add(); movemntkryptonDataGridView[dateMovementColumn.Index, r].Value = itm.EVENT.TRANSACTION_DATE; movemntkryptonDataGridView[eventCodeMovementColumn.Index, r].Value = itm.EVENT.CODE; movemntkryptonDataGridView[eventTypeMovementColumn.Index, r].Value = itm.STOCK_CARD_ENTRY_TYPE.ToString(); movemntkryptonDataGridView[QtyMovementColumn.Index, r].Value = itm.GetAmountInSmallestUnit(); movemntkryptonDataGridView[unitMovementColumn.Index, r].Value = m_part.UNIT.CODE; movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = "-"; switch (itm.STOCK_CARD_ENTRY_TYPE) { case StockCardEntryType.PurchaseOrder: PurchaseOrderItem pi = (PurchaseOrderItem)itm; PurchaseOrder p = (PurchaseOrder)pi.EVENT; p.SUPPLIER = (Supplier)r_sup.GetById(p.SUPPLIER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = p.SUPPLIER.NAME; break; case StockCardEntryType.SalesOrder: SalesOrderItem soi = (SalesOrderItem)itm; SalesOrder so = (SalesOrder)soi.EVENT; so.CUSTOMER = (Customer)r_cus.GetById(so.CUSTOMER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = so.CUSTOMER.NAME; break; case StockCardEntryType.GoodReceiveNote: GoodReceiveNoteItem grni = (GoodReceiveNoteItem)itm; GoodReceiveNote grn = (GoodReceiveNote)grni.EVENT; grn.SUPPLIER = (Supplier)r_sup.GetById(grn.SUPPLIER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = grn.SUPPLIER.NAME; break; case StockCardEntryType.DeliveryOrder: DeliveryOrderItem doi = (DeliveryOrderItem)itm; DeliveryOrder dor = (DeliveryOrder)doi.EVENT; dor.CUSTOMER = (Customer)r_cus.GetById(dor.CUSTOMER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = dor.CUSTOMER.NAME; break; case StockCardEntryType.SupplierInvoice: SupplierInvoiceItem sii = (SupplierInvoiceItem)itm; SupplierInvoice si = (SupplierInvoice)sii.EVENT; si.SUPPLIER = (Supplier)r_sup.GetById(si.SUPPLIER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = si.SUPPLIER.NAME; break; case StockCardEntryType.CustomerInvoice: CustomerInvoiceItem cii = (CustomerInvoiceItem)itm; CustomerInvoice ci = (CustomerInvoice)cii.EVENT; ci.CUSTOMER = (Customer)r_cus.GetById(ci.CUSTOMER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = ci.CUSTOMER.NAME; break; case StockCardEntryType.PurchaseReturn: PurchaseReturnItem pri = (PurchaseReturnItem)itm; PurchaseReturn pr = (PurchaseReturn)pri.EVENT; pr.SUPPLIER = (Supplier)r_sup.GetById(pr.SUPPLIER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = pr.SUPPLIER.NAME; break; case StockCardEntryType.SalesReturn: SalesReturnItem sri = (SalesReturnItem)itm; SalesReturn sr = (SalesReturn)sri.EVENT; sr.CUSTOMER = (Customer)r_cus.GetById(sr.CUSTOMER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = sr.CUSTOMER.NAME; break; } movemntkryptonDataGridView[statusMovementColumn.Index, r].Value = itm.EVENT.POSTED.ToString(); } UserSetting.AddNumberToGrid(movemntkryptonDataGridView); }
public async Task Should_Success_UpdateThenAdd() { var dbContext = _dbContext(GetCurrentMethod() + "ThenAdd"); DeliveryOrderFacade facade = new DeliveryOrderFacade(dbContext, GetServiceProvider(GetCurrentMethod() + "ThenAdd").Object); DeliveryOrder model = await _dataUtil(facade, dbContext, GetCurrentMethod() + "ThenAdd").GetTestData(USERNAME); foreach (var item in model.Items) { foreach (var detail in item.Details) { detail.DOQuantity -= 1; } } foreach (var item in dbContext.InternalPurchaseOrderFulfillments.ToList()) { dbContext.Entry(item).State = EntityState.Detached; } var Response = await facade.Update((int)model.Id, model, USERNAME); Assert.NotEqual(0, Response); DeliveryOrderItem oldItem = model.Items.FirstOrDefault(); DeliveryOrderDetail oldDetail = oldItem.Details.FirstOrDefault(); DeliveryOrderItem newDuplicateItem = new DeliveryOrderItem { EPOId = oldItem.EPOId, EPONo = oldItem.EPONo, Details = new List <DeliveryOrderDetail>() }; DeliveryOrderDetail oldDuplicateDetail = new DeliveryOrderDetail { EPODetailId = oldDetail.EPODetailId, POItemId = oldDetail.POItemId, PRId = oldDetail.PRId, PRNo = oldDetail.PRNo, PRItemId = oldDetail.PRItemId, ProductId = oldDetail.ProductId, ProductCode = oldDetail.ProductCode, ProductName = oldDetail.ProductName, ProductRemark = oldDetail.ProductRemark, DOQuantity = oldDetail.DOQuantity, DealQuantity = oldDetail.DealQuantity, UomId = oldDetail.UomId, UomUnit = oldDetail.UomUnit, ReceiptQuantity = oldDetail.ReceiptQuantity, IsClosed = oldDetail.IsClosed, }; DeliveryOrderDetail newDuplicateDetail = new DeliveryOrderDetail { EPODetailId = oldDetail.EPODetailId, POItemId = oldDetail.POItemId, PRId = oldDetail.PRId, PRNo = oldDetail.PRNo, PRItemId = oldDetail.PRItemId, ProductId = "PrdId2", ProductCode = "PrdCode2", ProductName = "PrdName2", ProductRemark = oldDetail.ProductRemark, DOQuantity = oldDetail.DOQuantity, DealQuantity = oldDetail.DealQuantity, UomId = oldDetail.UomId, UomUnit = oldDetail.UomUnit, ReceiptQuantity = oldDetail.ReceiptQuantity, IsClosed = oldDetail.IsClosed, }; newDuplicateItem.Details.Add(oldDuplicateDetail); newDuplicateItem.Details.Add(newDuplicateDetail); model.Items.Add(newDuplicateItem); var ResponseAddDuplicateItem = await facade.Update((int)model.Id, model, USERNAME); Assert.NotEqual(0, ResponseAddDuplicateItem); }
public IActionResult AddDeliveryOrderItem([FromBody] DeliveryOrderItem model) { Deliveryorderitem_repo.Add(model); return(new OkObjectResult(new { DeliveryOrderItemID = model.DeliveryOrderItemId })); }
public async void Should_Success_Update_Data() { DeliveryOrder model = await DataUtil.GetTestData(USERNAME); foreach (var item in model.Items) { foreach (var detail in item.Details) { detail.DOQuantity -= 1; } } var Response = await Facade.Update((int)model.Id, model, USERNAME); Assert.NotEqual(Response, 0); DeliveryOrderItem oldItem = model.Items.FirstOrDefault(); DeliveryOrderDetail oldDetail = oldItem.Details.FirstOrDefault(); DeliveryOrderItem newDuplicateItem = new DeliveryOrderItem { EPOId = oldItem.EPOId, EPONo = oldItem.EPONo, Details = new List <DeliveryOrderDetail>() }; DeliveryOrderDetail oldDuplicateDetail = new DeliveryOrderDetail { EPODetailId = oldDetail.EPODetailId, POItemId = oldDetail.POItemId, PRId = oldDetail.PRId, PRNo = oldDetail.PRNo, PRItemId = oldDetail.PRItemId, ProductId = oldDetail.ProductId, ProductCode = oldDetail.ProductCode, ProductName = oldDetail.ProductName, ProductRemark = oldDetail.ProductRemark, DOQuantity = oldDetail.DOQuantity, DealQuantity = oldDetail.DealQuantity, UomId = oldDetail.UomId, UomUnit = oldDetail.UomUnit, ReceiptQuantity = oldDetail.ReceiptQuantity, IsClosed = oldDetail.IsClosed, }; DeliveryOrderDetail newDuplicateDetail = new DeliveryOrderDetail { EPODetailId = oldDetail.EPODetailId, POItemId = oldDetail.POItemId, PRId = oldDetail.PRId, PRNo = oldDetail.PRNo, PRItemId = oldDetail.PRItemId, ProductId = "PrdId2", ProductCode = "PrdCode2", ProductName = "PrdName2", ProductRemark = oldDetail.ProductRemark, DOQuantity = oldDetail.DOQuantity, DealQuantity = oldDetail.DealQuantity, UomId = oldDetail.UomId, UomUnit = oldDetail.UomUnit, ReceiptQuantity = oldDetail.ReceiptQuantity, IsClosed = oldDetail.IsClosed, }; newDuplicateItem.Details.Add(oldDuplicateDetail); newDuplicateItem.Details.Add(newDuplicateDetail); model.Items.Add(newDuplicateItem); var ResponseAddDuplicateItem = await Facade.Update((int)model.Id, model, USERNAME); Assert.NotEqual(ResponseAddDuplicateItem, 0); var newModelForAddItem = await DataUtil.GetNewData(USERNAME); DeliveryOrderItem newModelItem = newModelForAddItem.Items.FirstOrDefault(); model.Items.Add(newModelItem); model.Items.Add(newModelItem); var ResponseAddItem = await Facade.Update((int)model.Id, model, USERNAME); Assert.NotEqual(ResponseAddItem, 0); model.Items.Remove(newModelItem); model.Items.FirstOrDefault().Details.Remove(oldDetail); var ResponseRemoveItemDetail = await Facade.Update((int)model.Id, model, USERNAME); Assert.NotEqual(ResponseRemoveItemDetail, 0); }
public bool Valid() { errorProvider1.Clear(); bool a = textBoxCode.Text == "" && !r_prn.IsAutoNumber(); bool b = employeeKryptonComboBox.SelectedItem == null; bool k = supplierkryptonComboBox.SelectedItem == null; bool e = false; bool f = m_prn.ID > 0 ? false : r_prn.IsCodeExist(textBoxCode.Text); if (a) { errorProvider1.SetError(textBoxCode, "Code Can not Empty"); } if (b) { errorProvider1.SetError(employeeKryptonComboBox, "Employee Can not Empty"); } if (k) { errorProvider1.SetError(supplierkryptonComboBox, "Customer Can not Empty"); } if (f) { errorProvider1.SetError(textBoxCode, a ? "Code Can not Empty & Code already used" : "Code already used"); } int j = 0; for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { DeliveryOrderItem pi = (DeliveryOrderItem)itemsDataGrid[scanColumn.Index, i].Tag; if (pi == null) { continue; } Part p = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (p == null) { continue; } if (itemsDataGrid[unitColumn.Index, i].Value == null) { itemsDataGrid.Rows[i].ErrorText = "Please choose unit."; e = true; } //if (itemsDataGrid[warehouseColumn.Index, i].Value == null) //{ // itemsDataGrid.Rows[i].ErrorText = "Please choose warehouse."; // e = true; //} double qty = Convert.ToDouble(itemsDataGrid[QtyColumn.Index, i].Value); if (qty == 0) { itemsDataGrid.Rows[i].ErrorText = itemsDataGrid.Rows[i].ErrorText + " Quantity must not 0(zero)"; e = true; } j++; } bool g = j == 0; if (g) { errorProvider1.SetError(itemsDataGrid, "Items must at least 1(one)"); } return(!a && !b && !e && !f && !g); }
void dataItemskryptonDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (m_editMode == EditMode.View) { return; } itemsDataGrid.Rows[e.RowIndex].ErrorText = ""; if (!itemsDataGrid[e.ColumnIndex, e.RowIndex].IsInEditMode) { return; } if (e.ColumnIndex == scanColumn.Index) { if (e.FormattedValue.ToString() == "") { return; } IList addedPI = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { if (i == e.RowIndex) { continue; } SalesOrderItem pi = (SalesOrderItem)itemsDataGrid[scanColumn.Index, i].Tag; if (pi == null) { continue; } addedPI.Add(pi.ID); } IList res = r_po.FindSObyPartAndSONo(e.FormattedValue.ToString(), addedPI, ((Customer)supplierkryptonComboBox.SelectedItem).ID, dateKryptonDateTimePicker.Value); if (res.Count == 0) { using (SearchSOForDOForm fr = new SearchSOForDOForm(e.FormattedValue.ToString(), ((Customer)supplierkryptonComboBox.SelectedItem), addedPI, m_mainForm.CurrentUser, dateKryptonDateTimePicker.Value)) { fr.ShowDialog(); IList result = fr.RESULT; m_poItems = result; } } else { m_poItems = res; } } if (QtyColumn.Index == e.ColumnIndex) { SalesOrderItem pi = (SalesOrderItem)itemsDataGrid[scanColumn.Index, e.RowIndex].Tag; if (pi == null) { return; } Part p = (Part)itemsDataGrid[codeColumn.Index, e.RowIndex].Tag; if (p == null) { return; } Unit u = (Unit)Utils.FindEntityInList(itemsDataGrid[unitColumn.Index, e.RowIndex].Value.ToString(), m_units); if (u == null) { return; } p.UNIT_CONVERSION_LIST = r_part.GetUnitConversions(p.ID); DeliveryOrderItem sample = new DeliveryOrderItem(); sample.PART = p; sample.UNIT = u; sample.QYTAMOUNT = Convert.ToDouble(e.FormattedValue); double qty = sample.GetAmountInSmallestUnit(); double rest = r_po.GetOutstandingDelivered(pi.ID) - qty; if (rest < 0) { e.Cancel = true; itemsDataGrid.Rows[e.RowIndex].ErrorText = "Quantity exceed outstanding quantity"; } //itemsDataGrid[OutstandingPOColumn.Index, e.RowIndex].Value = rest; } if (unitColumn.Index == e.ColumnIndex) { SalesOrderItem pi = (SalesOrderItem)itemsDataGrid[scanColumn.Index, e.RowIndex].Tag; if (pi == null) { return; } Part p = (Part)itemsDataGrid[codeColumn.Index, e.RowIndex].Tag; if (p == null) { return; } Unit u = (Unit)Utils.FindEntityInList(e.FormattedValue.ToString(), m_units); if (u == null) { return; } p.UNIT_CONVERSION_LIST = r_part.GetUnitConversions(p.ID); DeliveryOrderItem sample = new DeliveryOrderItem(); sample.PART = p; sample.UNIT = u; sample.QYTAMOUNT = Convert.ToDouble(itemsDataGrid[QtyColumn.Index, e.RowIndex].Value); double qty = sample.GetAmountInSmallestUnit(); double rest = r_po.GetOutstandingDelivered(pi.ID) - qty; if (rest < 0) { e.Cancel = true; itemsDataGrid.Rows[e.RowIndex].ErrorText = "Quantity exceed outstanding quantity"; } //itemsDataGrid[OutstandingPOColumn.Index, e.RowIndex].Value = rest; } }
public void AddDeliveryOrderItem(DeliveryOrderItem deliveryOrderItem) { _context.DeliveryOrderItem.Add(deliveryOrderItem); _context.SaveChanges(); }