⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit3.pas

📁 工资管理源码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, Grids, DBGrids, DB, ADODB, ComCtrls,
  DBCtrls, Mask, printers,  RM_dset, RM_class, RM_dbset;

type
  Tmain = class(TForm)
    Panel1: TPanel;
    BitBtn1: TBitBtn;
    ADOQuery1: TADOQuery;
    DataSource1: TDataSource;
    BitBtn2: TBitBtn;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    Panel2: TPanel;
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    UpDown1: TUpDown;
    ADOConnection1: TADOConnection;
    gzjg: TADOTable;
    DataSource_gzjg: TDataSource;
    xjgzb: TADOQuery;
    ComboBox3: TComboBox;
    Label1: TLabel;
    Edit3: TEdit;
    Label2: TLabel;
    Edit4: TEdit;
    Panel3: TPanel;
    BitBtn7: TBitBtn;
    BitBtn8: TBitBtn;
    BitBtn9: TBitBtn;
    ComboBox1: TComboBox;
    DBGrid2: TDBGrid;
    TabSheet3: TTabSheet;
    de: TADOQuery;
    DBNavigator3: TDBNavigator;
    BitBtn10: TBitBtn;
    hjje: TADOQuery;
    DBNavigator1: TDBNavigator;
    DBNavigator2: TDBNavigator;
    gz: TADOQuery;
    BitBtn3: TBitBtn;
    BitBtn5: TBitBtn;
    BitBtn6: TBitBtn;
    DBGrid1: TDBGrid;
    sor: TADOQuery;
    ADOTable1: TADOTable;
    DataSource2: TDataSource;
    DBGrid3: TDBGrid;
    Panel4: TPanel;
    chd: TADOQuery;
    RMReport1: TRMReport;
    RMDBDataSet1: TRMDBDataSet;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure BitBtn7Click(Sender: TObject);
    procedure BitBtn8Click(Sender: TObject);
    procedure BitBtn9Click(Sender: TObject);
    procedure ComboBox3Change(Sender: TObject);
    procedure BitBtn10Click(Sender: TObject);
    procedure ADOQuery1AfterOpen(DataSet: TDataSet);
    procedure BitBtn5Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure BitBtn6Click(Sender: TObject);
    procedure ADOTable1AfterPost(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  main: Tmain;
  month1,field_name,field_name1,table_name,field_lx,tmp_hao,gzb_sql,tmp_month:string;
  mytables:tstringlist;
  title_rep,gz_xm,hz_tmp,hmc_tmp:string;
   v: TrmView;
   b: TrmBandView;
   Page: TrmPage;
   gz_x,fie_len:integer;
implementation

uses Unit1;

{$R *.dfm}

procedure Tmain.BitBtn1Click(Sender: TObject);
begin
table_name:=edit1.Text+combobox1.Text;
mytables:=tstringlist.Create ;
ADOConnection1.GetTableNames(mytables);
if not (mytables.IndexOf(table_name)=-1) then
 application.MessageBox('脑病!该月工资表已做!!你不嫌累吗?','系统警告',MB_ok+MB_Iconstop)
else
begin

main.gzjg.First;
tmp_hao:='';
gzb_sql:='';
while main.gzjg.eof=false do
begin
if main.gzjg.FieldByName('字段类型').asstring='文本' then field_lx:='char'+'('+ main.gzjg.fieldbyname('字段长度').asstring+')' else field_lx:='money';
gzb_sql:=gzb_sql+tmp_hao+main.gzjg.fieldbyname('项目').asstring+' '+field_lx;
tmp_hao:=',';
main.gzjg.Next;
end;

with main.xjgzb do
begin
close;
sql.Clear;
SQL.Add('Create Table '+table_name);
sql.Add('(ID IDENTITY(1,1) PRIMARY KEY,'+gzb_sql+');');
execSQL;
end;

with adoquery1 do
begin
close;
sql.clear;
if combobox3.text='全部人员' then sql.Add('select * from '+table_name)
else sql.Add('select * from '+table_name+'where 编制='+combobox3.text);
sql.add('order by 排序');
open;
end;
             

end;
end;

procedure Tmain.BitBtn2Click(Sender: TObject);
var
 I,k:integer;
 tmp_sor,tiaoj,tmp_tiaoj:string;
begin
table_name:=edit1.Text+combobox1.Text;
if strtoint(combobox1.Text)=1 then
field_name1:=inttostr(strtoint(edit1.Text)-1)+'12' else
begin
tmp_month:=inttostr(strtoint(combobox1.Text)-1);
if length(tmp_month)=1 then tmp_month:='0'+tmp_month;
field_name1:=edit1.Text+tmp_month;
end;
if adoquery1.Active=true then
begin
if adoquery1.RecordCount<1 then

begin
mytables:=tstringlist.Create ;
ADOConnection1.GetTableNames(mytables);
if (mytables.IndexOf(field_name1)=-1) then
application.MessageBox('懒货,上月工资表还没做!!!','系统警告',MB_ok+MB_Iconstop) 
else
begin

with sor do
begin
close;
sql.Clear;
sql.add('select * from '+field_name1);
open;
end;
with de do
begin
close;
sql.clear;
sql.Add('select * from '+table_name);
open;
end;

tiaoj:='';
tmp_tiaoj:='';
for i := 0 to sor.FieldCount - 1 do            //上月源表的表结构名
begin
tmp_sor:=sor.Fields[i].FieldName;
for k := 0 to de.FieldCount - 1 do
begin
if tmp_sor=de.Fields[k].FieldName then
 begin
  tiaoj:=tmp_tiaoj+tmp_sor;
  tmp_tiaoj:=tiaoj+',';
 end;
end;
end;


with xjgzb do
begin
close;
sql.Clear;
sql.add('insert into '+table_name+'('+tiaoj+')'+' select '+tiaoj+' from '+field_name1);
execSQL;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.Add('select * from '+table_name);
sql.add('order by 排序');
open;
end;
for i:=0 to adoquery1.FieldCount-1 do
  if adoquery1.Fields[i].DataType in [ftFloat,ftCurrency,ftBCD] then
    TFloatField(adoquery1.Fields[i]).Displayformat:='#,##0.00';

end;
end else application.MessageBox('蠢货,已导入上月数据!!!','系统警告',MB_ok+MB_Iconstop);
end else application.MessageBox('血笨!请先生成表结构!!!','系统警告',MB_ok+MB_Iconstop);

end;

procedure Tmain.ComboBox1Change(Sender: TObject);
var i:integer;
begin
table_name:=edit1.Text+combobox1.Text;
mytables:=tstringlist.Create ;
with adoquery1 do
begin
close;
sql.clear;
end;
main.ADOConnection1.GetTableNames(mytables);
if not (mytables.IndexOf(table_name)=-1) then
begin
with adoquery1 do
begin
close;
sql.clear;
sql.Add('select * from '+table_name);
if combobox3.text<>'全部人员' then sql.Add('where 编制='+''''+combobox3.text+'''');
sql.add('order by 排序');
open;
end;
edit3.text:=inttostr(adoquery1.RecordCount);


for i:=0 to adoquery1.FieldCount-1 do
  if adoquery1.Fields[i].DataType in [ftFloat,ftCurrency,ftBCD] then
    TFloatField(adoquery1.Fields[i]).Displayformat:='#,##0.00';


with hjje do
begin
close;
sql.clear;
sql.add('select sum(实发金额) from '+table_name);
if combobox3.text<>'全部人员' then sql.Add('where 编制='+''''+combobox3.text+'''');
open;
end;
edit4.Text:=hjje.Fields[0].asstring;
end;
end;

procedure Tmain.FormShow(Sender: TObject);
var i:integer;
begin
combobox3.items.clear;
combobox3.items.add('全部人员');
adotable1.First;
while adotable1.eof=false do
begin
combobox3.items.add(adotable1.Fields[1].asstring);
adotable1.Next;
end;
combobox3.ItemIndex:=0;

EDIT1.Text:=formatdatetime('yyyy',now);
table_name:=edit1.Text+combobox1.Text;
mytables:=tstringlist.Create ;
main.ADOConnection1.GetTableNames(mytables);
if not (mytables.IndexOf(table_name)=-1) then
begin

with adoquery1 do
begin
close;
sql.clear;
if combobox3.text='全部人员' then sql.Add('select * from '+table_name)
else sql.Add('select * from '+table_name+' where 编制='+''''+combobox3.text+'''');
sql.add('order by 排序');
open;
end;
for i:=0 to adoquery1.FieldCount-1 do
  if adoquery1.Fields[i].DataType in [ftFloat,ftCurrency,ftBCD] then
    TFloatField(adoquery1.Fields[i]).Displayformat:='#,##0.00';

edit3.text:=inttostr(adoquery1.RecordCount);
with hjje do
begin
close;
sql.clear;
sql.add('select sum(实发金额) from '+table_name);
if combobox3.text<>'全部人员' then sql.Add('where 编制='+''''+combobox3.text+'''');
open;
end;
edit4.Text:=hjje.Fields[0].asstring;
end;
end;

procedure Tmain.BitBtn7Click(Sender: TObject);
begin
close;
end;

procedure Tmain.BitBtn8Click(Sender: TObject);
begin
form1.showmodal;
end;

procedure Tmain.BitBtn9Click(Sender: TObject);
begin
if application.MessageBox('国华同志,删除后不能恢复!请确定要删除吗!!','张新志的警告',MB_yesno+MB_Iconstop)=idyes then
begin
table_name:=edit1.Text+combobox1.Text;
if adoquery1.Active=true then
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.add('drop table '+table_name);
execSQL;
end;
end else application.MessageBox('该月工资表不存在!!!!','系统警告',MB_ok+MB_Iconstop);
end;
end;

procedure Tmain.ComboBox3Change(Sender: TObject);
var i:integer;
begin
table_name:=edit1.Text+combobox1.Text;
with adoquery1 do
begin
close;
sql.clear;
end;
mytables:=tstringlist.Create ;
main.ADOConnection1.GetTableNames(mytables);
if not (mytables.IndexOf(table_name)=-1) then
begin

with adoquery1 do
begin
close;
sql.clear;
if combobox3.text='全部人员' then sql.Add('select * from '+table_name)
else sql.Add('select * from '+table_name+' where 编制='+''''+combobox3.text+'''');
sql.add('order by 排序');
open;
end;
for i:=0 to adoquery1.FieldCount-1 do
  if adoquery1.Fields[i].DataType in [ftFloat,ftCurrency,ftBCD] then
    TFloatField(adoquery1.Fields[i]).Displayformat:='#,##0.00';

edit3.text:=inttostr(adoquery1.RecordCount);
with hjje do
begin
close;
sql.clear;
sql.add('select sum(实发金额) from '+table_name);
if combobox3.text<>'全部人员' then sql.Add('where 编制='+''''+combobox3.text+'''');
open;
end;
edit4.Text:=hjje.Fields[0].asstring;
end;
end;

procedure Tmain.BitBtn10Click(Sender: TObject);
var
i:integer;
tmp_add,tmp_fie,add_fie:string;
begin
table_name:=edit1.Text+combobox1.Text;
if adoquery1.eof=false then
begin
tmp_add:='';
add_fie:='';
for i := 0 to adoquery1.FieldCount - 1 do
begin
tmp_fie:=adoquery1.Fields[i].FieldName;
gzjg.locate('项目',tmp_fie,[loCaseInsensitive]);
if trim(gzjg.FieldByName('类别').asstring)='加' then
begin
add_fie:=tmp_add+tmp_fie;   
tmp_add:=add_fie+'+' ;
end;
end;
with xjgzb do
begin
close;
sql.Clear;
sql.add('update '+table_name+' set '+'应发金额='+add_fie);
execSQL;
end;

tmp_add:='';
add_fie:='';
for i := 0 to adoquery1.FieldCount - 1 do
begin
tmp_fie:=adoquery1.Fields[i].FieldName;
gzjg.locate('项目',tmp_fie,[loCaseInsensitive]);
if trim(gzjg.FieldByName('类别').asstring)='扣' then
begin
add_fie:=tmp_add+tmp_fie;
tmp_add:=add_fie+'-' ;
end;
end;
with xjgzb do
begin
close;
sql.Clear;
sql.add('update '+table_name+' set '+'实发金额=应发金额-'+add_fie);
execSQL;
end;

with adoquery1 do
begin
close;
sql.clear;
if combobox3.text='全部人员' then sql.Add('select * from '+table_name)
else sql.Add('select * from '+table_name+' where 编制='+''''+combobox3.text+'''');
sql.add('order by 排序');
open;
end;
for i:=0 to adoquery1.FieldCount-1 do
  if adoquery1.Fields[i].DataType in [ftFloat,ftCurrency,ftBCD] then
    TFloatField(adoquery1.Fields[i]).Displayformat:='#,##0.00';

with hjje do
begin
close;
sql.clear;
sql.add('select sum(实发金额) from '+table_name);
if combobox3.text<>'全部人员' then sql.Add('where 编制='+''''+combobox3.text+'''');
open;
end;
edit4.Text:=hjje.Fields[0].asstring;
end;

end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -