예제 #1
0
        //**************************************************************************
        ///    <Description>
        ///       Validate Bussiness rule
        ///    </Description>
        ///    <Inputs>
        ///
        ///    </Inputs>
        ///    <Outputs>
        ///
        ///    </Outputs>
        ///    <Returns>
        ///
        ///    </Returns>
        ///    <Authors>
        ///       THIENHD
        ///    </Authors>
        ///    <History>
        ///       15-Dec-2004
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************


        private bool ValidateBusiness(object pObjectDetail)
        {
            const string METHOD_NAME = THIS + ".ValidateBusiness()";

            try
            {
                ITM_ProductVO objITM_ProductVO = (ITM_ProductVO)pObjectDetail;
                if (objITM_ProductVO.CategoryID > 0)
                {
                    //Check this category.
                    //This category must be a leaf node
                    ITM_CategoryDS objITM_CategoryDS = new ITM_CategoryDS();
                    if (!objITM_CategoryDS.IsLeafNode(objITM_ProductVO.CategoryID))
                    {
                        throw new PCSBOException(ErrorCode.MSG_PRODUCTINFO_CATEGORY_NOTALEAFNODE, METHOD_NAME, null);
                    }
                }
                return(true);
            }
            catch (PCSDBException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public int ImportUpdateMappingData(DataTable dtImpData, int intPartyID, int intCCNID, int intMaxLine, DataSet dstMappingData)
        {
            int          intResult         = 0;
            const string TEMP_QTY_COL_NAME = "TempQty";

            //Add new column for temp qty
            DataColumn objCol = new DataColumn(TEMP_QTY_COL_NAME);

            objCol.DataType     = typeof(Decimal);
            objCol.DefaultValue = 0;
            dstMappingData.Tables[0].Columns.Add(objCol);
            int intMaxID = 0;

            dstMappingData.Tables[0].DefaultView.Sort = PO_PurchaseOrderDetailTable.PURCHASEORDERDETAILID_FLD;
            try
            {
                intMaxID = int.Parse(dstMappingData.Tables[0].Rows[dstMappingData.Tables[0].Rows.Count - 1][PO_PurchaseOrderDetailTable.PURCHASEORDERDETAILID_FLD].ToString());
            }
            catch
            {
                intMaxID = 0;
            }
            dstMappingData.Tables[0].DefaultView.Sort = string.Empty;

            //walk through data
            ITM_ProductDS dsProduct = new ITM_ProductDS();

            for (int i = INT_BEGIN_DATA_ROW; i < dtImpData.Rows.Count; i++)
            {
                //findout Item Code
                string strItemCode    = dtImpData.Rows[i][INDEX_CODE].ToString();
                string strDescription = dtImpData.Rows[i][INDEX_NAME].ToString();
                string strRevision    = dtImpData.Rows[i][INDEX_REVISION].ToString();
                //find out total quantity at last column
                decimal dcmOrderQty = int.Parse(dtImpData.Rows[i][dtImpData.Columns.Count - 1].ToString());

                //check if this item existed, update quantity only
                DataRow[] arrRows = dstMappingData.Tables[0].Select(ITM_ProductTable.CODE_FLD + "='" + strItemCode + "'");
                if (arrRows.Length > 0)
                {
                    arrRows[0][TEMP_QTY_COL_NAME] = decimal.Parse(arrRows[0][TEMP_QTY_COL_NAME].ToString()) + dcmOrderQty;
                    continue;
                }
                if (dcmOrderQty <= 0)
                {
                    continue;
                }

                ITM_ProductVO voProduct = (ITM_ProductVO)dsProduct.GetObjectVO(strItemCode, strDescription, strRevision);

                //New row
                DataRow dr = dstMappingData.Tables[0].NewRow();

                UtilsBO boUtils = new UtilsBO();
                //fill row
                dr[TEMP_QTY_COL_NAME] = dcmOrderQty;
                dr[PO_PurchaseOrderDetailTable.ORDERQUANTITY_FLD] = dcmOrderQty;
                dr[PO_PurchaseOrderDetailTable.PRODUCTID_FLD]     = voProduct.ProductID;
                dr[ITM_ProductTable.CODE_FLD]                             = voProduct.Code;
                dr[ITM_ProductTable.DESCRIPTION_FLD]                      = voProduct.Description;
                dr[ITM_ProductTable.REVISION_FLD]                         = voProduct.Revision;
                dr[PO_PurchaseOrderDetailTable.BUYINGUMID_FLD]            = voProduct.BuyingUMID;
                dr[PO_PurchaseOrderDetailTable.UNITPRICE_FLD]             = voProduct.ListPrice;
                dr[PO_PurchaseOrderDetailTable.TOTALAMOUNT_FLD]           = voProduct.ListPrice * dcmOrderQty;
                dr[PO_PurchaseOrderDetailTable.UMRATE_FLD]                = boUtils.GetUMRate(voProduct.StockUMID, voProduct.BuyingUMID);
                dr[PO_PurchaseOrderDetailTable.LINE_FLD]                  = ++intMaxLine;
                dr[PO_PurchaseOrderDetailTable.PURCHASEORDERDETAILID_FLD] = ++intMaxID;
                dr[PO_PurchaseOrderDetailTable.STOCKUMID_FLD]             = voProduct.StockUMID;
                dr[TEMP_QTY_COL_NAME] = dcmOrderQty;
                dstMappingData.Tables[0].Rows.Add(dr);
            }
            if (intResult != 0)
            {
                dstMappingData.Tables[0].Columns.Remove(objCol);
                return(intResult);
            }
            //refine data, with correct line
            int intLine = 1;

            for (int i = 0; i < dstMappingData.Tables[0].Rows.Count; i++)
            {
                if (int.Parse(dstMappingData.Tables[0].Rows[i][TEMP_QTY_COL_NAME].ToString()) == 0)
                {
                    dstMappingData.Tables[0].Rows[i][PO_PurchaseOrderDetailTable.LINE_FLD] = -1;
                }
                else
                {
                    //Update Line
                    dstMappingData.Tables[0].Rows[i][PO_PurchaseOrderDetailTable.LINE_FLD] = intLine;
                    //Update quantity
                    dstMappingData.Tables[0].Rows[i][PO_PurchaseOrderDetailTable.ORDERQUANTITY_FLD] = dstMappingData.Tables[0].Rows[i][TEMP_QTY_COL_NAME];
                    intLine++;
                }
            }

            dstMappingData.Tables[0].Columns.Remove(objCol);
            return(intResult);
        }
예제 #3
0
        public int ImportNewMappingData(DataTable dtImpData, int intPartyID, int intCCNID, int intMaxLine, DataSet dstMappingData)
        {
            int intResult = 0;
            int intMaxID  = 0;

            dstMappingData.Tables[0].DefaultView.Sort = PO_PurchaseOrderDetailTable.PURCHASEORDERDETAILID_FLD;
            try
            {
                intMaxID = int.Parse(dstMappingData.Tables[0].Rows[dstMappingData.Tables[0].Rows.Count - 1][PO_PurchaseOrderDetailTable.PURCHASEORDERDETAILID_FLD].ToString());
            }
            catch
            {
                intMaxID = 0;
            }
            dstMappingData.Tables[0].DefaultView.Sort = string.Empty;

            ITM_ProductDS dsProduct = new ITM_ProductDS();

            for (int i = INT_BEGIN_DATA_ROW; i < dtImpData.Rows.Count; i++)
            {
                string strItemCode    = dtImpData.Rows[i][INDEX_CODE].ToString();
                string strDescription = dtImpData.Rows[i][INDEX_NAME].ToString();
                string strRevision    = dtImpData.Rows[i][INDEX_REVISION].ToString();

                //find out total quantity at last column
                decimal dcmOrderQty = decimal.Parse(dtImpData.Rows[i][dtImpData.Columns.Count - 1].ToString());

                //check if this item existed, update quantity only
                DataRow[] arrRows = dstMappingData.Tables[0].Select(ITM_ProductTable.CODE_FLD + "='" + strItemCode + "'");
                if (arrRows.Length > 0)
                {
                    arrRows[0][PO_PurchaseOrderDetailTable.ORDERQUANTITY_FLD] = decimal.Parse(arrRows[0][PO_PurchaseOrderDetailTable.ORDERQUANTITY_FLD].ToString()) + dcmOrderQty;
                    continue;
                }

                if (dcmOrderQty <= 0)
                {
                    continue;
                }

                ITM_ProductVO voProduct = (ITM_ProductVO)dsProduct.GetObjectVO(strItemCode, strDescription, strRevision);

                //New row
                DataRow dr = dstMappingData.Tables[0].NewRow();

                UtilsBO boUtils = new UtilsBO();
                //fill row
                dr[PO_PurchaseOrderDetailTable.ORDERQUANTITY_FLD] = dcmOrderQty;
                dr[PO_PurchaseOrderDetailTable.PRODUCTID_FLD]     = voProduct.ProductID;
                dr[ITM_ProductTable.CODE_FLD]                             = voProduct.Code;
                dr[ITM_ProductTable.DESCRIPTION_FLD]                      = voProduct.Description;
                dr[ITM_ProductTable.REVISION_FLD]                         = voProduct.Revision;
                dr[PO_PurchaseOrderDetailTable.BUYINGUMID_FLD]            = voProduct.BuyingUMID;
                dr[PO_PurchaseOrderDetailTable.UNITPRICE_FLD]             = voProduct.ListPrice;
                dr[PO_PurchaseOrderDetailTable.TOTALAMOUNT_FLD]           = voProduct.ListPrice * dcmOrderQty;
                dr[PO_PurchaseOrderDetailTable.UMRATE_FLD]                = boUtils.GetUMRate(voProduct.StockUMID, voProduct.BuyingUMID);
                dr[PO_PurchaseOrderDetailTable.LINE_FLD]                  = ++intMaxLine;
                dr[PO_PurchaseOrderDetailTable.PURCHASEORDERDETAILID_FLD] = ++intMaxID;
                dr[PO_PurchaseOrderDetailTable.STOCKUMID_FLD]             = voProduct.StockUMID;
                dstMappingData.Tables[0].Rows.Add(dr);
            }

            return(intResult);
        }