//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "UDemoBDE.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "MRViewer"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
        if (RGType->ItemIndex == 0)
        {
           switch (RGReport->ItemIndex) {
             case 0: MRViewer->LoadReport("..\\..\\Reports\\DemoGraph1.mrp"); break;
             case 1: MRViewer->LoadReport("..\\..\\Reports\\DemoGraph2.mrp"); break;
             case 2: MRViewer->LoadReport("..\\..\\Reports\\DemoGraph3.mrp"); break;
           };
        }
        else
        {
           switch (RGReport->ItemIndex) {
             case 0: MRViewer->LoadReport("..\\..\\Reports\\Demo1.mrp"); break;
             case 1: MRViewer->LoadReport("..\\..\\Reports\\Demo2.mrp"); break;
             case 2: MRViewer->LoadReport("..\\..\\Reports\\Demo3.mrp"); break;
           };
        };

        MRViewer->Preview();
        MRViewer->UnLoadReport();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::MRViewerProgress(int Position)
{
    ProgressBar->Position = Position;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::MRViewerGetDataSet(AnsiString Name, bool IsMain,
      AnsiString DetailInternalName, TDataSet *&FDataSet)
{
    switch (RGReport->ItemIndex)
    {
      case 0: FDataSet = Table; break;

      case 1: FDataSet = Query2; break;

      case 2:  if (IsMain)
                  FDataSet = Table3;
               else // detail
               {
                   Query3->Active = False;
                   Query3->SQL->Clear();
                   Query3->SQL->Add("select * from  parts where VendorNo=" + Table3->FieldByName("VendorNo")->AsString);
                   Query3->Active = True;
                   FDataSet = Query3;
               };
               break;
    };
}
//---------------------------------------------------------------------------
