otmoney.pas
来自「pasa人力资源考勤管理系统」· PAS 代码 · 共 393 行
PAS
393 行
unit otmoney;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids, DBGrids, Buttons, ExtCtrls, Db, ADODB, OleServer,
Excel97, Menus;
type
TFormotmoney = class(TForm)
DBGrid1: TDBGrid;
GroupBox1: TGroupBox;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
Label9: TLabel;
Label10: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Panel1: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
Qryotmoney: TADOQuery;
DSotmoney: TDataSource;
Qryotmoneyotmoneyno: TStringField;
Qryotmoneyotmoneyname: TStringField;
Qryotmoneymemo1: TStringField;
Qryotmoneymemo2: TStringField;
SpeedButton6: TSpeedButton;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
ExcelApplication1: TExcelApplication;
procedure SpeedButton4Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure DBGrid1KeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton3Click(Sender: TObject);
procedure QryotmoneyBeforePost(DataSet: TDataSet);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure QryotmoneyAfterInsert(DataSet: TDataSet);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure Edit1Exit(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
procedure formchangelan;
end;
var
Formotmoney: TFormotmoney;
str1,str2:string;
implementation
uses datamol,publicfunction,main,cvcode;
{$R *.DFM}
procedure TFormotmoney.SpeedButton4Click(Sender: TObject);
begin
close;
end;
procedure TFormotmoney.CheckBox1Click(Sender: TObject);
begin
{ if (Sender as Tcheckbox).checked then
begin
TEdit(Findcomponent('Edit'+copy((sender as tcheckbox).Name,length((sender as Tcheckbox).Name),1))).Enabled:=true;
end
else
begin
TEdit(FindComponent('Edit'+copy((sender as tcheckbox).Name,length((sender as Tcheckbox).Name),1))).Enabled:=false;
end;
}
end;
procedure TFormotmoney.FormCreate(Sender: TObject);
begin
qryotmoney.open;
qryotmoney.edit;
end;
procedure TFormotmoney.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
if qryotmoney.Modified then
if application.messagebox('你是否要对所做的修改进行保存?','保存确认',mb_okcancel+mb_iconquestion)=idok then
qryotmoney.post
else
qryotmoney.cancel;
qryotmoney.close;
end;
procedure TFormotmoney.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
dbgrid_keypress(sender,key);
end;
procedure TFormotmoney.SpeedButton3Click(Sender: TObject);
var
i:integer;
field:TField;
// check:boolean;
begin
{ check:=false;
for i:=1 to 8 do
begin
if TCheckbox(Findcomponent('CheckBox'+inttostr(i))).Checked then
if (trim(TEdit(FindComponent('Edit'+inttostr(i))).Text)='0') or (trim(TEdit(FindComponent('Edit'+inttostr(i))).Text)='') then
check:=true;
end;
if check then
application.messagebox('小时数不能为空或为零','输入错误',mb_okcancel+mb_iconerror)
else
begin
}
str1:='';
str2:='';
for i:=1 to 8 do
begin
IF TCheckbox(Findcomponent('CheckBox'+inttostr(i))).Checked then
begin
// Str1:=Str1+TCheckbox(Findcomponent('CheckBox'+inttostr(i))).Caption+'/'+TEdit(Findcomponent('Edit'+inttostr(i))).Text+'小时+';
Str1:=Str1+TCheckbox(Findcomponent('CheckBox'+inttostr(i))).Caption+'+';
Field:=FindField(Datamod.ADOpersonal,TCheckbox(Findcomponent('CheckBox'+inttostr(i))).Caption);
str2:=Str2+Field.FieldName+'+';
// str2:=Str2+Field.FieldName+'/'+TEdit(Findcomponent('Edit'+inttostr(i))).Text+'小时+';
end;
end;
Delete(str1,length(str1),1);
Delete(str2,length(str2),1);
if ((str1<>'') and (str2<>'')) then // or (trim(Edit9.text)<>'') then
begin
qryotmoney.edit;
// if trim(Edit9.text)='' then
// qryotmoneymoneyperhour.asfloat:=0
// else
// qryotmoneymoneyperhour.asfloat:=strtofloat(edit9.text);
Qryotmoneymemo1.asstring:=str1;
qryotmoneymemo2.asstring:=str2;
qryotmoney.post;
qryotmoney.disablecontrols;
qryotmoney.close;
qryotmoney.open;
qryotmoney.enablecontrols;
end;
end;
procedure TFormotmoney.QryotmoneyBeforePost(DataSet: TDataSet);
begin
if trim(qryotmoneyotmoneyno.asstring)='' then
begin
application.messagebox('不能输入一个空的加班费种类编号','错误',mb_okcancel+mb_iconerror);
qryotmoney.cancel;
end;
end;
procedure TFormotmoney.SpeedButton5Click(Sender: TObject);
begin
if application.messagebox('你确定要删除这笔资料吗?','删除确认',mb_okcancel+mb_iconquestion)=idok then
qryotmoney.delete;
end;
procedure TFormotmoney.SpeedButton2Click(Sender: TObject);
begin
qryotmoney.cancel;
end;
procedure TFormotmoney.SpeedButton1Click(Sender: TObject);
begin
qryotmoney.append;
dbgrid1.setfocus;
end;
procedure TFormotmoney.QryotmoneyAfterInsert(DataSet: TDataSet);
var
i:integer;
field:TField;
begin
str1:='';
str2:='';
for i:=1 to 8 do
begin
IF TCheckbox(Findcomponent('CheckBox'+inttostr(i))).Checked then
begin
// Str1:=Str1+TCheckbox(Findcomponent('CheckBox'+inttostr(i))).Caption+'/'+TEdit(Findcomponent('Edit'+inttostr(i))).Text+'小时+';
Str1:=Str1+TCheckbox(Findcomponent('CheckBox'+inttostr(i))).Caption+'+';
Field:=FindField(Datamod.ADOpersonal,TCheckbox(Findcomponent('CheckBox'+inttostr(i))).Caption);
str2:=Str2+Field.FieldName+'+';
// str2:=Str2+Field.FieldName+'/'+TEdit(Findcomponent('Edit'+inttostr(i))).Text+'小时+';
end;
end;
Delete(str1,length(str1),1);
Delete(str2,length(str2),1);
if ((str1<>'') and (str2<>'')) then // or (trim(Edit9.text)<>'') then
begin
qryotmoney.edit;
// if trim(Edit9.text)='' then
// qryotmoneymoneyperhour.asfloat:=0
// else
// qryotmoneymoneyperhour.asfloat:=strtofloat(edit9.text);
qryotmoneymemo1.asstring:=str1;
qryotmoneymemo2.asstring:=str2;
end else
qryotmoney.cancel;
end;
procedure TFormotmoney.FormKeyPress(Sender: TObject; var Key: Char);
begin
{ if key=#13 then
begin
key:=#0;
selectnext(activecontrol,true,true);
end;
}end;
procedure TFormotmoney.Edit1Exit(Sender: TObject);
begin
if trim((sender as TEdit).text)='0' then
begin
application.messagebox('不能除以0小时,若你不想要此项可以将其屏蔽掉.','除数不能为0',mb_okcancel+mb_iconerror);
(sender as tedit).setfocus;
end;
end;
procedure TFormotmoney.SpeedButton6Click(Sender: TObject);
begin
if qryotmoney.modified then
qryotmoney.post;
end;
procedure TFormotmoney.N1Click(Sender: TObject);
var
RangeE: Excel97.Range;
I, Row: Integer;
Bookmark: TBookmarkStr;
begin
ExcelApplication1.Visible [0] := True;
ExcelApplication1.Workbooks.Add (NULL, 0);
RangeE := ExcelApplication1.ActiveCell;
for I := 0 to Qryotmoney.Fields.Count - 1 do
begin
RangeE.Value := Qryotmoney.Fields [I].DisplayLabel;
RangeE := RangeE.Next;
end;
Qryotmoney.DisableControls;
try
Bookmark := Qryotmoney.Bookmark;
try
if Qryotmoney.State=dsInactive then
Qryotmoney.Open;
Qryotmoney.First;
Row := 2;
while not Qryotmoney.EOF do
begin
RangeE := ExcelApplication1.Range ['A' + IntToStr (Row),
'A' + IntToStr (Row)];
for I := 0 to Qryotmoney.Fields.Count - 1 do
begin
RangeE.Value := Qryotmoney.Fields [I].AsString;
RangeE := RangeE.Next;
end;
Qryotmoney.Next;
Inc (Row);
end;
finally
Qryotmoney.Bookmark := Bookmark;
end;
finally
Qryotmoney.EnableControls;
end;
RangeE:=ExcelApplication1.Activecell;
RangeE.AutoFormat(3,NULL,Null,null,null,null,null);
end;
procedure TFormotmoney.formchangelan;
var i,j:integer;
begin
if language='Chinese_GB' then
begin
Caption:=BIG5toGB(Caption);
Font.Charset:=GB2312_CHARSET;
for i:=0 to ComponentCount-1 do
begin
if components[i].ClassType=TButton then
begin
TButton(components[i]).Font.Charset:=GB2312_CHARSET;
TButton(Components[i]).Caption:=BIG5toGB(TButton(Components[i]).Caption);
TButton(Components[i]).Hint:=BIG5toGB(TButton(Components[i]).Hint);
end;
if components[i].ClassType=TSpeedButton then
begin
TSpeedButton(components[i]).Font.Charset:=GB2312_CHARSET;
TSpeedButton(components[i]).Caption:=BIG5toGB(TSpeedButton(Components[i]).Caption);
TSpeedButton(components[i]).Hint:=BIG5toGB(TSpeedButton(components[i]).Hint);
end;
if components[i].ClassType=TBitBtn then
begin
TBitBtn(components[i]).Font.Charset:=GB2312_CHARSET;
TBitBtn(components[i]).Caption:=BIG5toGB(TBitBtn(Components[i]).Caption);
TBitBtn(components[i]).Hint:=BIG5toGB(TBitBtn(Components[i]).Hint);
end;
if components[i].ClassType=TRadioButton then
begin
TRadioButton(components[i]).Font.Charset:=GB2312_CHARSET;
TRadioButton(components[i]).Caption:=BIG5toGB(TRadioButton(Components[i]).Caption);
TRadioButton(components[i]).Hint:=BIG5toGB(TRadioButton(Components[i]).Hint);
end;
if components[i].ClassType=TLabel then
begin
TLabel(components[i]).Font.Charset:=GB2312_CHARSET;
TLabel(components[i]).Caption:=BIG5toGB(TLabel(Components[i]).Caption);
TLabel(components[i]).Hint:=BIG5toGB(TLabel(Components[i]).Hint);
end;
if components[i].ClassType=TStaticText then
begin
TStaticText(components[i]).Font.Charset:=GB2312_CHARSET;
TStaticText(Components[i]).Caption:=BIG5toGB(TStaticText(components[i]).Caption);
TStaticText(Components[i]).Hint:=BIG5toGB(TStaticText(components[i]).Hint);
end;
if components[i].ClassType=TGroupBox then
begin
TGroupBox(components[i]).Font.Charset:=GB2312_CHARSET;
TGroupBox(components[i]).Caption:=BIG5toGB(TGroupBox(Components[i]).Caption);
TGroupBox(components[i]).Hint:=BIG5toGB(TGroupBox(Components[i]).Hint);
end;
if components[i].ClassType=TRadioGroup then
begin
TRadioGroup(components[i]).Font.Charset:=GB2312_CHARSET;
TRadioGroup(components[i]).Caption:=BIG5toGB(TRadioGroup(components[i]).Caption);
TRadioGroup(components[i]).Hint:=BIG5toGB(TRadioGroup(components[i]).Hint);
for j:=0 to TRadioGroup(components[i]).Items.Count-1 do
TRadioGroup(components[i]).Items.Strings[j]:=BIG5toGB(TRadioGroup(components[i]).Items.Strings[j]);
end;
if components[i].ClassType=TCheckBox then
begin
TCheckBox(components[i]).Font.Charset:=GB2312_CHARSET;
TCheckBox(components[i]).Caption:=BIG5toGB(TCheckBox(Components[i]).Caption);
TCheckBox(components[i]).Hint:=BIG5toGB(TCheckBox(Components[i]).Hint);
end;
if components[i].ClassType=TCombobox then
begin
TCombobox(components[i]).Font.Charset:=GB2312_CHARSET;
TCombobox(components[i]).Hint:=BIG5toGB(TCombobox(components[i]).Hint);
for j:=0 to TCombobox(components[i]).Items.Count-1 do
TCombobox(components[i]).Items.Strings[j]:=BIG5toGB(TCombobox(components[i]).Items.Strings[j]);
end;
if components[i].ClassType=TPanel then
begin
TPanel(components[i]).Font.Charset:=GB2312_CHARSET;
TPanel(components[i]).Caption:=BIG5toGB(TPanel(components[i]).Caption);
TPanel(components[i]).Hint:=BIG5toGB(TPanel(components[i]).Hint);
end;
if Components[i].ClassType=TDBGrid then
begin
TDBGrid(components[i]).Hint:=BIG5toGB(TDBGrid(components[i]).Hint);
for j:=0 to TDBGrid(components[i]).Columns.Count-1 do
TDBGrid(components[i]).Columns[j].Title.Caption:=BIG5toGB(TDBGrid(components[i]).Columns[j].Title.Caption);
end;
end; //for
end; //if
end;
procedure TFormotmoney.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=VK_F1 then
begin
//showmessage('ok!')
//MessageDlg(Key + ' has been pressed', mtInformation, [mbOK], 0);
Application.HelpFile :=Extractfilepath(application.ExeName)+ 'help\pasahelp.hlp';
application.HelpJump('SHM_CONTENTS0053');
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?