frm_k_bcszpas.pas
来自「是一个用delphi设计的考勤系统」· PAS 代码 · 共 379 行
PAS
379 行
unit Frm_K_BcszPas;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ModalForm, Menus, StdCtrls, ExtCtrls, DBTables, DB, ComCtrls,
Buttons, YLabelButton, ChangeImage, ADODB, ImgList, UErrDisplay,
ModalForm1;
type
TFrm_K_Bcsz = class(TMyModalForm1)
Label1: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
YhLv: TListView;
Panel1: TPanel;
TV: TTreeView;
BcLv: TListView;
ProgressBar1: TProgressBar;
rbnfg: TRadioButton;
rbnhl: TRadioButton;
cmbN: TComboBox;
cmbY: TComboBox;
ChangeImg1: TChangeImg;
LabelB1: TLabelB;
BtnNext: TChangeImg;
BtnPrev: TChangeImg;
BtnFirst: TChangeImg;
BtnLast: TChangeImg;
qryBcsd: TADOQuery;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure TVClick(Sender: TObject);
procedure BtnNextClick(Sender: TObject);
procedure BtnLastClick(Sender: TObject);
procedure BtnPrevClick(Sender: TObject);
procedure BtnFirstClick(Sender: TObject);
procedure YhLvColumnClick(Sender: TObject; Column: TListColumn);
procedure BcLvColumnClick(Sender: TObject; Column: TListColumn);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_K_Bcsz: TFrm_K_Bcsz;
nodevalue: string; //树节点的数值
implementation
uses UGlobal, DM_DataModal;
{$R *.dfm}
procedure TFrm_K_Bcsz.FormCreate(Sender: TObject);
begin
inherited;
gtKqgl.LoadOrganTree(Winddata.AdoConn,TV,4); //初始化用户信息
gtKqgl.IniBcListView(bcLv); //初始化班次
Yhlv.Items.clear; //初始化用户列表
with qryBcsd do //提取最后一次班次设定的年月
begin
sql.Clear;
sql.Add('select distinct n,y from kq_bcsd order by y,n desc');
open;
if not eof then
begin
cmbn.Text := trim(fieldbyname('n').asstring);
cmby.text := trim(fieldbyname('y').asstring);
end
else
begin
cmbn.Text := copy(datetostr(date), 1, 4);
cmby.Text := copy(datetostr(date), 6, 2);
end;
end;
end;
procedure TFrm_K_Bcsz.TVClick(Sender: TObject);
begin
inherited;
///////////加载人员信息//////////////////////////////////////////////////
NodeValue := ptTreeNode(TV.Selected.data)^.nodeValue;
if (copy(NodeValue, 1, 1) = 'd') then gtKqgl.LoadUserTree(TV,copy(NodeValue, 2, Length(NodeValue)-1));
/////////////////////////////////////////////////////////////
end;
procedure TFrm_K_Bcsz.BtnNextClick(Sender: TObject);
var
Query: TADOQuery;
qrybc: TADOQuery;
sYhxm: string;
ListItem: TListItem;
iCount: integer;
begin
inherited;
Query := TADOQuery.Create(Screen.activeForm);
Query.Connection := WindData.AdoConn;
qrybc := TADOQuery.Create(Screen.activeForm);
qrybc.Connection := WindData.AdoConn;;
if (copy(NodeValue, 1, 1) = 'e') then
begin
sYhxm := tv.selected.text;
with query do
begin
sql.clear;
sql.add('select yhbh,yhxm from zx_s_yhxx');
sql.add('where yhxm=''' + sYhxm + '''');
sql.add(' order by yhbh');
open;
first;
if recordcount = 0 then
begin
application.messagebox('该用户未发卡,不能在本系统进行考勤管理,所以不能设定班次', '系统提示', mb_ok + mb_iconinformation);
exit;
end;
////////////////////////////////////////////////}
while not eof do
begin
with YhLv do
begin
if not gtKqgl.isListViewExistSameItem(yhlv,Query.FieldByName('yhbh').asstring,Query.FieldByName('yhxm').asstring,0) then
begin
ListItem := Items.Add;
Checkboxes := true;
ListItem.caption := Query.FieldByName('yhbh').asstring;
ListItem.SubItems.Add(Query.FieldByName('yhxm').asstring);
ListItem.SubItems.Add(tv.selected.Parent.text);
listitem.SubItems.Add('');
with qrybc do
begin
sql.Clear;
sql.add('select * from kq_bcsd where yhbh=''' + Query.FieldByName('yhbh').asstring + ''' and n=''' + cmbN.text + ''' and y=''' + cmby.text + '''');
open;
while not eof do
begin
listitem.SubItems[2] := listitem.SubItems[2] + inttostr(fieldbyname('bc').asinteger) + '/';
next;
end;
close;
end;
end;
end;
next;
end;
for iCount := 0 to YhLv.Items.count - 1 do
YhLv.items[iCount].Checked := true;
////////////////////////////////////////////////
end;
end;
end;
procedure TFrm_K_Bcsz.BtnLastClick(Sender: TObject);
var
Query: TADOQuery;
qrybc: TADOQuery;
sBmmc: string;
ListItem: TListItem;
iCount: integer;
begin
inherited;
Query := TADOQuery.Create(Screen.activeForm);
Query.Connection := WindData.AdoConn;
qrybc := TADOQuery.Create(Screen.activeForm);
qrybc.Connection := WindData.AdoConn;
if (copy(NodeValue, 1, 1) = 'd') then
begin
sBmmc := tv.selected.text;
with query do
begin
sql.clear;
sql.add('select yhbh,yhxm,bjmc from Vzx_s_yhxx');
sql.add(' where bjmc=''' + sBmmc + '''');
sql.add(' order by yhbh');
open;
first;
if recordcount = 0 then
begin
application.messagebox('该部门人员未发卡,不能在本系统进行考勤管理,所以不能设定班次', '系统提示', mb_ok + mb_iconinformation);
exit;
end;
////////////////////////////////////////////////
while not eof do
begin
with YhLv do
begin
if not gtKqgl.isListViewExistSameItem(YhLv,Query.FieldByName('yhbh').asstring, Query.FieldByName('yhxm').asstring,0) then
begin
ListItem := Items.Add;
ListItem.caption := Query.FieldByName('yhbh').asstring;
ListItem.SubItems.Add(Query.FieldByName('yhxm').asstring);
ListItem.SubItems.Add(tv.selected.text);
listitem.SubItems.Add('');
with qrybc do
begin
sql.Clear;
sql.add('select * from kq_bcsd where yhbh=''' + Query.FieldByName('yhbh').asstring + ''' and n=''' + cmbN.text + ''' and y=''' + cmby.text + '''');
open;
while not eof do
begin
listitem.SubItems[2] := listitem.SubItems[2] + inttostr(fieldbyname('bc').asinteger) + '/';
next;
end;
close;
end;
end;
end;
next;
end;
//////////////////选定用户---------------
for iCount := 0 to YhLv.Items.count - 1 do
YhLv.items[iCount].Checked := true;
////////////////////////////////////////////////
end;
end;
end;
procedure TFrm_K_Bcsz.BtnPrevClick(Sender: TObject);
var
iCount,i: integer;
begin
inherited;
try
i:= YhLv.Items.count;
for iCount := 0 to i - 1 do
begin
If YhLv.Items.count<iCount+1 then Exit;
if not YhLv.items[iCount].Checked then
YhLv.items[iCount].Delete;
end;
YhLv.Refresh;
except
end;
end;
procedure TFrm_K_Bcsz.BtnFirstClick(Sender: TObject);
begin
inherited;
YhLv.items.clear;
end;
procedure TFrm_K_Bcsz.YhLvColumnClick(Sender: TObject;
Column: TListColumn);
var
iCount: integer;
begin
inherited;
if Column.ID = 0 then
begin
for iCount := 0 to YhLv.Items.count - 1 do
YhLv.items[iCount].Checked := not (YhLv.items[iCount].Checked);
end;
end;
procedure TFrm_K_Bcsz.BcLvColumnClick(Sender: TObject;
Column: TListColumn);
var
iCount: integer;
begin
inherited;
if Column.ID = 0 then
begin
for iCount := 0 to BcLv.Items.count - 1 do
BcLv.items[iCount].Checked := not (BcLv.items[iCount].Checked);
end;
end;
procedure TFrm_K_Bcsz.BitBtn1Click(Sender: TObject);
var
iBcCount, iYhCount: integer;
sYhbh, sBmbh, sBc: string;
sQuery: Tquery;
begin
inherited;
if (cmbn.Text = '') or (cmby.text = '') then
begin
application.MessageBox('请选择日期后重试', '系统提示', mb_ok + mb_iconwarning);
exit;
end;
with qryBcsd do
begin
sql.clear;
sql.add('select yhbh,yhxm,bjmc as bmmc,bjbh as bmbh from Vzx_s_yhxx');
open;
last;
ProgressBar1.Max := recordcount;
progressBar1.Position := 0;
if recordcount = 0 then
begin
application.messagebox('系统内无用户,不能进行班次设定', '系统提示', mb_ok + mb_iconinformation);
exit;
end;
first;
while not eof do
begin
ProgressBar1.Position := ProgressBar1.Position + 1;
sYhbh := fieldbyname('yhbh').asstring;
for iBcCount := 0 to BcLv.Items.count - 1 do
begin
sBc := BcLv.Items[iBcCount].caption;
with WindData.Pkq_d_bcsd do
begin
parameters.parambyname('@yhbh').Value := sYhbh;
parameters.parambyname('@bc').Value := strtoint(sBc);
parameters.parambyname('@n').Value := cmbn.text;
parameters.parambyname('@y').Value := cmby.text;
if bclv.Items[iBcCount].Checked then //判断是覆盖还是忽略
begin
if rbnfg.Checked then
parameters.parambyname('@sign').Value := 0
else
parameters.parambyname('@sign').Value := 1;
end else
parameters.parambyname('@sign').Value := 2;
execproc;
end;
end;
next;
end;
end;
//************************************************************************
application.messagebox('班次设定完毕', '系统提示', mb_ok + mb_iconinformation);
YhLv.Items.clear; //清除条目
ProgressBar1.Position := 0;
end;
procedure TFrm_K_Bcsz.BitBtn2Click(Sender: TObject);
var
iBcCount, iYhCount: integer;
sYhbh, sBmmc, sBmbh, sBc: string;
sQuery: Tquery;
begin
inherited;
if (cmbn.Text = '') or (cmby.text = '') then
begin
application.MessageBox('请选择日期后重试', '系统提示', mb_ok + mb_iconwarning);
exit;
end;
ProgressBar1.Max := YhLv.Items.count;
for iYhCount := 0 to YhLv.Items.count - 1 do //选定用户
begin
ProgressBar1.Position := iYhCount + 1;
sYhbh := YhLv.items[iYhCount].caption;
if YhLv.items[iYhCount].Checked then
Begin
for iBcCount := 0 to BcLv.Items.count - 1 do
begin
sBc := BcLv.Items[iBcCount].caption;
with WindData.Pkq_d_bcsd do
begin
parameters.parambyname('@yhbh').Value := sYhbh;
parameters.parambyname('@bc').Value := strtoint(sBc);
parameters.parambyname('@n').Value := cmbn.text;
parameters.parambyname('@y').Value := cmby.text;
if bclv.Items[iBcCount].Checked then
begin
if rbnfg.Checked then //判断是覆盖还是忽略
parameters.parambyname('@sign').Value := 0
else
parameters.parambyname('@sign').Value := 1;
end else
parameters.parambyname('@sign').Value := 2;
execproc;
end;
end;
end;
end;
application.messagebox('班次设定完毕', '系统提示', mb_ok + mb_iconinformation);
YhLv.Items.clear; //清除条目
ProgressBar1.Position := 0;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?