private void ValidUser()
{
string sName = ConfigurationManager.AppSettings["UserName"].ToString();
string sPwd = ConfigurationManager.AppSettings["Pwd"].ToString();
if (!string.IsNullOrEmpty(sName))
{
string pwd = DESEncrypt.Encrypt(sPwd);
using (var ctx = new HSQDataDataContext())
{
string sqlStr = string.Format("select count(*) from OT_User where Name='{0}' and Password='{1}' and Enabled=1",sName,pwd);
int count = ctx.ExecuteCommand(sqlStr);
if (count > 0)
{
var list = (from p in ctx.OT_User
where p.Name == sName
select p).SingleOrDefault();
int userId = list.Id;
LoginSuccessInfo loginSuccessInfo = new LoginSuccessInfo();
loginSuccessInfo.UserName = list.Name;
loginSuccessInfo.UserID = userId;
var listrole = from p in ctx.OT_RoleUser
where p.UserId == userId
select p;
foreach (var l in listrole)
{
loginSuccessInfo.ListRoleID.Add((int)l.RoleId);
}
var listdep = from p in ctx.OT_DeptUser
where p.UserId == userId
select p;
foreach (var l in listdep)
{
loginSuccessInfo.ListDeptid.Add((int)l.DeptId);
}
}
}
// Business.Helper.LogHelper.Add("登录:" + dt.Rows[0]["RealName"].ToString());
// Response.Redirect("main.aspx");
}
}