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

📄 u_public.pas

📁 很好的合同管理系统完整源码,适合初学者参考
💻 PAS
字号:
unit U_Public;

interface
uses  SysUtils, Classes, DB, ADODB, Dialogs, Controls, IniFiles, Forms, ComCtrls,
      ExtCtrls, StdCtrls, Graphics, windows, Mask, DBGrids,DBCtrls,Word2000,
      Grids, OleServer,  Excel2000, Variants;
function WordPath(Const FileName: String): Boolean;
procedure exec_sql(P_Str_lj:String);
procedure Rz_Gl(czy,czsj,sj:string);
procedure xt_path;
procedure net_path;
procedure ini_data();
procedure open_data(p_str_lj:string);
procedure wordPrint( State,Path: String; WordApplication: TwordApplication;worddocument:Tworddocument);
Procedure Skinload();
procedure close_data;
procedure OpenWordFile(State,Path: String; WordApplication1: TwordApplication;worddocument:Tworddocument);
procedure wordRead( State,Path: String; WordApplication: TwordApplication;worddocument:Tworddocument);

var
sb_path:string;
gg:string;
czy:string;
yb_path,cg_path,sy_path,xg_path,qd_path,hsz_path:string;
g_str_skinname:string;
g_str_skinpath:string;
dr1:integer;
DBServer,DBName,DBLogon,DBPass:string;
con_str:string;
netpath:string;
ini_file:Tinifile;

implementation

uses U_Data;

procedure xt_path;
begin
with data1.xtsz do
begin
   close;
   sql.Clear;
   sql.Add('select * from 系统路径');
   open;
end;
if data1.xtsz.RecordCount>0 then
begin
//yb_path:=data1.ADOQuery1.fieldbyname('yblj').Value;
cg_path:=data1.xtsz.fieldbyname('cglj').Value;
sy_path:=data1.xtsz.fieldbyname('sylj').Value;
xg_path:=data1.xtsz.fieldbyname('xglj').Value;
qd_path:=data1.xtsz.fieldbyname('qdlj').Value;
hsz_path:=data1.xtsz.fieldbyname('hsz').Value;
end;
end;

procedure net_path;
begin
with data1.ADOQuery1 do
begin
   close;
   sql.Clear;
   sql.Add('select * from 网络路径');
   open;
end;
netpath:=data1.ADOQuery1.fieldbyname('netpath').Value;
end;

procedure ini_data();
begin 
   con_str:=extractfilepath(application.ExeName)+'system.ini';
   ini_file:=TiniFile.Create(con_str);
   DBServer:=ini_file.ReadString('Database','DBServer',DBServer);
   DBName:=ini_file.ReadString('Database','DBName',DBName);
   DBLogon:=ini_file.ReadString('Database','DBLogon',DBLogon);
   DBPass:=ini_file.ReadString('Database','DBPass',DBPass);
   data1.AC.ConnectionString:='provider=SQLOLEDB.1;password='+DBPass+
                           ';presist security info=tree;user id='+DBLogon+
                           ';initial catalog='+DBName+';data source='+DBServer;
end;

procedure wordPrint( State,Path: String; WordApplication: TwordApplication;worddocument:Tworddocument);
var
   itemindex :olevariant;
   filename, confirmconversions, readonly, addtorecentfiles,
   passworddocument, passwordtemplate, revert,
   writepassworddocument, writepasswordtemplate, format, Encoding, Visible: olevariant;
begin
   WordApplication.Connect;
   wordApplication.Visible:=false;
   filename := Path;                  //文档名 ( 包含路径 )
   confirmconversions := false;       //是否显示文件转换对话框
   if state='false' then readonly:=false
   else
   readonly := false;                  //是否以只读方式打开文档
   addtorecentfiles := false;         //是否将文件添加到 " 文件 " 菜单底部的最近使用文件列表中
   passworddocument := '';            //打开此文档时所需要的密码
   passwordtemplate := '';            //打开此模板时所需要的密码
   revert := true;                    //如果文档已经 ,是否重新打开文档
   writepassworddocument := '';       //保存对文档更改时所需要的密码
   writepasswordtemplate := '';       //保存对模板进行更改时所需要的密码
   format := wdopenformatdocument;    //打开文档时所需使用的文件转换器
   Encoding:='';                      //所使用的文档代码页
   Visible:= 1;                       //打开文档的窗口是否可见
   wordapplication.documents.open(filename, confirmconversions,readonly, addtorecentfiles,passworddocument, passwordtemplate,revert, writepassworddocument,writepasswordtemplate, format ,Encoding, Visible);
          itemindex := 1;
          worddocument.connectto(wordapplication.documents.item(itemindex));
          worddocument.PrintOut;
            worddocument.Disconnect;
            WordApplication.Disconnect;
end;

function WordPath(Const FileName: String): Boolean;
    begin
         //察看文件是否存在
         Result:=FileExists(FileName);
    end;

procedure open_data(p_str_lj:string);
begin
   data1.AC.Open();
   data1.skin.SQL.Clear;
   data1.skin.SQL.Add(p_str_lj);
   data1.skin.ExecSQL;
   data1.skin.Open;
end;

Procedure Skinload();  //可以
var
AppPath:String;//程序路径
begin
   GetDir(0,AppPath);
   open_data('select * from skin');
