Ejemplo n.º 1
0
        /// <summary>
        /// AddAndReturnID
        /// </summary>
        /// <param name="pobjObject"></param>
        /// <author>Trada</author>
        /// <date>Wednesday, July 27 2005</date>

        public int AddAndReturnID(object pobjObject)
        {
            string          METHODE_NAME    = "AddAndReturnID()";
            IV_AdjustmentVO voIV_Adjustment = (IV_AdjustmentVO)pobjObject;
            decimal         decRemain       = 0;
            //Check Available Quantity
            InventoryUtilsBO boInventoryUtils = new InventoryUtilsBO();
            DateTime         dtmCurrentDate   = new UtilsBO().GetDBDate().AddDays(1);

            if (voIV_Adjustment.AdjustQuantity < 0)
            {
                decRemain = boInventoryUtils.GetAvailableQtyByPostDate(dtmCurrentDate, voIV_Adjustment.CCNID, voIV_Adjustment.MasterLocationID, voIV_Adjustment.LocationID, voIV_Adjustment.BinID, voIV_Adjustment.ProductID)
                            + voIV_Adjustment.AdjustQuantity;

                if (decRemain < 0)
                {
                    throw new PCSBOException(ErrorCode.MESSAGE_IV_ADJUSTMENT_ADJUSTQTY_MUST_BE_SMALLER_THAN_AVAILABLEQTY, METHODE_NAME, new Exception());
                }
                else
                {
                    decimal decAvailableQty = boInventoryUtils.GetAvailableQtyByPostDate(new UtilsBO().GetDBDate(), voIV_Adjustment.CCNID, voIV_Adjustment.MasterLocationID, voIV_Adjustment.LocationID, voIV_Adjustment.BinID, voIV_Adjustment.ProductID);
                    if (-voIV_Adjustment.AdjustQuantity > decAvailableQty)
                    {
                        throw new PCSBOException(ErrorCode.MESSAGE_AVAILABLE_WAS_USED_AFTER_POSTDATE, METHODE_NAME, new Exception());
                    }
                }
            }

            //AddAndReturnID
            int             pintIV_AdjustmentID;
            IV_AdjustmentDS dsIV_Adjustment = new IV_AdjustmentDS();

            pintIV_AdjustmentID = dsIV_Adjustment.AddAndReturnID(pobjObject);

            //Update Add Onhand Quantity
            boInventoryUtils.UpdateAddOHQuantity(voIV_Adjustment.CCNID, voIV_Adjustment.MasterLocationID, voIV_Adjustment.LocationID, voIV_Adjustment.BinID,
                                                 voIV_Adjustment.ProductID, voIV_Adjustment.AdjustQuantity, voIV_Adjustment.Lot, voIV_Adjustment.Serial);
            //Save history to MST_TransactionHistory
            MST_TransactionHistoryVO voMST_TransactionHistory = new MST_TransactionHistoryVO();

            voMST_TransactionHistory.CCNID            = voIV_Adjustment.CCNID;
            voMST_TransactionHistory.MasterLocationID = voIV_Adjustment.MasterLocationID;
            voMST_TransactionHistory.LocationID       = voIV_Adjustment.LocationID;
            voMST_TransactionHistory.BinID            = voIV_Adjustment.BinID;
            voMST_TransactionHistory.ProductID        = voIV_Adjustment.ProductID;
            voMST_TransactionHistory.RefMasterID      = pintIV_AdjustmentID;
            voMST_TransactionHistory.TranTypeID       = new MST_TranTypeDS().GetTranTypeID(TransactionType.INVENTORY_ADJUSTMENT);
            voMST_TransactionHistory.PostDate         = voIV_Adjustment.PostDate;
            voMST_TransactionHistory.TransDate        = new UtilsBO().GetDBDate();
            voMST_TransactionHistory.Quantity         = voIV_Adjustment.AdjustQuantity;
            voMST_TransactionHistory.StockUMID        = voIV_Adjustment.StockUMID;
            boInventoryUtils.SaveTransactionHistory(TransactionType.INVENTORY_ADJUSTMENT, (int)PurposeEnum.Adjustment, voMST_TransactionHistory);
            return(pintIV_AdjustmentID);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public int AddNewReturnToVendor(PO_ReturnToVendorMasterVO pobjReturnToVendorMasterVO, DataSet pdstDetail)
        {
            try
            {
                //check onhand quantity
                CheckOnHandQty(pdstDetail, pobjReturnToVendorMasterVO);

                //store the master first
                PO_ReturnToVendorMasterDS objPO_ReturnToVendorMasterDS = new PO_ReturnToVendorMasterDS();
                PO_ReturnToVendorDetailDS objPO_ReturnToVendorDetailDS = new PO_ReturnToVendorDetailDS();
                //first we need to add to the master and return the latest ID
                int intReturnToVendorMasterID = objPO_ReturnToVendorMasterDS.AddNewReturnToVendor(pobjReturnToVendorMasterVO);

                //assign this ID into the detail
                //update the dataset all of this id
                for (int i = 0; i < pdstDetail.Tables[0].Rows.Count; i++)
                {
                    if (pdstDetail.Tables[0].Rows[i].RowState != DataRowState.Deleted)
                    {
                        pdstDetail.Tables[0].Rows[i][PO_ReturnToVendorDetailTable.RETURNTOVENDORMASTERID_FLD] = intReturnToVendorMasterID;
                    }
                }
                //Add this database into database
                if (pobjReturnToVendorMasterVO.PurchaseOrderMasterID != 0)
                {
                    objPO_ReturnToVendorDetailDS.UpdateReturnToVendorDataSet(pdstDetail, intReturnToVendorMasterID);
                }
                else if (pobjReturnToVendorMasterVO.InvoiceMasterID != 0)
                {
                    objPO_ReturnToVendorDetailDS.UpdateDataSetForInvoice(pdstDetail);
                }

                // Add value to pobjReturnToVendorMasterVO
                pobjReturnToVendorMasterVO.ReturnToVendorMasterID = intReturnToVendorMasterID;

                //Update inventory data
                UpdateInventoryInfor(pdstDetail, true, pobjReturnToVendorMasterVO);
                // HACK: Trada 27-12-2005
                //Update MST_TransactionHistory
                new UtilsBO();
                InventoryUtilsBO          boInventoryUtils       = new InventoryUtilsBO();
                PO_ReturnToVendorDetailDS dsReturnToVendorDetail = new PO_ReturnToVendorDetailDS();
                pdstDetail = dsReturnToVendorDetail.ListReturnToVendorDetail(intReturnToVendorMasterID);
                foreach (DataRow drow in pdstDetail.Tables[0].Rows)
                {
                    MST_TransactionHistoryVO voTransactionHistory = new MST_TransactionHistoryVO();

                    voTransactionHistory.CCNID            = pobjReturnToVendorMasterVO.CCNID;
                    voTransactionHistory.MasterLocationID = pobjReturnToVendorMasterVO.MasterLocationID;
                    voTransactionHistory.PartyID          = pobjReturnToVendorMasterVO.PartyID;
                    voTransactionHistory.PostDate         = pobjReturnToVendorMasterVO.PostDate;
                    voTransactionHistory.PartyLocationID  = pobjReturnToVendorMasterVO.PurchaseLocID;

                    //HACK: Modify by Tuan TQ 03 Apr, 2006. Fix error no. 3279
                    //Rem by Tuan TQ: 03 Apr, 2006
                    //voTransactionHistory.RefMasterID = intReturnToVendorMasterID;

                    //Rem by Tuan TQ: 15 June, 2006
                    //voTransactionHistory.RefMasterID = pobjReturnToVendorMasterVO.PurchaseOrderMasterID;

                    //HACK: Modified by Tuan TQ: 15 June, 2006. RefMasterID must be RTV MasterID (for Stock Card report)
                    voTransactionHistory.RefMasterID = intReturnToVendorMasterID;
                    //end hack

                    //End Hack

                    voTransactionHistory.LocationID = int.Parse(drow[PO_ReturnToVendorDetailTable.LOCATIONID_FLD].ToString());
                    if (drow[PO_ReturnToVendorDetailTable.BINID_FLD].ToString() != string.Empty)
                    {
                        voTransactionHistory.BinID = int.Parse(drow[PO_ReturnToVendorDetailTable.BINID_FLD].ToString());
                    }
                    if (drow[PO_ReturnToVendorDetailTable.RETURNTOVENDORDETAILID_FLD].ToString() != string.Empty)
                    {
                        voTransactionHistory.RefDetailID = int.Parse(drow[PO_ReturnToVendorDetailTable.RETURNTOVENDORDETAILID_FLD].ToString());
                    }
                    if (drow[PO_ReturnToVendorDetailTable.LOT_FLD].ToString() != string.Empty)
                    {
                        voTransactionHistory.Lot = drow[PO_ReturnToVendorDetailTable.LOT_FLD].ToString();
                    }
                    if (drow[PO_ReturnToVendorDetailTable.SERIAL_FLD].ToString() != string.Empty)
                    {
                        voTransactionHistory.Serial = drow[PO_ReturnToVendorDetailTable.SERIAL_FLD].ToString();
                    }

                    if (drow[PO_ReturnToVendorDetailTable.PRODUCTID_FLD].ToString() != string.Empty)
                    {
                        voTransactionHistory.ProductID = int.Parse(drow[PO_ReturnToVendorDetailTable.PRODUCTID_FLD].ToString());
                    }

                    if (drow[PO_ReturnToVendorDetailTable.STOCKUMID_FLD].ToString() != string.Empty)
                    {
                        voTransactionHistory.StockUMID = int.Parse(drow[PO_ReturnToVendorDetailTable.STOCKUMID_FLD].ToString());
                    }

                    voTransactionHistory.Quantity = Decimal.Parse(drow[PO_ReturnToVendorDetailTable.QUANTITY_FLD].ToString());

                    voTransactionHistory.TransDate = new UtilsBO().GetDBDate();

                    boInventoryUtils.SaveTransactionHistory(Constants.TRANTYPE_PORETURNTOVENDOR, (int)PurposeEnum.ReturnToVendor, voTransactionHistory);
                }
                // END: Trada 27-12-2005
                return(intReturnToVendorMasterID);
            }
            catch (PCSBOException ex)
            {
                throw ex;
            }
            catch (PCSDBException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }