H HNXXCXG Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-21 #1 delphi老人,非诚无扰 手机:13667414960 QQ:254072148
H HNXXCXG Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-26 #5 { 面试作品之"工厂模式的简化"。姓名:陈新光 手机:13667414960 QQ:254072148 EMAIL:hnxxcxg@yahoo.com.cn } {*******************************************************} { } { 数据工厂 } { } { 版权所有 (C) 2008 陈新光 } { } {*******************************************************} unit DataFactory; interface uses SysUtils,ADODB,DB,Classes,uCommFunc; function GetADODataSet(Owner:TComponent;ASQL:string):TDataSet; function GetBDEDataSet(Owner:TComponent;ASQL:string):TDataSet; implementation { 使用Owner:TComponent参数自动控制对象的生命周期 } function GetADODataSet(Owner:TComponent;ASQL:string):TDataSet; var Conn:TADOConnection; DataSet:TADOQuery; sFileName,sSection:string; begin sFileName:=GetINIFile; sSection:='conn db'; Conn:=TADOConnection.Create(Owner); with Conndo begin LoginPrompt:=False; Provider:='SQLOLEDB'; Properties['Data Source'].Value:=ReadIniFile(sFileName,sSection,'server',''); Properties['User ID'].Value:=ReadIniFile(sFileName,sSection,'userid',''); Properties['Password'].Value:=ReadIniFile(sFileName,sSection,'password',''); Properties['Initial Catalog'].Value:=ReadIniFile(sFileName,sSection,'database',''); try open; except raise.Exception('数据库连接失败'); end; end; dataset:=tadoquery.Create(owner); dataset.Connection:=conn; with datasetdo begin Close; SQL.Clear; SQL.Text:=ASQL; Open; end; Result:=DataSet; end; function GetBDEDataSet(Owner:TComponent;ASQL:string):TDataSet; begin //do something; end; end. {*******************************************************} { } { 主程序 } { } { 版权所有 (C) 2008 陈新光 } { } {*******************************************************} uses DataFactory; ... type TFormHycx = class(TFormMdi) private FADODataSet:TDataSet; ... procedure TFormHycx.GetDataSet; var sqlText: string; begin IsSelAll(edt1.Text); sqlText:=ReadIniFile(GetINIFile,'sql command','hycx',''); sqlText:=Format(sqlText,[QuotedStr('%'+edt1.Text+'%'),QuotedStr('%'+edt1.Text+'%')]); FADODataSet:=GetADODataSet(Self,sqlText); DataSource.DataSet:=FADODataSet; end;
{ 面试作品之"工厂模式的简化"。姓名:陈新光 手机:13667414960 QQ:254072148 EMAIL:hnxxcxg@yahoo.com.cn } {*******************************************************} { } { 数据工厂 } { } { 版权所有 (C) 2008 陈新光 } { } {*******************************************************} unit DataFactory; interface uses SysUtils,ADODB,DB,Classes,uCommFunc; function GetADODataSet(Owner:TComponent;ASQL:string):TDataSet; function GetBDEDataSet(Owner:TComponent;ASQL:string):TDataSet; implementation { 使用Owner:TComponent参数自动控制对象的生命周期 } function GetADODataSet(Owner:TComponent;ASQL:string):TDataSet; var Conn:TADOConnection; DataSet:TADOQuery; sFileName,sSection:string; begin sFileName:=GetINIFile; sSection:='conn db'; Conn:=TADOConnection.Create(Owner); with Conndo begin LoginPrompt:=False; Provider:='SQLOLEDB'; Properties['Data Source'].Value:=ReadIniFile(sFileName,sSection,'server',''); Properties['User ID'].Value:=ReadIniFile(sFileName,sSection,'userid',''); Properties['Password'].Value:=ReadIniFile(sFileName,sSection,'password',''); Properties['Initial Catalog'].Value:=ReadIniFile(sFileName,sSection,'database',''); try open; except raise.Exception('数据库连接失败'); end; end; dataset:=tadoquery.Create(owner); dataset.Connection:=conn; with datasetdo begin Close; SQL.Clear; SQL.Text:=ASQL; Open; end; Result:=DataSet; end; function GetBDEDataSet(Owner:TComponent;ASQL:string):TDataSet; begin //do something; end; end. {*******************************************************} { } { 主程序 } { } { 版权所有 (C) 2008 陈新光 } { } {*******************************************************} uses DataFactory; ... type TFormHycx = class(TFormMdi) private FADODataSet:TDataSet; ... procedure TFormHycx.GetDataSet; var sqlText: string; begin IsSelAll(edt1.Text); sqlText:=ReadIniFile(GetINIFile,'sql command','hycx',''); sqlText:=Format(sqlText,[QuotedStr('%'+edt1.Text+'%'),QuotedStr('%'+edt1.Text+'%')]); FADODataSet:=GetADODataSet(Self,sqlText); DataSource.DataSet:=FADODataSet; end;
H HNXXCXG Unregistered / Unconfirmed GUEST, unregistred user! 2008-02-26 #6 { 面试作品之"门面模式的简化"。姓名:陈新光 手机:13667414960 QQ:254072148 EMAIL:hnxxcxg@yahoo.com.cn } {*******************************************************} { } { 业务逻辑一 } { } { 版权所有 (C) 2008 陈新光 } { } {*******************************************************} unit Hello1; interface uses Dialogs; procedure SayHello; implementation procedure SayHello; begin ShowMessage('hello one'); end; end. {*******************************************************} { } { 业务逻辑二 } { } { 版权所有 (C) 2008 咏南工作室 } { } {*******************************************************} unit Hello2; interface uses Dialogs; procedure SayHello2; implementation procedure SayHello2; begin ShowMessage('hello two'); end; end. {*******************************************************} { } { 接口 } { } { 版权所有 (C) 2008 咏南工作室 } { } {*******************************************************} unit InterFace1; interface uses Hello1,Hello2; procedure Say1; procedure Say2; implementation procedure Say1; begin SayHello; end; procedure Say2; begin SayHello2; end; end. {*******************************************************} { } { 主程序 } { } { 版权所有 (C) 2008 咏南工作室 } { } {*******************************************************} unit Main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls, InterFace1;//接口 type TForm1 = class(TForm) btn1: TButton; btn2: TButton; procedure btn1Click(Sender: TObject); procedure btn2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.btn1Click(Sender: TObject); begin Say1; end; procedure TForm1.btn2Click(Sender: TObject); begin Say2; end; end.
{ 面试作品之"门面模式的简化"。姓名:陈新光 手机:13667414960 QQ:254072148 EMAIL:hnxxcxg@yahoo.com.cn } {*******************************************************} { } { 业务逻辑一 } { } { 版权所有 (C) 2008 陈新光 } { } {*******************************************************} unit Hello1; interface uses Dialogs; procedure SayHello; implementation procedure SayHello; begin ShowMessage('hello one'); end; end. {*******************************************************} { } { 业务逻辑二 } { } { 版权所有 (C) 2008 咏南工作室 } { } {*******************************************************} unit Hello2; interface uses Dialogs; procedure SayHello2; implementation procedure SayHello2; begin ShowMessage('hello two'); end; end. {*******************************************************} { } { 接口 } { } { 版权所有 (C) 2008 咏南工作室 } { } {*******************************************************} unit InterFace1; interface uses Hello1,Hello2; procedure Say1; procedure Say2; implementation procedure Say1; begin SayHello; end; procedure Say2; begin SayHello2; end; end. {*******************************************************} { } { 主程序 } { } { 版权所有 (C) 2008 咏南工作室 } { } {*******************************************************} unit Main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls, InterFace1;//接口 type TForm1 = class(TForm) btn1: TButton; btn2: TButton; procedure btn1Click(Sender: TObject); procedure btn2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.btn1Click(Sender: TObject); begin Say1; end; procedure TForm1.btn2Click(Sender: TObject); begin Say2; end; end.
S Shuzi Unregistered / Unconfirmed GUEST, unregistred user! 2008-03-05 #10 如果愿意到西安,请看看: http://www.jobxa.com/enterprise/listalljob.asp?selectedid=5399