⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 charge.cpp

📁 CBUILDER+SQL的实现
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Charge.h"
#include "shoufei.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm5 *Form5;
//---------------------------------------------------------------------------
__fastcall TForm5::TForm5(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm5::Button1Click(TObject *Sender)
{

 try
 {
 Query1->Close();
 Query1->SQL->Clear();
 AnsiString strSQL="select sno,sname,zhuanye,deptName,Student.houseNo,schooling,Hshoufei,incidental ";
     strSQL+=" from Student,Department,House ";
     strSQL+="where Student.deptNo=Department.deptNo ";
     strSQL+="and  Student.houseNo=House.houseNo ";
     strSQL+="and sname like '%"+LabeledEdit1->Text+"%'";

 Query1->SQL->Add(strSQL);   //等价Query1->SQL->Text=strSQL;

 Query1->Prepare();//预先准备查询方法,此语句可提高查询效率
 //Query1->ExecSQL();//执行语句
 Query1->Open();   //打开表显示内容,一定要写的方法。

 //查询charge收费表
  Query2->Close();
 Query2->SQL->Clear();
 strSQL="select * from Charge ";
  strSQL+="where sname like '%"+LabeledEdit1->Text+"%';";

   Query2->SQL->Add(strSQL);
 Query2->Prepare();
 Query2->Open();

 if(Query1->RecordCount!=0)
  {  if(Query2->RecordCount!=0)
     MessageBox(Handle,"查询成功","信息提示",MB_OK);
    else
     MessageBox(Handle,"查询成功,但查询到的人都尚未缴费","信息提示",MB_OK);
  }
  else
    {MessageBox(Handle,"没有此人!","信息提示",MB_OK);}
 }
 catch (Exception &e)
 {MessageBox(Handle,"查询失败","信息提示",MB_OK);
 }

 
}
//---------------------------------------------------------------------------

void __fastcall TForm5::N1Click(TObject *Sender)
{
 Form6->ShowModal();
 
}
//---------------------------------------------------------------------------

void __fastcall TForm5::Button2Click(TObject *Sender)
{
Close();        
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -