home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Info / TeachU14 / SAMS / Code / Day12 / dbfiltru.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-08  |  2.1 KB  |  61 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "DbFiltrU.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init);
  8. #pragma resource "*.dfm"
  9. TForm2 *Form2;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm2::TForm2(TComponent* Owner)
  12.   : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16.  
  17. void __fastcall TForm2::DBNamesComboBoxChange(TObject *Sender)
  18. {
  19.   if (Table1->Active == true)
  20.     Table1->Active = false;
  21.   TablesComboBox->Text = "";
  22.   String DBName = DBNamesComboBox->Text;
  23.   TDatabase* db = new TDatabase(this);
  24.   db->AliasName = DBName;
  25.   if (db->IsSQLBased)
  26.     Session->GetTableNames(DBName, "",
  27.       false, true, TablesComboBox->Items);
  28.   else
  29.     Session->GetTableNames(DBName, "",
  30.       true, false, TablesComboBox->Items);
  31.   Table1->DatabaseName = DBName;
  32.   TablesComboBox->DroppedDown = true;
  33.   delete db;
  34. }
  35. //---------------------------------------------------------------------------
  36. void __fastcall TForm2::TablesComboBoxChange(TObject *Sender)
  37. {
  38.   if (Table1->Active == true)
  39.     Table1->Active = false;
  40.   Table1->TableName = TablesComboBox->Text;
  41.   Table1->Active = true;
  42.   FieldsComboBox->Enabled = true;
  43.   OperatorComboBox->Enabled = true;
  44.   ValueEdit->Enabled = true;
  45.   Table1->GetFieldNames(FieldsComboBox->Items);
  46.   FieldsComboBox->Text = FieldsComboBox->Items->Strings[0];
  47. }
  48. //---------------------------------------------------------------------------
  49. void __fastcall TForm2::FormCreate(TObject *Sender)
  50. {
  51.   Session->GetDatabaseNames(DBNamesComboBox->Items);
  52. }
  53. //---------------------------------------------------------------------------
  54. void __fastcall TForm2::FilterBtnClick(TObject *Sender)
  55. {
  56.   Table1->Filter = FieldsComboBox->Text +
  57.     " " + OperatorComboBox->Text + " '" + ValueEdit->Text + "'";
  58.   Table1->Filtered = true;
  59. }
  60. //---------------------------------------------------------------------------
  61.