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 void table_RowChanged(object sender, DataRowChangeEventArgs e) { if (e.Action != DataRowAction.Add) { return; } if (validator.check(e.Row)) { if (block()) { try { for (int i = 0; i < cols.Length; ++i) { ToolCell.set(e.Row, cols[i], values[i]); } } finally { unblock(); } } } }
public static void mult(DataRow row, string col, object val1, object val2, object coif) { if (!(ToolCell.isNull(val1) || ToolCell.isNull(val2) || ToolCell.isNull(coif))) { ToolCell.set(row, col, (double)val1 * (double)val2 * (double)coif); } }
protected void table_ColumnChanged(object sender, DataColumnChangeEventArgs e) { if (e.Row.RowState != DataRowState.Detached) { string curColumn = e.Column.ColumnName; if (isMyCollumn(curColumn) && validator.check(e.Row)) { if (block()) { try { if (curColumn == colDateTime) { ToolCell.set(e.Row, colIntDate, toInt((DateTime)e.ProposedValue)); } else if (curColumn == colIntDate) { ToolCell.set(e.Row, colDateTime, fromInt((int)e.ProposedValue)); } } finally { unblock(); } } } } }
public override void activityForRow(DataColumnChangeEventArgs e) { for (int i = 0; i < columns.Length; ++i) { evaluator.setVar(columns[i], e.Row[columns[i]]); } ToolCell.set(e.Row, column, evaluator.getResult(column)); }
public static object[] getVallueArrayForTable(DataTable table) { object[] arr = new object[table.Columns.Count]; for (int i = 0; i < table.Columns.Count; ++i) { arr[i] = ToolCell.getCellTypeDefaulValue(table.Columns[i].DataType); } return(arr); }
public static void setColumnValue(DataTable table, string col, object val) { for (int i = 0; i < table.Rows.Count; ++i) { if (table.Rows[i].RowState != DataRowState.Deleted) { ToolCell.set(table.Rows[i], col, val); } } }
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))); } } }
private void distribute(DataRow dataRow) { DateTime datetime = (DateTime)ToolCell.isNull(dataRow[columns[0]], DateTime.Now); for (int i = 1; i < columns.Length; ++i) { object part = dateTimePart(datetime, parts[i]); ToolCell.set(dataRow, columns[i], part); } }
public static DataRow initTableNewRow(DataRow row, string[] cols) { DataTable table = row.Table; for (int i = 0; i < cols.Length; ++i) { ToolCell.set(row, cols[i], ToolCell.getCellTypeDefaulValue(table.Columns[cols[i]].DataType)); } return(row); }
public static void copyRowToRow(DataRow rowS, DataRow rowD) { if ((rowS != null) && (rowD != null)) { for (int i = 0; i < rowS.Table.Columns.Count; ++i) { ToolCell.set(rowD, i, rowS[i]); } } }
public static void copyArrToRow(object[] arr, DataRow row) { if ((arr != null) && (row != null)) { for (int i = 0; i < arr.Length; ++i) { ToolCell.set(row, i, arr[i]); } } }
public static object getColumnLastValue(DataTable table, string col, object def) { for (int i = table.Rows.Count - 1; i >= 0; --i) { if (table.Rows[i].RowState != DataRowState.Deleted) { return(ToolCell.isNull(table.Rows[i][col], def)); } } return(def); }
public static DataRow initTableNewRow(DataRow row) { if (row != null) { DataTable table = row.Table; for (int i = 0; i < table.Columns.Count; ++i) { ToolCell.set(row, i, ToolCell.getCellTypeDefaulValue(table.Columns[i].DataType)); } } return(row); }
private void compile(DataRow dataRow) { DateTime datetime = (DateTime)ToolCell.isNull(dataRow[columns[0]], DateTime.Now); for (int i = 1; i < columns.Length; ++i) { if (!ToolCell.isNull(dataRow[columns[i]])) { datetime = setDateTimePatr(datetime, parts[i], dataRow[columns[i]]); } } ToolCell.set(dataRow, columns[0], datetime); }
public long getCellTouch(DataRow row, string col) { long last = untouched; if (row != null && col != null) { if (accessList.ContainsKey(row)) { last = (long)ToolCell.isNull(accessList[row][col], (long)untouched); } } return(last); }
public static void trimColumn(DataTable table, string col) { if ((table != null) && (table.Columns[col].DataType == typeof(string))) { for (int i = 0; i < table.Rows.Count; ++i) { if (!ToolRow.isDeleted(table.Rows[i])) { table.Rows[i][col] = ((string)ToolCell.isNull(table.Rows[i][col], string.Empty)).Trim(); } } } }
public static void fillNull(DataTable table) { for (int c = 0; c < table.Columns.Count; ++c) { object defVal = ToolCell.getCellTypeDefaulValue(table.Columns[c].DataType); for (int r = 0; r < table.Rows.Count; ++r) { if (table.Rows[r].IsNull(c)) { table.Rows[r][c] = defVal; } } } }
public static void div(DataRow row, string col, object val1, object val2, object coif) { if (!(ToolCell.isNull(val1) || ToolCell.isNull(val2) || ToolCell.isNull(coif))) { if (Math.Abs((double)val2 * (double)coif) > (double)Common.Const.ConstValues.minPositive) { ToolCell.set(row, col, (double)val1 / ((double)val2 * (double)coif)); } else { ToolCell.set(row, col, 0.0); } } }
public static double getSumDouble(DataRow[] rows, string col) { double res = 0; if (rows != null) { for (int i = 0; i < rows.Length; ++i) { if (!ToolRow.isDeleted(rows[i])) { res += (double)ToolCell.isNull(rows[i][col], 0.0); } } } return(res); }
public static double sumExp(DataRow[] rows, string exp) { double res = 0; if ((rows != null) && (rows.Length > 0)) { ImplRowEvaluator eval = new ImplRowEvaluator(rows[0].Table); eval.addExpression(exp, typeof(double)); for (int i = 0; i < rows.Length; ++i) { eval.setVar(rows[i]); res += (double)ToolCell.isNull(eval.getResult(), 0.0); } } return(res); }
public static double getSumDouble(DataTable table, string col) { double res = 0; if (table != null) { for (int i = 0; i < table.Rows.Count; ++i) { if (!ToolRow.isDeleted(table.Rows[i])) { res += (double)ToolCell.isNull(table.Rows[i][col], 0.0); } } } return(res); }
protected void table_DistributeValues(DataRow[] topRows, DataRow[] subRows) { double topSum = 0; for (int i = 0; i < topRows.Length; ++i) { evaluator.setVar(topRows[i]); topSum += (double)evaluator.getResult(nameTopExp); } for (int i = 0; i < subRows.Length; ++i) { DataRow curSubRow = subRows[i]; Stack <string> stack = toucher.sort(subCols, curSubRow); string column; if (stack.Count > 0) { column = stack.ToArray()[stack.Count - 1]; } else { column = subCols[subCols.Length - 1]; } for (int s = 0; s < subCols.Length; ++s) { if (subCols[s] == column) { object tmpRes; // evaluator.setVar(_TOP_VALUE_, topSum); evaluator.setVar(curSubRow); tmpRes = evaluator.getResult(getName(subCols[s])); ToolCell.set(curSubRow, column, tmpRes); // topSum = (double)evaluator.getResult(nameSubCoorectExp); // topSum = (double)ToolCell.isNull(tmpRes, 0.0); // } } } }
void table_RowDeleting(object sender, DataRowChangeEventArgs e) { if (validator.check(e.Row)) { if (block()) { try { for (int i = 0; i < columns.Length; ++i) { ToolCell.set(e.Row, columns[i], values[i]); } } finally { unblock(); } } } }
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))); } } }
public void check() { if (block()) { try { DataRow fRow = null; switch (direction) { case RowMaintainDirection.down: fRow = ToolRow.getFirstRealRow(tableSource, validator); break; case RowMaintainDirection.up: fRow = ToolRow.getLastRealRow(tableSource, validator); break; } if (fRow == null || !maintainRow.check(fRow)) { DataRow nRow = ToolRow.initTableNewRow(tableSource.NewRow()); for (int i = 0; i < cols.Length; ++i) { ToolCell.set(nRow, cols[i], values[i]); } int indx = 0; switch (place) { case RowMaintainPlace.top: indx = ToolRow.getSectionStart(tableSource, validator); break; case RowMaintainPlace.bottom: indx = ToolRow.getSectionEnd(tableSource, validator); if (indx >= 0) { ++indx; } break; } if (indx < 0) { switch (noSectionPlace) { case RowMaintainPlace.top: indx = 0; break; case RowMaintainPlace.bottom: indx = int.MaxValue; break; } } tableSource.Rows.InsertAt(nRow, indx); } } finally { unblock(); } } }
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)); } } } } } }