home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / progs / CB / DATA.Z / FRMTRANS.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-20  |  2.4 KB  |  63 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Frmtrans.hpp"
  6. #include "DmCSDemo.hpp"
  7. //---------------------------------------------------------------------------
  8. #pragma resource "*.dfm"
  9. TFrmTransDemo *FrmTransDemo;
  10. //---------------------------------------------------------------------------
  11. __fastcall TFrmTransDemo::TFrmTransDemo(TComponent* Owner)
  12.   : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TFrmTransDemo::FormShow(TObject *Sender)
  17. {
  18.   DmEmployee->EmployeeDatabase->StartTransaction();
  19.   DmEmployee->EmployeeTable->Open();
  20. }
  21. //---------------------------------------------------------------------
  22. void __fastcall TFrmTransDemo::FormHide(TObject *Sender)
  23. {
  24.   DmEmployee->EmployeeDatabase->Commit();
  25. }
  26. //---------------------------------------------------------------------
  27. void __fastcall TFrmTransDemo::BtnCommitEditsClick(TObject *Sender)
  28. {
  29.    // NOTE: All Pronto Exmaples should be using MessageDlg instead of MessageBox...
  30.    // NOTE: Also I cannot get Application->MessageBox to work either...
  31.  
  32.    if (DmEmployee->EmployeeDatabase->InTransaction == True)
  33.    {
  34.       if (MessageDlg("Are you sure you want to commit your changes?",
  35.             mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0) == mrYes)
  36.       {
  37.          DmEmployee->EmployeeDatabase->Commit();
  38.          DmEmployee->EmployeeDatabase->StartTransaction();
  39.          DmEmployee->EmployeeTable->Refresh();
  40.       }
  41.    }
  42.    else
  43.       MessageDlg("Can't Commit Changes: No Transaction Active", mtError,
  44.                TMsgDlgButtons() << mbOK, 0);
  45. }
  46. //---------------------------------------------------------------------
  47. void __fastcall TFrmTransDemo::BtnUndoEditsClick(TObject *Sender)
  48. {
  49.    if (DmEmployee->EmployeeDatabase->InTransaction == True)
  50.    {
  51.       if (MessageDlg("Are you sure you want to undo all changes",
  52.             mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0) == mrYes)
  53.       {
  54.          DmEmployee->EmployeeDatabase->Rollback();
  55.          DmEmployee->EmployeeDatabase->StartTransaction();
  56.          DmEmployee->EmployeeTable->Refresh();
  57.       }
  58.    }
  59.    else
  60.       MessageDlg("Can't Undo Edits: No Transaction Active", mtError,
  61.                TMsgDlgButtons() << mbOK, 0);
  62. }
  63. //---------------------------------------------------------------------