📄 simple3.~pas
字号:
unit Simple3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, ExtCtrls, DBCtrls, Grids, DBGrids;
type
TfrmSimple3 = class(TForm)
dbgDepartment: TDBGrid;
dbgEmployee: TDBGrid;
adoConnection: TADOConnection;
atbDepartment: TADOTable;
atbEmployee: TADOTable;
dsDepartment: TDataSource;
dsEmployee: TDataSource;
atbDepartmentDEPARTMENTNO: TWideStringField;
atbDepartmentDEPARTMENTNAME: TWideStringField;
atbDepartmentUPPERDEPARTMENTNO: TWideStringField;
atbDepartmentMANAGER: TWideStringField;
atbDepartmentADDRESS: TWideStringField;
atbDepartmentTELEPHONE: TWideStringField;
atbEmployeeEMPLOYEENO: TWideStringField;
atbEmployeeEMPLOYEENAME: TWideStringField;
atbEmployeeDEPARTMENTNO: TWideStringField;
atbEmployeeSEX: TWideStringField;
atbEmployeeEMPLOYEEDATE: TDateTimeField;
atbEmployeeWORKDATE: TDateTimeField;
atbEmployeeNATIONNO: TWideStringField;
atbEmployeePOSTNO: TWideStringField;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmSimple3: TfrmSimple3;
implementation
{$R *.dfm}
procedure TfrmSimple3.FormShow(Sender: TObject);
begin
//当表单显示时,建立数据库的连接
if adoConnection.Connected then adoConnection.Close ;
try
adoConnection.Open ;
except
application.MessageBox('连接数据库出错','错误');
application.Terminate ; //应用程序终止
end;
//打开部门表
try
atbDepartment.Open ;
except
application.MessageBox('打开部门表出错','错误');
application.Terminate ; //应用程序终止
end;
//打开员工表
try
atbEmployee.Open ;
except
application.MessageBox('打开员工表出错','错误');
application.Terminate ; //应用程序终止
end;
end;
procedure TfrmSimple3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if atbEmployee.Active then atbEmployee.Close;
if atbDepartment.Active then atbDepartment.Close;
if adoConnection.Connected then adoConnection.Close ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -