public void UpdateInventory(DataTable pdtbAdjustmentTable, DataTable pdtbCache, string pstrComment) { // update adjustment if (pdtbAdjustmentTable.Rows.Count > 0) { DataSet dstData = new DataSet(); dstData.Tables.Add(pdtbAdjustmentTable); IV_AdjustmentDS dsAdjustment = new IV_AdjustmentDS(); dsAdjustment.UpdateDataSet(dstData); IV_BinCacheDS dsBinCache = new IV_BinCacheDS(); DataSet dstCache = new DataSet(); dstCache.Tables.Add(pdtbCache); dsBinCache.UpdateDataSetForTaking(dstCache); // update location and master location cache IV_LocationCacheDS dsLocation = new IV_LocationCacheDS(); dsLocation.UpdateAllQuantityFromBin(); // update transaction history InventoryUtilsBO boIVUtils = new InventoryUtilsBO(); DataSet dstTransaction = boIVUtils.ListTransactionHistory(0); // get the list of new adjustment DataSet dstAdjust = dsAdjustment.List(pstrComment); foreach (DataRow drowData in dstAdjust.Tables[0].Rows) { // each row will be on transaction history #region Transaction history //SaveTransactionHistory DataRow drowTransaction = dstTransaction.Tables[0].NewRow(); drowTransaction[MST_TransactionHistoryTable.CCNID_FLD] = drowData[IV_AdjustmentTable.CCNID_FLD]; drowTransaction[MST_TransactionHistoryTable.TRANSDATE_FLD] = drowData[IV_AdjustmentTable.POSTDATE_FLD]; drowTransaction[MST_TransactionHistoryTable.POSTDATE_FLD] = drowData[IV_AdjustmentTable.POSTDATE_FLD]; drowTransaction[MST_TransactionHistoryTable.REFMASTERID_FLD] = drowData[IV_AdjustmentTable.ADJUSTMENTID_FLD]; drowTransaction[MST_TransactionHistoryTable.PRODUCTID_FLD] = drowData[IV_AdjustmentTable.PRODUCTID_FLD]; drowTransaction[MST_TransactionHistoryTable.TRANTYPEID_FLD] = 17; drowTransaction[MST_TransactionHistoryTable.USERNAME_FLD] = drowData[IV_AdjustmentTable.USERNAME_FLD]; drowTransaction[MST_TransactionHistoryTable.QUANTITY_FLD] = drowData[IV_AdjustmentTable.ADJUSTQUANTITY_FLD]; drowTransaction[MST_TransactionHistoryTable.MASTERLOCATIONID_FLD] = drowData[IV_AdjustmentTable.MASTERLOCATIONID_FLD]; drowTransaction[MST_TransactionHistoryTable.LOCATIONID_FLD] = drowData[IV_AdjustmentTable.LOCATIONID_FLD]; drowTransaction[MST_TransactionHistoryTable.BINID_FLD] = drowData[IV_AdjustmentTable.BINID_FLD]; drowTransaction[MST_TransactionHistoryTable.STOCKUMID_FLD] = drowData[IV_AdjustmentTable.STOCKUMID_FLD]; dstTransaction.Tables[0].Rows.Add(drowTransaction); #endregion } MST_TransactionHistoryDS dsTransactionHistory = new MST_TransactionHistoryDS(); dsTransactionHistory.UpdateDataSet(dstTransaction); } }
public void UpdateRelease(ArrayList parrMaster, DataSet pdstCommitDetail, DataSet pdstMasLocCache, DataSet pdstLocCache, DataSet pdstBinCache, DataSet pdstTransaction) { const string METHOD_NAME = THIS + ".UpdateRelease()"; SO_CommitInventoryMasterDS dsMaster = new SO_CommitInventoryMasterDS(); DataSet dstCopyOfDetail = pdstCommitDetail.Clone(); DataSet dstCopyOfTransaction = pdstTransaction.Clone(); UtilsBO boUtils = new UtilsBO(); foreach (SO_CommitInventoryMasterVO voMaster in parrMaster) { int intOldID = voMaster.CommitInventoryMasterID; voMaster.CommitmentNo = boUtils.GetNoByMask(SO_CommitInventoryMasterTable.TABLE_NAME, SO_CommitInventoryMasterTable.COMMITMENTNO_FLD, voMaster.CommitDate, Constants.YYYYMMDD0000); // add new master object and get new id voMaster.CommitInventoryMasterID = dsMaster.AddAndReturnID(voMaster); #region find all detail object to assign new master id DataRow[] drowDetails = pdstCommitDetail.Tables[0].Select(SO_CommitInventoryDetailTable.COMMITINVENTORYMASTERID_FLD + "=" + intOldID); foreach (DataRow drowDetail in drowDetails) { if (drowDetail.RowState != DataRowState.Deleted) { DataRow drowCommitDetail = dstCopyOfDetail.Tables[0].NewRow(); foreach (DataColumn dcol in dstCopyOfDetail.Tables[0].Columns) { drowCommitDetail[dcol.ColumnName] = drowDetail[dcol.ColumnName]; } drowCommitDetail[SO_CommitInventoryDetailTable.COMMITINVENTORYMASTERID_FLD] = voMaster.CommitInventoryMasterID; dstCopyOfDetail.Tables[0].Rows.Add(drowCommitDetail); } } #endregion #region find all transaction history object to assign new master id DataRow[] drowTransaction = pdstTransaction.Tables[0].Select(MST_TransactionHistoryTable.REFMASTERID_FLD + "=" + intOldID); foreach (DataRow drowDetail in drowTransaction) { if (drowDetail.RowState != DataRowState.Deleted) { DataRow drowNewTransaction = dstCopyOfTransaction.Tables[0].NewRow(); foreach (DataColumn dcol in dstCopyOfTransaction.Tables[0].Columns) { drowNewTransaction[dcol.ColumnName] = drowDetail[dcol.ColumnName]; } drowNewTransaction[MST_TransactionHistoryTable.REFMASTERID_FLD] = voMaster.CommitInventoryMasterID; dstCopyOfTransaction.Tables[0].Rows.Add(drowNewTransaction); } } #endregion } // update detail dataset SO_CommitInventoryDetailDS dsCommitDetail = new SO_CommitInventoryDetailDS(); dsCommitDetail.UpdateDataSet(dstCopyOfDetail); // update transaction history MST_TransactionHistoryDS dsTransaction = new MST_TransactionHistoryDS(); dsTransaction.UpdateDataSet(dstCopyOfTransaction); // update bin cache IV_BinCacheDS dsBinCache = new IV_BinCacheDS(); dsBinCache.UpdateDataSet(pdstBinCache); // update location cache IV_LocationCacheDS dsLocCache = new IV_LocationCacheDS(); dsLocCache.UpdateDataSet(pdstLocCache); // update master location cache IV_MasLocCacheDS dsMasLocCache = new IV_MasLocCacheDS(); dsMasLocCache.UpdateDataSet(pdstMasLocCache); }