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());
        }
Beispiel #2
0
        void table_RowDeleting(object sender, DataRowChangeEventArgs e)
        {
            if (validator.check(e.Row))
            {
                if (block())
                {
                    try
                    {
                        DataTable table   = e.Row.Table;
                        DataRow[] topRows = forTop.get(e.Row);
                        DataRow[] subRows = forSub.get(e.Row);
                        if (topRows != null && subRows != null)
                        {
                            for (int i = 0; i < topRows.Length; ++i)
                            {
                                if (object.ReferenceEquals(topRows[i], e.Row))
                                {
                                    for (int r = 0; r < subRows.Length; ++r)
                                    {
                                        subRows[r].Delete();
                                    }
                                }
                            }
                        }
                    }

                    finally
                    {
                        unblock();
                    }
                }
            }
        }
        void table_ColumnChangedRow(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
                        {
                            for (int i = 0; i < e.Row.Table.Rows.Count; ++i)
                            {
                                DataRow row = e.Row.Table.Rows[i];
                                if (row.RowState != DataRowState.Deleted)
                                {
                                    if (validatorMainRow.check(row))
                                    {
                                        wkrRow.Invoke(e.Row);
                                    }
                                }
                            }
                        }

                        finally
                        {
                            unblock();
                        }
                    }
                }
            }
        }
        public void addRelation(string[] pCols, ITableColumnChange pActivity, IBlockPoint pBlock, IRowValidator pValidator, ColumnChangeEventType pEvent)
        {
            pValidator = (pValidator == null) ? new RowValidatorTrue() : pValidator;

            try
            {
                blockPointMain.block();
                for (int i = 0; i < tableTarget.Rows.Count; ++i)
                {
                    DataRow row = tableTarget.Rows[i];
                    if (pValidator.check(row))
                    {
                        pActivity.initForColumnChanged(row);
                    }
                }
            }
            finally
            {
                blockPointMain.unblock();
            }

            foreach (string col in pCols)
            {
                add(col, pActivity, pBlock, pValidator, pEvent);
            }
        }
        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;
            }
        }
        public void export(XmlDocument doc)
        {
            if (this.getExportDescriptor() == null)
            {
                initExportDescriptor(this, _userAdapter);
            }
            correctDoc(doc);
            DataSet    dataSet    = _userAdapter.getDataSet();
            XmlElement xmlExpRoot = doc.CreateElement(_nodeItemName);

            xmlExpRoot.SetAttribute(_attrRootCode, dataSet.DataSetName);
            char   sepChar = '\t';
            string expTable;

            string[] expCols;
            IEnumerator <KeyValuePair <string, string[]> > expTabsEnumer = _expDesc.GetEnumerator();

            expTabsEnumer.Reset();
            while (expTabsEnumer.MoveNext())
            {
                expTable = expTabsEnumer.Current.Key;
                expCols  = expTabsEnumer.Current.Value;

                DataTable     table     = dataSet.Tables[expTable];
                IRowValidator validator = getValidator(expTable);
                //
                XmlElement xmlExpTab = doc.CreateElement(expTable);
                xmlExpTab.SetAttribute(_attrItemTableCols, ToolString.joinList(sepChar, expCols));
                xmlExpRoot.AppendChild(xmlExpTab);
                //
                StringWriter strData = new StringWriter();
                strData.WriteLine();
                foreach (DataRow expRow in table.Rows)
                {
                    if (validator.check(expRow))
                    {
                        bool isFirstVal = true;
                        foreach (string expCol in expCols)
                        {
                            if (isFirstVal)
                            {
                                isFirstVal = false;
                            }
                            else
                            {
                                strData.Write(sepChar);
                            }
                            strData.Write(_formating.format(expRow[expCol]));
                        }
                        strData.WriteLine();
                    }
                }
                xmlExpTab.InnerText = strData.GetStringBuilder().ToString();
            }
            doc[_nodeRootName].AppendChild(xmlExpRoot);
        }
 public void set(DataRow pRow)
 {
     if (pRow != null && validator.check(pRow))
     {
         for (int i = 0; i < cols.Length; ++i)
         {
             ToolCell.set(pRow, cols[i], vals[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());
        }
Beispiel #9
0
 public static DataRow getFirstRealRow(DataTable table, IRowValidator validator)
 {
     for (int i = 0; i < table.Rows.Count; ++i)
     {
         if ((table.Rows[i].RowState != DataRowState.Deleted) && validator.check(table.Rows[i]))
         {
             return(table.Rows[i]);
         }
     }
     return(null);
 }
Beispiel #10
0
 public void refresh()
 {
     if (bp.block())
     {
         try
         {
             for (int i = 0; i < tableSource.Rows.Count; ++i)
             {
                 if (validator.check(tableSource.Rows[i]))
                 {
                     distribute(tableSource.Rows[i], bindChildCol);
                 }
             }
         }
         finally
         {
             bp.unblock();
         }
     }
 }
Beispiel #11
0
 public static int getSectionStart(DataTable table, IRowValidator validator)
 {
     for (int indx = 0; indx < table.Rows.Count; ++indx)
     {
         if ((table.Rows[indx].RowState != DataRowState.Deleted))
         {
             if (validator.check(table.Rows[indx]))
             {
                 return(indx);
             }
         }
     }
     return(-1);
 }
Beispiel #12
0
 public void refresh()
 {
     if (!flags.isFlagEnabled(UpdateTypeFlags.stopRefresh))
     {
         if (bp.block())
         {
             try
             {
                 for (int i = 0; i < tableSource.Rows.Count; ++i)
                 {
                     if (validator.check(tableSource.Rows[i]))
                     {
                         distribute(tableSource.Rows[i], bindChildCol);
                     }
                 }
             }
             finally
             {
                 bp.unblock();
             }
         }
     }
 }
        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 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();
                }
            }
        }