Exemplo n.º 1
0
        /// <summary>
        /// Reflects changes in Excel worksheet if this row has just been added to a <see cref="MySqlDataTable"/>.
        /// </summary>
        private void ReflectChangesForAddedRow()
        {
            if (ExcelRange == null)
            {
                return;
            }

            ExcelRange.SetInteriorColor(ExcelUtilities.UncommittedCellsOleColor);
            ExcelModifiedRangesList.Add(ExcelRange);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves the given color in an array for the modified Excel cells related to the current row.
        /// </summary>
        /// <param name="oleColor">The new interior color for the Excel cells.</param>
        private void SaveCurrentColor(int oleColor)
        {
            if (_excelRangePreviousColors == null)
            {
                return;
            }

            foreach (int colIndex in ExcelModifiedRangesList.Select(modifiedRange => modifiedRange.Column).Where(colIndex => colIndex <= _excelRangePreviousColors.Length))
            {
                _excelRangePreviousColors[colIndex - 1] = oleColor;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Reflects the error set to the row on its corresponding Excel range cells.
        /// </summary>
        public void ReflectError()
        {
            if (IsBeingDeleted || ExcelRange == null)
            {
                return;
            }

            var cellsColor = HasConcurrencyWarnings ? ExcelUtilities.WarningCellsOleColor : ExcelUtilities.ErroredCellsOleColor;

            ExcelModifiedRangesList.SetInteriorColor(cellsColor);
            SaveCurrentColor(cellsColor);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Reflects changes in Excel worksheet if this row has just been modified.
        /// </summary>
        private void ReflectChangesForModifiedRow()
        {
            if (RowState == DataRowState.Added && ExcelRange != null)
            {
                // A recently added row's value is being modified, we just need to re-paint the whole "added" row.
                ExcelRange.SetInteriorColor(ExcelUtilities.UncommittedCellsOleColor);
            }

            if (RowState != DataRowState.Modified)
            {
                return;
            }

            if (ExcelRange != null)
            {
                ExcelModifiedRangesList.Clear();
            }

            ChangedColumnNames.Clear();

            // Check column by column for data changes, set related Excel cells color accordingly.
            for (int colIndex = 0; colIndex < Table.Columns.Count; colIndex++)
            {
                ExcelInterop.Range columnCell     = ExcelRange != null ? ExcelRange.Cells[1, colIndex + 1] : null;
                bool originalAndModifiedIdentical = this[colIndex].Equals(this[colIndex, DataRowVersion.Original]);
                if (!originalAndModifiedIdentical)
                {
                    if (columnCell != null)
                    {
                        ExcelModifiedRangesList.Add(columnCell);
                    }

                    ChangedColumnNames.Add(Table.Columns[colIndex].ColumnName);
                }

                if (columnCell == null)
                {
                    continue;
                }

                var cellColor = originalAndModifiedIdentical ? _excelRangePreviousColors[colIndex] : ExcelUtilities.UncommittedCellsOleColor;
                columnCell.SetInteriorColor(cellColor);
            }

            // If the row resulted with no modifications (maybe some values set back to their original values by the user) then undo changes.
            if (ChangedColumnNames.Count == 0)
            {
                RejectChanges();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Reflects changes in Excel worksheet if this row has just been commited.
        /// </summary>
        private void ReflectChangesForCommittedRow()
        {
            if (!IsBeingDeleted && ExcelRange != null)
            {
                ExcelModifiedRangesList.SetInteriorColor(ExcelUtilities.CommitedCellsOleColor);
                SaveCurrentColor(ExcelUtilities.CommitedCellsOleColor);
                if (!HasErrors)
                {
                    ExcelModifiedRangesList.Clear();
                }
            }

            if (!HasErrors)
            {
                ChangedColumnNames.Clear();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Reflects changes in Excel worksheet if this row has just been rolled back.
        /// </summary>
        private void ReflectChangesForRolledbackRow()
        {
            if (!IsBeingDeleted)
            {
                for (int colIndex = 0; colIndex < Table.Columns.Count; colIndex++)
                {
                    ExcelInterop.Range columnCell = ExcelRange != null ? ExcelRange.Cells[1, colIndex + 1] : null;
                    if (columnCell == null)
                    {
                        continue;
                    }

                    columnCell.SetInteriorColor(_excelRangePreviousColors[colIndex]);
                }

                ExcelModifiedRangesList.Clear();
            }

            ChangedColumnNames.Clear();
            IsBeingDeleted = false;
        }