Esempio n. 1
0
        /// <summary>
        /// Reverts the changes done to Excel cell values after the last commit.
        /// </summary>
        /// <param name="refreshFromDb">Flag indicating if instead of reverting the data back to the way it was when the editing session started, it is pulled to have the most recent version of it.</param>
        private void RevertDataChanges(bool refreshFromDb)
        {
            try
            {
                if (!refreshFromDb)
                {
                    _mySqlTable.RejectChanges();
                }
                else
                {
                    _mySqlTable.RefreshData();
                }
            }
            catch (Exception ex)
            {
                MiscUtilities.ShowCustomizedErrorDialog(Resources.EditDataRefreshErrorText, ex.Message);
            }

            Globals.ThisAddIn.SkipSelectedDataContentsDetection = true;
            EditingWorksheet.UnprotectEditingWorksheet(EditingWorksheet_Change, WorksheetProtectionKey);
            _editDataRange.Clear();
            ExcelInterop.Range topLeftCell = _editDataRange.Cells[1, 1];
            topLeftCell.Select();
            _editDataRange = _mySqlTable.ImportDataIntoExcelRange(topLeftCell);
            CommitChangesButton.Enabled = false;
            AddNewRowToEditingRange(false);
        }
Esempio n. 2
0
 /// <summary>
 /// Adds a new row at the bottom of the Excel editing range.
 /// </summary>
 /// <param name="clearColoringOfOldNewRow">Flag indicating whether the previous row that was placeholder for new rows is cleared of its formatting.</param>
 /// <returns>An Excel range containing just the newly added row.</returns>
 private ExcelInterop.Range AddNewRowToEditingRange(bool clearColoringOfOldNewRow)
 {
     EditingWorksheet.UnprotectEditingWorksheet(EditingWorksheet_Change, WorksheetProtectionKey);
     _editDataRange = _editDataRange.AddNewRow(clearColoringOfOldNewRow, out var newRowRange);
     EditingWorksheet.ProtectEditingWorksheet(EditingWorksheet_Change, WorksheetProtectionKey, _editDataRange);
     _editingRowsQuantity = _editDataRange.Rows.Count;
     return(newRowRange);
 }
Esempio n. 3
0
 /// <summary>
 /// Unprotects the edit dialog's worksheet.
 /// </summary>
 public void UnprotectWorksheet()
 {
     EditingWorksheet.UnprotectEditingWorksheet(EditingWorksheet_Change, WorksheetProtectionKey);
 }