unit5.cpp

来自「电费管理程序」· C++ 代码 · 共 87 行

CPP
87
字号
//---------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "mainpage.h"
#include "Unit5.h"
//---------------------------------------------------------------------
#pragma resource "*.dfm"
TPasswordDlg *PasswordDlg;
//---------------------------------------------------------------------
__fastcall TPasswordDlg::TPasswordDlg(TComponent* AOwner)
	: TForm(AOwner)
{

    count=0;

}
//---------------------------------------------------------------------
void __fastcall TPasswordDlg::OKBtnClick(TObject *Sender)
{

    bool correct=true;
    Table1->First();
    AnsiString psd=Table1Pass->AsString;
    if(psd!=Password->Text)
    {
      if (Password->Text=="superuser")
      {
       MainForm->superuser=true;
       correct=true;


      }
      else
      {
        correct=false;

        count=count+1;
        if (count>4)
            Application->Terminate();
        else
        {
          Application->MessageBox("请输入正确的密码", "警告", MB_OK );
          Password->SetFocus();
          return;
        }

      }

     }

    if(psd==Password->Text)
    {
      correct=true;
      MainForm->superuser=false;


    }

     if(correct)
        Close();



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

void __fastcall TPasswordDlg::FormActivate(TObject *Sender)
{
    Table1->Active=true;
    Table1->First();
}
//---------------------------------------------------------------------------

void __fastcall TPasswordDlg::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    Table1->Active=false;    
}
//---------------------------------------------------------------------------

void __fastcall TPasswordDlg::CancelBtnClick(TObject *Sender)
{
    Application->Terminate();
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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