Layered, new third board layered

Source: Internet
Author: User

Layered, new third board layered

UI (user layer), BLL (business logic layer), DAL (data access layer ).
The UI is used for display, such as some display styles and interface design.

BLL is used to handle business logic problems.

DAL deals with databases. 

> Data Access Layer: This Layer is at the bottom Layer and is responsible for interacting with databases, also known as DAL (Data Access Layer ).

> Presentation Layer: This Layer directly deals with users and is responsible for displaying or retrieving data, also known as the User Interface Layer ). Whether using the console or Windows Forms to display data, it is an application of the presentation layer.

The presentation layer depends on the data access layer. The two layers of functions are separated to assist in the work and their dependencies.

 The call relationship between them is that the UI calls BLL, and The BLL calls the DAL layer.

 

 

Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using System. Data;
Using System. Data. SqlClient;
Using System. Configuration;
Using MySchoolModel;

Namespace MySchoolDAL
{
Public class Student
{


Public bool IsLogin (string name, string pwd)
{
Bool flag = false;
Try
{
String str = "data source =.; initial Catalog = MySchool; uid = sa; pwd = mnbv ";
SqlConnection conn = new SqlConnection (str );
Conn. Open ();
String SQL = "select count (1) from Admin where Name = '" + name + "' and Pwd = '" + pwd + "'";
SqlCommand cmd = new SqlCommand (SQL, conn );
Int num = Convert. ToInt32 (cmd. ExecuteScalar ());
If (num> 0 ){
Flag = true;
}
}
Catch (Exception ex)
{
Console. WriteLine (ex. Message );
}
Return true;
}

Public bool Add (string name, string pwd)
{
Bool flag = false;
Try
{

String str = "data source =.; initial Catalog = MySchool; uid = sa; pwd = mnbv ";
SqlConnection conn = new SqlConnection (str );
Conn. Open ();
String SQL = "insert into Student values ('" + name + "', '" + pwd + "')";
SqlCommand cmd = new SqlCommand (SQL, conn );
Int num = Convert. ToInt32 (cmd. ExecuteScalar ());
If (num> 0)
{

}
}
Catch (Exception ex)
{
Console. WriteLine (ex. Message );
}
Return true;
}
Public static List <Student> Const ()
{
List <Student> list = new List <Student> ();

DataSet da = new DataSet ();
String SQL = "select * from Student ";
SqlConnection conn = new SqlConnection (SqlHelper. ConStr );

Try
{
Conn. Open ();

SqlCommand cmd = new SqlCommand (SQL, conn );
SqlDataReader dr = cmd. ExecuteReader ();
While (dr. Read ())
{
Student st = new Student ();

St. name = dr ["name"]. ToString ();
St. pwd = dr ["pwd"]. ToString ();


List. Add (st );
}
Dr. Close ();
Return list;
}
Catch (Exception ex)
{
Throw ex;
}
Finally
{
Conn. Close ();
}

}

 

 

 

Public string name {get; set ;}

Public string pwd {get; set ;}
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.