using IDal;
using System;
using System.Text;
using System.Reflection;
using MSSQLServerService;
using System.Collections.Generic;
namespace Factory
{
public static class DataAccess
{
public static IUser CreateIUser()
{
return (IUser)(UsersService)Assembly.Load("MSSQLServerService").CreateInstance("MSSQLServerService.UsersService");
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Model;
namespace IDal
{
public interface IUser
{
/// <summary>
/// 登陆查询
/// </summary>
/// <param name="booksInfo"></param>
/// <returns>BooksInfo</returns>
UserInfo GetUsersInfo(UserInfo usersInfo);
}
}
using Model;
using System;
using System.Collections.Generic;
using System.Text;
namespace Model
{
/// <summary>
/// 用户实体类
/// </summary>
[Serializable]
public class UserInfo
{
#region 属性
private int uid;
private string name;
private string password;
private string issue;
private string answer;
private string companyName;
private string contacts;
private string city;
private string email;
private string belong;
private string httpAddress;
private string companyProfile;
private string address;
private string phone;
private string zip;
private string fax;
private string msn;
private string qq;
private IList<ProductsInfo> productsInfo;
private AdminsInfo adminsInfo;
private IList<InfosMessage> info;
private IList<DemandInfo> demand;
#endregion
#region 字段
public int Uid
{
get { return uid; }
set { uid = value; }
}
public IList<InfosMessage> Info
{
get { return info; }
set { info = value; }
}
public IList<DemandInfo> Demand
{
get { return demand; }
set { demand = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public string Password
{
get { return password; }
set { password = value; }
}
public string Issue
{
get { return issue; }
set { issue = value; }
}
public string Answer
{
get { return answer; }
set { answer = value; }
}
public string CompanyName
{
get { return companyName; }
set { companyName = value; }
}
public string Contacts
{
get { return contacts; }
set { contacts = value; }
}
public string City
{
get { return city; }
set { city = value; }
}
public string Email
{
get { return email; }
set { email = value; }
}
public string Belong
{
get { return belong; }
set { belong = value; }
}
public string HttpAddress
{
get { return httpAddress; }
set { httpAddress = value; }
}
public string CompanyProfile
{
get { return companyProfile; }
set { companyProfile = value; }
}
public string Address
{
get { return address; }
set { address = value; }
}
public string Phone
{
get { return phone; }
set { phone = value; }
}
public string Zip
{
get { return zip; }
set { zip = value; }
}
public string Fax
{
get { return fax; }
set { fax = value; }
}
public string Msn
{
get { return msn; }
set { msn = value; }
}
public string Qq
{
get { return qq; }
set { qq = value; }
}
public IList<ProductsInfo> ProductsInfo
{
get { return productsInfo; }
set { productsInfo = value; }
}
public AdminsInfo AdminsInfo
{
get { return adminsInfo; }
set { adminsInfo = value; }
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Model;
using IDal;
using DBUtility;
using System.Data.SqlClient;
using System.Data;
namespace MSSQLServerService
{
public sealed class UsersService:IUser
{
#region SQL语句
private const string SQL_USERS_ALL = "select * from users";
private const string SQL_USERS_ISEXIST = "select * from users where name=@loginId";
private const string SQL_USER_LOGIN = "SELECT * FROM users WHERE name = @loginId AND password = @loginPwd";
private const string SQL_PARMS_ID = "@id";
private const string SQL_PARMS_LOGINID = "@loginId";
private const string SQL_PARMS_LOGINPWD = "@loginPwd";
private const string SQL_PARMS_NAME = "@name";
private const string SQL_PARMS_ADDRESS = "@address";
private const string SQL_PARMS_PHONE = "@phone";
private const string SQL_PARMS_EMAIL = "@email";
private const string SQL_PARMS_USERROLEID = "@UserRoleId"; //UserRoleId身份
#endregion
#region IUser 成员
public UserInfo GetUsersInfo(UserInfo usersInfo)
{
SqlDataReader reader;
try
{
SqlParameter[] parms = new SqlParameter[2];
parms[0] = new SqlParameter(SQL_PARMS_LOGINID, SqlDbType.VarChar);
parms[0].Value = usersInfo.Name;
parms[1] = new SqlParameter(SQL_PARMS_LOGINPWD, SqlDbType.VarChar);
parms[1].Value = usersInfo.Password;
reader = SqlHelper.GetDataReader(SQL_USER_LOGIN, parms);
}
catch
{
throw;
}
UserInfo user = new UserInfo();
if (reader.HasRows)
{
while (reader.Read())
{
user.Uid = Convert.ToInt32(reader["Uid"]);
user.Name = reader["Name"].ToString();
user.Password = reader["Password"].ToString();
user.Issue = reader["Issue"].ToString();
user.Answer = reader["Answer"].ToString();
user.CompanyName = reader["CompanyName"].ToString();
user.Contacts = reader["Contacts"].ToString();
user.City = reader["City"].ToString();
user.Email = reader["Email"].ToString();
user.Belong = reader["Belong"].ToString();
user.HttpAddress = reader["HttpAddress"].ToString();
user.CompanyProfile = reader["CompanyProfile"].ToString();
user.Address = reader["Address"].ToString();
user.Zip = reader["Zip"].ToString();
user.Phone = reader["Phone"].ToString();
user.Fax = reader["Fax"].ToString();
user.Msn = reader["Msn"].ToString();
user.Qq = reader["Qq"].ToString();
}
}
else {
return null;
}
return user;
}
#endregion
#region IUser 成员
/// <summary>
/// ID return UserName
/// </summary>
/// <param name="userInfo"></param>
/// <returns></returns>
public UserInfo OneUserInfo(UserInfo userInfo)
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Model;
using IDal;
using Factory;
namespace BLL
{
public static class UsersManager
{
private static IUser iUsers = DataAccess.CreateIUser();
public static UserInfo UserSubmit(UserInfo userInfo)
{
try
{
return iUsers.GetUsersInfo(userInfo);
}
catch (Exception)
{
throw;
}
}
}
}