公司员工上班下班午休打卡考勤系统,这是一个有过多家应用的实用考勤程序
procedure Tmainform.N37Click(Sender: TObject);
var
form:TformSelday;
i:integer;
begin
form:=TformSelday.Create(self);
if (form.ShowModal=1) then
begin
bIsEat := true;
query.SQL.Clear;
query.SQL.Add('select cdate as 日期, tag as 就餐,people as 姓名,time1 as 午餐,time2 as 晚餐 from eat where cdate=:v1 order by cdate desc');
if (form.RadioButton1.Checked=true) then
begin
query.Parameters.ParamByName('v1').Value:=date;
sDate := DateToStr(date);
end
else
begin
query.Parameters.ParamByName('v1').Value:=DateToStr(form.dtpBgn.date);
sDate := DateToStr(form.dtpBgn.date);
end;
query.ExecSQL;
//query.Active:=true;
if (query.RecordCount=0) then
begin
ShowMessage('没有相关纪录');
dbgrid1.Visible:=false;
form.Free;
exit;
end;
datasource1.DataSet:=query;
dbgrid1.Visible:=true;
for i:=0 to dbgrid1.Columns.Count-1 do
dbgrid1.Columns[i].Width := dbgrid1.Width div dbgrid1.Columns.Count-1;
num1:=0;
num2:=0;
//统计并设置状态栏
while (not query.Eof) do
begin
if (query.FieldByName('午餐').Value<>'0:00:00') then num1:=num1 1;
if (query.FieldByName('晚餐').Value<>'0:00:00') then num2:=num2 1;
query.Next;
end;
statusbar1.Panels[0].Text:='共有纪录' inttostr(query.RecordCount) '条';
statusbar1.Panels[1].Text:='午餐:' inttostr(num1) '人次 晚餐:' inttostr(num2) '人次';
end;
form.Free;
end;
procedure Tmainform.N36Click(Sender: TObject);
var
result:string;
//qry:TAdoQuery;
begin
num1:=0;
num2:=0;
if (dbgrid1.Visible=false) then exit;
if bIsEat = false then exit;
if (dbgrid1.DataSource.DataSet=Nil) then exit;
if (dbgrid1.DataSource.DataSet.RecordCount=0) then
begin
showmessage('没有记录,不能统计');
exit;
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qry.Close;
qry.SQL.Clear;
if sDate = '0' then
begin
qry.SQL.Add('select count(*) as num1 from eat where time1<>''0:00:00'' ');
end
else
begin
qry.SQL.Add('select count(*) as num1 from eat where cdate=:cd and time1<>''0:00:00'' ');
qry.Parameters.ParamByName('cd').Value := sDate;
end;
qry.Open;
num1 := qry.FieldByName('num1').Value;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qry.Close;
qry.SQL.Clear;
if sDate = '0' then
begin
qry.SQL.Add('select count(*) as num2 from eat where time2<>''0:00:00'' ');
end
else
begin
qry.SQL.Add('select count(*) as num2 from eat where cdate=:cd and time2<>''0:00:00'' ');
qry.Parameters.ParamByName('cd').Value := sDate;
end;
qry.Open;
num2 := qry.FieldByName('num2').Value;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
result:='当前视图:午餐' inttostr(num1) '人次,晚餐' inttostr(num2) '人次';
showmessage(result);
end;
procedure Tmainform.N34Click(Sender: TObject);
begin
Application.CreateForm(TfrmEatAdd, frmEatAdd);
frmEatAdd.ShowModal;
frmEatAdd.Free;
end;
procedure Tmainform.N39Click(Sender: TObject);
begin
Application.CreateForm(TfrmBook, frmBook);
frmBook.ShowModal;
frmBook.Free;
end;
评论