protected void lkbtLogin_Click(object sender SystemEventArgs e)
{
if(txtVerifyNumTextTrim() != Session[SessionAppendNumber]ToString())
{
oprtbAlertMsg(輸入的驗證碼錯誤Page)
return;
}
DataSet ds = new DataSet()
string sql = select UserIDNameDepartIDCompanyID;
sql = sql+(select Name from Depart where ((DepartID=UserListDepartID) and ( CompanyID=UserListCompanyID))) as DepartName;
sql = sql+(select Name from Company where (CompanyID=UserListCompanyID)) as CompanyName ;
sql = sql+from UserList where UserID= + txtUserIDTextTrim() + and Password= + EncryptEncryptPwd(txtPasswordTextTrim()MD) + and Cancellation = ;
//string sql = select * from UserList where UserID= + txtUserIDTextTrim() + and Password= + EncryptEncryptPwd(txtPasswordTextTrim()MD) + and Cancellation = ;
ds = oprtbSelectTable(sql)
if (dsTables[]RowsCount <= )
{
oprtbAlertMsg(輸入的用戶名或密碼錯誤Page)
return;
}
else
{
string UHAddress = RequestUserHostAddress;
string currentTime = DateTimeNowToString(yyyyMMdd hhmmss)
//登陸成功
Session[UserID] = dsTables[]Rows[][UserID]ToString()
Session[Name] = dsTables[]Rows[][Name]ToString()
Session[DepartID] = dsTables[]Rows[][DepartID]ToString()
Session[DepartName] = dsTables[]Rows[][DepartName]ToString()
Session[CompanyID] = dsTables[]Rows[][CompanyID]ToString()
Session[CompanyName] = dsTables[]Rows[][CompanyName]ToString()
//設置用戶的登陸時間
oprtbSetStartTime(txtUserIDTextTrim())
//設置用戶的登陸標記
string s_mark = txtUserIDTextTrim() + _ + UHAddress + _ + currentTime;
oprtbSetLoginMark(s_marktxtUserIDTextTrim())
//保存登陸標記
Session[LoginMark] = s_mark;
MCompanySystemLog slstru = new YesErpMCompanySystemLog()
slstruSystemLog_IP = UHAddress;
slstruSystemLog_LogIn = SystemDateTimeNow;
slstruSystemLog_Name = dsTables[]Rows[][Name]ToString()//用戶姓名
slstruSystemLog_ID = IntParse(dsTables[]Rows[][UserID]ToString())//用戶ID
//寫系統日志
oprtbLoginSystemLog(slstru)
//oprtbAlertMsg(登錄成功Page)
Session[LoginTime] = SystemDateTimeNow;
//判斷並轉到新的頁面
oprtbChangeUrl(/indexaspxPage)
}
}
From:http://tw.wingwit.com/Article/program/net/201311/13460.html