[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

clock in application

Posted on 2004-04-15
2
Medium Priority
?
214 Views
Last Modified: 2010-08-05
Click in and Clock out application connecting to Access database with ODBC
storing the user name and the password in the database

thank you
0
Comment
Question by:zgeorge_2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Expert Comment

by:sftweng
ID: 10838903
zgeorge_2, are you looking for ideas or for a "shrink-wrapped" solution published here?
0
 
LVL 17

Accepted Solution

by:
mokule earned 2000 total points
ID: 10839779
Hi George,
this is Your code.

{-------------------------------------------------------------}
program ClockInOut1;

uses
  Forms,
  Main1 in 'Main1.pas' {Form1},
  Pswd in 'Pswd.pas' {FPswd},
  Clock in 'Clock.pas' {FClock},
  Data in 'Data.pas' {DM1: TDataModule};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TDM1, DM1);
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TFPswd, FPswd);
  Application.CreateForm(TFClock, FClock);
  Application.Run;
end.
{-------------------------------------------------------------}
unit Main1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons;

type
  TForm1 = class(TForm)
    edID: TEdit;
    BitBtn2: TBitBtn;
    BitBtn1: TBitBtn;
    BitBtn3: TBitBtn;
    BitBtn4: TBitBtn;
    BitBtn5: TBitBtn;
    BitBtn6: TBitBtn;
    BitBtn7: TBitBtn;
    BitBtn8: TBitBtn;
    BitBtn9: TBitBtn;
    BitBtn10: TBitBtn;
    BitBtn11: TBitBtn;
    BitBtn12: TBitBtn;
    BitBtn13: TBitBtn;
    procedure BitBtn4Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure edIDKeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Pswd, Data, Clock;

{$R *.dfm}

procedure TForm1.BitBtn4Click(Sender: TObject);
var
  str: string;
  ind: integer;
begin
  str := edID.Text;
  ind := edID.SelStart;
  if (Length(str) < edID.MaxLength) or (edID.MaxLength = 0) then
    begin
    Insert( Char(Ord('0')+(Sender as TBitBtn).Tag),
            str, edID.SelStart+1);
    edID.Text := str;
    ActiveControl := edID;
    edID.SelStart := ind+1;
    end
  else
    begin
    ActiveControl := edID;
    edID.SelStart := ind;
    end;
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
var
  str: string;
  ind: integer;
begin
  str := edID.Text;
  ind := edID.SelStart;
  if ind > 0 then
    begin
    Delete(str, edID.SelStart,1);
    edID.Text := str;
    end;
  ActiveControl := edID;
  if ind > 0 then
    edID.SelStart := ind-1
  else
    edID.SelStart := 0;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  edID.Text := '';
  ActiveControl := edID;
end;

procedure TForm1.BitBtn3Click(Sender: TObject);
begin
  DM1.ADOQuery1.Close;
  DM1.ADOQuery1.SQL.Text :=
    Format('SELECT * FROM Tab_usr WHERE usr_id=%d',[StrToIntDef(edID.Text,-1)]);
  DM1.ADOQuery1.Open;
  if not DM1.ADOQuery1.Eof then
    begin
    FPswd.edPswd.Text := '';
    FPswd.edID.Text := edID.Text;
    if FPswd.ShowModal = mrOK then
      begin
      DM1.ADOQuery2.Close;
      DM1.ADOQuery2.SQL.Text :=
        Format('SELECT TOP 1 * FROM tab_clk WHERE clk_usr_nr=%d ORDER BY clk_time DESC',
               [DM1.ADOQuery1.FieldByName('usr_nr').AsInteger]);
      DM1.ADOQuery2.Open;
      if DM1.ADOQuery2.Eof then
        begin
        FClock.Button1.Visible := True;
        FClock.Button2.Visible := True;
        end
      else if (DM1.ADOQuery2.FieldByName('clk_type').AsString = 'O') then
        begin
        FClock.Button1.Visible := True;
        FClock.Button2.Visible := False;
        end
      else
        begin
        FClock.Button1.Visible := False;
        FClock.Button2.Visible := True;
        end;
      FClock.ShowModal;
      end;
    edID.Text := '';
    end
  else
    begin
    Application.MessageBox('Inalid ID Entered !','Error',MB_OK+MB_ICONEXCLAMATION)
    end;
end;

procedure TForm1.edIDKeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in ['0'..'9',#8]) then
    Key := #0;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  DM1.ADOConnection1.Connected := True;
end;

end.

{-------------------------------------------------------------}
unit Clock;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TFClock = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Label1: TLabel;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    procedure InsertTime(t: Char);
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FClock: TFClock;

implementation

uses Data;

{$R *.dfm}

procedure TFClock.FormActivate(Sender: TObject);
begin
  ActiveControl := nil;
  Timer1.Enabled := True;
end;

procedure TFClock.Timer1Timer(Sender: TObject);
var
  str: string;
begin
  str := DateTimeToStr(Now);
  if str <> Label1.Caption then
    Label1.Caption := str;
end;

procedure TFClock.Button1Click(Sender: TObject);
begin
  InsertTime('I');
  Close;
end;

procedure TFClock.InsertTime(t: Char);
var
  nr: integer;
begin
  nr := DM1.ADOQuery1.FieldByName('usr_nr').AsInteger;
  DM1.ADOCommand1.CommandText :=
      Format('INSERT INTO tab_clk (clk_usr_nr,clk_type,clk_time) VALUES (%d,''%s'',''%s'')',
                       [nr,t,Label1.Caption]);
  DM1.ADOCommand1.Execute;
end;

procedure TFClock.Button2Click(Sender: TObject);
begin
  InsertTime('O');
  Close;
end;

end.
{-------------------------------------------------------------}
unit Pswd;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TFPswd = class(TForm)
    edPswd: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    edID: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FPswd: TFPswd;

implementation

uses Main1, Clock, Data;

{$R *.dfm}

procedure TFPswd.FormCreate(Sender: TObject);
begin
  Left := Form1.Left + 150;
  Top := Form1.Top -30;
end;

procedure TFPswd.Button3Click(Sender: TObject);
begin
  DM1.ADOQuery1.Close;
  DM1.ADOQuery1.SQL.Text :=
    Format('SELECT * FROM Tab_usr WHERE usr_id=%d AND usr_pswd=''%s''',
          [StrToIntDef(edID.Text,-1),edPswd.Text]);
  DM1.ADOQuery1.Open;
  if not DM1.ADOQuery1.Eof then
    ModalResult := mrOK
  else
    Application.MessageBox('Inalid password entered !','Error',MB_OK+MB_ICONEXCLAMATION)
end;

procedure TFPswd.FormActivate(Sender: TObject);
begin
  ActiveControl := edPswd;
end;

end.
{-------------------------------------------------------------}
unit Data;

interface

uses
  SysUtils, Classes, DB, ADODB;

type
  TDM1 = class(TDataModule)
    ADOConnection1: TADOConnection;
    ADOQuery1: TADOQuery;
    ADOCommand1: TADOCommand;
    ADOQuery2: TADOQuery;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  DM1: TDM1;

implementation

{$R *.dfm}

end.
{-------------------------------------------------------------}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question