日期:2014-05-17 浏览次数:20455 次
<connectionStrings>
<add name="ConnectionString" providerName="System.Data.SqlClient" connectionString="server=localhost\SQLEXPRESS;database=数据库名;uid=sa;pwd=12345"/>
</connectionStrings>
protected void btn_OK_Click(object sender, EventArgs e)
{
AppUser user = AppSettingSRV.VerifyPassword(loginName, password);
if (user == null)
{
AppUser loginUser = AppSettingSRV.GetAppUserByLoginName(loginName);
this.LoginFail.InnerText = (loginUser == null ? "用戶不存在." : "密码错误.");
}
else
{
this.LoginFail.InnerText = "登录成功";
}
}
public static AppUser GetAppUserByLoginName(string loginName)
{
AppUserORM user = AppUserController.GetAppUserByLoginName(loginName);
if (user == null)
{
return null;
}
return user.ConvertAppUserORMToEDM();
}
public static AppUserORM GetAppUserByLoginName(string loginName)
{
string sql = "SELECT * FROM AppUser WHERE LoginName = @LoginName";
SqlCommand command = new SqlCommand(sql);
command.Parameters.Add("@LoginName", SqlDbType.NVarChar).Value = loginName;
DataTable table = DBProvider.DefaultDBOperator.GetDataTable(command);
if (table.Rows.Count == 0)
{
return null;
}
return table.Rows[0].ConvertToDBModel<AppUserORM>();
}