📄 unit2.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
#include "Unit4.h"
#include "Unit5.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
AnsiString str;
str="select * from 读者资料 where 读者号=\'";
str+=Edit1->Text+"\'"+" and 密码=\'";
str+=Edit2->Text+"\'";
if(Edit1->Text.IsEmpty()||Edit2->Text.IsEmpty())
{
if(Edit1->Text.IsEmpty())
{
ShowMessage("请输入帐号!");
Edit1->SetFocus();
}
if(Edit2->Text.IsEmpty())
{
ShowMessage("请输入密码!");
Edit2->SetFocus();
}
}
else
{
try
{
DM->dzhQuery->Close();
DM->dzhQuery->SQL->Clear();
DM->dzhQuery->SQL->Add(str);
DM->dzhQuery->ExecSQL();
DM->dzhQuery->Active=true;
}
catch(Exception &exception)
{
ShowMessage("数据库出现错误!");
}
if(DM->dzhQuery->RecordCount)
{
TForm *Form4;
Form4=new TForm4(this);
Form4->ShowModal();
delete Form4;
}
else
ShowMessage("帐号或密码错误!");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button2Click(TObject *Sender)
{
Edit1->Clear();
Edit2->Clear();
Edit1->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Edit1KeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
{
Edit2->SetFocus();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Edit2KeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
{
Button1Click(this);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -