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

📄 datalinkunit.pas

📁 工商收费系统,主要是管理非税收收入的费用的管理
💻 PAS
字号:
unit DataLinkUnit;interfaceuses  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,  Db, ADODB,menus,dbgrids,stdctrls;type  TDMMain = class(TDataModule)    adoConnMain: TADOConnection;    Q: TADOQuery;    conComm: TADOConnection;    procedure DataModuleCreate(Sender: TObject);  private    { Private declarations }  public     ////////////////////////函数///////////////////////////     Procedure FilterTable(sql:string;tb:TADOQuery);    Function  AdoQueryOpen(strSQL:String;AdoQuery:TAdoQuery;strQueryType:String;strDbType:string):Boolean;    Function  AdoQueryOpen1(strSQL:String;AdoQuery:TAdoQuery;strQueryType:String;strDbType:string):Boolean;    procedure writequeryflag(gstrOperaterName:String;AdoQuery:TAdoQuery);////////////////////////过程/////////////////////////    { Public declarations }  end;var  DMMain: TDMMain;  gstrDBPath:string; // 数据库全路径implementationuses GlobalLibUnit;{$R *.DFM}//更新表Function UpdateTable(tblUpdateTable:TADOTable):integer;begin   UpdateTable:=1;   try      tblUpdateTable.UpdateBatch;      UpdateTable:=0;   except     On E:Exception do        begin             if Pos('Key violation',E.Message)<>0 then                begin                     Application.MessageBox('已经有此代码,不能再次添加此代码!','错误框',MB_ICONStop);                     Exit;                end             else if Pos('违反唯一约束',E.Message)<>0 then                begin                     Application.MessageBox('已经有此代码,不能再次添加此代码!','错误框',MB_ICONStop);                     Exit;                end             else if Pos('cannot be a zero_string length',E.Message)<>0 then                begin                     Application.MessageBox('字符串不等为空!','错误框',MB_ICONStop);                     Exit;                end             else if Pos('primary key',E.Message)<>0 then                begin                     Application.MessageBox('已经有此代码,不能再次添加此代码!','错误框',MB_ICONStop);                     Exit;                end             else if Pos('Master record missing',E.Message)<>0 then                begin                     Application.MessageBox('该代码已经在其他表中使用,不能编辑!','错误框',MB_ICONStop);                     Exit;                end             else                begin                     Application.MessageBox(PChar(E.Message),'错误框',MB_ICONStop);                     Exit;                end;        end;   end;end;procedure TDMMain.DataModuleCreate(Sender: TObject);var   strDatabaseConnectString:string;begin   //判断数据库文件是否存在  If not FileExists(ExtractFilePath(Application.EXEName)+'\Db\DosoftTicket.mdb') then   begin      Application.MessageBox('数据库文件不存在,请重新安装本系统!','初始化错误',mb_OK+mb_IconStop);      Application.Terminate;   end;   if not adoConnMain.Connected then   begin      //连接数据库{      strDatabaseConnectString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='         + ExtractFilePath(Application.EXEName)+'Db\DosoftTicket.mdb'+';Persist Security'         + ' Info=False;Jet OLEDB:Database Password=19721118';}      strDatabaseConnectString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='         + gstrDBPath+';Persist Security'         + ' Info=False;Jet OLEDB:Database Password=23981972a';      adoConnMain.Provider:='Microsoft.Jet.OLEDB.4.0';      conComm.Provider:='Microsoft.Jet.OLEDB.4.0';      conComm.ConnectionString:=strDatabaseConnectString;      adoConnMain.ConnectionString:=strDatabaseConnectString;      try          adoConnMain.Connected:=True;          conComm.Connected:=True;      except      begin          Application.MessageBox('数据库连接失败,请重新安装本系统或恢复数据库!','初始化错误',mb_OK+mb_IconStop);          Application.Terminate;      end;      end;   end;   writequeryflag(gstrOperaterName,Q);end; ////////////////////////////////////// //////////////////////////////////////// //函数功能:打开数据表(执行数据表)                                          // //输入参数:                                                                 // //SqlStr—SQL字符串,AdoQuery—数据连接串,QueryType—0-打开(1-执行),        // //BeginCol—开始列,LastCol—结束列                                           // //输出参数:                                                                 // //无                                                                         // //编写人:宫俊                                                               // //编写日期:2001.6.2                                                         // ////////////////////////////////////// ////////////////////////////////////////Function  TDMMain.AdoQueryOpen(strSQL:String;AdoQuery:TAdoQuery;strQueryType:String;strDbType:string):Boolean;begin     AdoQuery.Close;     case strToint(strQueryType) of        1: AdoQuery.Connection:=adoConnMain;     end;     AdoQuery.Close;     AdoQuery.SQL.Clear;     AdoQuery.SQL.Text:=strSQL;     try        if strQueryType='0' then           AdoQuery.Open//打开数据表        else if strQueryType='1' then           begin            AdoQuery.Prepared;            AdoQuery.ExecSQL;//执行数据表           end;     except on E: Exception do       begin         Result:=False;         Exit;       end;     end;     Result:=True;end;procedure TDMMain.writequeryflag(gstrOperaterName:String;AdoQuery:TAdoQuery);var strsql:string;begin    gstrOperaterquery:=0;    gstrOperaterCode:='00';    AdoQuery.Close;    strsql:='select 操作员编码 from tc00 where 操作员名称='''+gstrOperaterName+'''';    AdoQueryOpen(strsql,AdoQuery,'0','1');    AdoQuery.First;    if AdoQuery.RecordCount<>0 then       gstrOperaterCode:=AdoQuery.Fields[0].AsString;    AdoQuery.Close;    strsql:='select 启动按操作员查询 from td98';   AdoQueryOpen(strsql,AdoQuery,'0','1');    AdoQuery.First;    if AdoQuery.RecordCount<>0 then      if  AdoQuery.Fields[0].AsBoolean then        gstrOperaterquery:=1;   if gstrOperaterquery=1 then  gstrOperater:='and 操作员编码='''+gstrOperaterCode+'''' ;   if gstrOperaterquery=0 then  gstrOperater:=''; end; function TDMMain.AdoQueryOpen1(strSQL: String; AdoQuery: TAdoQuery;  strQueryType, strDbType: string): Boolean;
begin
     AdoQuery.Close;
     case strToint(strQueryType) of        1: AdoQuery.Connection:=conComm;     end;     AdoQuery.Close;     AdoQuery.SQL.Clear;     AdoQuery.SQL.Text:=strSQL;     try        if strQueryType='0' then           AdoQuery.Open//打开数据表        else if strQueryType='1' then           begin            AdoQuery.Prepared;            AdoQuery.ExecSQL;//执行数据表           end;     except on E: Exception do       begin         Result:=False;         Exit;       end;     end;     Result:=True;
end;

end.

⌨️ 快捷键说明

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