if not data1.skin.Eof  then
begin
   g_str_skinname:=trim(data1.skin.FieldValues['mc']);
   g_str_skinpath:=apppath+'\skin\'+g_str_skinname+'\';
end;
close_data;
if g_str_skinname<>'' then
begin
   if (strtoint(g_str_skinname)<1) and  (strtoint(g_str_skinname)>4) then
   begin
     g_str_skinname:='';
     g_str_skinpath:='';
   end;
end;
if g_str_skinname='' then
begin
   g_str_skinname:='';
   g_str_skinpath:='';
end;
end;

procedure Rz_Gl(czy,czsj,sj:string); //日志管理
var NN:string;
begin
   NN:='insert into 日志(czy,czsj,sj) values(';
   NN:=NN+quotedstr(czy)+',';
   NN:=NN+quotedstr(czsj)+',';
   NN:=NN+quotedstr(sj)+')';
   exec_sql(nn);
end;

procedure Exec_Sql(P_Str_lj:String);
begin
   data1.AC.Open();
   data1.Rz_Gl.SQL.Clear;
   data1.Rz_Gl.SQL.Add(p_str_lj);
   data1.Rz_Gl.ExecSQL;
   close_data;
end;

procedure close_data;
begin
   data1.Rz_Gl.Close;
   //data1.AC.Close;
end;

procedure OpenWordFile(State,Path: String; WordApplication1: TwordApplication;worddocument:Tworddocument);
var
   itemindex :olevariant;
   filename, confirmconversions, readonly, addtorecentfiles,
   passworddocument, passwordtemplate, revert,
   writepassworddocument, writepasswordtemplate, format, Encoding, Visible: olevariant;
   begin
      WordApplication1.Connect;
      wordApplication1.Visible:=True;
      filename :=path ;                  //文档名 ( 包含路径 )
      //showmessage(filename);
      confirmconversions := false;       //是否显示文件转换对话框
      if state='false' then readonly:=false
      else
      readonly :=false;                  //是否以只读方式打开文档
      addtorecentfiles := false;         //是否将文件添加到 " 文件 " 菜单底部的最近使用文件列表中
      passworddocument := '';            //打开此文档时所需要的密码
      passwordtemplate := '';            //打开此模板时所需要的密码
      revert := true;                    //如果文档已经 ,是否重新打开文档
      writepassworddocument := '';       //保存对文档更改时所需要的密码
      writepasswordtemplate := '';       //保存对模板进行更改时所需要的密码
      format := wdopenformatdocument;    //打开文档时所需使用的文件转换器
      Encoding:='';                      //所使用的文档代码页
      Visible:= 1;                       //打开文档的窗口是否可见
      wordapplication1.documents.open( filename, confirmconversions,readonly, addtorecentfiles,passworddocument, passwordtemplate,revert, writepassworddocument,writepasswordtemplate, format ,Encoding, Visible);
      itemindex := 1;
         // worddocument.connectto(wordapplication.documents.item(itemindex));

         // wordapplication.options.checkspellingasyoutype := true; //可以拼写
          if state='True' then
             begin
               WordApplication1.CommandBars.ActiveMenuBar.Set_Enabled(False); //整个菜单工具兰隐藏
             end
          else
            begin
               WordApplication1.CommandBars.ActiveMenuBar.Set_Enabled(True);
            end;

           // worddocument.Disconnect;
            WordApplication1.Disconnect;

          //设置一个模态焦点到Word窗口.当他关闭时将WordApplication断开连接
           //wordapplication.options.checkgrammarasyoutype := true;

end;

procedure wordRead( State,Path: String; WordApplication: TwordApplication;worddocument:Tworddocument);
    var
        itemindex :olevariant;
        filename, confirmconversions, readonly, addtorecentfiles,
        passworddocument, passwordtemplate, revert,
        writepassworddocument, writepasswordtemplate, format, Encoding, Visible: olevariant;
    begin
         WordApplication.Connect;
         wordApplication.Visible:=false;
          filename := Path;                  //文档名 ( 包含路径 )
          confirmconversions := false;       //是否显示文件转换对话框
          if state='false' then readonly:=false
          else
          readonly := true;                  //是否以只读方式打开文档
          addtorecentfiles := false;         //是否将文件添加到 " 文件 " 菜单底部的最近使用文件列表中
          passworddocument := '';            //打开此文档时所需要的密码
          passwordtemplate := '';            //打开此模板时所需要的密码
          revert := true;                    //如果文档已经 ,是否重新打开文档
          writepassworddocument := '';       //保存对文档更改时所需要的密码
          writepasswordtemplate := '';       //保存对模板进行更改时所需要的密码
          format := wdopenformatdocument;    //打开文档时所需使用的文件转换器
          Encoding:='';                      //所使用的文档代码页
          Visible:= 1;                       //打开文档的窗口是否可见
          wordapplication.documents.open(filename, confirmconversions,readonly, addtorecentfiles,passworddocument, passwordtemplate,revert, writepassworddocument,writepasswordtemplate, format ,Encoding, Visible);
          itemindex := 1;
          worddocument.connectto(wordapplication.documents.item(itemindex));
          gg:=worddocument.Range.Text;
            worddocument.Disconnect;
            WordApplication.Disconnect;
end;

end.

⌨️ 快捷键说明

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