Q&A

  • 좀 도와주세요!!!!
사원번호 중복을 체크하여 같은 번호가 입력되지 않게 하기위한것인데 ...

실행시키면 사원번호가 다같다고 나오거든요.....

좀 도와 주세요!!!!



procedure TFPinsa.scodeKeyPress(Sender: TObject; var Key: Char);

var

s:string;

begin

if Key = #13 then

begin

SelectNext(Sender As TWinControl, True, True);

Key := #13;

s:= fdm.tperson.fieldbyname('scode').asstring;

////////////////////////////////////////같은 사원번호가 안나오게 하기위하부분...

with fdm.tperson do

begin

if scode.text = s then

begin

showmessage('다시 입력해주세요');

scode.setfocus;

end

else if scode.text <> s then

begin

irum.setfocus;

end;

end;

end;

end;

4  COMMENTS
  • Profile
    초보 2001.08.07 23:07
    kkk wrote:

    > 사원번호 중복을 체크하여 같은 번호가 입력되지 않게 하기위한것인데 ...

    > 실행시키면 사원번호가 다같다고 나오거든요.....

    > 좀 도와 주세요!!!!

    >

    > procedure TFPinsa.scodeKeyPress(Sender: TObject; var Key: Char);

    > var

    > s:string;

    > begin

    > if Key = #13 then begin

    > SelectNext(Sender As TWinControl, True, True);

    > Key := #13;



    s:= 사원번호.Text;

    with fdm.tperson do begin

    close;

    sql.clear;

    sql.add('select 사원번호필드명 from 인사디비');

    sql.add('where 사원번호필드명 = :사원법호');

    prambyname('사원번호').asstring := s;

    if RecordCount > 0 then begin

    showmessage('사원번호가 이미 있당. 다시 입력해주세요');

    사원번호.SetFocus;

    Exit;

    end else

    irum.setfocus;

    end;

    end;

    end;

  • Profile
    kkk 2001.08.07 23:18
    초보 wrote:

    > kkk wrote:

    > > 사원번호 중복을 체크하여 같은 번호가 입력되지 않게 하기위한것인데 ...

    > > 실행시키면 사원번호가 다같다고 나오거든요.....

    > > 좀 도와 주세요!!!!

    > >

    > > procedure TFPinsa.scodeKeyPress(Sender: TObject; var Key: Char);

    > > var

    > > s:string;

    > > begin

    > > if Key = #13 then begin

    > > SelectNext(Sender As TWinControl, True, True);

    > > Key := #13;

    >

    > s:= 사원번호.Text;

    > with fdm.tperson do begin

    > close;

    > sql.clear;

    > sql.add('select 사원번호필드명 from 인사디비');

    > sql.add('where 사원번호필드명 = :사원법호');

    > prambyname('사원번호').asstring := s;

    > if RecordCount > 0 then begin

    > showmessage('사원번호가 이미 있당. 다시 입력해주세요');

    > 사원번호.SetFocus;

    > Exit;

    > end else

    > irum.setfocus;

    > end;

    > end;

    > end;



    근데요 위부분은 테이블인데요..... 퀴리가아니구요...-.-

    제가 주석을 달았어야 했눈데..

    님 죄송하지만 한번만 더봐주시세요....

    부탁이에요!!!!

  • Profile
    초보 2001.08.08 23:04
    kkk wrote:

    procedure TFPinsa.scodeKeyPress(Sender: TObject; var Key: Char);

    var

    s:string;

    begin

    if Key = #13 then begin

    SelectNext(Sender As TWinControl, True, True);

    Key := #13;

    s:= 사원번호.Text;

    with fdm.tperson do begin

    open;

    if Findkey(['s']) then begin //Findkey 문법이 이게맞나? 아리까리..

    showmessage('사원번호가 이미 있당. 다시 입력해주세요');

    사원번호.SetFocus;

    close;

    Exit;

    end else

    irum.setfocus;

    close;

    end;

    end;

    end;

  • Profile
    비쥬얼네트 2001.08.07 22:32
    kkk wrote:

    > 사원번호 중복을 체크하여 같은 번호가 입력되지 않게 하기위한것인데 ...

    > 실행시키면 사원번호가 다같다고 나오거든요.....

    > 좀 도와 주세요!!!!

    >

    > procedure TFPinsa.scodeKeyPress(Sender: TObject; var Key: Char);

    > var

    > s:string;

    > begin

    > if Key = #13 then

    > begin

    > SelectNext(Sender As TWinControl, True, True);

    > Key := #13;

    > s:= fdm.tperson.fieldbyname('scode').asstring;

    > ////////////////////////////////////////같은 사원번호가 안나오게 하기위하부분...

    > with fdm.tperson do

    > begin

    > if scode.text = s then

    > begin

    > showmessage('다시 입력해주세요');

    > scode.setfocus;

    > end

    > else if scode.text <> s then

    > begin

    > irum.setfocus;

    > end;

    > end;

    > end;

    > end;



    insert 모드일때만 체크해야 할것 같은데..

    if table1.State = dsInsert then

    begin

    //처리문장

    .

    .

    end;