麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > Delphi > 正文

Delphi中實現界面與業務邏輯的分離

2019-11-18 18:17:57
字體:
來源:轉載
供稿:網友

Delphi中實現界面與業務邏輯的分離

                                                       J雪(zhuam)[email protected]

在做Delphi軟件開發之前,我從事java軟件的開發工作,從Java開源社區我學到了很多軟件的設計理想,這也許就是我從Java那里得到的回報啊! 開闊了眼界!

最近的項目是用Delphi開發,所以我又看起了Delphi,一個月的時間里我看了差不多看了4本Delphi方面書籍,在做Delphi項目的時候我更是用DELPHI的語法,JAVA的思想來進行軟件的開發與設計,感覺有些累!啊,閑話少說啊,進入正題吧!

DELPHI是一個快速軟件開發的IDE,通常的PRogrammer 都是先畫View(界面) ,然后在在相應的事件里面書寫Source Code,看事例:

1、比如我要向數據庫中插入一條記錄,通常的做法是這樣吧!

SQL Example:  Insert   Into   ExampleTable1 (Field1,Field2,Field3) Values(Values1,Values2,Values3)

現在假設這個DELPHI窗體上有三個TEXT控件,Name分別為 Frist,Second,Three

下面我用三種不同方法將數據插入到數據庫中:

1、直接插入
client  ---------->  Database

Insert   Into   ExampleTable1 (Field1,Field2,Field3) Values(Frist.text,Second.text,Three.text)

2、間接插入
 client  ---(Text傳遞)--->  dataClass ------->  Database

意思是先將該窗體數據保存到一個數據類中去,然后在由用戶從這個數據類中取數據,將這些數據
傳到數據庫中去

注意:
窗體控件是直接通過TEXT將數據存儲到(dataClass)數據類中去的。
這個dataClass只是用于存儲數據狀態的,里面全是屬性,沒有業務邏輯的實現!

如下:
{---------------------------------------------
  author:zhuam
  date:2004/09/04
  type:class
  property:all AssociatorRunBean Information Set Mothed
  descripte: 用于保存會員的行駛證信息 ,
-----------------------------------------------}
type
  TAssociatorRunBean=class(TObject)
  private
    FKiloMetre: Double;
    FCarNumber: string;
    FNumber17: string;
    FCarColor: string;
    FAssociatorID: string;
    FCarCapacity: string;
    FFrameNumber: string;
    FEngineNumber: string;
    FAvailabilityDate: TDate;
    FRegisterDate: TDate;
    FBackPicture:TImage;
    FFrontPicture: TImage;
    FLeftPicture: TImage;
    FRightPicture: TImage;
    function getBackPicture: TImage;
    function getFrontPicture: TImage;
    function getLeftPicture: TImage;
    function getRightPicture: TImage;
    procedure setAssociatorID(const Value: string);
    procedure setAvailabilityDate(const Value: TDate);
    procedure setBackPicture(const Value: TImage);
    procedure setCarCapacity(const Value: string);
    procedure setCarColor(const Value: string);
    procedure setCarNumber(const Value: string);
    procedure setEngineNumber(const Value: string);
    procedure setFrameNumber(const Value: string);
    procedure setFrontPicture(const Value: TImage);
    procedure setKiloMetre(const Value: Double);
    procedure setLeftPicture(const Value: TImage);
    procedure setNumber17(const Value: string);
    procedure setRegisterDate(const Value: TDate);
    procedure setRightPicture(const Value: TImage);
  public
    constructor create;
    destructor destroy;override;
    property  AssociatorID:string read FAssociatorID write setAssociatorID;    //會員號碼
    property  CarNumber:string read FCarNumber write setCarNumber;             //車牌號碼
    property  CarColor:string read FCarColor write setCarColor;                //汽車顏色
    property  CarMode:string read FCarColor write setCarColor;                 //車型
    property  EngineNumber:string read FEngineNumber write setEngineNumber;    //發動機號碼
    property  FrameNumber:string read FFrameNumber write setFrameNumber;       //車架號
    property  CarCapacity:string read FCarCapacity write setCarCapacity;       //排量
    property  Number17:string read FNumber17 write setNumber17;                //17位號
    property  KiloMetre:Double read FKiloMetre write setKiloMetre;             //公里數
    property  RegisterDate:TDate read FRegisterDate write setRegisterDate;     //注冊日期
    property  AvailabilityDate:TDate read FAvailabilityDate write setAvailabilityDate; //有效日期
    property  FrontPicture:TImage read getFrontPicture write setFrontPicture;
    property  BackPicture:TImage read getBackPicture write setBackPicture;
    property  LeftPicture:TImage read getLeftPicture write setLeftPicture;
    property  RightPicture:TImage read getRightPicture write setRightPicture;

end;

Insert   Into   ExampleTable1 (Field1,Field2,Field3) Values(AssociatorRunBean.Frist,AssociatorRunBean.Second,AssociatorRunBean.text)

3、間接插入
 client  ---(自定義property傳遞)--->  dataClass ------->  Database

意思是先將該窗體數據保存到一個數據類中去,然后在由用戶從這個數據類中取數據,將這些數據
傳到數據庫中去

注意:
窗體控件是直接通過的自定義property將數據存儲到(dataClass)數據類中去的。
這個dataClass只是用于存儲數據狀態的,里面全是屬性,沒有業務邏輯的實現!

Insert   Into   ExampleTable1 (Field1,Field2,Field3) Values(AssociatorRunBean.Frist,AssociatorRunBean.Second,AssociatorRunBean.text)

說到這里有人會問我,這樣實現有什么意義哩!細心的同志也許已經有所察覺啊!
這正是完成Delphi界面與業務邏輯的分離的一種手段啊

 

 

 

 

 

 

 


上一篇:用Delphi對SQL-DMO進行封裝的一種實現

下一篇:Delphi的編碼規范

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 久久久久久久久久亚洲 | 深夜免费观看视频 | 成年人在线视频观看 | 污片视频在线观看 | 91国内精品久久久久免费影院 | 免费专区 - 91爱爱 | 欧美 日韩 中文 | 免费国产网站 | 毛片免费一区二区三区 | 国产男女爽爽爽爽爽免费视频 | 精品一区二区三区免费 | 强伦女教师视频 | 国产精品成人久久 | 欧美a级在线免费观看 | 美女黄色影院 | 国产在线中文 | 国产午夜精品一区二区三区免费 | av免费提供 | 免费h片网站 | 亚洲精华液久久含羞草 | 国产成人精品网站 | 91免费视频版 | 久久这| 在线成人影视 | 精品一区二区三区网站 | 精品三级内地国产在线观看 | 极品美女一级毛片 | 91九色国产视频 | 国产1区在线 | 久久亚洲精品国产一区 | 精品国产一区二区三区天美传媒 | 久久人体| 全免费午夜一级毛片真人 | 欧美视频一级 | 中文字幕线观看 | 免费一级欧美大片视频 | 欧美人人干 | 天天夜夜草 | 国产一级毛片国产 | 国产人成免费爽爽爽视频 | 日韩精品久久久久久久九岛 |