private void RunOnceOnActivationManual() { // Always disable the deletable flag chkDetailDeletable.Enabled = false; // No grid sorting because it is done using the DisplayIndex column grdDetails.SortableHeaders = false; FMainDS.PAddressLayoutCode.DefaultView.Sort = String.Format("{0} ASC", PAddressLayoutCodeTable.GetDisplayIndexDBName()); // Select first row after altering the sort SelectRowInGrid(1); }
private void PromoteOrDemoteRecord(Boolean APromote) { // Get the display index of the current row int curIndex = FPreviouslySelectedDetailRow.DisplayIndex; // Create a view on this display index and the neighbouring one DataView dv = new DataView(FMainDS.PAddressLayoutCode, String.Format("{0}={1} OR {0}={2}", PAddressLayoutCodeTable.GetDisplayIndexDBName(), curIndex, APromote ? curIndex - 1 : curIndex + 1), String.Format("{0} ASC", PAddressLayoutCodeTable.GetDisplayIndexDBName()), DataViewRowState.CurrentRows); // We should have two rows if (dv.Count == 2) { PAddressLayoutCodeRow row1 = (PAddressLayoutCodeRow)dv[0].Row; PAddressLayoutCodeRow row2 = (PAddressLayoutCodeRow)dv[1].Row; row1.DisplayIndex = row1.DisplayIndex + 1; row2.DisplayIndex = row2.DisplayIndex - 1; FMainDS.PAddressLayoutCode.DefaultView.Sort = String.Format("{0} ASC", PAddressLayoutCodeTable.GetDisplayIndexDBName()); if (APromote) { SelectRowInGrid(GetSelectedRowIndex() - 1); } else { SelectRowInGrid(GetSelectedRowIndex() + 1); } FPetraUtilsObject.SetChangedFlag(); } else { // The display index values in the database have got mixed up. // Either there is a break in the sequence or there are two rows with the same index MessageBox.Show(Catalog.GetString( "The application encountered a problem with the record order, but has attempted to fix it. Please try clicking the button again."), Catalog.GetString("Layout Code Order"), MessageBoxButtons.OK, MessageBoxIcon.Information); // We can use the same code we use after deleting rows to restore a sequential display order FixDisplayIndexValues(); } }
private void RunOnceOnActivationManual() { FIndexedGridRowsHelper = new TSgrdDataGrid.IndexedGridRowsHelper( grdDetails, PAddressLayoutCodeTable.ColumnDisplayIndexId, btnDemote, btnPromote, delegate { FPetraUtilsObject.SetChangedFlag(); }); // Always disable the deletable flag chkDetailDeletable.Enabled = false; // No grid sorting because it is done using the DisplayIndex column grdDetails.SortableHeaders = false; FMainDS.PAddressLayoutCode.DefaultView.Sort = String.Format("{0} ASC", PAddressLayoutCodeTable.GetDisplayIndexDBName()); // Select first row after altering the sort SelectRowInGrid(1); if (FPetraUtilsObject.SecurityReadOnly) { btnDelete.Enabled = false; } }