Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 void tableSource_ColumnChanging(object sender, DataColumnChangeEventArgs e)
 {
     if (e.Row.RowState != DataRowState.Detached)
     {
         if (isMyCollumn(e.Column.ColumnName) && validator.check(e.Row))
         {
             if (block())
             {
                 try
                 {
                     ToolRow.initTableNewRow(e.Row, cols);
                 }
                 finally
                 {
                     unblock();
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 void tableSource_RowDeleting(object sender, DataRowChangeEventArgs e)
 {
     if (e.Row.RowState != DataRowState.Detached)
     {
         if (validator.check(e.Row))
         {
             if (block())
             {
                 try
                 {
                     ToolRow.initTableNewRow(e.Row, cols);
                 }
                 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();
                }
            }
        }
Exemplo n.º 5
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));
                     }
                 }
             }
         }
     }
 }