功能是按时间检查表格数字是否连续
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB, Grids, DBGrids, RzDBGrid, ExtCtrls, sMemo,
ComCtrls, sTreeView, sListView, Mask, RzEdit,inifiles;
type
TForm1 = class(TForm)
Panel1: TPanel;
RzDBGrid1: TRzDBGrid;
Label1: TLabel;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
ComboBox1: TComboBox;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Label2: TLabel;
Label3: TLabel;
DateTimePicker3: TDateTimePicker;
DateTimePicker4: TDateTimePicker;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Read_inifile;
procedure Initialize;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Server, //登录的服务器名
UserName, //登录用户名
Password:string;//登录密码
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
temp :string;
str:string;
date1,date2:string;
begin
//showmessage(datetostr(datetimepicker1.date));
// showmessage(timetostr(datetimepicker2.time));
date1 :=quotedstr(formatdatetime('yyyy-mm-dd',datetimepicker1.date)+' '+formatdatetime('HH:mm:ss',datetimepicker2.time));
date2 :=quotedstr(formatdatetime('yyyy-mm-dd',datetimepicker4.date)+' '+formatdatetime('HH:mm:ss',datetimepicker3.time));
// showmessage(date1);
// showmessage(date2);
if Edit1.Text <> '' then
begin
temp := Edit1.Text;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
str:='select *,serialno = substring(zzbdata,1,4) from tbl_zzbinfo where zzbdate > '+date1+'and zzbdate < '+date2+'and productidno = '''+temp+''' order by zzbdate asc ';
//showmessage(str) ;
adoquery1.SQL.text:= str;
adoquery1.Open;
end
else
showmessage('输入查询的IDNum');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
temp : string;
FNum : integer;
HNum : integer;
Inum : integer;
begin
combobox1.Clear;
temp := adoquery1.fieldbyname('serialno').asstring;
HNum :=strtoint(temp);
while not adoquery1.Eof do
begin
temp := adoquery1.fieldbyname('serialno').asstring;
FNum :=strtoint(temp);
while HNum+1<FNum do
begin
temp :=inttostr(HNum+1) ;
combobox1.items.Add(temp);
HNum :=HNum+1;
end;
HNum :=HNum+1;
adoquery1.Next;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
adoquery1.SQL.text:= 'select *,serialno = substring(zzbdata,1,4) from tbl_zzbinfo';
//adoquery1.ExecSQL;
adoquery1.Open;
end;
procedure TForm1.Read_inifile;
var
Myini:Tinifile;
begin
Myini:=Tinifile.Create(ExtractFilePath(Application.ExeName)+'config\SqlSet.ini');
Server:=Myini.readstring('information','Server','');
UserName:=Myini.readstring('information','UserName','');
Password:=Myini.readstring('information','Password','');
Myini.Free;
end;
procedure TForm1.Initialize;
begin
try
ADOConnection1.close;
ADOConnection1.Connected := False;
ADOConnection1.ConnectionString := 'Provider=SQLOLEDB.1;Password=' + PassWord +
';Persist Security Info=True;User ID=' + UserName+
';Initial Catalog=AponZZBDB;Data Source=' +Server+
';Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;' +
'Use Encryption for Data=False;Tag with column collation when possible=False';
ADOConnection1.loginprompt := false;
except
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Read_inifile;
Initialize;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
adoquery1.SQL.text:= 'select *,serialno = substring(zzbdata,1,4) from tbl_zzbinfo';
adoquery1.Open;
end;
end.