/// <summary> /// AddComponentScrapAndReturnID /// </summary> /// <param name="pobjCompScrapMasterVO"></param> /// <param name="pdstData"></param> /// <returns></returns> /// <author>Trada</author> /// <date>Friday, July 1 2005</date> public int AddComponentScrapAndReturnID(object pobjCompScrapMasterVO, DataSet pdstData) { //Add a new CompScrapMasterVO to PRO_ComponentScrapMaster Table int pintComponentScrapMasterID; PRO_ComponentScrapMasterDS dsComponentScrapMaster = new PRO_ComponentScrapMasterDS(); pintComponentScrapMasterID = dsComponentScrapMaster.AddAndReturnID(pobjCompScrapMasterVO); PRO_ComponentScrapMasterVO voComponentScrapMaster = (PRO_ComponentScrapMasterVO)pobjCompScrapMasterVO; //UpdateDataSet into PRO_ComponentScrapDetail Table foreach (DataRow drow in pdstData.Tables[0].Rows) { drow[PRO_ComponentScrapDetailTable.COMPONENTSCRAPMASTERID_FLD] = pintComponentScrapMasterID; } foreach (DataRow drow in pdstData.Tables[0].Rows) { InventoryUtilsBO boInventoryUtils = new InventoryUtilsBO(); //update add inventory boInventoryUtils.UpdateAddOHQuantity(voComponentScrapMaster.CCNID, voComponentScrapMaster.MasterLocationID, int.Parse(drow[PRO_ComponentScrapDetailTable.TOLOCATIONID_FLD].ToString()), int.Parse(drow[PRO_ComponentScrapDetailTable.TOBINID_FLD].ToString()), int.Parse(drow[PRO_ComponentScrapDetailTable.COMPONENTID_FLD].ToString()), decimal.Parse( drow[PRO_ComponentScrapDetailTable.SCRAPQUANTITY_FLD].ToString()), string.Empty, string.Empty); //update subtract inventory boInventoryUtils.UpdateSubtractOHQuantity(voComponentScrapMaster.CCNID, voComponentScrapMaster.MasterLocationID, int.Parse( drow[PRO_ComponentScrapDetailTable.FROMLOCATIONID_FLD].ToString()), int.Parse( drow[PRO_ComponentScrapDetailTable.FROMBINID_FLD].ToString()), int.Parse( drow[PRO_ComponentScrapDetailTable.COMPONENTID_FLD].ToString()), decimal.Parse( drow[PRO_ComponentScrapDetailTable.SCRAPQUANTITY_FLD].ToString()), string.Empty, string.Empty); //update transaction history MST_TransactionHistoryVO voTransactionHistory = new MST_TransactionHistoryVO(); voTransactionHistory.CCNID = voComponentScrapMaster.CCNID; voTransactionHistory.MasterLocationID = voComponentScrapMaster.MasterLocationID; voTransactionHistory.PostDate = voComponentScrapMaster.PostDate; voTransactionHistory.TransDate = (new UtilsBO()).GetDBDate(); voTransactionHistory.RefMasterID = pintComponentScrapMasterID; //voTransactionHistory.RefDetailID = int.Parse(drow[PRO_ComponentScrapDetailTable.COMPONENTSCRAPDETAILID_FLD].ToString()); voTransactionHistory.LocationID = int.Parse(drow[PRO_ComponentScrapDetailTable.FROMLOCATIONID_FLD].ToString()); voTransactionHistory.BinID = int.Parse(drow[PRO_ComponentScrapDetailTable.FROMBINID_FLD].ToString()); voTransactionHistory.Quantity = -decimal.Parse(drow[PRO_ComponentScrapDetailTable.SCRAPQUANTITY_FLD].ToString()); voTransactionHistory.ProductID = int.Parse(drow[PRO_ComponentScrapDetailTable.COMPONENTID_FLD].ToString()); voTransactionHistory.PurposeID = (int)PurposeEnum.Scrap; voTransactionHistory.TranTypeID = new MST_TranTypeDS().GetTranTypeID(TransactionTypeEnum.IVMiscellaneousIssue.ToString()); voTransactionHistory.StockUMID = int.Parse(drow[ITM_ProductTable.STOCKUMID_FLD].ToString()); boInventoryUtils.SaveTransactionHistory(TransactionTypeEnum.IVMiscellaneousIssue.ToString(), (int)PurposeEnum.Scrap, voTransactionHistory); voTransactionHistory.LocationID = int.Parse(drow[PRO_ComponentScrapDetailTable.TOLOCATIONID_FLD].ToString()); voTransactionHistory.BinID = int.Parse(drow[PRO_ComponentScrapDetailTable.TOBINID_FLD].ToString()); voTransactionHistory.Quantity = decimal.Parse(drow[PRO_ComponentScrapDetailTable.SCRAPQUANTITY_FLD].ToString()); boInventoryUtils.SaveTransactionHistory(TransactionTypeEnum.IVMiscellaneousIssue.ToString(), (int)PurposeEnum.Scrap, voTransactionHistory); } PRO_ComponentScrapDetailDS dsComponentScrapDetail = new PRO_ComponentScrapDetailDS(); dsComponentScrapDetail.UpdateDataSet(pdstData); return(pintComponentScrapMasterID); }
public int AddAndReturnID(object pobjMasterVO, DataSet pdstData) { CST_RecoverMaterialMasterVO voRecoverMaterialMaster = new CST_RecoverMaterialMasterVO(); voRecoverMaterialMaster = (CST_RecoverMaterialMasterVO)pobjMasterVO; int intMasterID = new CST_RecoverMaterialMasterDS().AddAndReturnID(pobjMasterVO); //update Detail for (int i = 0; i < pdstData.Tables[0].Rows.Count; i++) { if (pdstData.Tables[0].Rows[i].RowState == DataRowState.Deleted) { continue; } pdstData.Tables[0].Rows[i][CST_RecoverMaterialDetailTable.RECOVERMATERIALMASTERID_FLD] = intMasterID; } new CST_RecoverMaterialDetailDS().UpdateDataSet(pdstData); //subtract InventoryUtilsBO boInventoryUtils = new InventoryUtilsBO(); boInventoryUtils.UpdateSubtractOHQuantity(voRecoverMaterialMaster.CCNID, voRecoverMaterialMaster.MasterLocationID, voRecoverMaterialMaster.FromLocationID, voRecoverMaterialMaster.FromBinID, voRecoverMaterialMaster.ProductID, voRecoverMaterialMaster.Quantity, string.Empty, string.Empty); //update Transaction history MST_TransactionHistoryVO voMST_TransactionHistory = new MST_TransactionHistoryVO(); voMST_TransactionHistory.CCNID = voRecoverMaterialMaster.CCNID; voMST_TransactionHistory.MasterLocationID = voRecoverMaterialMaster.MasterLocationID; voMST_TransactionHistory.LocationID = voRecoverMaterialMaster.FromLocationID; voMST_TransactionHistory.BinID = voRecoverMaterialMaster.FromBinID; voMST_TransactionHistory.ProductID = voRecoverMaterialMaster.ProductID; voMST_TransactionHistory.RefMasterID = intMasterID; voMST_TransactionHistory.PostDate = voRecoverMaterialMaster.PostDate; voMST_TransactionHistory.TransDate = new UtilsBO().GetDBDate(); voMST_TransactionHistory.Quantity = -voRecoverMaterialMaster.Quantity; boInventoryUtils.SaveTransactionHistory(TransactionType.RECOVERABLE_MATERIAL, (int)PurposeEnum.ThanhLyLinhKienSauHuy, voMST_TransactionHistory); //add foreach (DataRow drow in pdstData.Tables[0].Rows) { if ((drow[CST_RecoverMaterialDetailTable.TOLOCATIONID_FLD].ToString() != string.Empty) && (drow[CST_RecoverMaterialDetailTable.TOBINID_FLD].ToString() != string.Empty)) { boInventoryUtils.UpdateAddOHQuantity(voRecoverMaterialMaster.CCNID, voRecoverMaterialMaster.MasterLocationID, int.Parse(drow[CST_RecoverMaterialDetailTable.TOLOCATIONID_FLD].ToString()), int.Parse(drow[CST_RecoverMaterialDetailTable.TOBINID_FLD].ToString()), int.Parse(drow[CST_RecoverMaterialDetailTable.PRODUCTID_FLD].ToString()), decimal.Parse(drow[CST_RecoverMaterialDetailTable.RECOVERQUANTITY_FLD].ToString()), string.Empty, string.Empty); //Save history to MST_TransactionHistory voMST_TransactionHistory = new MST_TransactionHistoryVO(); voMST_TransactionHistory.CCNID = voRecoverMaterialMaster.CCNID; voMST_TransactionHistory.MasterLocationID = voRecoverMaterialMaster.MasterLocationID; voMST_TransactionHistory.LocationID = int.Parse(drow[CST_RecoverMaterialDetailTable.TOLOCATIONID_FLD].ToString()); voMST_TransactionHistory.BinID = int.Parse(drow[CST_RecoverMaterialDetailTable.TOBINID_FLD].ToString()); voMST_TransactionHistory.ProductID = int.Parse(drow[CST_RecoverMaterialDetailTable.PRODUCTID_FLD].ToString()); voMST_TransactionHistory.RefMasterID = intMasterID; //Se update lai TrantypeID //voMST_TransactionHistory.TranTypeID = (int)TransactionTypeEnum.IVMiscellaneousIssue; voMST_TransactionHistory.PostDate = voRecoverMaterialMaster.PostDate; voMST_TransactionHistory.TransDate = new UtilsBO().GetDBDate(); voMST_TransactionHistory.Quantity = decimal.Parse(drow[CST_RecoverMaterialDetailTable.RECOVERQUANTITY_FLD].ToString()); voMST_TransactionHistory.StockUMID = int.Parse(drow[CST_RecoverMaterialDetailTable.UNITOFMEASUREID_FLD].ToString()); boInventoryUtils.SaveTransactionHistory(TransactionType.RECOVERABLE_MATERIAL, (int)PurposeEnum.TanDungLinhKienSauHuy, voMST_TransactionHistory); } } return(intMasterID); }