private void ShowDetailsManual(PAddressLayoutCodeRow ARow)
 {
     if (FIndexedGridRowsHelper != null)
     {
         FIndexedGridRowsHelper.UpdateButtons(GetSelectedRowIndex(), FPetraUtilsObject.SecurityReadOnly);
     }
 }
        // A method that fixes the values of DisplayIndex so they are sequential.
        // Used in particular after deleting rows
        private void FixDisplayIndexValues()
        {
            for (int i = 0; i < FMainDS.PAddressLayoutCode.DefaultView.Count; i++)
            {
                PAddressLayoutCodeRow row = (PAddressLayoutCodeRow)FMainDS.PAddressLayoutCode.DefaultView[i].Row;

                if (row.DisplayIndex != i + 1)
                {
                    row.DisplayIndex = i + 1;
                }
            }
        }
        private void ShowDetailsManual(PAddressLayoutCodeRow ARow)
        {
            if (ARow == null)
            {
                btnUp.Enabled   = false;
                btnDown.Enabled = false;
            }
            else
            {
                btnUp.Enabled   = (GetSelectedRowIndex() > 1);
                btnDown.Enabled = (GetSelectedRowIndex() > 0) && (GetSelectedRowIndex() < grdDetails.Rows.Count - 1);
            }

            btnDelete.Enabled = (pnlDetails.Enabled && CanDeleteSelection());
        }
        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 NewRowManual(ref PAddressLayoutCodeRow ARow)
        {
            string newName        = Catalog.GetString("NEWCODE");
            Int32  countNewDetail = 0;

            if (FMainDS.PAddressLayoutCode.Rows.Find(new object[] { newName }) != null)
            {
                while (FMainDS.PAddressLayoutCode.Rows.Find(new object[] { newName + countNewDetail.ToString() }) != null)
                {
                    countNewDetail++;
                }

                newName += countNewDetail.ToString();
            }

            ARow.Code         = newName;
            ARow.DisplayIndex = FMainDS.PAddressLayoutCode.Rows.Count + 1;
        }
        private void ShowDetailsManual(PAddressLayoutCodeRow ARow)
        {
            if (ARow == null)
            {
                btnUp.Enabled = false;
                btnDown.Enabled = false;
            }
            else
            {
                btnUp.Enabled = (GetSelectedRowIndex() > 1);
                btnDown.Enabled = (GetSelectedRowIndex() > 0) && (GetSelectedRowIndex() < grdDetails.Rows.Count - 1);
            }

            btnDelete.Enabled = (pnlDetails.Enabled && CanDeleteSelection());
        }
        private void NewRowManual(ref PAddressLayoutCodeRow ARow)
        {
            string newName = Catalog.GetString("NEWCODE");
            Int32 countNewDetail = 0;

            if (FMainDS.PAddressLayoutCode.Rows.Find(new object[] { newName }) != null)
            {
                while (FMainDS.PAddressLayoutCode.Rows.Find(new object[] { newName + countNewDetail.ToString() }) != null)
                {
                    countNewDetail++;
                }

                newName += countNewDetail.ToString();
            }

            ARow.Code = newName;
            ARow.DisplayIndex = FMainDS.PAddressLayoutCode.Rows.Count + 1;
        }