Beispiel #1
0
        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();
                    }
                }
            }
        }
        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();
                        }
                    }
                }
            }
        }
Beispiel #3
0
 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);
     }
 }
 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));
 }
Beispiel #5
0
 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]);
         }
     }
 }
Beispiel #6
0
 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]);
         }
     }
 }
Beispiel #7
0
        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);
            }
        }
Beispiel #8
0
 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)));
         }
     }
 }
Beispiel #10
0
        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);
        }
Beispiel #11
0
 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);
 }
Beispiel #12
0
        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);
        }
Beispiel #13
0
 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);
         }
     }
 }
        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();
                    }
                }
            }
        }
Beispiel #16
0
 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));
                     }
                 }
             }
         }
     }
 }
        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();
                }
            }
        }