Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:3k
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- AnsiString fieldname,filename,asstype;
- int nn;
- double aa;
- filename="test1.dbf";
- asstype="T1";
- Query1->Active=False;
- Query1->SQL->Clear();
- Query1->SQL->Add("SELECT");
- Query1->SQL->Add("MAX(NUM)");
- Query1->SQL->Add("From ""+filename+""");
- if(CheckBox1->Checked)
- Query1->SQL->Add("WHERE TYPE='"+asstype+"'");
- Query1->Active=True;
- nn=Query1->FieldCount;
- if(nn>0)
- fieldname=Query1->Fields->Fields[0]->FieldName;
- aa=Query1->FieldByName(fieldname)->AsFloat;
- Edit1->Text=FloatToStr(aa);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- AnsiString fieldname,filename,asstype;
- int nn;
- double aa;
- filename="test1.dbf";
- asstype="T1";
- Query1->Active=False;
- Query1->SQL->Clear();
- Query1->SQL->Add("SELECT");
- Query1->SQL->Add("SUM(NUM)");
- Query1->SQL->Add("From ""+filename+""");
- if(CheckBox1->Checked)
- Query1->SQL->Add("WHERE TYPE='"+asstype+"'");
- Query1->Active=True;
- nn=Query1->FieldCount;
- if(nn>0)
- fieldname=Query1->Fields->Fields[0]->FieldName;
- aa=Query1->FieldByName(fieldname)->AsFloat;
- Edit1->Text=FloatToStr(aa);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button3Click(TObject *Sender)
- {
- AnsiString fieldname,filename,asstype;
- int nn;
- double aa;
- filename="test1.dbf";
- asstype="T1";
- Query1->Active=False;
- Query1->SQL->Clear();
- Query1->SQL->Add("SELECT");
- Query1->SQL->Add("AVG(NUM)");
- Query1->SQL->Add("From ""+filename+""");
- if(CheckBox1->Checked)
- Query1->SQL->Add("WHERE TYPE='"+asstype+"'");
- Query1->Active=True;
- nn=Query1->FieldCount;
- if(nn>0)
- fieldname=Query1->Fields->Fields[0]->FieldName;
- aa=Query1->FieldByName(fieldname)->AsFloat;
- Edit1->Text=FloatToStr(aa);
- }
- //---------------------------------------------------------------------------