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

📄 main.pas

📁 pasa人力资源考勤管理系统
💻 PAS
📖 第 1 页 / 共 5 页
字号:
begin
    Outlook1.ActiveTab:=8;
end;

procedure Tformmain.rule_setClick(Sender: TObject);
begin
  Outlook1.ActiveTab:=8;
end;

//薪资参数设定
procedure Tformmain.sal_basicClick(Sender: TObject);
begin
  if not assigned(formsalset) then
    formsalset:=TFormsalset.create(application);
  formsalset.show;
end;
procedure Tformmain.quitClick(Sender: TObject);
begin
  close;
end;
//登出
procedure Tformmain.logoutClick(Sender: TObject);
begin
   formpassword:=TFormpassword.Create(application);
   formpassword.showmodal;
   formpassword.free;
   default:=0;
   login;
   statusbarpro1.panels[3].text:='User:'+pubworkname;
end;

//过程,显示背景画
procedure Tformmain.showimage (var Msg: TMessage);
var
  BmpWidth, BmpHeight: Integer;
  I, J: Integer;
begin
  // default processing first
  Msg.Result := CallWindowProc (OldWinProc,ClientHandle, Msg.Msg, Msg.wParam, Msg.lParam);

  // handle background repaint
  if Msg.Msg = wm_EraseBkgnd then
  begin
    BmpWidth := Formmain.Image1.Width;
    BmpHeight :=Formmain.Image1.Height;
    if (BmpWidth <> 0) and (BmpHeight <> 0) then
    begin
      OutCanvas.Handle := Msg.wParam;
      for I := 0 to FormMain.ClientWidth div BmpWidth do
        for J := 0 to FormMain.ClientHeight div BmpHeight do
          OutCanvas.Draw (I*BmpWidth, J * BmpHeight, Formmain.Image1.Picture.Graphic);
    end;
  end;
end;

//新建报表
procedure Tformmain.newreportClick(Sender: TObject);
begin
end;

//薪资核算
procedure Tformmain.sal_removeClick(Sender: TObject);
begin
   if not assigned(formsalcal) then
     case (sender as tmenuitem).tag of
      0: sal_cal:=0;
      1: sal_cal:=1;
      2: sal_cal:=2;
      4: sal_cal:=4;
      5: sal_cal:=5;
     end;
   formsalcal:=Tformsalcal.create(application);
   formsalcal.show;
end;
//薪资总表
procedure Tformmain.sal_totalClick(Sender: TObject);
begin
   if not assigned(formsaldata) then
     formsaldata:=TFormsaldata.create(application);     
   formsaldata.show;
end;                   
procedure Tformmain.tileshowClick(Sender: TObject);
begin
   tile;
end;
procedure Tformmain.cascadeshowClick(Sender: TObject);
begin
   cascade;
end;

procedure Tformmain.help_onlineClick(Sender: TObject);
begin
 Application.HelpFile :=Extractfilepath(application.ExeName)+ 'help\pasahelp.hlp';
 application.HelpJump('');
end;

procedure Tformmain.connectsql ;
var f:textfile;
    myfile,fline:string;
    AdoConnect:string;
    i:integer;
begin
    Adoconnect:='';
    for i:=1 to 2 do
    begin
    try
     datamod.database1.Connected :=false;
     datamod.database1.LoginPrompt :=false;         //驱动程式
     datamod.database1.ConnectionString:='Provider=SQLOLEDB;Integrated Security=SSPI;';
     myfile:=extractfilepath(application.ExeName)+'data\login.ini';
     if fileexists(myfile) then
       begin
        assignfile(f,myfile);
        reset(f);
        while not eof(f) do
         begin
          readln(f,fline);
           if pos('word',fline)>0 then
             if length(trim(copy(fline,pos('=',fline)+1,20)))>0 then     //用户密码     password of database user
             begin
               Adoconnect:=Adoconnect+'password='+copy(fline,pos('=',fline)+1,20)+';Persist Security Info=True;';
               sqlpass:=copy(fline,pos('=',fline)+1,20);
             end else Adoconnect:=Adoconnect+'Persist Security Info=false;';
           if pos('atabase',fline)>0 then
           begin                                                         //数据库  database name
              Adoconnect:=Adoconnect+'Initial Catalog='+copy(fline,pos('=',fline)+1,20)+';' ;
              database:=copy(fline,pos('=',fline)+1,20);
           end;
           if pos('erver',fline)>0 then
           begin
              Adoconnect:=Adoconnect+'Data Source='+copy(fline,pos('=',fline)+1,20)+';' ;  //数据源       sql server name
              server:=copy(fline,pos('=',fline)+1,20);
           end;
           if pos('ser',fline)>1 then
           begin
              Adoconnect:=Adoconnect+'User ID='+copy(fline,pos('=',fline)+1,20)+';' ;      //数据库用户     database user
              sqluser:=copy(fline,pos('=',fline)+1,20);
           end;
         end;
         closefile(f);
         datamod.database1.ConnectionString:=Adoconnect+'Auto Translate=True';
         datamod.database1.Connected :=true;
         datamod.database1.keepconnection :=true;
       end
     else
       Application.messagebox( '无法连接数据库!','登入错误',mb_ok+mb_iconerror);
   except
     if i=1 then
       Adoconnect:='Integrated Security=SSPI;';
     if i=2 then
      begin
       Application.messagebox( '无法连接数据库!','登入错误',mb_ok+mb_iconerror);
       close;
      end;
   end;
   if datamod.database1.Connected then
     break;
   end;
end;

//员工帐号设定
procedure Tformmain.accountClick(Sender: TObject);
begin
  if not assigned(formaccount) then
     formaccount:=TFormaccount.create(self);
     menuname:=(Sender as TMenuItem).name;
    formname:=formaccount;
    GetRight(menuname,formname);
   formaccount.show;
end;

//人事主档的异动档
procedure tformmain.login;
var
   i,j,k,c:integer;
begin
  with datamod do
  begin
    Query2.close;
    Query2.sql.text:='Select * from sys03010';
    Query2.open;
    c:=Query2.RecordCount;
    Query2.close;
    Query2.sql.clear;
    Query1.Close;
    Query1.sql.text:='select * from  sys03010 ';
    Query1.open;
    for i:=0 to MainMenu1.items.Count-1 do
    begin
      MainMenu1.items[i].Enabled:=false;
      if (c=0) and (MainMenu1.items[i].Caption<>'-') then
         Query2.sql.add('Insert into sys03010 (menuname,menucaptionbig) values('''+MainMenu1.items[i].Name+''','''+MainMenu1.items[i].Caption+''') ');
      for j:=0 to MainMenu1.items[i].Count-1 do
      begin
        MainMenu1.items[i].items[j].Enabled:=false;
        if (c=0) and (MainMenu1.items[i].Items[j].caption<>'-') then
           Query2.sql.add('Insert into sys03010 (menuname,menucaptionbig,parentname,menuparentbig) values('''+MainMenu1.items[i].items[j].Name+''','+
                           ''''+MainMenu1.items[i].items[j].Caption+''','''+MainMenu1.items[i].name+''','''+MainMenu1.items[i].caption+''') ');
        if MainMenu1.items[i].items[j].Count>0 then
          for k:=0 to MainMenu1.items[i].items[j].Count-1 do
          begin
           MainMenu1.items[i].items[j].items[k].enabled:=false;
           if (c=0) and (MainMenu1.items[i].Items[j].items[k].caption<>'-') then
             Query2.sql.add('Insert into sys03010 (menuname,menucaptionbig,parentname,menuparentbig,subparentname,menusubparentbig) values('''+MainMenu1.items[i].items[j].items[k].Name+''','+
                            ''''+MainMenu1.items[i].items[j].items[k].Caption+''','''+MainMenu1.items[i].name+''','''+MainMenu1.items[i].caption+''','+
                            ''''+MainMenu1.items[i].items[j].name+''','''+MainMenu1.items[i].items[j].caption+''') ');
          end;
      end;
    end;
     //query2.SQL.SaveToFile('d:\sys.sql');
     if Query2.sql.text<>'' then
     begin


        Query2.execsql;
     end;                                      
     Query1.close;
     if (pubworkno='Super_Pasa_Apple') or (pubworkno='pasa') then
     begin
        FuncList:=TList.create;
        menuenable('password_set','common','');
     end
     else
     begin
        Query1.sql.text:='Select * from view_menu where no='''+pubworkno+''' ';
        Query1.open;
        Query1.first;
        FuncList:=TList.create;
        while not Query1.eof do
        begin
           menuenable(query1.fieldbyname('menuname').asstring,query1.fieldbyname('parentname').asstring,query1.fieldbyname('subparentname').asstring);
           Query1.next;
        end;
     end;
   end;
end;
procedure Tformmain.wmsystemcommand(var MSG: TWMSysCommand);
begin
   if MSG.CmdType=10000 then
     Application.MessageBox('Welcome to you use this AP!','PASA',mb_ok+mb_iconinformation);
   inherited;
end;

procedure Tformmain.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin
   if (Msg.message=WM_SysCommand) and (Msg.wParam=10000) then
    begin
       about.onClick(self);
       Handled:=true;
    end;
    inherited;
end;

procedure Tformmain.FormShow(Sender: TObject);
begin
   Appendmenu(Getsystemmenu(handle,false),MF_STRING,10000,'About PASA');
   Appendmenu(Getsystemmenu(application.handle,false),MF_STRING,10000,'&About PASA');
end;

procedure Tformmain.outputClick(Sender: TObject);
var
   i,c:integer;
   dbg:Array [1..10] of string;
begin
     c:=0;
     for i:=1 to 10 do dbg[i]:='';
     if (Self.MDIChildCount>0) then
     begin
        if Self.ActiveMDIChild.FindComponent('Pagecontrol1')<>nil then
        begin
           for i:=0 to Self.ActiveMDIChild.ComponentCount-1 do
               if Self.ActiveMDIChild.Components[i].ClassType=TDBGrid then
               begin
                  if (TDBGrid(Self.ActiveMDIChild.Findcomponent('DBGrid'+copy(Self.ActiveMDIChild.Components[i].Name,7,1))).parent.name)=TPageControl(Self.ActiveMDIChild.FindComponent('Pagecontrol1')).ActivePage.Name then
                  begin
                     inc(c);
                     dbg[c]:=Self.ActiveMDIChild.Components[i].Name;
                  end;
               end;
           if c>1 then
               for i:=1 to c do
               begin
                   scExcelExport1.Dataset:=TDBGrid(Self.ActiveMDIChild.FindComponent(dbg[i])).DataSource.DataSet;
                   scExcelExport1.ExportDataset;
               end
           else if c=1 then
               begin
                   scExcelExport1.Dataset:=TDBGrid(TDBGrid(Self.ActiveMDIChild.FindComponent('DBGrid'+inttostr(TPageControl(Self.ActiveMDIChild.Findcomponent('Pagecontrol1')).ActivePageIndex+1)))).DataSource.DataSet;
                   scExcelExport1.ExportDataset;
               end
               else exit;
        end
       else begin
          for i:=0 to Self.ActiveMDIChild.ComponentCount-1 do
           if (Self.ActiveMDIChild.Components[i].ClassType=TDBGrid) then
             if TDBGrid(Self.ActiveMDIChild.Components[i]).visible=true then inc(c);
           if c>1 then
             for i:=1 to c do
             begin
                scExcelExport1.Dataset:=TDBGrid(Self.ActiveMDIChild.FindComponent('DBGrid'+inttostr(i))).DataSource.DataSet;
                scExcelExport1.ExportDataset;
             end
             else if Self.ActiveMDIChild.FindComponent('DBGrid1')<>nil then
             begin
                   scExcelExport1.Dataset:=TDBGrid(Self.ActiveMDIChild.FindComponent('DBGrid1')).Datasource.Dataset;
                   scExcelExport1.ExportDataset;
             end;
        end;
     end;
end;


procedure Tformmain.ExportData(Table:TDataset);
var
  RangeE: Excel97.Range;
  I, Row: Integer;
  Bookmark: TBookmarkStr;
begin
try
  ExcelApplication1.Visible [0] := True;
  ExcelApplication1.Workbooks.Add (NULL, 0);
  RangeE := ExcelApplication1.ActiveCell;
  for I := 0 to Table.Fields.Count - 1 do
  begin
    RangeE.Value := Table.Fields [I].DisplayLabel;
    RangeE := RangeE.Next;
  end;
  Table.DisableControls;
  try
    Bookmark := Table.Bookmark;
    try
      if Table.State=dsInactive then
        Table.Open;
      Table.First;
      Row := 2;
      while not Table.EOF do
      begin
        RangeE := ExcelApplication1.Range ['A' + IntToStr (Row),
          'A' + IntToStr (Row)];
        for I := 0 to Table.Fields.Count - 1 do
        begin
          if Table.Fields[i].DataType=ftString then
             if numstring(table.fields[i].AsString) or (length(table.fields[i].asstring)>10) then
//                RangeE.Value:='~'+Table.Fields[I].AsString
                  RangeE.Value:=Table.Fields[I].AsString
             else
                RangeE.Value:=Table.Fields[I].AsString
          else
             RangeE.Value:=Table.Fields[i].Value;
          RangeE:=RangeE.next;
        end;
        Table.Next;
        Inc (Row);
      end;
    finally
      Table.Bookmark := Bookmark;
    end;
  finally
    Table.EnableControls;
  end;
  RangeE.AutoFormat(0,NULL,Null,null,null,null,null);
except
//  Application.MessageBox('对不起,您没有安装 Microsoft Excel,请安装后再导出,'+#13#10+'或在导出到Excel时出现错误,可能有些栏位为空值.','Excel错误',mb_ok+mb_iconerror);
end;
end;
//节假日定义
procedure Tformmain.piesetClick(Sender: TObject);

⌨️ 快捷键说明

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