Example #1
0
void CRecordView::OnUpdateRecordLast(CCmdUI* pCmdUI)
{
    CRecordset* prs = OnGetRecordset();

    // enable if opened, can scroll,
    pCmdUI->Enable(prs->IsOpen() && prs->CanScroll() &&
                   // >= 1 records present and not already on last record
                   !(prs->IsEOF() && prs->IsBOF()) && !IsOnLastRecord());
}
Example #2
0
void CRecordView::OnUpdateRecordNext(CCmdUI* pCmdUI)
{
    CRecordset* prs = OnGetRecordset();

    // enable if opened and >= 1 records present
    pCmdUI->Enable(prs->IsOpen() && !(prs->IsEOF() && prs->IsBOF())
                   // and not already on last record
                   && !IsOnLastRecord());
}
Example #3
0
BOOL CRecordView::OnMove(UINT nIDMoveCommand)
{
    CRecordset* pSet = OnGetRecordset();
    if (pSet->CanUpdate() && !pSet->IsDeleted())
    {
        pSet->Edit();
        if (!UpdateData())
            return TRUE;

        pSet->Update();
    }

    switch (nIDMoveCommand)
    {
    case ID_RECORD_PREV:
        pSet->MovePrev();
        if (!pSet->IsBOF())
            break;

    case ID_RECORD_FIRST:
        pSet->MoveFirst();
        break;

    case ID_RECORD_NEXT:
        pSet->MoveNext();
        if (!pSet->IsEOF())
            break;
        if (!pSet->CanScroll())
        {
            // clear out screen since we're sitting on EOF
            pSet->SetFieldNull(NULL);
            break;
        }

    case ID_RECORD_LAST:
        pSet->MoveLast();
        break;

    default:
        // Unexpected case value
        ASSERT(FALSE);
    }

    // Show results of move operation
    UpdateData(FALSE);
    return TRUE;
}