Three-tier architecture, three-tier architecture and mvc difference
The three-layer architecture includes the presentation layer (UI) and business logic layer(BLL (Business Logic Layer ))Data Access Layer (DAL) and Object Library (Model)
1. The object library (Model) Stores Table fields in the database.
Operation:
(1) first, create an object class library Model, open the project, right-click solution> Add> Create Project> select class library> rename Model> OK
(2) Select the Model class library --> Shift + ALT + C --> Create an object class. UserInfo class
namespace Model{ public class UserInfo { public string UserName { get; set; } public string Password { get; set; } }}
2. Data access layer (DAL) is mainly used to store access to data classes, that is, basic operations such as adding, deleting, modifying, and updating databases.
Operation:
(1) first, create the data access layer class library DAL, open the project, right-click the solution, and choose add> new project> select class library> rename DAL> OK.
(2) Add a reference to the Model in the DAL, and select DAL -- Alt + P + R -- Solution -- project -- select MOdel -- and OK.
(3) Add a reference to system. configuration in DAL, and select DAL --> Alt + P + R --> assembly --> framework --> select System. configuration --> OK.
(4) create a data category and select DAL --> Shift + ALT + C --> Create a data category. UserDB class
Namespace DAL {class UserDB {private string connString = ConfigurationManager. connectionStrings [connString]. toString (); public int AddUser (UserInfo userInfo) {// Add a user operation to the database string commandText = insert into UserInfo (userName, Password) values (@ userName, @ Password); SqlParameter [] paras = new SqlParameter [] {new SqlParameter (@ userName, userInfo. userName), new SqlParameter (@ Password, userInfo. password)}; return SqlHelper. executeNonQuery (connString, CommandType. text, commandText, paras );}}
3. the business logic layer (BLL) performs logical judgment and discount on transmitted data and transfers the correct value.
(1) first create the business logic layer class library BLL, open the project, right-click the solution, and choose add> new project> select class library> rename BLL> OK.
(2) Add a reference to Model and DAL to BLL, and select BLL --> Alt + P + R --> solution --> project --> select MOdel and DAL --> OK.
(3) create a business logic class, and select BLL --> Shift + ALT + C --> create a business logic class. LoginManager class
4.The presentation layer (UI) is the user interface layer.
(1) Add a reference to Model and BLL in the UI. Select UI -- Alt + P + R -- Solution -- project -- and select MOdel and BLL --.
(2) write code to pass data to the BLL layer.