📄 login.~cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "ShFwMain.h"
#include "Login.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TLoginForm *LoginForm;
//---------------------------------------------------------------------------
__fastcall TLoginForm::TLoginForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TLoginForm::FormCreate(TObject *Sender)
{
AnsiString Imagepath;
MainForm->ADOConnection1->Open();
ADOQuery1->Close();
ADOQuery1->Open();
MainForm->LoginFlag = false;
Imagepath = MainForm->CurDir + "\\LoginPict.jpg";
if ( FileExists( Imagepath )== true )
Image1->Picture->LoadFromFile(Imagepath);
else
Application->MessageBox("装入登录背景文件出现错误","警告",MB_OK+MB_ICONWARNING);
Imagepath = MainForm->CurDir + "\\StartPict.ico";
if ( FileExists( Imagepath )== true )
Image2->Picture->LoadFromFile(Imagepath);
else
Application->MessageBox("装入登录图标文件出现错误","警告",MB_OK+MB_ICONWARNING);
Imagepath = MainForm->CurDir + "\\Shut Down.ico";
if ( FileExists( Imagepath )== true )
Image3->Picture->LoadFromFile(Imagepath);
else
Application->MessageBox("装入退出图标文件出现错误","警告",MB_OK+MB_ICONWARNING);
}
//---------------------------------------------------------------------------
void __fastcall TLoginForm::FormClose(TObject *Sender,
TCloseAction &Action)
{
ADOQuery1->Close();
MainForm->ADOConnection1->Close();
}
//---------------------------------------------------------------------------
void __fastcall TLoginForm::CreateParams(TCreateParams &Params)
{
TForm::CreateParams(Params); // call base class first
Params.Style &= ~WS_CAPTION; // then clear caption bit
}
void __fastcall TLoginForm::Image2Click(TObject *Sender)
{
if(DBLookupComboBox1->Text.Trim()=="") {
Application->MessageBox("请选择用户","错误",MB_OK+MB_ICONERROR);
Abort();
}
if(Edit1->Text.Trim()=="") {
Application->MessageBox("请输入密码","错误",MB_OK+MB_ICONERROR);
Abort();
}
if(Edit1->Text!=ADOQuery1->FieldByName("passwd")->AsString) {
Application->MessageBox("密码有误","错误",MB_OK+MB_ICONERROR);
Edit1->Text="";
Edit1->SetFocus();
Abort();
}
MainForm->LoginFlag = true;
MainForm->MyLoginBh = ADOQuery1->FieldByName("rybh")->AsString;
MainForm->MyLoginName = ADOQuery1->FieldByName("ryxm")->AsString;
MainForm->MyLoginJb = ADOQuery1->FieldByName("jb")->AsString;
MainForm->fwslqx = ADOQuery1->FieldByName("fwslqx")->AsString;
MainForm->fwpgqx = ADOQuery1->FieldByName("fwpgqx")->AsString;
MainForm->fwjsqx = ADOQuery1->FieldByName("fwjsqx")->AsString;
MainForm->hfjsqx = ADOQuery1->FieldByName("hfjsqx")->AsString;
MainForm->pjglqx = ADOQuery1->FieldByName("pjglqx")->AsString;
MainForm->setqx = ADOQuery1->FieldByName("setqx")->AsString;
MainForm->cxqx = ADOQuery1->FieldByName("bmxxcxqx")->AsString;
Close();
}
//---------------------------------------------------------------------------
void __fastcall TLoginForm::Image3Click(TObject *Sender)
{
MainForm->LoginFlag = false;
Close();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -