public DealingUIDM LoadLocation(NZString locationCode) { DealingBIZ biz = new DealingBIZ(); DealingDTO dto = biz.LoadLocation(locationCode); return(MapDTOToModel(dto)); }
public ErrorItem CheckOnhandQty_AfterTR(Database db, EVOFramework.Windows.Forms.IControlIdentify owner, NZString ItemCD, NZString LocationCD, NZString LotNo) { // FIRST CHECK FOR LOCATION IF IT ALLOW NEGATIVE STOCK DealingBIZ bizLoc = new DealingBIZ(); DealingDTO dtoLoc = bizLoc.LoadLocation(LocationCD); if (!dtoLoc.ALLOW_NEGATIVE.IsNull && dtoLoc.ALLOW_NEGATIVE.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eALLOW_NEGATIVE.Yes)) { // IF THE LOCATION IS ALLOW FOR NEGATIVE THEN NOT CHECK ONHAND return(null); } InventoryBIZ biz = new InventoryBIZ(); ActualOnhandViewDTO dto = biz.LoadActualInventoryOnHand(db, ItemCD, LocationCD, LotNo); SysConfigBIZ bizConfig = new SysConfigBIZ(); SysConfigDTO dtoMinusQty = bizConfig.LoadByPK(DataDefine.eSYSTEM_CONFIG.LOCATION.SYS_GROUP_ID, (NZString)DataDefine.eSYSTEM_CONFIG.LOCATION.SYS_KEY.MINUS_QTY.ToString()); decimal decMinusQty = 0; decimal.TryParse(dtoMinusQty.CHAR_DATA.StrongValue, out decMinusQty); if (dto.ONHAND_QTY < decMinusQty) { return(new ErrorItem(owner, TKPMessages.eValidate.VLM0063.ToString(), new[] { ItemCD, LocationCD })); } return(null); }
/// <summary> /// Check On hand Inventory function follow business rule /// </summary> /// <param name="eOperation"></param> /// <param name="eInoutCls"></param> /// <param name="QTY"></param> /// <param name="ItemCD"></param> /// <param name="LocationCD"></param> /// <param name="LotNo"></param> /// <param name="strTranID">in case of Update, this value must be sent, the others send null.</param> /// <returns></returns> public ErrorItem CheckOnhandQty(DataDefine.eOperationClass eOperation, DataDefine.eIN_OUT_CLASS eInoutCls, NZDecimal QTY, NZString ItemCD, NZString LocationCD, NZString LotNo, NZString strTranID) { // FIRST CHECK FOR LOCATION IF IT ALLOW NEGATIVE STOCK DealingBIZ bizLoc = new DealingBIZ(); DealingDTO dtoLoc = bizLoc.LoadLocation(LocationCD); if (!dtoLoc.ALLOW_NEGATIVE.IsNull && dtoLoc.ALLOW_NEGATIVE.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eALLOW_NEGATIVE.Yes)) { // IF THE LOCATION IS ALLOW FOR NEGATIVE THEN NOT CHECK ONHAND return(null); } //Operation Class switch (eOperation) { case DataDefine.eOperationClass.Add: //Do notting break; case DataDefine.eOperationClass.Update: //Find Diff Qty InventoryTransBIZ biz = new InventoryTransBIZ(); InventoryTransactionDTO dto = biz.LoadByTransactionID(strTranID); if (dto != null) { QTY = (QTY - dto.QTY).ToNZDecimal(); } break; case DataDefine.eOperationClass.Delete: //Delete Inverse Qty QTY = (-1 * QTY.StrongValue).ToNZDecimal(); break; } //inout Class if (eInoutCls == DataDefine.eIN_OUT_CLASS.Out) { QTY = (-1 * QTY.StrongValue).ToNZDecimal(); } // CHECK FOR ONHAND WITH ACTUAL INVENTORY ONHAND InventoryBIZ bizInv = new InventoryBIZ(); ActualOnhandViewDTO dtoActOnhand = bizInv.LoadActualInventoryOnHand(ItemCD, LocationCD, LotNo); decimal decActualOnhandQty = 0; if (dtoActOnhand != null && !dtoActOnhand.ONHAND_QTY.IsNull) { decActualOnhandQty = dtoActOnhand.ONHAND_QTY.StrongValue; } decActualOnhandQty = decActualOnhandQty + QTY; if (decActualOnhandQty < 0) { return(new ErrorItem(QTY.Owner, TKPMessages.eValidate.VLM0063.ToString(), new[] { ItemCD, LocationCD })); } return(null); }
private List <InventoryTransactionDTO> CreateConsumptionDTO(InventoryTransactionDTO dto) { List <InventoryTransactionDTO> dtoConList = new List <InventoryTransactionDTO>(); InventoryTransactionDTO dtoCon; InventoryBIZ biz = new InventoryBIZ(); // GET LOCATION INFORMATION DealingBIZ bizLoc = new DealingBIZ(); DealingDTO dtoLoc = bizLoc.LoadLocation(dto.DEALING_NO); bool AllowNegative = dtoLoc.ALLOW_NEGATIVE.StrongValue == "01"; //WorkResultController ctrlWR=new WorkResultController (); List <WorkResultEntryViewDTO> dtoChildItem = biz.LoadConsumptionListFromItemCode(dto.ITEM_CD, dto.DEALING_NO, dto.QTY); for (int j = 0; j < dtoChildItem.Count; j++) { // GET CONSUMPTION ITEM FROM FIFO PROCESS WRITE BY KIMMIK. List <ActualOnhandViewDTO> dtoListActOnhand = biz.FifoListingProcess(Common.CurrentDatabase , dtoChildItem[j].ITEM_CD.StrongValue, dtoChildItem[j].LOC_CD.StrongValue, dtoChildItem[j].CONSUMPTION_QTY.StrongValue , !AllowNegative, AllowNegative); if (dtoListActOnhand != null && dtoListActOnhand.Count > 0) { for (int i = 0; i < dtoListActOnhand.Count; i++) { dtoCon = new InventoryTransactionDTO(); dtoCon.ITEM_CD = dtoListActOnhand[i].ITEM_CD; dtoCon.LOC_CD = dtoListActOnhand[i].LOC_CD; dtoCon.LOT_NO = dtoListActOnhand[i].LOT_NO; dtoCon.DEALING_NO = dto.DEALING_NO; dtoCon.TRANS_DATE = dto.TRANS_DATE; dtoCon.TRANS_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Consumption); dtoCon.IN_OUT_CLS.Value = DataDefine.Convert2ClassCode(DataDefine.eIN_OUT_CLASS.Out); dtoCon.QTY = dtoListActOnhand[i].ONHAND_QTY; dtoCon.OBJ_ORDER_QTY = dto.QTY; dtoCon.OBJ_ITEM_CD = dto.ITEM_CD; dtoCon.REMARK = dto.REMARK; dtoCon.CRT_BY = Common.CurrentUserInfomation.UserCD; dtoCon.CRT_MACHINE = Common.CurrentUserInfomation.Machine; dtoCon.UPD_BY = Common.CurrentUserInfomation.UserCD; dtoCon.UPD_MACHINE = Common.CurrentUserInfomation.Machine; dtoCon.SCREEN_TYPE = DataDefine.ScreenType.ReceivingEntry.ToNZString(); dtoCon.REF_NO = dto.REF_NO; dtoConList.Add(dtoCon); } } } return(dtoConList); }
private void txtCusCD_Leave(object sender, EventArgs e) { DealingBIZ bizLocation = new DealingBIZ(); DealingDTO dtoLocation = bizLocation.LoadLocation((NZString)Convert.ToString(txtCusCD.Text)); if (dtoLocation != null) { txtCusName.Text = Convert.ToString(dtoLocation.LOC_DESC); } else { txtCusName.Text = string.Empty; } }
public AdjustmentEntryUIDM ConvertDTOToUIDM(InventoryTransactionDTO dto) { AdjustmentEntryUIDM model = new AdjustmentEntryUIDM(); model.TransactionID = dto.TRANS_ID; model.AdjustNo = dto.SLIP_NO; model.AdjustDate = dto.TRANS_DATE; model.AdjustType = dto.IN_OUT_CLS; model.ItemCode = dto.ITEM_CD; model.StoredLoc = dto.LOC_CD; model.LotNo = dto.LOT_NO; model.PackNo = dto.PACK_NO; model.FGNo = dto.FG_NO; model.ExternalLotNo = dto.EXTERNAL_LOT_NO; model.AdjustWeight = dto.WEIGHT; model.AdjustQty = dto.QTY; model.Remark = dto.REMARK; model.ReasonCode = dto.TRAN_SUB_CLS; //== Get Item Description. ItemBIZ biz = new ItemBIZ(); ItemDTO itemDTO = biz.LoadItem(dto.ITEM_CD); model.ItemDesc = itemDTO.SHORT_NAME; //-- Get Customer Name DealingBIZ bizCust = new DealingBIZ(); DealingDTO dtoCust = bizCust.LoadLocation(itemDTO.CUSTOMER_CD); model.CustomerName = dtoCust.LOC_DESC; //== Get OnHand. InventoryBIZ inventoryBIZ = new InventoryBIZ(); InventoryPeriodBIZ inventoryPeriodBIZ = new InventoryPeriodBIZ(); InventoryPeriodDTO inventoryPeriodDTO = inventoryPeriodBIZ.LoadCurrentPeriod(); InventoryOnhandDTO inventoryOnhandDTO = inventoryBIZ.LoadInventoryOnHandByDate(inventoryPeriodDTO.YEAR_MONTH, dto.TRANS_DATE, dto.ITEM_CD, dto.LOC_CD, dto.LOT_NO, dto.PACK_NO); if (inventoryOnhandDTO == null) { model.OnHandQty.Value = 0; } else { model.OnHandQty = inventoryOnhandDTO.ON_HAND_QTY; } return(model); }
public string GetCustomerData(NZString ItemCD) { ItemBIZ bizItem = new ItemBIZ(); ItemDTO dtoItem = bizItem.LoadItem(ItemCD); if (dtoItem == null || dtoItem.ITEM_DESC.IsNull) { return(string.Empty); } //get customer DealingBIZ bizCust = new DealingBIZ(); DealingDTO dtoCust = bizCust.LoadLocation(dtoItem.CUSTOMER_CD); if (dtoCust == null || dtoCust.LOC_DESC.IsNull) { return(string.Empty); } SelectedCustomerData = dtoCust; return(dtoCust.LOC_DESC.StrongValue); }
public SalesUnitPriceUIDM LoadSalesUnitPriceWithItemInfo(NZString ITEM_CD, NZDateTime START_EFF_DATE, NZString CURRENCY) { SalesUnitPriceBIZ bizPrice = new SalesUnitPriceBIZ(); SalesUnitPriceDTO dtoPrice = bizPrice.LoadSalesUnitPriceByPK(ITEM_CD, START_EFF_DATE, CURRENCY); if (dtoPrice == null) { return(null); } ItemBIZ bizItem = new ItemBIZ(); ItemDTO dtoItem = bizItem.LoadItem(ITEM_CD); DealingBIZ bizCust = new DealingBIZ(); DealingDTO dtoCust = null; if (dtoItem != null && !dtoItem.CUSTOMER_CD.IsNull) { dtoCust = bizCust.LoadLocation(dtoItem.CUSTOMER_CD); } return(MapDTOToModel(dtoPrice, dtoItem, dtoCust)); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns>If save data operation completed will return true. Otherwise return false.</returns> public bool SaveData(WorkResultEntryUIDM model, DataDefine.eCONSUMPTION_CLS ConsumptionClass) { ItemBIZ bizItem = new ItemBIZ(); ClassListBIZ bizClassList = new ClassListBIZ(); InventoryBIZ biz = new InventoryBIZ(); IssueEntryValidator valLot = new IssueEntryValidator(); // Load default over consumption checking. ClassListDTO dtoOverConsumptionCheck = bizClassList.LoadByPK((NZString)DataDefine.OVER_CONSUME_CHK, (NZString)DataDefine.Convert2ClassCode(DataDefine.eOVER_CONSUME_CHK.DEFAULT)); bool bOverConsumeChk = false; if (dtoOverConsumptionCheck != null && dtoOverConsumptionCheck.CLS_DESC.NVL(String.Empty) == "1") { bOverConsumeChk = true; } //string mode = "UPD"; //if (model.WorkOrderNo.IsNull) //{ // mode = "ADD"; //} #region Validate data //== Validate Header, contain: ItemCode, Order Location and Qty. #region Validate mandatory WorkResultEntryValidator workResultEntryValidator = new WorkResultEntryValidator(); ItemValidator itemValidator = new ItemValidator(); DealingValidator locationValidator = new DealingValidator(); CommonBizValidator commonVal = new CommonBizValidator(); ValidateException.ThrowErrorItem(workResultEntryValidator.CheckWorkResultDate(model.WorkResultDate)); ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(model.ItemCode)); ValidateException.ThrowErrorItem(workResultEntryValidator.CheckEmptyShiftType(model.ShipClass)); ValidateException.ThrowErrorItem(workResultEntryValidator.CheckDifferentLocationOfItem(model.DataView)); BusinessException itemFound = itemValidator.CheckItemNotExist(model.ItemCode); if (itemFound != null) { ValidateException.ThrowErrorItem(itemFound.Error); } if (ConsumptionClass != DataDefine.eCONSUMPTION_CLS.No) { ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(model.OrderLoc)); ValidateException.ThrowErrorItem(locationValidator.CheckNotExistsLocationCode(model.OrderLoc)); } ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(model.StoredLoc)); ValidateException.ThrowErrorItem(locationValidator.CheckNotExistsLocationCode(model.StoredLoc)); ValidateException.ThrowErrorItem(workResultEntryValidator.CheckWorkResultQty(model.WorkResultQty)); ValidateException.ThrowErrorItem(workResultEntryValidator.CheckWorkResultGoodQty((NZDecimal)(model.WorkResultQty.StrongValue - model.NGQty.StrongValue))); // Check LotNo ValidateException.ThrowErrorItem(commonVal.CheckInputLot(model.ItemCode, new NZString(), model.LotNo, false)); #endregion //== Validate Detail list. if (ConsumptionClass == DataDefine.eCONSUMPTION_CLS.Manual) { List <WorkResultEntryViewDTO> listItems = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(model.DataView); #region Validate detail list. // Check ItemCD & LotNo List <string> listInvalidLotNo = new List <string>(); List <string> listInvalidConsumptionQty = new List <string>(); for (int i = 0; i < listItems.Count; i++) { BusinessException itemChildNotFound = itemValidator.CheckItemNotExist(listItems[i].ITEM_CD); if (itemChildNotFound != null) { ValidateException.ThrowErrorItem(itemChildNotFound.Error); } ItemDTO dtoItem = bizItem.LoadItem(listItems[i].ITEM_CD); WorkResultEntryViewDTO line = listItems[i]; //line.LOT_CONTROL_CLS = dtoItem.LOT_CONTROL_CLS; if (line.LOT_CONTROL_CLS.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eLOT_CONTROL_CLS.Yes) && (line.LOT_NO.IsNull || line.LOT_NO.StrongValue.Trim() == string.Empty)) { if (listInvalidLotNo.Contains(line.ITEM_CD.StrongValue)) { continue; } listInvalidLotNo.Add(line.ITEM_CD.StrongValue); } if (bOverConsumeChk) { if (line.CONSUMPTION_QTY.StrongValue > line.ON_HAND_QTY.StrongValue) { if (listInvalidConsumptionQty.Contains(line.ITEM_CD.StrongValue)) { continue; } listInvalidConsumptionQty.Add(line.ITEM_CD.StrongValue); } } ValidateException.ThrowErrorItem(commonVal.CheckInputLot(line.ITEM_CD, line.LOC_CD, line.LOT_NO, true)); } // Generate item doesn't input LOT_NO if (listInvalidLotNo.Count > 0) { listInvalidLotNo.Sort(); string errorItems = string.Empty; for (int i = 0; i < listInvalidLotNo.Count; i++) { if (i != 0) { errorItems += ", "; } errorItems += listInvalidLotNo[i]; } ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0050.ToString(), new object[] { errorItems })); return(false); } // Generate list item that input consumption qty more than stock onhand qty. if (listInvalidConsumptionQty.Count > 0) { listInvalidConsumptionQty.Sort(); string errorItems = string.Empty; for (int i = 0; i < listInvalidConsumptionQty.Count; i++) { if (i != 0) { errorItems += ", "; } errorItems += listInvalidConsumptionQty[i]; } ValidateException.ThrowErrorItem(new ErrorItem(null, TKPMessages.eValidate.VLM0051.ToString(), new object[] { errorItems })); return(false); } #endregion // Validate Child Item to support Parent Item. #region Validate Child Item to support Parent item. // Summary Consumption Qty by Item (not include LotNo) and then check compare with RequestQty. InventoryBIZ bizInventory = new InventoryBIZ(); List <WorkResultEntryViewDTO> listSourceChildItems = bizInventory.LoadConsumptionListFromItemCode(model.ItemCode, model.OrderLoc, model.WorkResultQty); for (int i = 0; i < listSourceChildItems.Count; i++) { object objSumByItem = model.DataView.Compute( String.Format("SUM({0})", WorkResultEntryViewDTO.eColumns.CONSUMPTION_QTY), String.Format("{0} = '{1}'", WorkResultEntryViewDTO.eColumns.ITEM_CD, listSourceChildItems[i].ITEM_CD.StrongValue) ); decimal sumConsumptionQty = 0; if (objSumByItem != null && objSumByItem != DBNull.Value) { sumConsumptionQty = Convert.ToDecimal(objSumByItem); } decimal diffQty = Math.Abs(sumConsumptionQty - listSourceChildItems[i].CONSUMPTION_QTY.StrongValue); if (sumConsumptionQty < listSourceChildItems[i].REQUEST_QTY.StrongValue) // Total of ConsumtpionQty < RequestQty { // Confirmation to continue save. MessageDialogResult dr = MessageDialog.ShowConfirmation(null, Message.LoadMessage(TKPMessages.eConfirm.CFM0001.ToString(), new object[] { listSourceChildItems[i].ITEM_CD.StrongValue, model.ItemCode.StrongValue, diffQty.ToString(DataDefine.DEFAULT_FORMAT_NUMBER) }), MessageDialogButtons.YesNo); if (dr == MessageDialogResult.No) { return(false); } } else if (sumConsumptionQty > listSourceChildItems[i].REQUEST_QTY.StrongValue) // Total of ConsumtpionQty > RequestQty { // Confirmation to continue save. MessageDialogResult dr = MessageDialog.ShowConfirmation(null, Message.LoadMessage(TKPMessages.eConfirm.CFM0002.ToString(), new object[] { listSourceChildItems[i].ITEM_CD.StrongValue, model.ItemCode.StrongValue, diffQty.ToString(DataDefine.DEFAULT_FORMAT_NUMBER) }), MessageDialogButtons.YesNo); if (dr == MessageDialogResult.No) { return(false); } } } #endregion } #endregion DataTable dtData; if (model.DataView == null) { WorkResultEntryViewDTO dto = new WorkResultEntryViewDTO(); dto.CreateDataTableSchema(out dtData); } else { dtData = model.DataView; } DataTable dtAdd = dtData.GetChanges(DataRowState.Added); DataTable dtUpdate = dtData.GetChanges(DataRowState.Modified); DataTable dtDelete = dtData.GetChanges(DataRowState.Deleted); List <InventoryTransactionDTO> listAdd = new List <InventoryTransactionDTO>(); List <InventoryTransactionDTO> listUpdate = new List <InventoryTransactionDTO>(); List <InventoryTransactionDTO> listDelete = new List <InventoryTransactionDTO>(); Database db = null; try { db = Common.CurrentDatabase; db.KeepConnection = true; db.BeginTransaction(); //TransactionValidator valTran = new TransactionValidator(); //InventoryTransBIZ bizTran = new InventoryTransBIZ(); //bizTran.l #region Header NZString runningNo = new NZString(); //ให้ generate lot ใหม่อีกครั้ง กรณีกรอกพร้อมกัน 2 เครื่อง ไม่งั้นมันจะ insert ข้อมูลมั่ว // ที่ใส่ตรงนี้เพราะว่า จะได้แก้ model.LotNo ก่อนที่จะสร้าง object dto //เนื่องจาก reserve ก็มีดึง lot no ไปใช้ if (model.WorkResultNo.IsNull) { RunningNumberBIZ runnningBiz = new RunningNumberBIZ(); NZString strCompleteLotNo = runnningBiz.GetCompleteLotNo(new NZDateTime(null, model.WorkResultDate.StrongValue), model.StoredLoc, model.ItemCode, new NZInt(null, 0)); model.LotNo = strCompleteLotNo; } InventoryTransactionDTO dtoWorkResult = CreateDTOForWorkResult(model); InventoryTransactionDTO dtoNGResult = CreateDTOForNGResult(model); InventoryTransactionDTO dtoReserveResult = CreateDTOForReserveResult(model); InventoryTransBIZ bizTran = new InventoryTransBIZ(); bizTran.LockRefSlipNumber(dtoWorkResult.REF_SLIP_NO); if (model.WorkResultNo.IsNull) { RunningNumberBIZ runningNumberBIZ = new RunningNumberBIZ(); runningNo = runningNumberBIZ.GetCompleteRunningNo((NZString)"WORK_RESULT_SLIP_NO", (NZString)"TB_INV_TRANS_TR"); // Create new transaction. dtoWorkResult.SLIP_NO = runningNo; dtoNGResult.SLIP_NO = runningNo; dtoReserveResult.SLIP_NO = runningNo; listAdd.Add(dtoWorkResult); if (model.NGQty.NVL(0) > 0) { listAdd.Add(dtoNGResult); } if (model.ReserveQty.NVL(0) > 0) { listAdd.Add(dtoReserveResult); } } else { // Update old transaction runningNo = model.WorkResultNo; listUpdate.Add(dtoWorkResult); if (!model.NGTransactionID.IsNull) // UPDATE NG IF IT ALREADY HAS NG QTY { listUpdate.Add(dtoNGResult); } else if (model.NGQty.NVL(0) > 0) // ADD NEW NG TRANS IF NEW NG IS INPUT { //dtoNGResult.SLIP_NO = dtoWorkResult.SLIP_NO; listAdd.Add(dtoNGResult); } if (!model.ReserveTransactionID.IsNull) // UPDATE Reserve IF IT ALREADY HAS Reserve QTY { listUpdate.Add(dtoReserveResult); } else if (model.ReserveQty.NVL(0) > 0) // ADD NEW Reserve TRANS IF NEW NG IS INPUT { //dtoReserveResult.SLIP_NO = dtoWorkResult.SLIP_NO; listAdd.Add(dtoNGResult); } } #endregion #region Detail #region Do Auto Consumption if (ConsumptionClass == DataDefine.eCONSUMPTION_CLS.Auto) { // WHEN CONSUMPTION IS AUTO // DELETE ALL OLD TRANSACTION FIRST THEN ADD NEW //Modify by Bunyapat L. //28 Apr 2011 //ให้สั่ง ClearConsumption ไปเลย List <WorkResultEntryViewDTO> listTMPDelete = null; List <InventoryTransactionDTO> listTmpDelete = null; if (dtData != null && dtData.Rows.Count > 0) { listTMPDelete = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtData); listTmpDelete = new List <InventoryTransactionDTO>(); for (int i = 0; i < listTMPDelete.Count; i++) { WorkResultEntryViewDTO line = listTMPDelete[i]; InventoryTransactionDTO dto = CreateDTOForConsumption(model, line); dto.REF_NO = runningNo; listTmpDelete.Add(dto); } // Move to delete below section //biz.WorkResultItems(Common.CurrentDatabase, null, null, listTmpDelete); } biz.ClearConsumption(Common.CurrentDatabase, dtoWorkResult); if (dtData != null && dtData.Rows.Count > 0) { List <WorkResultEntryViewDTO> listTMPAdd = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtData); // GET LOCATION INFORMATION DealingBIZ bizLoc = new DealingBIZ(); for (int i = 0; i < listTMPAdd.Count; i++) { DealingDTO dtoLoc = bizLoc.LoadLocation(listTMPAdd[i].LOC_CD); bool AllowNegative = dtoLoc.ALLOW_NEGATIVE.StrongValue == "01"; // GET CONSUMPTION ITEM FROM FIFO PROCESS WRITE BY KIMMIK. List <ActualOnhandViewDTO> dtoListActOnhand = biz.FifoListingProcess(Common.CurrentDatabase , listTMPAdd[i].ITEM_CD.StrongValue, listTMPAdd[i].LOC_CD.StrongValue , listTMPAdd[i].CONSUMPTION_QTY.StrongValue , !AllowNegative, AllowNegative); if (dtoListActOnhand != null && dtoListActOnhand.Count > 0) { for (int j = 0; j < dtoListActOnhand.Count; j++) { InventoryTransactionDTO dto = CreateDTOForConsumption(model, dtoListActOnhand[j]); dto.REF_NO = runningNo; listAdd.Add(dto); } } } } biz.WorkResultItems(Common.CurrentDatabase, listAdd, listUpdate, listDelete); } #endregion #region Do Manual Consumption if (ConsumptionClass == DataDefine.eCONSUMPTION_CLS.Manual) { List <InventoryTransactionDTO> listTmpDelete = new List <InventoryTransactionDTO>(); //== Update process. //Modify by Bunyapat L. //28 Apr 2011 //Manual consumption ให้ใช้การ insert เข้า Delete ทุกตัวที่เป็นตัวเก่า //แล้วค่อย Add ตัวใหม่แทน เพราะข้างใน function มันจะทำการ clear consumption ทั้งหมด ไม่งั้นจะเกิด bug ตอน update if (dtUpdate != null && dtUpdate.Rows.Count > 0) { List <WorkResultEntryViewDTO> listViewUpdate = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtUpdate); for (int i = 0; i < listViewUpdate.Count; i++) { WorkResultEntryViewDTO line = listViewUpdate[i]; // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว InventoryTransactionDTO dto = CreateDTOForConsumption(model, line); dto.REF_NO = runningNo; //listUpdate.Add(dto); listAdd.Add(dto); listTmpDelete.Add((InventoryTransactionDTO)dto.Clone()); } } //== Insert process. if (dtAdd != null && dtAdd.Rows.Count > 0) { List <WorkResultEntryViewDTO> listViewAdd = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtAdd); for (int i = 0; i < listViewAdd.Count; i++) { WorkResultEntryViewDTO line = listViewAdd[i]; InventoryTransactionDTO dto = CreateDTOForConsumption(model, line); dto.REF_NO = runningNo; listAdd.Add(dto); } } //== Delete process. if (dtDelete != null && dtDelete.Rows.Count > 0) { List <WorkResultEntryViewDTO> listViewDelete = DTOUtility.ConvertDataTableToList <WorkResultEntryViewDTO>(dtDelete); for (int i = 0; i < dtDelete.Rows.Count; i++) { WorkResultEntryViewDTO line = listViewDelete[i]; // Copy ค่า Header จาก Model ไปยัง DTO แต่ละตัว InventoryTransactionDTO dto = CreateDTOForConsumption(model, line); dto.REF_NO = runningNo; listDelete.Add(dto); } } biz.WorkResultItems(Common.CurrentDatabase, null, null, listTmpDelete); biz.WorkResultItems(Common.CurrentDatabase, listAdd, listUpdate, listDelete); } #endregion #region Do No Consumption if (ConsumptionClass == DataDefine.eCONSUMPTION_CLS.No) { biz.WorkResultItems(Common.CurrentDatabase, listAdd, listUpdate, listDelete); } #endregion #endregion db.Commit(); } catch (Exception) { db.Rollback(); throw; } finally { if (db.DBConnectionState == ConnectionState.Open) { db.Close(); } } return(true); }