You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/SysMng/DAL/USERINFO/USERINFODAL.cs

141 lines
4.4 KiB
C#

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.Areas.SysMng.Models.USERINFO;
using HcUtility.Comm;
using Microsoft.Practices.EnterpriseLibrary.Data;
namespace DSWeb.Areas.SysMng.DAL.USERINFO
{
public partial class USERINFODAL
{
#region 主表
static public List<USERmb> GetDataList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("U.GID,U.SHOWNAME,U.PASSWORD,U.USERNAME,U.DJY_CODENAME,U.DJY_PASSWORD");
strSql.Append(" from [USER] U ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetData(strSql);
}
private static List<USERmb> SetData(StringBuilder strSql)
{
var headList = new List<USERmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
USERmb data = new USERmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.SHOWNAME = Convert.ToString(reader["SHOWNAME"]);
data.PASSWORD = Convert.ToString(reader["PASSWORD"]);
data.USERNAME = Convert.ToString(reader["USERNAME"]);
data.DJY_CODENAME = Convert.ToString(reader["DJY_CODENAME"]);
data.DJY_PASSWORD = Convert.ToString(reader["DJY_PASSWORD"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
static public USERmb GetData(string condition)
{
var list = GetDataList(condition);
if (list.Count > 0)
return list[0];
return new USERmb();
}
#endregion
#region 明细表
static public List<USERINFOmb> GetUSERINFOList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("UI.GID,UI.USERID,UI.OFFICEPHONE,UI.HOMEPHONE,UI.MOBILE,UI.FAX,UI.EMAIL1,UI.EMAIL2,UI.HOMEADDRESS,UI.QQ");
strSql.Append(" from [USER_BASEINFO] UI ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetUSERINFOData(strSql);
}
private static List<USERINFOmb> SetUSERINFOData(StringBuilder strSql)
{
var headList = new List<USERINFOmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
USERINFOmb data = new USERINFOmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.USERID = Convert.ToString(reader["USERID"]);
data.OFFICEPHONE = Convert.ToString(reader["OFFICEPHONE"]);
data.HOMEPHONE = Convert.ToString(reader["HOMEPHONE"]);
data.MOBILE = Convert.ToString(reader["MOBILE"]);
data.FAX = Convert.ToString(reader["FAX"]);
data.EMAIL1 = Convert.ToString(reader["EMAIL1"]);
data.EMAIL2 = Convert.ToString(reader["EMAIL2"]);
data.HOMEADDRESS = Convert.ToString(reader["HOMEADDRESS"]);
data.QQ = Convert.ToString(reader["QQ"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
public static USERINFOmb GetUserInfo(string USERID)
{
var condition = " GID='" + USERID + "'";
var headInfoData = GetUSERINFOList(condition)[0];
return headInfoData;
}
public static USERmb GetUser(string USERID)
{
var condition = " GID='" + USERID + "'";
var headData = GetData(condition);
return headData;
}
}
}