frm_k_sjszpas.pas
来自「是一个用delphi设计的考勤系统」· PAS 代码 · 共 236 行
PAS
236 行
unit Frm_K_SjszPas;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ModalForm, Menus, StdCtrls, ExtCtrls, YLabelButton, ChangeImage,
ComCtrls, Grids, DBGrids, Buttons, DB, ADODB, ImgList, UErrDisplay,
ModalForm1;
type
TFrm_K_Sjsz = class(TMyModalForm1)
Panel3: TPanel;
Label9: TLabel;
Label10: TLabel;
Label1: TLabel;
GroupBox1: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
dtp1: TDateTimePicker;
dtp3: TDateTimePicker;
dtp2: TDateTimePicker;
dtp4: TDateTimePicker;
bc: TEdit;
bcms: TEdit;
cmbCdZt: TComboBox;
TV: TTreeView;
ADOTSjb: TADOTable;
ADOTSjbbc: TIntegerField;
ADOTSjbbcms: TStringField;
ADOTSjbkssj: TStringField;
ADOTSjbdksj: TStringField;
ADOTSjbjzsj: TStringField;
ADOTSjbyssj: TStringField;
ADOTSjbcdzt: TStringField;
BtnBrowse: TChangeImg;
LBtnBrowse: TLabelB;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
DSSjb: TDataSource;
popmenuYhxx: TPopupMenu;
N5: TMenuItem;
DBGrid1: TDBGrid;
procedure FormCreate(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure bcKeyPress(Sender: TObject; var Key: Char);
procedure BtnBrowseClick(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
private
{ Private declarations }
procedure showKqsj;
function DataOpt:Boolean;
public
{ Public declarations }
end;
var
Frm_K_Sjsz: TFrm_K_Sjsz;
implementation
uses DM_DataModal, UGlobal, Frm_K_QjszPas,UTKqgl;
{$R *.dfm}
procedure TFrm_K_Sjsz.FormCreate(Sender: TObject);
begin
inherited;
ADOTSjb.Close;
ADOTSjb.open;
if ADOTSjb.Eof then exit;
gtKqgl.ShowBcTree(TV);
showKqsj;
end;
procedure TFrm_K_Sjsz.showKqsj;
begin
with ADOTSjb do
begin
bc.text := fieldbyname('bc').asstring;
bcms.text := fieldbyname('bcms').asstring;
if trim(fieldbyname('cdzt').asstring) = 'C' then
cmbCdZt.text := 'C:迟到'
else if trim(fieldbyname('cdzt').asstring) = 'Z' then
cmbCdZt.text := 'C:早退';
if fieldbyname('kssj').asstring = '' then
dtp1.Time := strtotime('00:00:00')
else
dtp1.Time := strtotime(fieldbyname('kssj').asstring);
if fieldbyname('dksj').asstring = '' then
dtp2.Time := strtotime('00:00:00')
else
dtp2.Time := strtotime(fieldbyname('dksj').asstring);
if fieldbyname('jzsj').asstring = '' then
dtp3.Time := strtotime('00:00:00')
else
dtp3.Time := strtotime(fieldbyname('jzsj').asstring);
if fieldbyname('yssj').asstring = '' then
dtp4.Time := strtotime('00:00:00')
else
dtp4.Time := strtotime(fieldbyname('yssj').asstring);
gtKqgl.SjBc:=StrToInt(Trim(Bc.Text));
end;
end;
procedure TFrm_K_Sjsz.DBGrid1CellClick(Column: TColumn);
begin
inherited;
showKqsj;
end;
procedure TFrm_K_Sjsz.bcKeyPress(Sender: TObject; var Key: Char);
begin
inherited;
if key = char(vk_back) then exit;
if key = #13 then
begin
bcms.SetFocus;
exit;
end;
if not (key in ['0'..'9']) then key := #0;
end;
Function TFrm_K_Sjsz.DataOpt:Boolean;
begin
Result:=False;
if timetostr(dtp1.Time) > timetostr(dtp2.Time) then
begin
application.MessageBox('开始时间必须小于上班时间!', '提示信息', mb_ok + mb_iconinformation);
exit;
end;
if timetostr(dtp1.Time) > timetostr(dtp3.Time) then
begin
application.MessageBox('开始时间必须小于截止时间!', '提示信息', mb_ok + mb_iconinformation);
exit;
end;
if timetostr(dtp1.Time) > timetostr(dtp3.Time) then
begin
application.MessageBox('开始时间必须小于延时时间!', '提示信息', mb_ok + mb_iconinformation);
exit;
end;
if timetostr(dtp2.Time) > timetostr(dtp3.Time) then
begin
application.MessageBox('上班时间必须小于截止时间!', '提示信息', mb_ok + mb_iconinformation);
exit;
end;
if timetostr(dtp2.Time) > timetostr(dtp4.Time) then
begin
application.MessageBox('上班时间必须小于延时时间!', '提示信息', mb_ok + mb_iconinformation);
exit;
end;
if timetostr(dtp4.Time) > timetostr(dtp3.Time) then
begin
application.MessageBox('延时时间必须小于截止时间!', '提示信息', mb_ok + mb_iconinformation);
exit;
end;
if bc.text = '' then
begin
application.MessageBox('请输入班次!', '提示信息', mb_ok + mb_iconinformation);
bc.SetFocus;
exit;
end;
if cmbcdzt.text = '' then
begin
application.MessageBox('请选择缺勤类别!', '提示信息', mb_ok + mb_iconinformation);
exit;
end;
Result:=True;
end;
procedure TFrm_K_Sjsz.BtnBrowseClick(Sender: TObject);
begin
inherited;
Frm_K_Qjsz := TFrm_K_Qjsz.Create(application);
try
Frm_K_Qjsz.ShowModal;
finally
Frm_K_Qjsz.Free;
Frm_K_Qjsz:=nil;
end;
end;
procedure TFrm_K_Sjsz.BitBtn1Click(Sender: TObject);
begin
inherited;
if Not DataOpt then Exit;
gtKqgl.SjBc:=StrToInt(Trim(Bc.Text));
gtKqgl.SjBcms:=Trim(Bcms.Text);
gtKqgl.SjKssj:=timetostr(dtp1.Time);
gtKqgl.SjDksj:=timetostr(dtp2.Time);
gtKqgl.SjJzsj:=timetostr(dtp3.Time);
gtKqgl.SjYssj:=timetostr(dtp4.Time);
gtKqgl.SjCdzt:=copy(cmbcdzt.text, 1, 1);
gtKqgl.BcOpt(1);
ADOTSjb.Close;
ADOTSjb.Open;
application.MessageBox(Pchar(gtKqgl.RetMsg), '提示信息', mb_ok + mb_iconinformation);
gtKqgl.ShowBcTree(TV);
end;
procedure TFrm_K_Sjsz.BitBtn2Click(Sender: TObject);
begin
inherited;
if Not DataOpt then Exit;
gtKqgl.SjBc:=StrToInt(Trim(Bc.Text));
gtKqgl.SjBcms:=Trim(Bcms.Text);
gtKqgl.SjKssj:=timetostr(dtp1.Time);
gtKqgl.SjDksj:=timetostr(dtp2.Time);
gtKqgl.SjJzsj:=timetostr(dtp3.Time);
gtKqgl.SjYssj:=timetostr(dtp4.Time);
gtKqgl.SjCdzt:=copy(cmbcdzt.text, 1, 1);
gtKqgl.BcOpt(3);
ADOTSjb.Close;
ADOTSjb.Open;
application.MessageBox(PChar(gtKqgl.RetMsg), '提示信息', mb_ok + mb_iconinformation);
end;
procedure TFrm_K_Sjsz.BitBtn3Click(Sender: TObject);
begin
inherited;
if Not DataOpt then Exit;
gtKqgl.SjBc:=StrToInt(Trim(Bc.Text));
gtKqgl.BcOpt(2);
ADOTSjb.Close;
ADOTSjb.Open;
application.MessageBox(PChar(gtKqgl.RetMsg), '提示信息', mb_ok + mb_iconinformation);
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?