📄 login.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Login.h"
#include "DM1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormLogin *FormLogin;
int nError = 0;
//---------------------------------------------------------------------------
__fastcall TFormLogin::TFormLogin(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFormLogin::FormCreate(TObject *Sender)
{
pLogin = GetQuery("QYongHu");
pUser = GetQuery("Query3");
}
//---------------------------------------------------------------------------
void __fastcall TFormLogin::FormClose(TObject *Sender,
TCloseAction &Action)
{
pLogin->Close();
pUser->Close();
pUser->SQL->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TFormLogin::FormShow(TObject *Sender)
{
pLogin->Open();
while (!pLogin->Eof)
{
ComboBox1->Items->Add(pLogin->FieldByName("yhmc")->AsString);
pLogin->Next();
}
}
//---------------------------------------------------------------------------
void __fastcall TFormLogin::ComboBox1Change(TObject *Sender)
{
pLogin->First();
pLogin->MoveBy(ComboBox1->ItemIndex);
}
//---------------------------------------------------------------------------
void __fastcall TFormLogin::BitBtnOkClick(TObject *Sender)
{
if (ComboBox1->ItemIndex == -1)
{
ShowMessage("请选择用户名称!");
ComboBox1->SetFocus();
return;
}
if (pLogin->FieldByName("biaozi")->AsBoolean == 1)
{
ShowMessage("对不起,你的使用权已被暂停,请与管理员联系!");
BitBtnCancelClick(this);
return;
}
if (EditMima->Text != pLogin->FieldByName("mima")->AsString)
{
if (nError == 2)
{
ShowMessage("对不起,你无权使用本系统!");
BitBtnCancelClick(this);
return;
}
else
{
ShowMessage("密码错误,请重新输入!");
EditMima->SetFocus();
EditMima->SelectAll();
nError += 1;
}
}
else
{
nResult =1;
sYhmc = ComboBox1->Text ;
sQuanxian = pLogin->FieldByName("quanxian")->AsString;
pUser->Close();
pUser->SQL->Clear();
pUser->SQL->Add("insert into kq_login(yhmc,quanxian,sj,zt) values('" + sYhmc + "','" + sQuanxian + "','" + Now().FormatString("yyyy-mm-dd hh:mm:ss") + "','进入')");
pUser->ExecSQL();
Close();
}
}
//---------------------------------------------------------------------------
void __fastcall TFormLogin::BitBtnCancelClick(TObject *Sender)
{
nResult = 2;
Close();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -