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 );
}