ghquery.cpp
来自「C++ Builder数据库开发经典案例解析 示例程序都是在C++ Build」· C++ 代码 · 共 50 行
CPP
50 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "ghquery.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TfmQueryGH *fmQueryGH;
//---------------------------------------------------------------------------
__fastcall TfmQueryGH::TfmQueryGH(TComponent* Owner)
: TForm(Owner)
{
Edit1->Text = "";
Edit2->Text = "";
}
//---------------------------------------------------------------------------
void __fastcall TfmQueryGH::Button1Click(TObject *Sender)
{
AnsiString sql;
sql = "select 挂号科室, count(*) as 人数, sum(挂号费用) as 金额 ";
sql += "from 门诊挂号";
AnsiString con;
if(Edit1->Text.Length()>0)
con = " 时间>='" + Edit1->Text + "'";
if(Edit2->Text.Length()>0)
{
if(con.Length()>0)
con += " and ";
con = " 时间<='" + Edit2->Text + "'";
}
if(con.Length()>0)
sql += " where " + con;
sql += " group by 挂号科室";
Query1->SQL->Clear();
Query1->SQL->Add(sql);
Query1->Open();
}
//---------------------------------------------------------------------------
void __fastcall TfmQueryGH::FormClose(TObject *Sender,
TCloseAction &Action)
{
// 删除窗体并回收空间
Action = caFree;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?