searchstinfo.pas
来自「《Delphi 2005数据库系统开发与应用》源代码」· PAS 代码 · 共 206 行
PAS
206 行
unit SearchStInfo;
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data, Borland.Data.Provider;
type
FrmSearchStInfo = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
/// <summary>
/// Required designer variable.
/// </summary>
Components: System.ComponentModel.Container;
ErrorProvider1: System.Windows.Forms.ErrorProvider;
DgStInfo: System.Windows.Forms.DataGrid;
GroupBox1: System.Windows.Forms.GroupBox;
Label1: System.Windows.Forms.Label;
Label2: System.Windows.Forms.Label;
ComboSearchType: System.Windows.Forms.ComboBox;
TxtSearchValue: System.Windows.Forms.TextBox;
BtSearch: System.Windows.Forms.Button;
BdpConnection1: Borland.Data.Provider.BdpConnection;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure InitializeComponent;
procedure BtSearch_Click(sender: System.Object; e: System.EventArgs);
{$ENDREGION}
strict protected
/// <summary>
/// Clean up any resources being used.
/// </summary>
procedure Dispose(Disposing: Boolean); override;
private
{ Private Declarations }
public
constructor Create;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(FrmSearchStInfo))]
implementation
{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure FrmSearchStInfo.InitializeComponent;
type
TSystem_ObjectArray = array of System.Object;
begin
Self.ErrorProvider1 := System.Windows.Forms.ErrorProvider.Create;
Self.DgStInfo := System.Windows.Forms.DataGrid.Create;
Self.GroupBox1 := System.Windows.Forms.GroupBox.Create;
Self.BtSearch := System.Windows.Forms.Button.Create;
Self.TxtSearchValue := System.Windows.Forms.TextBox.Create;
Self.ComboSearchType := System.Windows.Forms.ComboBox.Create;
Self.Label2 := System.Windows.Forms.Label.Create;
Self.Label1 := System.Windows.Forms.Label.Create;
Self.BdpConnection1 := Borland.Data.Provider.BdpConnection.Create;
(System.ComponentModel.ISupportInitialize(Self.DgStInfo)).BeginInit;
Self.GroupBox1.SuspendLayout;
Self.SuspendLayout;
//
// ErrorProvider1
//
Self.ErrorProvider1.ContainerControl := Self;
//
// DgStInfo
//
Self.DgStInfo.DataMember := '';
Self.DgStInfo.Dock := System.Windows.Forms.DockStyle.Bottom;
Self.DgStInfo.HeaderForeColor := System.Drawing.SystemColors.ControlText;
Self.DgStInfo.Location := System.Drawing.Point.Create(0, 94);
Self.DgStInfo.Name := 'DgStInfo';
Self.DgStInfo.Size := System.Drawing.Size.Create(376, 184);
Self.DgStInfo.TabIndex := 0;
//
// GroupBox1
//
Self.GroupBox1.Controls.Add(Self.BtSearch);
Self.GroupBox1.Controls.Add(Self.TxtSearchValue);
Self.GroupBox1.Controls.Add(Self.ComboSearchType);
Self.GroupBox1.Controls.Add(Self.Label2);
Self.GroupBox1.Controls.Add(Self.Label1);
Self.GroupBox1.Location := System.Drawing.Point.Create(8, 8);
Self.GroupBox1.Name := 'GroupBox1';
Self.GroupBox1.Size := System.Drawing.Size.Create(360, 80);
Self.GroupBox1.TabIndex := 1;
Self.GroupBox1.TabStop := False;
Self.GroupBox1.Text := '查询学籍信息';
//
// BtSearch
//
Self.BtSearch.Location := System.Drawing.Point.Create(264, 48);
Self.BtSearch.Name := 'BtSearch';
Self.BtSearch.TabIndex := 4;
Self.BtSearch.Text := '查询';
Include(Self.BtSearch.Click, Self.BtSearch_Click);
//
// TxtSearchValue
//
Self.TxtSearchValue.Location := System.Drawing.Point.Create(128, 48);
Self.TxtSearchValue.Name := 'TxtSearchValue';
Self.TxtSearchValue.TabIndex := 3;
Self.TxtSearchValue.Text := '';
//
// ComboSearchType
//
Self.ComboSearchType.Items.AddRange(TSystem_ObjectArray.Create('学号', '姓名',
'性别', '出生日期', '班号', '联系电话', '入校日期', '家庭住址'));
Self.ComboSearchType.Location := System.Drawing.Point.Create(16, 48);
Self.ComboSearchType.Name := 'ComboSearchType';
Self.ComboSearchType.Size := System.Drawing.Size.Create(96, 20);
Self.ComboSearchType.TabIndex := 2;
Self.ComboSearchType.Text := '学号';
//
// Label2
//
Self.Label2.Location := System.Drawing.Point.Create(120, 16);
Self.Label2.Name := 'Label2';
Self.Label2.Size := System.Drawing.Size.Create(80, 23);
Self.Label2.TabIndex := 1;
Self.Label2.Text := '查询条件';
Self.Label2.TextAlign := System.Drawing.ContentAlignment.MiddleCenter;
//
// Label1
//
Self.Label1.Location := System.Drawing.Point.Create(16, 16);
Self.Label1.Name := 'Label1';
Self.Label1.Size := System.Drawing.Size.Create(80, 23);
Self.Label1.TabIndex := 0;
Self.Label1.Text := '查询方式';
Self.Label1.TextAlign := System.Drawing.ContentAlignment.MiddleCenter;
//
// BdpConnection1
//
Self.BdpConnection1.ConnectionOptions := 'transaction isolation=ReadCommitted;blob size=1024';
Self.BdpConnection1.ConnectionString := 'assembly=Borland.Data.Mssql,Version=1.5.0.0,Culture=neutral,PublicKeyToken=91d6'+
'2ebb5b0d1b1b;vendorclient=sqloledb.dll;database=教务信息管理系统;username=sa;hostname='+
'storm;password=sa;provider=MSSQL';
//
// FrmSearchStInfo
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
Self.ClientSize := System.Drawing.Size.Create(376, 278);
Self.Controls.Add(Self.GroupBox1);
Self.Controls.Add(Self.DgStInfo);
Self.Name := 'FrmSearchStInfo';
Self.Text := '查询学籍信息';
(System.ComponentModel.ISupportInitialize(Self.DgStInfo)).EndInit;
Self.GroupBox1.ResumeLayout(False);
Self.ResumeLayout(False);
end;
{$ENDREGION}
procedure FrmSearchStInfo.Dispose(Disposing: Boolean);
begin
if Disposing then
begin
if Components <> nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor FrmSearchStInfo.Create;
begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
//
// TODO: Add any constructor code after InitializeComponent call
//
end;
procedure FrmSearchStInfo.BtSearch_Click(sender: System.Object; e: System.EventArgs);
var
cda:BdpDataAdapter;
ds:DataSet;
slc:string;
exchange:string;
begin
case ComboSearchType.get_SelectedIndex of
0:exchange:='student_No';
1:exchange:='student_Name';
2:exchange:='student_Sex';
end;
slc:='Select * From student_Info Where '+exchange+'='+''''+TxtSearchValue.Text+'''';
cda:=BdpDataAdapter.Create(slc,bdpConnection1);
ds:=DataSet.Create;
cda.Fill(ds,'student_Info');
DgStInfo.DataSource:=ds.Tables[0].DefaultView;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?