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); }
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); }
public object GetProductVO(int pintID) { ITM_ProductDS dsProduct = new ITM_ProductDS(); return(dsProduct.GetObjectVO(pintID)); }