www.pudn.com > crestroncontrol.rar > Login.cpp, change:2006-09-30,size:3629b


//--------------------------------------------------------------------------- 
 
#include <vcl.h> 
#pragma hdrstop 
 
#include "Login.h" 
#include "stdio.h" 
#include "UDataModule.h" 
//--------------------------------------------------------------------------- 
#pragma package(smart_init) 
#pragma link "SnButton" 
#pragma link "SnEdit" 
#pragma link "SnComboBox" 
#pragma link "SnCustomComboBox" 
#pragma resource "*.dfm" 
TFormLogin *FormLogin; 
//--------------------------------------------------------------------------- 
__fastcall TFormLogin::TFormLogin(TComponent* Owner) 
  : TForm(Owner) 
{ 
} 
//--------------------------------------------------------------------------- 
 
/*__fastcall TFormLogin::TFormLogin(TComponent* Owner,TADOConnection *ThirdPartyConnection, TPlaceInfo *PlaceInfo) 
  : TForm(Owner) 
{ 
//    TempConnection=ThirdPartyConnection; 
 //   TempInfo=PlaceInfo; 
}   */ 
//--------------------------------------------------------------------------- 
 
//--------------------------------------------------------------------------- 
 
void __fastcall TFormLogin::ButtonOkClick(TObject *Sender) 
{ 
    if(EditName->Enabled == false) 
    { 
        ModalResult = mrOk; 
        return; 
    } 
    ModalResult = mrNo; 
 
    TADOQuery *qryUser = new TADOQuery(this); 
    try 
    { 
        qryUser->Close(); 
        qryUser->Connection = dmConn->ADOSPGL; 
        qryUser->SQL->Text = "Select * From v_spgl_user_depart Where EMP_NO = '" + EditName->Text + "'"; 
        qryUser->Open(); 
 
        if(qryUser->FieldByName("PASSWD")->AsString == EditPassword->Text) 
        { 
            username = qryUser->FieldByName("EMP_NAME")->AsString; 
            ModalResult = mrOk; 
        } 
        delete qryUser; 
    } 
    catch(...) 
    { 
        Application->MessageBox("数据库或网络异常,稍后再试!","提示",MB_ICONASTERISK); 
        delete qryUser; 
    } 
} 
//--------------------------------------------------------------------------- 
 
void __fastcall TFormLogin::EditNameKeyPress(TObject *Sender, char &Key) 
{ 
    if(Key==13) 
    { 
        EditPassword->SetFocus(); 
    } 
} 
//--------------------------------------------------------------------------- 
 
void __fastcall TFormLogin::EditPasswordKeyPress(TObject *Sender, 
      char &Key) 
{ 
    if(Key==13) 
    { 
        ButtonOkClick(ButtonOk); 
    } 
} 
//--------------------------------------------------------------------------- 
 
void __fastcall TFormLogin::ButtonCancelClick(TObject *Sender) 
{ 
    ModalResult = mrCancel;     
} 
//--------------------------------------------------------------------------- 
 
void __fastcall TFormLogin::FormShow(TObject *Sender) 
{ 
    EditName->SetFocus(); 
/*    TIniFile *iniFile = new TIniFile(ExtractFileDir(Application->ExeName) + "\\config.ini"); 
    AnsiString name = iniFile->ReadString("caption","name","上海市海事法院"); 
    Caption = name+"-登陆"; 
    Label3->Caption = name; 
    delete iniFile; */ 
/*    TADOQuery *qryUser = new TADOQuery(this); 
    try 
    { 
        qryUser->Close(); 
        qryUser->Connection = dmConn->ADOSPGL; 
        qryUser->SQL->Text = "select * from v_spgl_user_depart";; 
        qryUser->Open(); 
        while(!qryUser->Eof) 
        { 
            EditName->Items->Add(qryUser->FieldByName("EMP_NAME")->AsString); 
            qryUser->Next(); 
        } 
        delete qryUser; 
    } 
    catch(...) 
    { 
        Application->MessageBox("数据库或网络异常,稍后再试!","提示",MB_ICONASTERISK); 
        delete qryUser; 
    }*/ 
} 
//---------------------------------------------------------------------------