private void dtReceiveDate_ValueChanged(object sender, EventArgs e) { if (dtReceiveDate.Value.HasValue) { int row = shtView.Rows.Count; if (row > 0) { RunningNumberBIZ runningNoBiz = new RunningNumberBIZ(); for (int i = 0; i < row; i++) { //shtView.Cells[i, (int)eColView.LOT_NO].Value = dtReceiveDate.Value.Value.ToString(DataDefine.LOT_NO_FORMAT); string oLotControlCls = Convert.ToString(shtView.Cells[i, (int)eColView.LOT_CONTROL_CLS].Value); string strItemCode = Convert.ToString(shtView.Cells[i, (int)eColView.ITEM_CD].Value); if (oLotControlCls == DataDefine.Convert2ClassCode(DataDefine.eLOT_CONTROL_CLS.Yes)) { //shtView.Cells[row, (int)eColView.LOT_NO].Value = dtReceiveDate.Value.Value.ToString(DataDefine.LOT_NO_FORMAT); if (rdoReceive.Checked) { NZString strLotNoPrefix = runningNoBiz.GenerateLotNoPrefix(new NZDateTime(null, dtReceiveDate.Value)); NZInt iLastRunningNo = runningNoBiz.GetLastLotNoRunningBox(strLotNoPrefix, new NZString(cboStoredLoc, (string)cboStoredLoc.SelectedValue), (NZString)strItemCode, new NZInt(null, 0)); ReceivingEntryController rcvController = new ReceivingEntryController(); NZString strLotNo = rcvController.GenerateLotNo(strLotNoPrefix, ref iLastRunningNo); shtView.Cells[i, (int)eColView.LOT_NO].Value = strLotNo.StrongValue; } } else { shtView.Cells[i, (int)eColView.LOT_NO].Value = null; } } } } }
private List <InventoryTransactionDTO> SplitBoxSize(ReceivingEntryUIDM receivingModel , List <InventoryTransactionViewDTO> argReceivingList) { List <InventoryTransactionDTO> listSplitBox = new List <InventoryTransactionDTO>(); RunningNumberBIZ runningNoBiz = new RunningNumberBIZ(); NZString strLotNoPrefix = runningNoBiz.GenerateLotNoPrefix(new NZDateTime(null, receivingModel.RECEIVE_DATE.StrongValue)); Dictionary <string, NZInt> dictLastRunningNo = new Dictionary <string, NZInt>(); NZInt iLastRunningNo = new NZInt(); InventoryTransactionDTO transDTO = null; foreach (InventoryTransactionViewDTO receivingDTO in argReceivingList) { iLastRunningNo = new NZInt(null, 0); //lot size == 0 ไม่ต้องแตก lot if ((receivingDTO.LOT_CONTROL_CLS != DataDefine.Convert2ClassCode(DataDefine.eLOT_CONTROL_CLS.Yes)) || (receivingDTO.LOT_SIZE.NVL(0) <= 0) ) { transDTO = new InventoryTransactionDTO(); transDTO.ITEM_CD = receivingDTO.ITEM_CD; transDTO.LOT_NO = receivingDTO.LOT_NO; transDTO.PRICE = receivingDTO.PRICE; transDTO.QTY = receivingDTO.QTY; transDTO.EXTERNAL_LOT_NO = receivingDTO.EXTERNAL_LOT_NO; listSplitBox.Add(transDTO); } else { int iTotalBox = (int)Math.Ceiling(receivingDTO.QTY.NVL(0) / receivingDTO.LOT_SIZE.NVL(1)); if (dictLastRunningNo.ContainsKey(receivingDTO.ITEM_CD.StrongValue)) { iLastRunningNo = dictLastRunningNo[receivingDTO.ITEM_CD.StrongValue]; } else { iLastRunningNo = runningNoBiz.GetLastLotNoRunningBox(strLotNoPrefix, receivingModel.STORED_LOC, receivingDTO.ITEM_CD, new NZInt(null, 0)); dictLastRunningNo.Add(receivingDTO.ITEM_CD.StrongValue, iLastRunningNo); } NZDecimal dRemainQty = new NZDecimal(null, receivingDTO.QTY.StrongValue); for (int iBox = 0; iBox < iTotalBox; iBox++) { transDTO = new InventoryTransactionDTO(); transDTO.ITEM_CD = receivingDTO.ITEM_CD; transDTO.LOT_NO = GenerateLotNo(strLotNoPrefix, ref iLastRunningNo); transDTO.PRICE = receivingDTO.PRICE; transDTO.EXTERNAL_LOT_NO = receivingDTO.EXTERNAL_LOT_NO; if (dRemainQty.NVL(0) >= receivingDTO.LOT_SIZE.NVL(0)) { transDTO.QTY = new NZDecimal(null, receivingDTO.LOT_SIZE.StrongValue); dRemainQty.Value = dRemainQty.StrongValue - transDTO.QTY.StrongValue; } else { transDTO.QTY = new NZDecimal(null, dRemainQty.StrongValue); } listSplitBox.Add(transDTO); } } } return(listSplitBox); }