home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 April / Chip_1997-04_cd.bin / prezent / cb / data.z / FRMTRANS.CPP < prev    next >
C/C++ Source or Header  |  1997-01-16  |  3KB  |  65 lines

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