void recalculate() { if (block()) { try { double result = 0; for (int r = 0; r < tableSource.Rows.Count; ++r) { DataRow row = tableSource.Rows[r]; if (row.RowState != DataRowState.Deleted && validator.check(row)) { for (int i = 0; i < columns.Length; ++i) { evaluator.setVar(columns[i], row[columns[i]]); } if (oper == ConstMathOperation.sum) { result += (double)evaluator.getResult(column); } } } ToolColumn.setColumnValue(tableDest, column, result); } finally { unblock(); } } }
void recalculate() { if (block()) { try { object result = DBNull.Value; object curVal; object prevAmngVal = defaultAmang; for (int r = 0; r < tableSource.Rows.Count; ++r) { DataRow row = tableSource.Rows[r]; if ((row.RowState != DataRowState.Deleted) && validator.check(row)) { // evaluatorRow.setVar(row); curVal = evaluatorRow.getResult(); // evaluatorAmangRow.setVar(colPrevValue, prevAmngVal); evaluatorAmangRow.setVar(colCurValue, curVal); prevAmngVal = evaluatorAmangRow.getResult(); // } } evaluatorFinal.setVar(colAmangValue, prevAmngVal); ToolColumn.setColumnValue(tableDest, column, evaluatorFinal.getResult()); } finally { unblock(); } } }
void recalculate() { if (block()) { try { List <object> list = new List <object>(); for (int r = 0; r < tableSource.Rows.Count; ++r) { DataRow row = tableSource.Rows[r]; if (row.RowState != DataRowState.Deleted && validator.check(row)) { object obj = row[columns[0]]; if (distinct) { if (list.IndexOf(obj) >= 0) { continue; } } list.Add(obj); } } ToolColumn.setColumnValue(tableDest, column, list.Count); } finally { unblock(); } } }
void tableS__ColumnChanged(object sender, DataColumnChangeEventArgs e) { for (int s = 0; s < columnS_.Length; ++s) { if (e.Column.ColumnName == columnS_[s]) { ToolColumn.setColumnValue(tableD_, columnD_[s], e.ProposedValue); } } }
void tableD__ColumnChanged(object sender, DataRowChangeEventArgs e) { if (e.Action == DataRowAction.Add) { for (int d = 0; d < columnD_.Length; ++d) { ToolCell.set(e.Row, columnD_[d], ToolColumn.getColumnLastValue(tableS_, columnS_[d], ToolCell.getCellTypeDefaulValue(tableS_.Columns[columnS_[d]].DataType))); } } }
public RowColumnsBindingInnerExpr(DataTable table, string[] colArr, string col, string expresion, IRowValidator pValidator) : base(table, colArr, col, expresion, pValidator) { tableSource.ColumnChanged += new DataColumnChangeEventHandler(table_ColumnChangedForRow); if (ToolColumn.isColumnFullName(column)) { foreach (DataRow row in tableSource.Rows) { table_ColumnChangedForRow(tableSource, new DataColumnChangeEventArgs(row, tableSource.Columns[columns[0]], row[columns[0]])); } } }
public TablesColumnsBinding(DataTable tableS, DataTable tableD, string[] columnS, string[] columnD, bool inherit) { tableS_ = tableS; columnS_ = columnS; tableD_ = tableD; columnD_ = columnD; tableS_.ColumnChanged += new DataColumnChangeEventHandler(tableS__ColumnChanged); if (inherit) { tableD_.RowChanged += new DataRowChangeEventHandler(tableD__ColumnChanged); } for (int d = 0; d < columnD_.Length; ++d) { if (ToolColumn.isColumnFullName(columnD_[d])) { ToolColumn.setColumnValue(tableD_, columnD_[d], ToolColumn.getColumnLastValue(tableS_, columnS_[d], ToolCell.getCellTypeDefaulValue(tableS_.Columns[columnS_[d]].DataType))); } } }
void init(DataTable pTable, IPagedSource pSource, string[] pBindChildCol, string[] pBindParentCol, string[] pChildCol, string[] pParentCol, UpdateTypeFlags pFlags, IRowValidator pValidator, string[] pTriggerCols) { flags.flagEnable(pFlags); source = pSource; for (int i = pChildCol.Length; i < pParentCol.Length; ++i) { pChildCol = ToolArray.resize <string>(pChildCol, pChildCol.Length + 1); pChildCol[pChildCol.Length - 1] = string.Empty; } for (int i = 0; i < pParentCol.Length; ++i) { if ((pChildCol[i] == string.Empty) || (pChildCol[i] == null)) { pChildCol[i] = ToolColumn.getColumnFullName(source.getBuilder().getName(), pParentCol[i]); } } triggerCols = pTriggerCols; bindChildCol = pBindChildCol; bindParentCol = pBindParentCol; childCol = pChildCol; parentCol = pParentCol; allChildCol = new string[bindChildCol.Length + childCol.Length]; bindChildCol.CopyTo(allChildCol, 0); childCol.CopyTo(allChildCol, bindChildCol.Length); allParentCol = new string[bindParentCol.Length + parentCol.Length]; bindParentCol.CopyTo(allParentCol, 0); parentCol.CopyTo(allParentCol, bindParentCol.Length); // for (int i = 0; i < bindChildCol.Length; ++i) { addColForMap(bindChildCol[i], bindParentCol[i]); } for (int i = 0; i < childCol.Length; ++i) { addColForMap(childCol[i], parentCol[i]); } // if (flags.isFlagEnabled(UpdateTypeFlags.activeOnRelColumn)) { columns = bindChildCol; } else { int len = allChildCol.Length; if (flags.isFlagEnabled(UpdateTypeFlags.activateIgnorLast1DrivedChilCols)) { len -= 1; } else if (flags.isFlagEnabled(UpdateTypeFlags.activateIgnorLast2DrivedChilCols)) { len -= 2; } else if (flags.isFlagEnabled(UpdateTypeFlags.activateIgnorLast3DrivedChilCols)) { len -= 3; } columns = new string[len]; Array.Copy(allChildCol, columns, len); } columns = ToolArray.merge <string>(columns, triggerCols); // if (flags.isFlagEnabled(UpdateTypeFlags.updateIgnoreRelColumn)) { updateChildCol = childCol; } else { updateChildCol = allChildCol; } //!!!!!!!!!!!!!!!!!!!!!!!!!!! // for (int i = 0; i < allChildCol.Length; ++i) { if (!tableSource.Columns.Contains(allChildCol[i])) { tableSource.Columns.Add(allChildCol[i], ToolTypeSet.helper.tObject);//check// source.getBuilder().getColumnType(allParentCol[i])); } } // try { flags.flagEnable(UpdateTypeFlags.__spe__updateIfDrived); for (int i = 0; i < tableSource.Rows.Count; ++i) { refresh(tableSource.Rows[i]); } } finally { flags.flagDisable(UpdateTypeFlags.__spe__updateIfDrived); } // tableSource.ColumnChanged += new DataColumnChangeEventHandler(table_ColumnChanged); }
void distribute(DataRow row, string[] cols) { if (validator.check(row)) { if (needUpdate(row, cols)) { bool drivedUpdateMode = flags.isFlagEnabled(UpdateTypeFlags.__spe__updateIfDrived); if (drivedUpdateMode) { bool hasFull = false; for (int i = 0; i < allChildCol.Length; ++i) { if (ToolColumn.isColumnFullName(allChildCol[i])) { hasFull = true; } } if (!hasFull) { return; } } //getData source.getBuilder().reset(); for (int i = 0; i < cols.Length; ++i) { string col = ToolColumn.extractColumnName(getColMap(cols[i])); string tab = ToolColumn.extractTableName(getColMap(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); } } IDictionary dicData = ToolRow.convertFirstToDictionary(source.getAll()); // if (dicData != null) { //Has data string[] tmpChildCol = (drivedUpdateMode ? ToolColumn.selectFullNameCols(updateChildCol) : updateChildCol); for (int i = 0; i < tmpChildCol.Length; ++i) { ToolCell.set(row, tmpChildCol[i], dicData[getColMap(tmpChildCol[i])]); } } else { //No data if (!flags.isFlagEnabled(UpdateTypeFlags.disableEditCancel)) { row.CancelEdit(); } else { if (flags.isFlagEnabled(UpdateTypeFlags.setTypeDefaultToDrivedChild)) { ToolRow.initTableNewRow(row, (drivedUpdateMode ? ToolColumn.selectFullNameCols(childCol) : childCol)); } if (flags.isFlagEnabled(UpdateTypeFlags.setTypeDefaultToRelChild)) { ToolRow.initTableNewRow(row, (drivedUpdateMode ? ToolColumn.selectFullNameCols(bindChildCol) : bindChildCol)); } } } } } }