//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "PsWd.h"
#include "Main.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TPsWdForm *PsWdForm;
String SvPsWd;
int selec;
//---------------------------------------------------------------------------
__fastcall TPsWdForm::TPsWdForm(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
__fastcall TPsWdForm::TPsWdForm(int Opt,TComponent* Owner)
        : TForm(Owner)
{     
        
       selec = Opt;

}
//---------------------------------------------------------------------------
void __fastcall TPsWdForm::OkBtnClick(TObject *Sender)
{
bool bo = false;
        Query1->Close();
        Query1->SQL->Clear();
        Query1->SQL->Add("select * from posuser where user_id = :uid and passwd = :psw");
        Query1->ParamByName("uid")->AsString = IdEdit->Text;
        Query1->ParamByName("psw")->AsString = PassEdit->Text;

        Query1->Prepare();


        if(Query1->Prepared)
                Query1->Open();

        switch(selec)
        {
                case 0:
                        bo = Query1->FieldByName("cal")->AsBoolean;
                        break;
                case 1:
                        bo = Query1->FieldByName("datain")->AsBoolean;
                        break;
                case 2:
                        bo = Query1->FieldByName("jungsan")->AsBoolean;
                        break;
                case 3:
                        bo = Query1->FieldByName("partin")->AsBoolean;
                        break;
                case 4:
                        bo = Query1->FieldByName("sellerin")->AsBoolean;
                        break;
                case 5:
                        bo = Query1->FieldByName("userin")->AsBoolean;
                        break;
                case 6:
                        bo = Query1->FieldByName("config")->AsBoolean;
                        break;
        }

        Query1->Close();
        if(bo == true)
        {
                MainForm = new TMainForm(selec,this);
                IdEdit->Text="";
                PassEdit->Text="";
                Close();
        }
        else
        {
                ShowMessage("사용권한이 없습니다.");

        }
        


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




void __fastcall TPsWdForm::PassEditKeyPress(TObject *Sender, char &Key)
{
        if(Key==0x0D)
        {
                OkBtn->Click();
        }
}
//---------------------------------------------------------------------------

