📄 index.~pas
字号:
unit index;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, Grids, DBGrids, DB, ComCtrls, ADODB;
type
Tindexform = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N12: TMenuItem;
N21: TMenuItem;
N22: TMenuItem;
GroupBox1: TGroupBox;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
GroupBox2: TGroupBox;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
ComboBox1: TComboBox;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
DBGrid1: TDBGrid;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Button1: TButton;
ADODataSet1: TADODataSet;
ADOConnection1: TADOConnection;
DataSource1: TDataSource;
Button2: TButton;
ADODataSet2: TADODataSet;
ADOTable1: TADOTable;
Label12: TLabel;
Label1: TLabel;
N8: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure N22Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure DBGrid1TitleClick(Column: TColumn);
procedure Button1Click(Sender: TObject);
procedure N18Click(Sender: TObject);
procedure N9Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
indexform: Tindexform;
username:string;
qx:array[1..2] of boolean;
implementation
uses login, user, pass, xsform, banquan, yangyu;
{$R *.dfm}
procedure Tindexform.FormCreate(Sender: TObject);
var
dbname:string;
begin
dbname:= ExtractFilePath(Application.ExeName) + 'yang.mdb';
with ADOConnection1 do
begin
ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;'+
'Data Source='+dbname+';'+
'Mode=ReadWrite;'+
'Persist Security Info=False';
Connected:=True;//打开数据连接
end;
end;
procedure Tindexform.FormActivate(Sender: TObject);
begin
DateTimePicker1.Date:=date()-1;
DateTimePicker2.Date:=Date();
loginform.showmodal();
if username<>'' then
begin
indexform.caption:='票务信息管理系统 使用者:'+ username+ ' 当前日期:'+ datetostr(date());
if qx[1] then
begin
//label1.caption:=username;
end
else
//label1.caption:='22222';
end
else
close;
dbgrid1.DataSource:=datasource1;
datasource1.DataSet:=adodataset1;
adodataset1.Connection:=adoconnection1;
adodataset1.close;
adodataset1.CommandType:=cmdtext;
adodataset1.CommandText:='select * from spiao order by pdate DESC';
adodataset1.open;
end;
procedure Tindexform.N22Click(Sender: TObject);
begin
close;
end;
procedure Tindexform.N12Click(Sender: TObject);
begin
userform.showmodal();
end;
procedure Tindexform.N4Click(Sender: TObject);
begin
passform.showmodal();
end;
procedure Tindexform.N7Click(Sender: TObject);
begin
xiaos.showmodal();
end;
procedure Tindexform.Button2Click(Sender: TObject);
var so : String;
begin
adodataset1.Close;
so:=edit1.text;
dbgrid1.DataSource:=datasource1;
datasource1.DataSet:=adodataset1;
adodataset1.Connection:=adoconnection1;
adodataset1.close;
adodataset1.CommandType:=cmdtext;
adodataset1.CommandText:='select * from spiao order by pdate DESC';
adodataset1.open;
adodataset1.Close;
adodataset1.CommandType:=cmdtext;
adodataset1.commandtext:='select sum(lirong) from spiao where xname like ''%'+so+'%''';
adodataset1.open;
if ADODataSet1.Fields[0].Value >0 then
label1.caption:='利润合计:'+ inttostr(ADODataSet1.Fields[0].Value) + '元。'
else
label1.caption:='';
adodataset1.Close;
adodataset1.commandtext:='select * from spiao where xname like ''%'+so+'%'' order by pdate DESC';
adodataset1.open;
adodataset2.Close;
adodataset2.Connection:=adoconnection1;
adotable1.Connection:=adoconnection1;
adotable1.tablename:='xinxi';
adotable1.active:=true;
adodataset2.close;
adodataset2.CommandType:=cmdtext;
adodataset2.CommandText:='select * from xinxi where yname=:soo';
adodataset2.Parameters.Clear;
adodataset2.Parameters.AddParameter;
adodataset2.Parameters[0].name:='soo';
adodataset2.Parameters[0].datatype:=ftstring;
adodataset2.Parameters[0].Direction:=pdinput;
adodataset2.Parameters[0].Value:=edit1.text;
adodataset2.open;
if adodataset2.Recordset.RecordCount=1 then
begin
//adotable1.next;
edit2.text:=adodataset2.FieldByName('yname').asstring;
edit3.text:=adodataset2.FieldByName('yadd').AsString;
edit4.text:=adodataset2.FieldByName('ytel1').asstring;
edit5.Text:=adodataset2.fieldbyname('ytel2').asstring;
edit6.text:=adodataset2.FieldByName('ydate').asstring;
ComboBox1.text:=adodataset2.FieldByName('ysex').asstring;
edit7.text:=adodataset2.FieldByName('yther').asstring;
edit8.text:=adodataset2.FieldByName('shnegfengzhen').asstring;
end;
adodataset2.close;
if adodataset1.Recordset.RecordCount<>0 then
begin
label12.caption:='查询结果:共有记录'+ IntToStr(adodataset1.RecordCount) + '条';
end
else
label12.caption:='目前没有任何记录,请重新输入条件进行查找。';
end;
procedure Tindexform.DBGrid1TitleClick(Column: TColumn);
begin
if (adodataset1.Sort<>column.FieldName+' ASC') then
adodataset1.Sort:=column.FieldName+' ASC'
else
adodataset1.sort:=column.fieldname+' DESC';
end;
procedure Tindexform.Button1Click(Sender: TObject);
begin
//so:=edit1.text;
if DateTimePicker1.date<=DateTimePicker2.date then
begin
adodataset1.Close;
dbgrid1.DataSource:=datasource1;
datasource1.DataSet:=adodataset1;
adodataset1.Connection:=adoconnection1;
adodataset1.close;
adodataset1.CommandType:=cmdtext;
adodataset1.CommandText:='select sum(lirong) from spiao where pdate between #'+DateToStr(DateTimePicker1.date)+'# and #'+DateToStr(DateTimePicker2.date)+'#';
adodataset1.open;
if ADODataSet1.Fields[0].Value >0 then
label1.caption:='利润合计:'+ inttostr(ADODataSet1.Fields[0].Value) + '元。'
else
label1.caption:='';
edit2.text:='没有用户';
end
else
application.MessageBox('开始日期不能大于结束日期,请重新选择!','提示信息',mb_ok);
//adodataset1.Close;
//between #'+DateToStr(dtp_date1.date)+'# and #'+DateToStr(dtp_date2.date)+'#'
adodataset1.Close;
adodataset1.commandtext:='select * from spiao where pdate between #'+DateToStr(DateTimePicker1.date)+'# and #'+DateToStr(DateTimePicker2.date)+'#';
adodataset1.open;
if adodataset1.Recordset.RecordCount<>0 then
begin
label12.caption:='查询结果:共有记录'+ IntToStr(adodataset1.RecordCount) + '条';
end
else
label12.caption:='目前没有任何记录,请重新输入条件进行查找。';
//adodataset1.Close;
end;
procedure Tindexform.N18Click(Sender: TObject);
begin
banquanform.showmodal();
end;
procedure Tindexform.N9Click(Sender: TObject);
begin
yangyuform.showmodal();
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -