//这个是第一个窗体的代码
unit LgWin;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Db, DBTables;
type
TLoginForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
LgName: TEdit;
LgPassword: TEdit;
YesBtn: TButton;
NoBtn: TButton;
Image1: TImage;
LgQY: TQuery;
Database1: TDatabase;
procedure YesBtnClick(Sender: TObject);
procedure NoBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
LoginForm: TLoginForm;
implementation
uses MainWin;
{$R *.DFM}
procedure TLoginForm.YesBtnClick(Sender: TObject);
begin
LgQY.SQL.Clear
LgQY.SQL.Add ('Select * From UserInfo Where UserName = ''' + LgName.Text + ''' And UserPassWord =''' + LgPassword.Text + '''');
LgQY.ExecSQL
LgQY.Active := True;
IF LgQY.RecordCount = 0 Then
Application.MessageBox('您的信息没有查到,无法确认身份!','登录',mb_Ok + mb_IconInformation)
Else
begin
MainForm.Show;
Self.Release;
end;
end;
procedure TLoginForm.NoBtnClick(Sender: TObject);
begin
Close
end;
end.
//这个是第二个窗体的代码
unit MainWin;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, ImgList, ComCtrls, DBTables, StdCtrls, Grids, DBGrids;
type
TMainForm = class(TForm)
InfoTree: TTreeView;
SysImgList: TImageList;
InfoGrid: TDBGrid;
InfoQY: TQuery;
Database: TDatabase;
InfoDS: TDataSource;
Button1: TButton;
Button2: TButton;
SetGroup: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
GroupBox1: TGroupBox;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Button8: TButton;
Button9: TButton;
Button10: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
RootNode: TTreeNode;
end;
var
MainForm: TMainForm;
implementation
{$R *.DFM}
procedure DBQuery(SQLStr: string D2TQuery: TQuery);
begin
D2TQuery.SQL.Clear
D2TQuery.SQL.Add(SQLStr)
D2TQuery.ExecSQL
If D2TQuery.Active <> True Then
D2TQuery.Active := True
end;
procedure DBToTree(var TTmpNode: TTreeNode TInfoTree: TTreeView strNodeInfo: String AddMode: Integer);
var
TmpND: TTreeNode;
begin
If AddMode = 0 Then
TTmpNode:= TInfoTree.Items.Add(Nil,strNodeInfo)
Else
begin
TmpND:= TInfoTree.Items.AddChild(TTmpNode,strNodeInfo);
TmpND.ImageIndex := 1;
end;
end;
procedure TMainForm.Button1Click(Sender: TObject);
begin
If InfoQY.Active <> True Then InfoQY.Active:= True;
end;
procedure TMainForm.Button2Click(Sender: TObject);
var
SQLStr,strFnode: String
I :Integer
begin
SQLStr:= 'Select * From ProgramDB Where Fnode = ''Root''';
DBQuery(SQLStr,InfoQY);
DBToTree(RootNode,InfoTree,InfoQY.Fields[0].Value,0);
RootNode.ImageIndex:= 0;
SQLStr:= 'Select * From ProgramDB Where Fnode = ''' + InfoQY.Fields[1].Value + '''';
DBQuery(SQLStr,InfoQY);
For I:= 0 To InfoQY.RecordCount - 1 Do
DBToTree(RootNode,InfoTree,InfoQY.Fields[1].Value,1)
end;
procedure TMainForm.Button10Click(Sender: TObject);
begin
Close;
end;
end.
我觉得没有什么特别的技术,不知道为什么,希望各位给分析分析,在98/2000都是一样的
结果。