Exemple #1
0
        public object GetMasterInfo(int pintID, out DataRow odrowInfo)
        {
            odrowInfo = null;
            PO_ReturnToVendorMasterDS dsMaster = new PO_ReturnToVendorMasterDS();

            odrowInfo = dsMaster.GetReturnToVendorMasterInfo(pintID).Rows[0];
            return(dsMaster.GetObjectVO(pintID));
        }
Exemple #2
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
        }
Exemple #3
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;
            }
        }
Exemple #4
0
        public DataTable GetReturnToVendorMasterInfo(int pintReturnToVendorMaster)
        {
            PO_ReturnToVendorMasterDS objPO_ReturnToVendorMasterDS = new PO_ReturnToVendorMasterDS();

            return(objPO_ReturnToVendorMasterDS.GetReturnToVendorMasterInfo(pintReturnToVendorMaster));
        }
Exemple #5
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;
            }
        }
Exemple #6
0
        public object GetObjectVO(int pintID, string VOclass)
        {
            PO_ReturnToVendorMasterDS dsMaster = new PO_ReturnToVendorMasterDS();

            return(dsMaster.GetObjectVO(pintID));
        }
Exemple #7
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
            }
        }