?? login.cpp
字號:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "sys.h"
#include "login.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TLoginForm *LoginForm;
//---------------------------------------------------------------------------
__fastcall TLoginForm::TLoginForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TLoginForm::BtLoginClick(TObject *Sender)
{
if (EdUser->Text.IsEmpty())
{
ShowMessage("請輸入用戶名, 用戶名不能為空!");
EdUser->SetFocus();
}
else
{
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("select * From student");
ADOQuery1->SQL->Add("where Name = :Name and Pass = :Pass");
ADOQuery1->Parameters->ParamByName("Name")->Value=EdUser->Text;
ADOQuery1->Parameters->ParamByName("Pass")->Value=EdPass->Text;
ADOQuery1->Open();
if(ADOQuery1->RecordCount!=1)
{
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("select * From teacher");
ADOQuery1->SQL->Add("where Name = :Name and Pass = :Pass");
ADOQuery1->Parameters->ParamByName("Name")->Value=EdUser->Text;
ADOQuery1->Parameters->ParamByName("Pass")->Value=EdPass->Text;
ADOQuery1->Open();
if (ADOQuery1->RecordCount!=1)
{
i++;
if(i<3)
{
ShowMessage("用戶名或口令錯誤,請您重新輸入!");
EdUser->SetFocus();
}
else if (i==3)
{
ShowMessage("非法用戶,無權登陸該系統!");
Application->Terminate();
}
}
else
{
MainForm->SPlan->Enabled = true;
MainForm->SCous->Enabled = true;
MainForm->SRoom->Enabled = true;
MainForm->SStud->Enabled = true;
MainForm->STeach->Enabled = true;
MainForm->SClass->Enabled = true;
MainForm->SAuto->Enabled = true;
MainForm->SQClas->Enabled = false;
MainForm->SQTeach->Enabled = true;
Close();
}
}
else if(ADOQuery1->RecordCount==1)
{
MainForm->SPlan->Enabled = false;
MainForm->SCous->Enabled = false;
MainForm->SRoom->Enabled = false;
MainForm->SStud->Enabled = false;
MainForm->STeach->Enabled = false;
MainForm->SClass->Enabled = false;
MainForm->SAuto->Enabled = false;
MainForm->SQClas->Enabled = true;
MainForm->SQTeach->Enabled = false;
Close();
}
}
}
//---------------------------------------------------------------------------
void __fastcall TLoginForm::FormCreate(TObject *Sender)
{
ClientHeight = 208;
ClientWidth = 331;
Left = 339;
Top = 233;
Width = 318;
Height = 242;
}
//---------------------------------------------------------------------------
void __fastcall TLoginForm::BtQuitClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TLoginForm::FormClose(TObject *Sender,
TCloseAction &Action)
{
Action = caFree;
}
//---------------------------------------------------------------------------
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -