Esempio n. 1
0
        public void UpdateAll(DataSet dstData, object pobjProduct)
        {
            // TODO:  Add BomBO.UpdateDataSet implementation
            try
            {
                //update dataset BOM
                ITM_BOMDS dsBOM  = new ITM_BOMDS();
                DataSet   dstBOM = new DataSet();
                dstBOM.Tables.Add(dstData.Tables[ITM_BOMTable.TABLE_NAME].Copy());
                dsBOM.UpdateDataSet(dstBOM);

                //update dataset Hierarchy
                DataSet dstHierarchy = new DataSet();
                dstHierarchy.Tables.Add(dstData.Tables[ITM_HierarchyTable.TABLE_NAME].Copy());
                ITM_HierarchyDS dsHierarchyDS = new ITM_HierarchyDS();
                dsHierarchyDS.UpdateDataSet(dstData);

                //update Product
                new ITM_ProductDS().UpdateForBom(pobjProduct);
                dstData.AcceptChanges();
            }
            catch (PCSDBException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
 public DataTable ListBOMDetailsOfProduct(int pintProductID)
 {
     try
     {
         ITM_BOMDS dsBOM = new ITM_BOMDS();
         return(dsBOM.ListBomDetailOfProduct(pintProductID));
     }
     catch (PCSDBException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
        //**************************************************************************
        ///    <Description>
        ///       add a new Product Item into database and return its new ID
        ///    </Description>
        ///    <Inputs>
        ///
        ///    </Inputs>
        ///    <Outputs>
        ///
        ///    </Outputs>
        ///    <Returns>
        ///
        ///    </Returns>
        ///    <Authors>
        ///       THIENHD
        ///    </Authors>
        ///    <History>
        ///       15-Dec-2004
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************


        public int AddAndReturnID(object pObjectDetail, int pintCopyFromProductID)
        {
            // TODO:  Add ProductItemInfoBO.Add implementation
            try
            {
                if (ValidateBusiness(pObjectDetail))
                {
                    ITM_ProductDS objITM_ProductDS       = new ITM_ProductDS();
                    int           intNewlyAddedProductID = objITM_ProductDS.AddAndReturnID(pObjectDetail);
                    if (pintCopyFromProductID > 0)
                    {
                        //we have to copy its BOM, routing, and hearachy
                        //1.Copy from BOM
                        ITM_BOMDS dsITM_BOMDS = new ITM_BOMDS();
                        dsITM_BOMDS.CopyBOM(pintCopyFromProductID, intNewlyAddedProductID);
                        //2.Copy from Routing
                        ITM_RoutingDS dsITM_RoutingDS = new ITM_RoutingDS();
                        dsITM_RoutingDS.CopyRouting(pintCopyFromProductID, intNewlyAddedProductID);
                        //3.Copy hearachy
                        ITM_HierarchyDS dsITM_HierarchyDS = new ITM_HierarchyDS();
                        dsITM_HierarchyDS.CopyHierarchy(pintCopyFromProductID, intNewlyAddedProductID);
                    }
                    return(intNewlyAddedProductID);
                }
                else
                {
                    return(-1);
                }
            }
            catch (PCSException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Get all BOM structure of system
        /// </summary>
        /// <param name="pintCCNID">CCN</param>
        /// <returns>DataTable</returns>

        public DataTable GetBOM(int pintCCNID)
        {
            ITM_BOMDS dsBOM = new ITM_BOMDS();

            return(dsBOM.GetBOMStructure(pintCCNID));
        }
Esempio n. 5
0
        /// <summary>
        /// Gets top level item of system
        /// </summary>
        /// <param name="pintCCNID">CCN</param>
        /// <returns>DataTable</returns>

        public DataTable GetTopLevelItem(int pintCCNID)
        {
            ITM_BOMDS dsBOM = new ITM_BOMDS();

            return(dsBOM.GetTopLevelItem(pintCCNID));
        }
Esempio n. 6
0
        public void DeleteReturnToVendor(int printReturnToVendorMasterID)
        {
            #region 1. Variable
            InventoryUtilsBO          boInventory   = new InventoryUtilsBO();
            PO_ReturnToVendorMasterDS RTVMasterDS   = new PO_ReturnToVendorMasterDS();
            PO_ReturnToVendorDetailDS RTVDetailDS   = new PO_ReturnToVendorDetailDS();
            MST_TransactionHistoryDS  TransactionDS = new MST_TransactionHistoryDS();
            DataSet dsRTVDetail = null;
            PO_ReturnToVendorMasterVO voRTVMaster = new PO_ReturnToVendorMasterVO();
            #endregion

            #region 2. Get Master Infomation
            voRTVMaster = (PO_ReturnToVendorMasterVO)RTVMasterDS.GetObjectVORTV(printReturnToVendorMasterID);
            if (voRTVMaster == null)
            {
                return;
            }
            #endregion

            #region 3. Get Detail Infomation
            dsRTVDetail = RTVDetailDS.ListReturnToVendorDetail(voRTVMaster.ReturnToVendorMasterID);
            #endregion

            #region 4. Update Inventory
            foreach (DataRow drow in dsRTVDetail.Tables[0].Rows)
            {
                //4.0 Variable
                int     LocationID   = (int)drow[PO_ReturnToVendorDetailTable.LOCATIONID_FLD];
                int     BinID        = (int)drow[PO_ReturnToVendorDetailTable.BINID_FLD];
                int     ProductionID = (int)drow[PO_ReturnToVendorDetailTable.PRODUCTID_FLD];
                decimal decQuantity  = (decimal)drow[PO_ReturnToVendorDetailTable.QUANTITY_FLD];
                //4.1 Update Add Item in Detail
                boInventory.UpdateAddOHQuantity(voRTVMaster.CCNID, voRTVMaster.MasterLocationID, LocationID, BinID, ProductionID, decQuantity, null, null);

                #region 4.2. Update Substract Bom Item
                if (voRTVMaster.ProductionLineId > 0)
                {
                    //4.2.1.Get BomDetail by ProductID
                    DataTable dtBomDetail = new ITM_BOMDS().ListBomDetailOfProduct((int)drow[ITM_ProductTable.PRODUCTID_FLD]);
                    if (dtBomDetail.Rows.Count <= 0)
                    {
                        return;
                    }

                    //4.2.2.Get LocationID and BinID by ProductionLineID
                    DataTable dtLocBin = new PO_ReturnToVendorMasterDS().GetLocationBin(voRTVMaster.ProductionLineId);

                    int intProLocationID = Convert.ToInt32(dtLocBin.Rows[0][MST_BINTable.LOCATIONID_FLD]);
                    int intProBinID      = Convert.ToInt32(dtLocBin.Rows[0][MST_BINTable.BINID_FLD]);

                    //4.2.3.Scan DataTable
                    foreach (DataRow dataRow in dtBomDetail.Rows)
                    {
                        int     intBomProductionID = (int)dataRow[ITM_BOMTable.COMPONENTID_FLD];
                        decimal decBomQuantity     = (decimal)drow[PO_ReturnToVendorDetailTable.QUANTITY_FLD] * (decimal)dataRow[ITM_BOMTable.QUANTITY_FLD];

                        new InventoryUtilsBO().UpdateSubtractOHQuantity(voRTVMaster.CCNID,
                                                                        voRTVMaster.MasterLocationID,
                                                                        intProLocationID,
                                                                        intProBinID,
                                                                        intBomProductionID,
                                                                        decBomQuantity,
                                                                        string.Empty,
                                                                        string.Empty);
                    }
                }
                #endregion
            }
            #endregion

            #region 5. Update TransactionHistory
            int OldTranTypeIDBom    = new MST_TranTypeDS().GetTranTypeID(TransactionType.MATERIAL_ISSUE);
            int OldTranTypeIDDetail = new MST_TranTypeDS().GetTranTypeID(TransactionType.RETURN_TO_VENDOR);
            int InspStatus          = 12;
            //5.1 Update TransactionHistory by Item detail
            TransactionDS.UpdateTranType(voRTVMaster.ReturnToVendorMasterID, OldTranTypeIDDetail, (int)TransactionTypeEnum.DeleteTransaction, InspStatus);
            //5.2 Update TransactionHistory by Bom Item
            TransactionDS.UpdateTranType(voRTVMaster.ReturnToVendorMasterID, OldTranTypeIDBom, (int)TransactionTypeEnum.DeleteTransaction, InspStatus);
            #endregion

            #region 6. Delete ReturnToVendor
            RTVMasterDS.DeleteReturnToVendor(voRTVMaster.ReturnToVendorMasterID);
            #endregion
        }
Esempio n. 7
0
        public void UpdateInventoryInfor(DataSet dsReturnToVendorDetail, bool blnNewRecord, PO_ReturnToVendorMasterVO pobjPO_ReturnToVendorMasterVO)
        {
            const string AVG_COST_FLD = "AVGCost";

            try
            {
                UtilsBO boUtils = new UtilsBO();
                foreach (DataRow drowReturnedGoodsDetail in dsReturnToVendorDetail.Tables[0].Rows)
                {
                    if (blnNewRecord && drowReturnedGoodsDetail.RowState == DataRowState.Deleted)
                    {
                        //in case of adding a new returned goods
                        //we don't care the deleted record
                        //we only care the other states : Modified and AddNew
                        continue;
                    }
                    int     intStockUMID  = int.Parse(drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.STOCKUMID_FLD].ToString());
                    int     intBuyingUMID = int.Parse(drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.BUYINGUMID_FLD].ToString());
                    Decimal decUMRate     = boUtils.GetUMRate(intBuyingUMID, intStockUMID);
                    if (decUMRate != 0)
                    {
                        drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.QUANTITY_FLD] = Decimal.Parse(drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.QUANTITY_FLD].ToString()) * decUMRate;
                    }
                    else
                    {
                        throw new PCSException(ErrorCode.MESSAGE_MUST_SET_UMRATE, string.Empty, new Exception());
                    }
                    //calculate the avergae cost

                    #region Update IV_BinCache
                    if (drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.BINID_FLD].ToString().Trim() != String.Empty)
                    {
                        //update bin cache
                        UpdateIVBinCache(drowReturnedGoodsDetail, blnNewRecord, pobjPO_ReturnToVendorMasterVO);
                    }
                    #endregion

                    #region update into the IV_locationCache
                    UpdateIVLocationCache(drowReturnedGoodsDetail, blnNewRecord, pobjPO_ReturnToVendorMasterVO);
                    #endregion

                    #region Update into the IV_MasterLocationCache
                    UpdateIVMasterLocationCache(drowReturnedGoodsDetail, blnNewRecord, pobjPO_ReturnToVendorMasterVO);
                    #endregion


                    #region UPDATE INTO TABLE MST_TransactionHistory

                    /*
                     * update MST_TransactionHistory
                     *
                     */
                    //UpdateTransactionHistory(drowReturnedGoodsDetail,blnNewRecord,pobjPO_ReturnToVendorMasterVO);
                    #endregion

                    #region INSERT INTO TABLE IV_CostHistory
                    if (drowReturnedGoodsDetail[SO_ReturnedGoodsDetailTable.LOT_FLD].ToString().Trim() != String.Empty)
                    {
                        UpdateCostHistory(drowReturnedGoodsDetail, blnNewRecord, pobjPO_ReturnToVendorMasterVO);
                    }
                    #endregion

                    #region Add By CanhNV: {Update add Inventory for Bom tree}

                    if (pobjPO_ReturnToVendorMasterVO.ProductionLineId > 0)
                    {
                        //1.Get BomDetail by ProductID
                        DataTable dtBomDetail = new ITM_BOMDS().ListBomDetailOfProduct((int)drowReturnedGoodsDetail[ITM_ProductTable.PRODUCTID_FLD]);
                        if (dtBomDetail.Rows.Count <= 0)
                        {
                            return;
                        }

                        //2.Get LocationID and BinID by ProductionLineID
                        DataTable dtLocBin = new PO_ReturnToVendorMasterDS().GetLocationBin(pobjPO_ReturnToVendorMasterVO.ProductionLineId);
                        if (dtLocBin.Rows.Count == 0)
                        {
                            throw new PCSBOException(ErrorCode.MESSAGE_MUST_SELECT_LOCATION, string.Empty, new Exception());
                        }
                        int intProLocationID = Convert.ToInt32(dtLocBin.Rows[0][MST_BINTable.LOCATIONID_FLD]);
                        int intProBinID      = Convert.ToInt32(dtLocBin.Rows[0][MST_BINTable.BINID_FLD]);

                        //3.Scan DataTable
                        foreach (DataRow dataRow in dtBomDetail.Rows)
                        {
                            //3.1.Set value to voTransactionHistory
                            MST_TransactionHistoryVO voTransactionHistory = new MST_TransactionHistoryVO();
                            voTransactionHistory.TransDate  = new UtilsBO().GetDBDate();
                            voTransactionHistory.TranTypeID = new MST_TranTypeDS().GetTranTypeID(TransactionType.MATERIAL_ISSUE);
                            voTransactionHistory.InspStatus = new MST_TranTypeDS().GetTranTypeID(TransactionType.RETURN_TO_VENDOR);
                            voTransactionHistory.ProductID  = (int)dataRow[ITM_BOMTable.COMPONENTID_FLD];
                            voTransactionHistory.CCNID      = pobjPO_ReturnToVendorMasterVO.CCNID;
                            voTransactionHistory.PostDate   = pobjPO_ReturnToVendorMasterVO.PostDate;

                            voTransactionHistory.RefMasterID = pobjPO_ReturnToVendorMasterVO.ReturnToVendorMasterID;
                            voTransactionHistory.RefDetailID = (int)drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.RETURNTOVENDORDETAILID_FLD];

                            voTransactionHistory.Quantity = -1 * (decimal)drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.QUANTITY_FLD] * (decimal)dataRow[ITM_BOMTable.QUANTITY_FLD];
                            decimal decQuantity = voTransactionHistory.Quantity;

                            voTransactionHistory.MasterLocationID = pobjPO_ReturnToVendorMasterVO.MasterLocationID;
                            voTransactionHistory.LocationID       = intProLocationID;
                            voTransactionHistory.BinID            = intProBinID;

                            //3.2.Update Inventory
                            new InventoryUtilsBO().UpdateSubtractOHQuantity(voTransactionHistory.CCNID,
                                                                            voTransactionHistory.MasterLocationID,
                                                                            voTransactionHistory.LocationID,
                                                                            voTransactionHistory.BinID,
                                                                            voTransactionHistory.ProductID,
                                                                            decQuantity,
                                                                            string.Empty,
                                                                            string.Empty);


                            //3.3.Update TransactionHistory
                            new InventoryUtilsBO().SaveTransactionHistory(TransactionType.MATERIAL_ISSUE, (int)PurposeEnum.ReturnToVendor, voTransactionHistory);
                        }
                    }

                    #endregion
                }
            }
            catch (PCSDBException ex)
            {
                throw ex;
            }
            catch (PCSException ex)
            {
                throw ex;
            }
        }
Esempio n. 8
0
        private void UpdateInventoryInfor(DataSet dsReturnToVendorDetail, bool blnNewRecord, PO_ReturnToVendorMasterVO pobjPO_ReturnToVendorMasterVO)
        {
            UtilsBO boUtils = new UtilsBO();

            foreach (DataRow drowReturnedGoodsDetail in dsReturnToVendorDetail.Tables[0].Rows)
            {
                if (blnNewRecord && drowReturnedGoodsDetail.RowState == DataRowState.Deleted)
                {
                    continue;
                }
                int     intStockUMID  = int.Parse(drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.STOCKUMID_FLD].ToString());
                int     intBuyingUMID = int.Parse(drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.BUYINGUMID_FLD].ToString());
                Decimal decUMRate     = boUtils.GetUMRate(intBuyingUMID, intStockUMID);
                if (decUMRate != 0)
                {
                    drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.QUANTITY_FLD] = Decimal.Parse(drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.QUANTITY_FLD].ToString()) * decUMRate;
                }
                else
                {
                    throw new PCSException(ErrorCode.MESSAGE_MUST_SET_UMRATE, string.Empty, new Exception());
                }

                #region Update IV_BinCache
                if (drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.BINID_FLD].ToString().Trim() != String.Empty)
                {
                    UpdateIVBinCache(drowReturnedGoodsDetail, blnNewRecord, pobjPO_ReturnToVendorMasterVO);
                }
                #endregion

                #region update into the IV_locationCache
                UpdateIVLocationCache(drowReturnedGoodsDetail, blnNewRecord, pobjPO_ReturnToVendorMasterVO);
                #endregion

                #region Update into the IV_MasterLocationCache
                UpdateIVMasterLocationCache(drowReturnedGoodsDetail, blnNewRecord, pobjPO_ReturnToVendorMasterVO);
                #endregion

                #region Add By CanhNV: {Update add Inventory for Bom tree}

                if (pobjPO_ReturnToVendorMasterVO.ProductionLineId > 0)
                {
                    //1.Get BomDetail by ProductID
                    DataTable dtBomDetail = new ITM_BOMDS().ListBomDetailOfProduct((int)drowReturnedGoodsDetail[ITM_ProductTable.PRODUCTID_FLD]);
                    if (dtBomDetail.Rows.Count <= 0)
                    {
                        return;
                    }

                    //2.Get LocationID and BinID by ProductionLineID
                    DataTable dtLocBin = new PO_ReturnToVendorMasterDS().GetLocationBin(pobjPO_ReturnToVendorMasterVO.ProductionLineId);
                    if (dtLocBin.Rows.Count == 0)
                    {
                        throw new PCSBOException(ErrorCode.MESSAGE_MUST_SELECT_LOCATION, string.Empty, new Exception());
                    }
                    int intProLocationID = Convert.ToInt32(dtLocBin.Rows[0][MST_BINTable.LOCATIONID_FLD]);
                    int intProBinID      = Convert.ToInt32(dtLocBin.Rows[0][MST_BINTable.BINID_FLD]);

                    //3.Scan DataTable
                    foreach (DataRow dataRow in dtBomDetail.Rows)
                    {
                        //3.1.Set value to voTransactionHistory
                        MST_TransactionHistoryVO voTransactionHistory = new MST_TransactionHistoryVO();
                        voTransactionHistory.TransDate  = new UtilsBO().GetDBDate();
                        voTransactionHistory.TranTypeID = new MST_TranTypeDS().GetTranTypeID(TransactionTypeEnum.IVMiscellaneousIssue.ToString());
                        voTransactionHistory.InspStatus = new MST_TranTypeDS().GetTranTypeID(TransactionTypeEnum.POReturnToVendor.ToString());
                        voTransactionHistory.ProductID  = (int)dataRow[ITM_BOMTable.COMPONENTID_FLD];
                        voTransactionHistory.CCNID      = pobjPO_ReturnToVendorMasterVO.CCNID;
                        voTransactionHistory.PostDate   = pobjPO_ReturnToVendorMasterVO.PostDate;

                        voTransactionHistory.RefMasterID = pobjPO_ReturnToVendorMasterVO.ReturnToVendorMasterID;
                        try
                        {
                            voTransactionHistory.RefDetailID = (int)drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.RETURNTOVENDORDETAILID_FLD];
                        }
                        catch {}

                        voTransactionHistory.Quantity = (decimal)drowReturnedGoodsDetail[PO_ReturnToVendorDetailTable.QUANTITY_FLD] * (decimal)dataRow[ITM_BOMTable.QUANTITY_FLD];
                        decimal decQuantity = voTransactionHistory.Quantity;

                        voTransactionHistory.MasterLocationID = pobjPO_ReturnToVendorMasterVO.MasterLocationID;
                        voTransactionHistory.LocationID       = intProLocationID;
                        voTransactionHistory.BinID            = intProBinID;

                        //3.2.Update Inventory
                        //
                        new InventoryUtilsBO().UpdateAddOHQuantity(voTransactionHistory.CCNID,
                                                                   voTransactionHistory.MasterLocationID,
                                                                   voTransactionHistory.LocationID,
                                                                   voTransactionHistory.BinID,
                                                                   voTransactionHistory.ProductID,
                                                                   decQuantity,
                                                                   string.Empty,
                                                                   string.Empty);


                        //3.3.Update TransactionHistory
                        new InventoryUtilsBO().SaveTransactionHistory(TransactionTypeEnum.IVMiscellaneousIssue.ToString(), (int)PurposeEnum.ReturnToVendor, voTransactionHistory);
                    }
                }

                #endregion
            }
        }
Esempio n. 9
0
        public DataSet ListComponents(int pintProductID)
        {
            ITM_BOMDS dsBOM = new ITM_BOMDS();

            return(dsBOM.ListComponents(pintProductID));
        }
Esempio n. 10
0
        public DataSet ListComponents()
        {
            ITM_BOMDS dsBOM = new ITM_BOMDS();

            return(dsBOM.ListComponents());
        }
Esempio n. 11
0
        public void UpdateDataSet(DataSet dstData)
        {
            ITM_BOMDS dsBOM = new ITM_BOMDS();

            dsBOM.UpdateDataSet(dstData);
        }