In this article, i am explaining about the creating the Windows application using 3-Tier architecture. I will explain about each layer of the 3-tier architecture. the use of Business logic layer, data Access layer and how we can create those layers to make our application as layered architecture.
You will see each of the steps performed are having screenshot so that it will be easy to understand and will give the real time flavor of the applications. I have specially taken care of the Coding standers so we all can follow the same when working in the real environment.
it will easy to understand as the coding also i kept as screen shots and each keywords will be easily recognized.
I will begin with the step where you have installed the Visual Studio so i am not explaining about the installation of Visual Studio and all. I will pre-assume that you have started the Visual studio already and then opened the first home window.
Creating windows app using 3 tier architecture
1. Create a new windows application.Enter the name and press OK.
2. Right click on the solution of the Windows Application and add the new project
3. Choose Class Library Project and enter the name as BLL(Business Logic Layer)
4. Enter the name (Business Logic Layer) and press OK
5. Same way add one more Class Library project and provide the name DataAccessLayer and press OK.
6. Your solution should have 3 different projects by this time.
7. Build the whole application.
8. Go to your main project and right click to add the reference of the BusinessLogicLayer.dll
9. Add the namespace of the BusinessLogicLayer to your form
10. Click on the button and go to its event handler. Here you need to create the object of the BusinessLogicLayer class and then access its method.
11. So first create a class in BusiessLogicLayer. Right click on BusinessLogicLayer and add a class. Provide the name
12. Now your solution should look like below:
13. Write the method in this new Class called as EmpBLL as below. To get all employee, write a method. Here we need to add the reference of DataAccesslayer class object. So first we need to create a class in DAtaAccessLayer similar to this
14. Go to the DataAccessLayer project and add a class with the name EmployeeDLL.csand write a method to get all the employees.
15. Build the project and Comeback to the BLL. Add the DataAcesslayer.dll in to this project as reference
16. Now add the namespace for the DataAccessLayer in to this project(BLL)
17. Now create the object of the DataAccesslayer class and return the result as
18. After adding all the references, your solution should look like below:
19. Now design your form as:
20. Write the eventhandler for the button to get the employee details by calling the BusienssLogic layer method as
21. Run the application and click on the Button, to get the employee details from the table in the database.
Hope it will be helpful to you.