chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Data.Common;
|
||||
using Wellan.Common;
|
||||
using Wellan.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for Login
|
||||
/// </summary>
|
||||
public class LoginBPAP
|
||||
{
|
||||
private string _userId = "";
|
||||
private string _password = "";
|
||||
private string _userName = "";
|
||||
private string _errMessage = "";
|
||||
private string _userLang = "";
|
||||
private bool _noPassword = false;
|
||||
|
||||
public LoginBPAP()
|
||||
{
|
||||
}
|
||||
|
||||
public string UserId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _userId;
|
||||
}
|
||||
set
|
||||
{
|
||||
_userId = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return _password;
|
||||
}
|
||||
set
|
||||
{
|
||||
_password = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _userName;
|
||||
}
|
||||
}
|
||||
|
||||
public string ErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return _errMessage;
|
||||
}
|
||||
}
|
||||
|
||||
public bool NoPassword
|
||||
{
|
||||
get
|
||||
{
|
||||
return _noPassword;
|
||||
}
|
||||
}
|
||||
|
||||
public string UserLang
|
||||
{
|
||||
get
|
||||
{
|
||||
return _userLang;
|
||||
}
|
||||
set
|
||||
{
|
||||
_userLang = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得是否登入成功
|
||||
/// </summary>
|
||||
/// <returns>登入成功與否。若回傳 false,錯誤訊息將儲存在 ErrorMessage 屬性中</returns>
|
||||
public bool GetResult()
|
||||
{
|
||||
WConnectionString.ConnectionConfigFile = WConfig.GetConnectionConfig();
|
||||
string ConnName = WConfig.GetConnectionConfigName();
|
||||
string ConnStr = WConnectionString.GetConnectionString(ConnName);
|
||||
string ConnType = WConnectionString.GetConnectionType(ConnName);
|
||||
|
||||
WQuery Query = new WQuery(ConnType);
|
||||
DbConnection conn = Query.NewConnection(ConnStr);
|
||||
DbCommand cmd = Query.NewCommand("SELECT BPENO, BPNME, BPPWD FROM BPAP WHERE BPENO=@BPENO");
|
||||
cmd.Parameters.Add(Query.NewParameter("@BPENO", _userId));
|
||||
DataTable rs = Query.Select(conn, cmd);
|
||||
_noPassword = false;
|
||||
|
||||
if (rs.Rows.Count == 0)
|
||||
{
|
||||
_errMessage = WStringTable.GetInstance().GetString(_userLang, "LOGIN.NOUSERID");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
string pwd1 = rs.Rows[0]["BPPWD"].ToString();
|
||||
string pwd2 = WGuard1.KeyDec(pwd1);
|
||||
|
||||
if (pwd1.CompareTo("\u007f\u007f\u007f\u007f") == 0)
|
||||
{
|
||||
_noPassword = true;
|
||||
pwd2 = "";
|
||||
}
|
||||
|
||||
if (_password.CompareTo(pwd2) != 0)
|
||||
{
|
||||
_errMessage = WStringTable.GetInstance().GetString(_userLang, "LOGIN.WRONGPASSWORD");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (rs.Rows[0]["BPEDY"] != DBNull.Value)
|
||||
{
|
||||
_errMessage = WStringTable.GetInstance().GetString(_userLang, "LOGIN.NORIGHT");
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
_errMessage = "";
|
||||
_userName = rs.Rows[0]["BPNME"].ToString();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user