📄 gzffglxt.~pas
字号:
StringGrid1.Col := 1;
end;
end;
if (Key = Vk_Down)and(IsNull = False)and(x = StringGrid1.RowCount-1) then
begin
StringGrid1.RowCount := StringGrid1.RowCount +1;
StringGrid1.Col := 1;
end
else if (Key = Vk_ReTurn)and(Trim(StringGrid1.Cells[0,x])='')and(Trim(StringGrid1.Cells[1,x])<>'')then
begin
with Data3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('Select * from 工资发放 where 员工姓名 = :a');
Parameters.ParamByName('a').Value := Trim(StringGrid1.Cells[1,x]);
Open;
end;
if Data3.ADOQuery1.RecordCount >0 then
begin
if Data3.ADOQuery1.RecordCount>1 then
begin
ListBox1.Clear;
while Not Data3.ADOQuery1.Eof do
begin
ListBox1.Items.Add(Data3.ADOQuery1.FieldByName('员工编号').Value);
Data3.ADOQuery1.Next ;
end;
ListBox1.Visible := True;
ListBox1.SetFocus;
ListBox1.ItemIndex := 0;
end
else
begin
StringGrid1.Cells[0,x]:= Data3.ADOQuery1.FieldByName('员工编号').Value;
StringGrid1.Cells[1,x]:= Data3.ADOQuery1.FieldByName('员工姓名').Value ;
StringGrid1.Cells[2,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('基本工资').Value);
StringGrid1.Cells[3,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('职务工资').Value);
StringGrid1.Cells[4,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('工龄工资').Value);
StringGrid1.Cells[5,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('养老保险金').Value);
StringGrid1.Cells[10,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('个人所得税').Value);
StringGrid1.Cells[11,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('住房补助').Value);
StringGrid1.Cells[13,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('保险费').Value);
StringGrid1.Cells[14,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('生活补助').Value);
with Data3.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select 余额 from 工资发放明细表 where 员工编号 = :c and year(时间) = :a and month(时间) = :b');
//如果当前月份是一月,上月余额应为上一年十二月份的余额
if Month1 >1 then
begin
Parameters.ParamByName('a').Value := Year1;
Parameters.ParamByName('b').Value := Month1-1;
end
else
begin
Parameters.ParamByName('a').Value := Year1-1;
Parameters.ParamByName('b').Value := 12;
end;
Parameters.ParamByName('c').Value := Trim(StringGrid1.Cells[0,x]);
Open;
end;
if Data3.ADOQuery2.FieldByName('余额').Value = Null then
StringGrid1.Cells[12,x] := '0'
else
StringGrid1.Cells[12,x] := FloatToStr(Data3.ADOQuery2.FieldByName('余额').Value);
StringGrid1.Col := 6;
end;
end
else
begin
StringGrid1.Cells[1,x]:= '';
Application.MessageBox('该员工工资信息不全或不存在,请重新输入。','提示',64);
end;
end
else if (Key = VK_ReTurn)and(Trim(StringGrid1.Cells[0,x])<>'')then
begin
if StringGrid1.Col < StringGrid1.ColCount-1 then
StringGrid1.Col := StringGrid1.Col+1;
end;
if (Key = VK_Shift)and(JCxmlb = True) then
BitBtn1.SetFocus;
end;
procedure TForm83.ClearString;
var
c: Integer;
begin
For c := 0 to StringGrid1.ColCount-1 do
StringGrid1.Cells[c,x]:='';
end;
procedure TForm83.ClearStringEnd;
var
c: Integer;
begin
For c := 0 to StringGrid1.ColCount-1 do
StringGrid1.Cells[c,StringGrid1.RowCount-1]:='';
end;
function TForm83.JCxmlb: Boolean;
var
a,b: Integer;
begin
JCxmlb := True;
For a := 1 to StringGrid1.RowCount-1 do
For b := 0 to StringGrid1.ColCount-1 do
if Trim(StringGrid1.Cells[b,a])='' then
begin
Jcxmlb := False;
break;
end;
end;
procedure TForm83.ListBox1DblClick(Sender: TObject);
begin
with Data3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 工资发放 where 员工编号 = :a');
Parameters.ParamByName('a').Value := Trim(ListBox1.Items[ListBox1.ItemIndex]);
OPen;
end;
StringGrid1.Cells[0,x]:= Data3.ADOQuery1.FieldByName('员工编号').Value;
StringGrid1.Cells[1,x]:= Data3.ADOQuery1.FieldByName('员工姓名').Value ;
StringGrid1.Cells[2,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('基本工资').Value);
StringGrid1.Cells[3,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('职务工资').Value);
StringGrid1.Cells[4,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('工龄工资').Value);
StringGrid1.Cells[5,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('养老保险金').Value);
StringGrid1.Cells[10,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('个人所得税').Value);
StringGrid1.Cells[11,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('住房补助').Value);
StringGrid1.Cells[13,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('保险费').Value);
StringGrid1.Cells[14,x]:= FloatToStr(Data3.ADOQuery1.FieldByName('生活补助').Value);
with Data3.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select 余额 from 工资发放明细表 where 员工编号 = :c and year(时间) = :a and month(时间) = :b');
//如果当前月份是一月,上月余额应为上一年十二月份的余额
if Month1 >1 then
begin
Parameters.ParamByName('a').Value := Year1;
Parameters.ParamByName('b').Value := Month1-1;
end
else
begin
Parameters.ParamByName('a').Value := Year1-1;
Parameters.ParamByName('b').Value := 12;
end;
Parameters.ParamByName('c').Value := Trim(StringGrid1.Cells[0,x]);
Open;
end;
if Data3.ADOQuery2.FieldByName('余额').Value = Null then
StringGrid1.Cells[12,x] := '0'
else
StringGrid1.Cells[12,x] := FloatToStr(Data3.ADOQuery2.FieldByName('余额').Value);
StringGrid1.SetFocus;
StringGrid1.Col := 6;
ListBox1.Visible := False;
end;
function TForm83.IsNull: Boolean;
var
a: integer;
begin
IsNull := False;
For a := 0 to StringGrid1.ColCount-1 do
if Trim(StringGrid1.Cells[a,x])='' then
begin
IsNull := True;
Break;
end;
end;
procedure TForm83.ListBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if key = VK_ReTurn then
ListBox1.OnDblClick(Sender);
end;
procedure TForm83.Clear;
var
a,b: Integer;
begin
For a := 1 to StringGrid1.RowCount-1 do
For b := 0 to StringGrid1.ColCount-1 do
StringGrid1.Cells[b,a]:= '';
StringGrid1.RowCount := 2;
StringGrid1.SetFocus;
StringGrid1.Col := 1;
end;
procedure TForm83.BitBtn2Click(Sender: TObject);
begin
inherited;
Clear;
end;
procedure TForm83.BitBtn1Click(Sender: TObject);
var
i: integer;
begin
inherited;
if Jcxmlb = True then
begin
if iscf = True then
begin
Application.MessageBox('员工信息不能重复。','提示',64);
Exit;
end;
if Biscf = False then
begin
Try
For i := 1 to StringGrid1.RowCount-1 do
begin
with Data3.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('insert 工资发放明细表 values(:a ,:b,:c,:d,:e,:f,:g,:h,:i,:j,:k,:l,:m,:n,:o,:p,Default)');
Parameters.ParamByName('a').Value := Trim(StringGrid1.Cells[0,i]);
Parameters.ParamByName('b').Value := Trim(StringGrid1.Cells[1,i]);
Parameters.ParamByName('c').Value := StrToFloat(StringGrid1.Cells[2,i]);
Parameters.ParamByName('d').Value := StrToFloat(StringGrid1.Cells[3,i]);
Parameters.ParamByName('e').Value := StrToFloat(StringGrid1.Cells[4,i]);
Parameters.ParamByName('f').Value := StrToFloat(StringGrid1.Cells[5,i]);
Parameters.ParamByName('g').Value := StrToInt(StringGrid1.Cells[6,i]);
Parameters.ParamByName('h').Value := StrToFloat(StringGrid1.Cells[7,i]);
Parameters.ParamByName('i').Value := StrToInt(StringGrid1.Cells[8,i]);
Parameters.ParamByName('j').Value := StrToFloat(StringGrid1.Cells[9,i]);
Parameters.ParamByName('k').Value := StrToFloat(StringGrid1.Cells[10,i]);
Parameters.ParamByName('l').Value := StrToFloat(StringGrid1.Cells[11,i]);
Parameters.ParamByName('m').Value := StrToFloat(StringGrid1.Cells[13,i]);
Parameters.ParamByName('n').Value := StrToFloat(StringGrid1.Cells[14,i]);
Parameters.ParamByName('o').Value := StrToFloat(StringGrid1.Cells[15,i]);
Parameters.ParamByName('p').Value := StrToFloat(StringGrid1.Cells[16,i]);
ExecSQL;
end;
end;
Application.MessageBox('操作成功。','提示',64);
Clear;
Except
Application.MessageBox('系统出错。','提示',64);
Close;
end;
end;
end
else
Application.MessageBox('项目列表有误。','提示',64);
end;
function TForm83.isCF: Boolean;
var
a,b: Integer;
begin
iscf := False;
if StringGrid1.RowCount>3 then
begin
For a := 1 to StringGrid1.RowCount-2 do
For b := a +1 to StringGrid1.RowCount-1 do
if Trim(StringGrid1.Cells[0,a])= Trim(StringGrid1.Cells[0,b]) then
begin
Iscf := True;
Break;
end;
end
else if StringGrid1.RowCount=3 then
begin
if Trim(StringGrid1.Cells[0,1])=Trim(StringGrid1.Cells[0,2]) then
Iscf := True;
end;
end;
function TForm83.Biscf: Boolean;
var
m: Integer;
Year1,Month1,Day1: Word;
begin
Biscf := False;
DecodeDate(Now(),year1,month1,day1);
For m := 1 to StringGrid1.RowCount-1 do
begin
with Data3.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * From 工资发放明细表 where 员工编号 =:a and year(时间) = :b and Month(时间)= :c');
Parameters.ParamByName('a').Value := Trim(StringGrid1.Cells[0,m]);
Parameters.ParamByName('b').Value := Year1;
parameters.ParamByName('c').Value := Month1;
Open;
end;
if Data3.ADOQuery1.RecordCount>0 then
begin
Biscf := True;
Application.MessageBox(Pchar('员工编号为'+ StringGrid1.Cells[0,m] +'的员工本月工资已发放。'),'提示',64);
Break;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -