问题描述
我刚刚使用VB.Net和SQL Server设计了一个3层的项目。我想知道我的项目是否真的设计为3层架构?等待你的评论!提前致谢!
表示层(PL):
这包含3个标签,3个文本框(TXTBX)的表单及其控件),2个命令按钮(搜索和清除)和1个DataGridView(DGV)以及用form.vb文件编写的验证,网格初始化,GridDisplay等代码
业务逻辑层(BLL):
这包含调用DAL的方法
数据访问层(DAL):
这包含连接数据库的方法。
对象文件(OBJFILE):
这包含Get和Set变量的属性
现在当我点击PL中的搜索按钮时,程序流程如下: -
通过名为DGVInit的函数对DGV进行初始化(设置DGV属性),该函数位于表单的.vb文件中。
在基类级别为OBJFILE实例化一个新对象。 br />
TXTBX值ar绑定到OBJFILE的对象。
此对象现在通过PL中名为'DispDGV'的函数传递给BLL的搜索方法'AgentSearch'作为参数。
BLL中的这个'AgentSearch'方法在DAL中调用一个名为'Search'的方法(连同对象作为参数)
DAL中的这个Search方法执行SP并将DataReader返回给BLL的'AgentSearch'方法。
BLL的'AgentSearch'方法又将DataReader返回到窗体.vb文件中的'DispDGV'方法。
此方法将返回的DataReader分配给DataTable,此DataTable将数据发送到DGV。
我为同一目的插入了项目的插图图像。
我还在MSDN中发布了一个带有图像的相同问题,这对于可视化项目可能很有用。
I had just designed a Project in 3-tier using VB.Net and SQL Server. I would like to know whether my project is really designed as a 3-tiered architecture? Awaiting your comments eagerly! Thanks in advance!
Presentation Layer(PL):
This contains the form and its controls that are 3 Labels, 3 TextBoxes(TXTBX), 2 Command Buttons(Search and Clear) and 1 DataGridView(DGV) and codes for validation, Grid Initialization, GridDisplay, etc that are written in form.vb file
Business Logic Layer(BLL):
This contains the methods that calls the DAL
Data Access Layer(DAL):
This contains the methods to connect to database.
Object File(OBJFILE):
This contains the Get and Set properties for the variables
Now when I click the Search Button in the PL, the program flow is as follows:-
The DGV is Initialized(setting DGV properties) through a function called DGVInit which lies within the form's .vb file
A new object is instantiated for the OBJFILE at the Base Class level.
The TXTBX values are bound to the object of the OBJFILE.
This object is now passed to a BLL's Search method, 'AgentSearch' as an argument through a function named 'DispDGV' in PL.
This 'AgentSearch' method in BLL calls a method(along with the object as an argument) named as 'Search' in DAL
This Search method in DAL executes a SP and returns the DataReader back to the BLL's 'AgentSearch' method.
The BLL's 'AgentSearch' method in turn returns the DataReader back to the 'DispDGV' method in form's .vb file.
This method assigns the returned DataReader to a DataTable and this DataTable sources out data to the DGV.
I have inserted an illustrated image of my project for the same purpose.
I have also posted the same question in MSDN with an image, that might be useful to visualize the Project. http://social.msdn.microsoft.com/Forums/getfile/349324
推荐答案
这篇关于我的3层建筑到底有多远?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!