实例介绍
【实例简介】公司员工上班下班午休打卡考勤系统,这是一个有过多家应用的实用考勤程序
【实例截图】

【核心代码】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;
【实例截图】


【核心代码】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;
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论