public static string getNext(IEnvironment env, DateTime date, short mod, short docType, short firm, short div, short factory, short wh, short group, short role, short user) { DataRow rowNum; DataTable tabNum = getData(env, date, mod, docType, firm, div, factory, wh, group, role, user); ////////////////////////////////// DataTable tabCopy = tabNum.Copy(); tabNum.Clear(); tabCopy.DefaultView.Sort = "USERID DESC"; tabNum.Load(tabCopy.DefaultView.ToTable().CreateDataReader()); ////////////////////////////////// rowNum = ToolRow.getFirstRealRow(tabNum); ToolSeq.lockByUpdate(env, TableDOCNUM.TABLE_REAL_NAME, rowNum[TableDOCNUM.LOGICALREF]); rowNum = ToolRow.getFirstRealRow(getData(env, (int)rowNum[TableDOCNUM.LOGICALREF])); // string newDocNum = getNewDocNum(rowNum, env, date, mod, docType, firm, div, factory, wh, group, role, user); // rowNum[TableDOCNUM.LASTASGND] = newDocNum; IAdapterTable adapter = new AdapterTableDocNum(env, TableDOCNUM.LOGICALREF); adapter.set(rowNum.Table); return(newDocNum); }
void refreshVal(double pValue, double pCf, string pCol, bool pReverse) { if (_blockPoint.block()) { try { if (pCf < ConstValues.minPositive) { pCf = 1.0; } DataRow rowMain = ToolRow.getFirstRealRow(_tableSchema); double mCf = (double)rowMain[TableDUMMY.CONVFACT]; double mAmount = pValue * (pReverse ? (mCf / pCf) : (pCf / mCf)); foreach (DataRow curRow in _tableSchema.Rows) { double curCf = (double)curRow[TableDUMMY.CONVFACT]; if (curCf < ConstValues.minPositive) { curCf = 1.0; } ToolCell.set(curRow, pCol, mAmount * (pReverse ? (curCf / mCf) : (mCf / curCf))); } } finally { _blockPoint.unblock(); } } }
bool needUpdate(DataRow row, string[] cols) { if (row == null) { return(false); } bool flagResetOnAllNullOrDef = flags.isFlagEnabled(UpdateTypeFlags.resetIfAllCurrentRelColsAreDefaultOrNull); bool flagStopIfOneNullOrDef = !flags.isFlagEnabled(UpdateTypeFlags.continueIfOneOfCurrentRelColsDefaultOrNull); if (ToolCell.isDefaultOrNullAll(row, cols)) { if (flagResetOnAllNullOrDef) { ToolRow.initTableNewRow(row, allChildCol); return(false); } if (flagStopIfOneNullOrDef) { return(false); } } if (ToolCell.hasDefaultOrNull(row, cols)) { if (flagStopIfOneNullOrDef) { return(false); } } return(true); }
protected bool startSave() { try { FinishDataEditing(); if (_checkLevel) { DataRow row = ToolRow.getFirstRealRow(_tableSchema); double amount = (double)ToolCell.isNull(row[TableDUMMY.AMOUNT], 0.0); double onhand = (double)ToolCell.isNull(_curMatRecord[TableDUMMY.ONHAND], 0.0); if ((amount - onhand) > ConstValues.minPositive) { ToolMsg.show(this, MessageCollection.T_MSG_INVALID_QUANTITY, null); return(false); } } DataRow _rowActiveUnit = this.BindingContext.getBindingItemRecord(cUnit); // if (_rowActiveUnit != null) { switch (handler.converCol(handler.column)) { case TableDUMMY.AMOUNT: ToolCell.set(handler.row, TableSTLINE.AMOUNT, ToolRow.getFirstRealRow(_tableSchema)[TableDUMMY.AMOUNT]); // if (_rowActiveUnit != null) { ToolCell.set(handler.row, TableSTLINE.UNIT, _rowActiveUnit[TableDUMMY.UNIT]); ToolCell.set(handler.row, TableSTLINE.UNITREF, _rowActiveUnit[TableDUMMY.UNITREF]); ToolCell.set(handler.row, TableSTLINE.UINFO1, _rowActiveUnit[TableDUMMY.UNITCF01]); ToolCell.set(handler.row, TableSTLINE.UINFO2, _rowActiveUnit[TableDUMMY.UNITCF02]); } // return(true); case TableDUMMY.PRICE: ToolCell.set(handler.row, TableSTLINE.PRICE, ToolRow.getFirstRealRow(_tableSchema)[TableDUMMY.PRICE]); return(true); case TableDUMMY.DISCPER: ToolCell.set(handler.row, TableSTLINE.DISCPER, ToolRow.getFirstRealRow(_tableSchema)[TableDUMMY.DISCPER]); return(true); case TableDUMMY.TOTAL: ToolCell.set(handler.row, TableSTLINE.TOTAL, ToolRow.getFirstRealRow(_tableSchema)[TableDUMMY.TOTAL]); return(true); } } } catch (Exception exc) { ToolMobile.setException(exc); } return(false); }
protected override void onNewAdded(EditingTools pTool, object pLref) { var ds_ = pTool.adapter.getDataSet(); if (ds_ != null) { var tab_ = ds_.Tables[TableINVOICE.TABLE]; if (tab_ != null) { tab_ = tab_.Copy(); DataRow row_ = ToolRow.getFirstRealRow(tab_); if (row_ != null) { var ext_ = row_[TableINVOICE.GENEXP1].ToString().ToLowerInvariant(); var text_ = environment.getSysSettings().getString(SettingsSysMob.MOB_SYS_DOPAYMENTEXP, "").ToLowerInvariant().Trim(); if (!string.IsNullOrEmpty(text_) && ext_ == text_) { var x = new Action(() => { doCash(row_); }); addActionOnResume(x); } } } } }
public InfoInvoiceSum calcSlipSum(DataSet pDataSet) { DataTable pTabSTLINE = pDataSet.Tables[TableSTLINE.TABLE]; DataTable pTabINVOICE = pDataSet.Tables[TableINVOICE.TABLE]; InfoInvoiceSum infoSum = new InfoInvoiceSum(); for (int i = 0; i < pTabSTLINE.Rows.Count; ++i) { DataRow row = pTabSTLINE.Rows[i]; if (isUsedRow(row) && !ToolRow.isDeleted(row)) { if (ToolStockLine.isLineMaterial(row)) { double tot = getLineRealTotal(row); double totNet = getLineNetTotal(row); infoSum.sumOfTotal += tot; infoSum.sumOfLocDisc += (tot - totNet); } if (ToolStockLine.isLinePromotion(row)) { double tot = getLineRealTotal(row); infoSum.sumOfLocPromo += tot; } } } double gDisc = (double)ToolColumn.getColumnLastValue(pTabINVOICE, TableINVOICE.DISCPER, 0.0); infoSum.sumOfGlobDisc = (infoSum.sumOfTotal - infoSum.sumOfLocDisc) * (gDisc / 100); return(infoSum); }
public bool addData(DataRow row) { try { if (row != null) { if (validator.check(row)) { rows.Add(ToolRow.createRowCopy(row)); EventHandler h_ = referenceMode.handlerOk; //make backup referenceMode.handlerOk = null; if (h_ != null) { h_.Invoke(this, EventArgs.Empty);// } if (this.getFlagStore().isFlagEnabled(ReferenceFlags.formBatchMode)) { this.clear(); //clear data and handler referenceMode.handlerOk = h_; //will be re-used return(false); //dont close } return(true); } } return(false); } finally { referenceMode.lastBatchModeIndex = -1; } }
protected void table_DistributeValues(DataRow[] topRows, DataRow[] subRows) { object topTotal = topOperDef; for (int i = 0; i < topRows.Length; ++i) { evalOnTopAny.setVarAll(ToolRow.copyRowToArr(columnsVars, topRows[i])); object tmpRes = evalOnTopAny.getResult(); evalOnTopAnyResult.setVarAll(new object[] { topTotal, tmpRes }); topTotal = evalOnTopAnyResult.getResult(); } for (int i = 0; i < subRows.Length; ++i) { object[] vals; object tmp; DataRow row = subRows[i]; string oldest = toucher.getOldest(columnsCalc, row); IEvaluator eval = evalOnSubCalc[Array.IndexOf <string>(columnsCalc, oldest)]; vals = ToolRow.copyRowToArr(columnsVars, row); vals = ToolArray.resize <object>(vals, vals.Length + 1); vals[vals.Length - 1] = topTotal; eval.setVarAll(vals); tmp = eval.getResult(); ToolCell.set(row, oldest, tmp); vals = ToolRow.copyRowToArr(columnsVars, row); vals = ToolArray.resize <object>(vals, vals.Length + 1); vals[vals.Length - 1] = topTotal; evalOnSubCorrect.setVarAll(vals); topTotal = evalOnSubCorrect.getResult(); } }
void calcColumn(DataRow pRow, string pCol) { IEvaluator eval = evals[Array.IndexOf <string>(columnsCalc, pCol)]; object[] vals = ToolRow.copyRowToArr(columnsVars, pRow); eval.setVarAll(vals); ToolCell.set(pRow, pCol, eval.getResult()); }
public DataRow insertRowIntoTable(DataTable table, int pos) { DataRow row = table.NewRow(); ToolRow.initTableNewRow(null); table.Rows.InsertAt(row, pos); return(row); }
public virtual DataTable getLast() { reverseSort(); DataTable table = getFirst(); reverseSort(); setBorder(ToolRow.getFirstRealRow(table)); return(ToolTable.createReversed(table)); }
void refreshVal() { if (!_blockPoint.isBlocked()) { DataRow rowMain = ToolRow.getFirstRealRow(_tableSchema); refreshVal((double)rowMain[TableDUMMY.AMOUNT], (double)rowMain[TableDUMMY.CONVFACT], TableDUMMY.AMOUNT, false); refreshVal((double)rowMain[TableDUMMY.PRICE], (double)rowMain[TableDUMMY.CONVFACT], TableDUMMY.PRICE, true); refreshVal((double)rowMain[TableDUMMY.TOTAL], TableDUMMY.TOTAL); refreshVal((double)rowMain[TableDUMMY.DISCPER], TableDUMMY.DISCPER); } }
public virtual DataTable getNext() { builder.reset(); preparingForSort(indexColumns); preparingForPagedWhere(indexColumns, borderData); DataTable table = new DataTable(builder.getName()); fill(table); setBorder(ToolRow.getLastRealRow(table)); return(convert(table)); }
public static DataRow getItemData(IEnvironment pEnv, object lref) { DataTable tab_ = SqlExecute.execute(pEnv, "SELECT * FROM LG_$FIRM$_ITEMS WHERE LOGICALREF = @P1", new object[] { lref }); tab_.TableName = TableITEMS.TABLE; return(ToolRow.getFirstRealRow(tab_)); //IPagedSource ps = new PagedSourceMaterial(pEnv); //ps.getBuilder().addParameterValue(TableITEMS.LOGICALREF, lref); //DataTable table = ps.getAll(); //return ToolRow.getFirstRealRow(table); }
public static DataRow getLineParent(DataRow row) { for (int i = row.Table.Rows.IndexOf(row); i >= 0; --i) { if (!ToolRow.isDeleted(row.Table.Rows[i])) { if (isLineMaterial(row.Table.Rows[i])) { return(row.Table.Rows[i]); } } } return(null); }
public DataRow[] get(DataRow row) { List <DataRow> rows = new List <DataRow>(); DataTable table = row.Table; string state; for (int i = table.Rows.IndexOf(row); i >= 0; --i) { DataRow locRow = table.Rows[i]; if (!ToolRow.isDeleted(locRow)) { if (validator.check(locRow)) { evalU.setVar(locRow); state = (string)evalU.getResult(expName); if (state.IndexOf(ConstSelectAction.yes) >= 0) { rows.Insert(0, locRow); } if (state.IndexOf(ConstSelectAction.stop) >= 0) { break; } } } } for (int i = table.Rows.IndexOf(row) + 1; i < table.Rows.Count; ++i) { DataRow locRow = table.Rows[i]; if ((!ToolRow.isDeleted(locRow))) { if (validator.check(locRow)) { evalB.setVar(locRow); state = (string)evalB.getResult(expName); if (state.IndexOf(ConstSelectAction.yes) >= 0) { rows.Add(locRow); } if (state.IndexOf(ConstSelectAction.stop) >= 0) { break; } } } } return(rows.ToArray()); }
public static DataTable getMainUnit(DataTable tableMatUnits) { DataRow uRow = null; for (int i = 0; i < tableMatUnits.Rows.Count; ++i) { DataRow row = tableMatUnits.Rows[i]; if ((short)row[TableITMUNITA.LINENR] == (short)1) { uRow = row; break; } } DataTable tab = tableMatUnits.Clone(); ToolRow.copyRowToTable(uRow, tab); return(tab); }
void distribute(DataRow row, string[] cols) { if (needUpdate(row, cols)) { //getData source.getBuilder().reset(); for (int i = 0; i < cols.Length; ++i) { string col = ToolColumn.extractColumnName(getColMapBind(cols[i])); string tab = ToolColumn.extractTableName(getColMapBind(cols[i])); object val = row[cols[i]]; if ((tab != string.Empty) && (col != string.Empty)) { source.getBuilder().addParameterValueTable(tab, col, val); } else if (col != string.Empty) { source.getBuilder().addParameterValue(col, val); } else if (col == string.Empty) { source.getBuilder().addFreeParameterValue(val); } } emptyDest(); DataTable tabData = source.getAll(); // if (tabData != null) { //Has data foreach (DataRow rowData in tabData.Rows) { DataRow nRow = tableDest.NewRow(); ToolRow.initTableNewRow(nRow); tableDest.Rows.Add(nRow); for (int i = 0; i < updateChildCol.Length; ++i) { ToolCell.set(nRow, getColMapData(updateChildCol[i]), rowData[updateChildCol[i]]); } } } } }
public DataRow[] get(DataRow row) { List <DataRow> rows = new List <DataRow>(); DataTable table = row.Table; for (int i = table.Rows.IndexOf(row); i >= 0; --i) { DataRow locRow = table.Rows[i]; if (!ToolRow.isDeleted(locRow)) { if (validator.check(locRow)) { if (validatorSelectT.check(locRow)) { rows.Insert(0, locRow); } if (validatorStopT.check(locRow)) { break; } } } } for (int i = table.Rows.IndexOf(row) + 1; i < table.Rows.Count; ++i) { DataRow locRow = table.Rows[i]; if ((!ToolRow.isDeleted(locRow))) { if (validator.check(locRow)) { if (validatorSelectB.check(locRow)) { rows.Add(locRow); } if (validatorStopB.check(locRow)) { break; } } } } return(rows.ToArray()); }
private string[] compareData(DataRowView row, DataColumn[] cols, string[] values) { bool sameData = true; string[] curValsStr = new string[values.Length]; object[] curValues = ToolRow.copyRowToArr(cols, row.Row); for (int i = 0; i < curValues.Length; ++i) { curValsStr[i] = (string)curValues[i]; if (sameData) { if ((string)curValues[i] != values[i]) { sameData = false; } } } return(sameData ? null : curValsStr); }
public static DataTable getMatUnitPrices(int unit, DateTime date, IEnvironment env, DataTable tablePrices, DataTable tableMatUnits) { DataTable resPrices = tablePrices.Clone(); ToolColumn.add(resPrices, TablePRCLIST.E_DUMMY__PRICE, typeof(double)); for (int i = 0; i < tablePrices.Rows.Count; ++i) { DataRow row = tablePrices.Rows[i]; short convertable = (short)row[TablePRCLIST.UNITCONVERT]; int curUnit = (int)row[TablePRCLIST.UOMREF]; if ((convertable == (short)ConstBool.yes) || (curUnit == unit)) { if (ToolDateTime.isBetween(date, (DateTime)row[TablePRCLIST.BEGDATE], (DateTime)row[TablePRCLIST.ENDDATE])) { DataRow curRow = ToolRow.copyRowToTable(row, resPrices); double cf = getMatUnitCF(curUnit, tableMatUnits); double cf_ = getMatUnitCF(unit, tableMatUnits); double price = (double)curRow[TablePRCLIST.PRICE]; price = (price / cf) * cf_; curRow[TablePRCLIST.PRICE] = price; double exchange = ToolGeneral.getExchange((short)curRow[TablePRCLIST.CURRENCY], date, env); curRow[TablePRCLIST.CURRENCY] = env.getInfoApplication().periodCurrencyNativeId; if (exchange > ConstValues.minPositive) { price /= exchange; } else { price = 0; } curRow[TablePRCLIST.E_DUMMY__PRICE] = price; curRow[TablePRCLIST.UOMREF] = unit; } } } return(resPrices); }
public static DataTable getSmallUnit(DataTable tableMatUnits) { DataRow uRow = null; double cfLast = double.MaxValue; short nrLast = short.MaxValue; for (int i = 0; i < tableMatUnits.Rows.Count; ++i) { DataRow row = tableMatUnits.Rows[i]; double cfCur = (double)row[TableITMUNITA.CONVFACT2] / (double)row[TableITMUNITA.CONVFACT1]; short nrCur = (short)row[TableITMUNITA.LINENR]; if ((cfLast > cfCur) || ((cfLast == cfCur) && (nrCur < nrLast))) { uRow = row; cfLast = cfCur; nrLast = nrCur; } } DataTable tab = tableMatUnits.Clone(); ToolRow.copyRowToTable(uRow, tab); return(tab); }
public override DataTable get() { DataTable exch; int date; short curr = (short)ToolCell.isNull(getBuilder().getParameterValue(TableDAILYEXCHANGES.CRTYPE), (short)0); object dt = getBuilder().getParameterValue(E_DATE_); if (dt != null) { date = ToolGeneral.date2IntDate((DateTime)dt); getBuilder().deleteParameter(E_DATE_); getBuilder().addParameterValue(TableDAILYEXCHANGES.DATE_, date); } else { date = (int)ToolCell.isNull(getBuilder().getParameterValue(TableDAILYEXCHANGES.DATE_), (int)0); } if ((curr == 0) || (curr == environment.getInfoApplication().periodCurrencyNativeId)) { exch = getTableInstance(); exch.Rows.Add(ToolRow.initTableNewRow(exch.NewRow())); ToolColumn.setColumnValue(exch, TableDAILYEXCHANGES.CRTYPE, curr); ToolColumn.setColumnValue(exch, TableDAILYEXCHANGES.DATE_, date); ToolColumn.setColumnValue(exch, TableDAILYEXCHANGES.RATES1, 1); ToolColumn.setColumnValue(exch, TableDAILYEXCHANGES.RATES2, 1); ToolColumn.setColumnValue(exch, TableDAILYEXCHANGES.RATES3, 1); ToolColumn.setColumnValue(exch, TableDAILYEXCHANGES.RATES4, 1); } else { exch = base.get(); } exch.Columns.Add(ToolColumn.getColumnFullName(TableDUMMY.TABLE, TableDUMMY.EXCHANGE), typeof(double), TableDAILYEXCHANGES.RATES1); return(exch); }
public static void syncWithClTran(DataTable tabPayTrans, DataTable tabClTrans) { DataRow rowTran = ToolRow.getFirstRealRow(tabClTrans); if (rowTran != null) { DataRow rowPay = ToolRow.getFirstRealRow(tabPayTrans); if (rowPay == null) { tabPayTrans.Rows.Add(rowPay = ToolRow.initTableNewRow(tabPayTrans.NewRow())); } ToolCell.set(rowPay, TablePAYTRANS.PAYNO, 1); ToolCell.set(rowPay, TablePAYTRANS.PROCDATE, rowTran[TableCLFLINE.DATE_]); ToolCell.set(rowPay, TablePAYTRANS.DISCDUEDATE, rowTran[TableCLFLINE.DATE_]); ToolCell.set(rowPay, TablePAYTRANS.DATE_, rowTran[TableCLFLINE.DATE_]); ToolCell.set(rowPay, TablePAYTRANS.TOTAL, rowTran[TableCLFLINE.AMOUNT]); ToolCell.set(rowPay, TablePAYTRANS.REPORTRATE, rowTran[TableCLFLINE.REPORTRATE]); ToolCell.set(rowPay, TablePAYTRANS.CARDREF, rowTran[TableCLFLINE.CLIENTREF]); ToolCell.set(rowPay, TablePAYTRANS.DISCDUEDATE, rowTran[TableCLFLINE.DATE_]); ToolCell.set(rowPay, TablePAYTRANS.TRCURR, rowTran[TableCLFLINE.TRCURR]); ToolCell.set(rowPay, TablePAYTRANS.TRNET, rowTran[TableCLFLINE.TRNET]); } }
DataRow searchRecord(DataTable pTab, object pKey) { return(ToolRow.search(pTab, TableDUMMY.LOGICALREF, pKey)); }
public DataRow addRowToTable(DataTable table) { object[] obj = ToolRow.getVallueArrayForTable(table); return(table.Rows.Add(obj)); }
void ImplAdapterUser_TableNewRow(object sender, DataTableNewRowEventArgs e) { ToolRow.initTableNewRow(e.Row); }
protected virtual bool isValidForEnumerationRow(DataRow pRow) { return(!ToolRow.isDeleted(pRow)); }
protected virtual bool isUsedRow(DataRow pRow) { return(!ToolRow.isDeleted(pRow)); }
public virtual DataRow getHeaderRecord() { return(ToolRow.getFirstRealRow(getHeaderTable())); }