|
|
unit update_sql_readme;
|
|
|
|
|
|
interface
|
|
|
|
|
|
uses
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
Dialogs, DB, ADODB, ComCtrls, Grids, DBGrids, ExtCtrls, DBCtrls,IniFiles,
|
|
|
StdCtrls, Mask, dxExEdtr, dxTL, dxDBCtrl, dxDBGrid, dxCntner, bsSkinCtrls;
|
|
|
|
|
|
type
|
|
|
Tfrmupdatesql = class(TForm)
|
|
|
ADOConnection1: TADOConnection;
|
|
|
t_sql1: TDataSource;
|
|
|
PageControl1: TPageControl;
|
|
|
TabSheet1: TTabSheet;
|
|
|
TabSheet2: TTabSheet;
|
|
|
Panel1: TPanel;
|
|
|
DBMemo1: TDBMemo;
|
|
|
t_readme1: TDataSource;
|
|
|
DBGrid2: TDBGrid;
|
|
|
Panel2: TPanel;
|
|
|
DBMemo2: TDBMemo;
|
|
|
Panel3: TPanel;
|
|
|
Label1: TLabel;
|
|
|
DBEdit1: TDBEdit;
|
|
|
Label2: TLabel;
|
|
|
DBEdit2: TDBEdit;
|
|
|
DBNavigator1: TDBNavigator;
|
|
|
Panel4: TPanel;
|
|
|
Label3: TLabel;
|
|
|
DBEdit3: TDBEdit;
|
|
|
DBNavigator2: TDBNavigator;
|
|
|
t_sql: TADOQuery;
|
|
|
t_readme: TADOQuery;
|
|
|
Button1: TButton;
|
|
|
t_view_update: TADOQuery;
|
|
|
t_view_update1: TDataSource;
|
|
|
TabSheet3: TTabSheet;
|
|
|
DBGrid3: TDBGrid;
|
|
|
Panel5: TPanel;
|
|
|
DBMemo3: TDBMemo;
|
|
|
Panel6: TPanel;
|
|
|
Label5: TLabel;
|
|
|
DBEdit5: TDBEdit;
|
|
|
DBNavigator3: TDBNavigator;
|
|
|
Button2: TButton;
|
|
|
Panel7: TPanel;
|
|
|
dxDBGrid1: TdxDBGrid;
|
|
|
dxDBGrid1Column1: TdxDBGridColumn;
|
|
|
dxDBGrid1Column2: TdxDBGridColumn;
|
|
|
bsSkinPanel1: TbsSkinPanel;
|
|
|
Edit1: TEdit;
|
|
|
Label4: TLabel;
|
|
|
Label6: TLabel;
|
|
|
Edit2: TEdit;
|
|
|
bsSkinSpeedButton1: TbsSkinSpeedButton;
|
|
|
bsSkinSpeedButton2: TbsSkinSpeedButton;
|
|
|
Label7: TLabel;
|
|
|
Edit3: TEdit;
|
|
|
procedure t_sqlBeforeInsert(DataSet: TDataSet);
|
|
|
procedure t_sqlAfterInsert(DataSet: TDataSet);
|
|
|
procedure ADOConnection1BeforeConnect(Sender: TObject);
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
procedure Button1Click(Sender: TObject);
|
|
|
procedure Button2Click(Sender: TObject);
|
|
|
procedure bsSkinSpeedButton2Click(Sender: TObject);
|
|
|
procedure bsSkinSpeedButton1Click(Sender: TObject);
|
|
|
private
|
|
|
{ Private declarations }
|
|
|
public
|
|
|
{ Public declarations }
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
frmupdatesql: Tfrmupdatesql;
|
|
|
banben,shunxu:integer;
|
|
|
|
|
|
implementation
|
|
|
|
|
|
uses u_update;
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
procedure Tfrmupdatesql.t_sqlBeforeInsert(DataSet: TDataSet);
|
|
|
begin
|
|
|
banben:=t_sql.fieldbyname('<27>汾<EFBFBD><E6B1BE>').AsInteger;
|
|
|
shunxu:=t_sql.fieldbyname('˳<><CBB3>').AsInteger;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrmupdatesql.t_sqlAfterInsert(DataSet: TDataSet);
|
|
|
begin
|
|
|
t_sql['<27>汾<EFBFBD><E6B1BE>']:=banben;
|
|
|
t_sql['˳<><CBB3>']:=shunxu+1;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrmupdatesql.ADOConnection1BeforeConnect(Sender: TObject);
|
|
|
begin
|
|
|
ADOConnection1.ConnectionString:='FILE NAME='+ExtractFilePath(ParamStr(0))+'sql.udl';
|
|
|
end;
|
|
|
|
|
|
procedure Tfrmupdatesql.FormShow(Sender: TObject);
|
|
|
var
|
|
|
str:string;
|
|
|
table:Tadoquery;
|
|
|
begin
|
|
|
table:=Tadoquery.Create(application);
|
|
|
|
|
|
table.Connection:=frmsoftupdate.db;
|
|
|
table.SQL.text:='select top 1 <20>汾<EFBFBD><E6B1BE> from t_sys_soft order by <20>汾<EFBFBD><E6B1BE> desc';
|
|
|
table.open;
|
|
|
str:=table.fieldbyname('<27>汾<EFBFBD><E6B1BE>').AsString;
|
|
|
str:=StringReplace(str,'.','',[rfReplaceAll]);
|
|
|
t_sql.close;
|
|
|
t_sql.sql.Clear;
|
|
|
t_sql.sql.add('select * from t_sql where <20>汾<EFBFBD><E6B1BE>>='+str+' order by <20>汾<EFBFBD><E6B1BE>,˳<><CBB3> ');
|
|
|
t_sql.open;
|
|
|
t_readme.open;
|
|
|
t_view_update.Open;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrmupdatesql.Button1Click(Sender: TObject);
|
|
|
var
|
|
|
table:Tadoquery;
|
|
|
inifile1:Tinifile;
|
|
|
str:string;
|
|
|
j,i:integer;
|
|
|
if_add:boolean;
|
|
|
TempStr,Stemp:TStringlist;
|
|
|
begin
|
|
|
// frmsoftupdate.Memo1.Lines.Clear;
|
|
|
frmsoftupdate.Memo1.Lines.Add('<27><>ʼִ<CABC><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'+DateTimeToStr(NOW));
|
|
|
|
|
|
{
|
|
|
try
|
|
|
frmsoftupdate.db.Connected:=true;
|
|
|
except
|
|
|
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>');
|
|
|
frmsoftupdate.Memo1.Lines.Add('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>');
|
|
|
end;
|
|
|
}
|
|
|
TempStr:=TStringList.Create;
|
|
|
Stemp:=TStringList.Create;
|
|
|
try
|
|
|
{
|
|
|
table:=Tadoquery.Create(application);
|
|
|
table.Connection:=frmsoftupdate.db;
|
|
|
table.SQL.text:='select <20>汾<EFBFBD><E6B1BE>,<2C>汾1,<2C>汾2,<2C>汾3 from t_sys_soft';
|
|
|
table.open;
|
|
|
|
|
|
j:=strtoint(table.fieldbyname('<27>汾1').asstring+table.fieldbyname('<27>汾2').asstring+table.fieldbyname('<27>汾3').asstring);
|
|
|
frmsoftupdate.Memo1.Lines.Add('<27><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE>:'+table.fieldbyname('<27>汾1').asstring+table.fieldbyname('<27>汾2').asstring+table.fieldbyname('<27>汾3').asstring);
|
|
|
}
|
|
|
if frmsoftupdate.Edit5.Text<>'' then begin
|
|
|
frmsoftupdate.Memo1.Lines.Add('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE>:'+frmsoftupdate.Edit5.Text);
|
|
|
end;
|
|
|
|
|
|
try
|
|
|
frmsoftupdate.Memo1.Lines.Add('ִ<>а汾<D0B0><E6B1BE>'+t_sql.FieldByName('<27>汾<EFBFBD><E6B1BE>').AsString+'˳<><CBB3>'+t_sql.FieldByName('<27>汾<EFBFBD><E6B1BE>').AsString+'<27><>');
|
|
|
TempStr.Text:=t_sql.fieldbyname('ִ<><D6B4>').asstring;
|
|
|
|
|
|
for i:=0 to TempStr.Count-1 do begin
|
|
|
if (TRIM(UpperCase(TempStr[i]))<>'GO') then
|
|
|
stemp.add(TempStr[i])
|
|
|
else begin
|
|
|
if (Stemp.Text)<>'' then begin
|
|
|
frmsoftupdate.p_update.close;
|
|
|
frmsoftupdate.p_update.Parameters.ParamByName('@sSQL').value:=Stemp.Text;
|
|
|
frmsoftupdate.p_update.Parameters.ParamByName('@pi_Result').value:=0;
|
|
|
frmsoftupdate.p_update.Parameters.ParamByName('@ps_Message').value:='';
|
|
|
frmsoftupdate.p_update.ExecProc;
|
|
|
stemp.Clear;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
if (Stemp.Text)<>'' then begin
|
|
|
frmsoftupdate.p_update.close;
|
|
|
frmsoftupdate.p_update.Parameters.ParamByName('@sSQL').value:=Stemp.Text;
|
|
|
frmsoftupdate.p_update.Parameters.ParamByName('@pi_Result').value:=0;
|
|
|
frmsoftupdate.p_update.Parameters.ParamByName('@ps_Message').value:='';
|
|
|
frmsoftupdate.p_update.ExecProc;
|
|
|
stemp.Clear;
|
|
|
end;
|
|
|
|
|
|
except
|
|
|
frmsoftupdate.Memo1.Lines.Add('ִ<>а汾<D0B0><E6B1BE>'+t_sql.FieldByName('<27>汾<EFBFBD><E6B1BE>').AsString+'˳<><CBB3>'+t_sql.FieldByName('<27>汾<EFBFBD><E6B1BE>').AsString+'ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
;
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD>');
|
|
|
frmsoftupdate.Memo1.Lines.Add('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ʱ<><CAB1>'+DateTimeToStr(Now));
|
|
|
FreeAndNil(TempStr);
|
|
|
FreeAndNil(Stemp);
|
|
|
// close;
|
|
|
except
|
|
|
showmessage('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
|
|
|
frmsoftupdate.Memo1.Lines.Add('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>,ʱ<><CAB1>'+DateTimeToStr(Now));
|
|
|
FreeAndNil(TempStr);
|
|
|
FreeAndNil(Stemp);
|
|
|
end;
|
|
|
// frmsoftupdate.Memo1.Lines.SaveToFile(ExtractFilePath(Application.ExeName)+FormatDateTime('YYYYMMDDHHNNSS',NOW)+'.txt');
|
|
|
end;
|
|
|
|
|
|
procedure Tfrmupdatesql.Button2Click(Sender: TObject);
|
|
|
var
|
|
|
table:Tadoquery;
|
|
|
inifile1:Tinifile;
|
|
|
str:string;
|
|
|
j,i:integer;
|
|
|
if_add:boolean;
|
|
|
begin
|
|
|
// frmsoftupdate.Memo1.Lines.Clear;
|
|
|
frmsoftupdate.Memo1.Lines.Add('<27><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>VIEW'+DateTimeToStr(NOW));
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
|
// try
|
|
|
|
|
|
|
|
|
frmsoftupdate.t_update.Close;
|
|
|
frmsoftupdate.Memo1.Lines.Add('ִ<>а汾<D0B0><E6B1BE>'+'˳<><CBB3>'+t_view_update.FieldByName('˳<><CBB3>').AsString+'<27><>');
|
|
|
frmsoftupdate.p_update.Parameters.ParamByName('SQLStr').value:=t_view_update.fieldbyname('ִ<><D6B4>').asstring;
|
|
|
frmsoftupdate.p_update.ExecProc;
|
|
|
|
|
|
|
|
|
// except
|
|
|
// frmsoftupdate.Memo1.Lines.Add('ִ<>а汾<D0B0><E6B1BE>'+'˳<><CBB3>'+t_view_update.FieldByName('˳<><CBB3>').AsString+'ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
;
|
|
|
// end;
|
|
|
|
|
|
|
|
|
|
|
|
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD>');
|
|
|
frmsoftupdate.Memo1.Lines.Add('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ʱ<><CAB1>'+DateTimeToStr(Now));
|
|
|
// close;
|
|
|
|
|
|
except
|
|
|
showmessage('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
|
|
|
frmsoftupdate.Memo1.Lines.Add('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>,ʱ<><CAB1>'+DateTimeToStr(Now));
|
|
|
end;
|
|
|
|
|
|
// frmsoftupdate.Memo1.Lines.SaveToFile(ExtractFilePath(Application.ExeName)+FormatDateTime('YYYYMMDDHHNNSS',NOW)+'.txt');
|
|
|
end;
|
|
|
|
|
|
procedure Tfrmupdatesql.bsSkinSpeedButton2Click(Sender: TObject);
|
|
|
begin
|
|
|
t_sql.close;
|
|
|
t_sql.sql.Clear;
|
|
|
t_sql.sql.add('select * from t_sql order by <20>汾<EFBFBD><E6B1BE>,˳<><CBB3> ');
|
|
|
t_sql.open;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrmupdatesql.bsSkinSpeedButton1Click(Sender: TObject);
|
|
|
begin
|
|
|
t_sql.close;
|
|
|
t_sql.sql.Clear;
|
|
|
t_sql.sql.add('select * from t_sql where 1=1 ');
|
|
|
if Edit1.Text<>'' then begin
|
|
|
t_sql.sql.add(' and <20>汾<EFBFBD><E6B1BE>='+Edit1.Text);
|
|
|
end;
|
|
|
if Edit2.Text<>'' then begin
|
|
|
t_sql.sql.add(' and ִ<><D6B4> like ''%'+Edit2.Text+'%''');
|
|
|
end;
|
|
|
if Edit3.Text<>'' then begin
|
|
|
t_sql.sql.add(' and ִ<><D6B4> like ''%'+Edit3.Text+'%''');
|
|
|
end;
|
|
|
t_sql.sql.add(' order by <20>汾<EFBFBD><E6B1BE>,˳<><CBB3> ');
|
|
|
t_sql.open;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end.
|