Mvc + three-tier website project: User Logon (1), mvc User Logon

Source: Internet
Author: User

Mvc + three-tier website project: User Logon (1), mvc User Logon

First, database-User table is (Manger)

Second, Layer 3-Model, entity layer Manger (User table)

Namespace YL. Model
{
Public class Manger
{
// System user ID
Public int Id
{
Get;
Set;
}
Public int RoleId
{
Get;
Set;
}
// User Name
Public string UserName
{
Get;
Set;
}
// User Password
Public string UserPassWord
{
Get;
Set;
}
// Role Id
Public int RoleIdng
{
Get;
Set;
}
//
Public int IsEnable
{
Get;
Set;
}
Public DateTime CreateTime
{

Get;
Set;
}
Public string Remark
{
Get;
Set;
}
Public int IsDel
{
Get;
Set;
}
Public int CreateUserId
{

Get;
Set;
}
Public int UpdateUserId
{
Get;
Set;
}
Public int DelUserId
{
Get;
Set;
}
Public int UserInfo
{
Get;
Set;
}
}

}

Third: Dal, data access layer, MangerDAL

Public Model. Manger GetLogin (string UserName)

{

StringBuilder SQL = new StringBuilder (); // instantiate an SQL object
SQL. Append ("select Id, UpdateUserId, DelUserId, UserName, UserPassWord, RoleId, IsEnable, CreateTime, Remark, IsDel, CreateUserId ");
SQL. Append ("from Manager"); // @: a space is required. Otherwise, an SQL statement error occurs.
SQL. append ("Where UserName = @ UserName"); // because it is a logon, the SQL statement is used as a query statement. append = works with several statements like glue, so the @ problem occurs.
SqlParameter [] parameters = {
New SqlParameter ("@ UserName", SqlDbType. NVarChar, 50)
};
Parameters [0]. Value = UserName;
Var data = new MySqlAdoProvide (). executeReader (dr => dr. getEntity <Model. manger> (), MySqlHelper. connectionStringManager, SQL. toString (), parameters ). firstOrDefault ();
// Data. convert an object to an object. convert an SQL statement to a string type. This parameter is used to expand the object type.
Return data; // return data

 

}

Fourth: BLL business logic layer MangerBLL

Public Model. Manger GetLogin (string UserName)

{

Retun dal. GetLogin (Username );

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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.