예제 #1
0
        object[] selectValues(object[] pKeys)
        {
            if (pKeys == null)
            {
                pKeys = new object[0];
            }

            List <object> list = new List <object>();

            foreach (object[] arr in data)
            {
                if (pKeys.Length < arr.Length)
                {
                    bool select_ = ToolArray.isEqual(pKeys, ToolArray.resize <object>(arr, pKeys.Length));
                    if (select_)
                    {
                        if (pKeys.Length < arr.Length)
                        {
                            object val_ = arr[pKeys.Length];

                            if (!list.Contains(val_))
                            {
                                list.Add(val_);
                            }
                        }
                    }
                }
            }

            return(list.ToArray());
        }
예제 #2
0
        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();
            }
        }
        public DataRow[] get(DataRow row)
        {
            DataRow[] rows  = new DataRow[0];
            DataTable table = row.Table;

            //
            if (row != null)
            {
                // if (row.RowState != DataRowState.Deleted)
                for (int i = 0; i < table.Rows.Count; ++i)
                {
                    DataRow locRow = table.Rows[i];
                    if (locRow.RowState != DataRowState.Deleted)
                    {
                        if ((!ToolStockLine.isLineStlineGlobal(locRow)) && ToolStockLine.isLineMonetary(locRow))
                        {
                            if (rows == null)
                            {
                                rows = new DataRow[] { locRow }
                            }
                        }
                    }
                    ;
                    else
                    {
                        rows = ToolArray.resize <DataRow>(rows, rows.Length + 1);

                        rows[rows.Length - 1] = locRow;
                    }
                }
예제 #4
0
        public DataRow[] get(DataRow row)
        {
            DataRow[] rows  = new DataRow[0];
            DataTable table = row.Table;

            //
            if (row != null && row.RowState != DataRowState.Deleted)
            {
                if (!ToolStockLine.isLineStlineGlobal(row))
                {
                    if (ToolStockLine.isLineMonetary(row))
                    {
                        for (int i = table.Rows.IndexOf(row) + 1; i < table.Rows.Count; ++i)
                        {
                            DataRow locRow = table.Rows[i];
                            if (locRow.RowState != DataRowState.Deleted)
                            {
                                if (ToolStockLine.isLineMonetary(locRow))
                                {
                                    break;
                                }
                                if ((!ToolStockLine.isLineStlineGlobal(locRow)) && ToolStockLine.isLinePureMoney(locRow))
                                {
                                    if (rows == null)
                                    {
                                        rows = new DataRow[] { locRow }
                                    }
                                    ;
                                    else
                                    {
                                        rows = ToolArray.resize <DataRow>(rows, rows.Length + 1);

                                        rows[rows.Length - 1] = locRow;
                                    }
                                }
                            }
                        }
                    }
                    else
                    if (ToolStockLine.isLinePureMoney(row))
                    {
                        rows = new DataRow[] { row };
                    }
                }
            }
            return(rows);
        }
예제 #5
0
        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);
        }