⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login.ascx

📁 ASP_NET程序设计教程 源代码 冶金工业出版社 肖金秀 冯沃辉 陈少涌
💻 ASCX
字号:
<% @ Import Namespace="Packaging" %>
<% @ Import Namespace="System.Data" %>
<% @ Import Namespace="System.Globalization" %>
<% @ Import Namespace="System.Web.Security " %>

<script language="VB" runat="server">

	Sub Page_Load(Sender As Object, e As EventArgs)
		checkdied
		If Not Request.IsAuthenticated Then
			login.Visible=true
			status.Visible=false
			classmate.Visible=False
		Else
			Dim MyUserDB As UserDB=New UserDB()
			MyUserDB.UserVisit(Context.User.Identity.Name)
			Dim MyDV As DataView
			MyDV=MyUserDB.GetUserInfo(Context.User.Identity.Name)
			Dim MyDR As DataRow=MyDV.Table.Rows(0)
			login.Visible=false
			status.Visible=true

			Uaccount.text=MyDR("UserAccount")
			Dim dt As DateTime=DateTime.Now()
			UlastAccess.text=dt.ToString("MMM.d, H:mm:ss",DateTimeFormatInfo.InvariantInfo)

			Dim MyInfo As InfoDB=New InfoDB()
			If MyInfo.GetMyId(Context.User.Identity.Name)<>0 Then
				Dim str As String
				If MyInfo.GetMyType(Context.User.Identity.Name)=2 Then
					str="t_personal.aspx?id="
					str &= MyInfo.GetMyId(Context.User.Identity.Name)
					link1.NavigateUrl=str
					classmate.Visible=True
				ElseIf MyInfo.GetMyType(Context.User.Identity.Name)<>0 Then
					str="s_personal.aspx?id="
					str &= MyInfo.GetMyId(Context.User.Identity.Name)
					link1.NavigateUrl=str
					classmate.Visible=True
				End If
			Else
				classmate.Visible=false
			End If
		End If
	End Sub

	Sub subm_Click(Sender As Object, e As ImageClickEventArgs)
		checkdied
		Dim MyUserDB As UserDB=New UserDB()
		Dim UserId As Integer=MyUserDB.Login(account.text, pass.text)
		If UserID=0 Then
			mes.Visible=true
			mes.Text="账号/密码错误!"
		Else
			mes.Visible=false
			login.Visible=false
			status.Visible=true

			Dim MyDV As DataView=MyUserDB.GetUserInfo1(UserID)
			Dim MyDR As DataRow=MyDV.Table.Rows(0)

			FormsAuthentication.SetAuthCookie(account.text, true)

			Uaccount.text=MyDR("UserAccount")
			Dim dt As DateTime=DateTime.Now()
			UlastAccess.text=dt.ToString("MMM.d, H:mm:ss",DateTimeFormatInfo.InvariantInfo)

			Dim MyInfo As InfoDB=New InfoDB()
			If MyInfo.GetMyId(account.text)<>0 Then
				Dim str As String
				If MyInfo.GetMyType(account.text)=2 Then
					str="t_personal.aspx?id="
					str &= MyInfo.GetMyId(account.text)
					link1.NavigateUrl=str
					classmate.Visible=True
				ElseIf MyInfo.GetMyType(account.text)<>0 Then
					str="s_personal.aspx?id="
					str &= MyInfo.GetMyId(account.text)
					link1.NavigateUrl=str
					classmate.Visible=True
				End If
			Else
				classmate.Visible=False
			End If
		End If
	End Sub

	Sub Checkdied
		Dim MyUser As UserDB=New UserDB()
		Dim MyDV As DataView=MyUser.GetOnlineUsers()

		Dim DR As DataRow
		For Each DR In MyDV.Table.Rows()
			If DateDiff(DateInterval.Minute, DR("UserLastAccess"), DateTime.now())>30 Then
				MyUser.UserSignOff(DR("UserID"))
			End If
		Next
	End Sub

</script>
<% @ Control %>
	<asp:Panel id="login" align="center" runat="server">
	<table border="0" cellpadding="0" cellspacing="0" width="90%" height="130">
		<tr><td width="100%" align="center">
		<table border="0" cellpadding="0" cellspacing="0" width="90%" height="104">
			<tr><td width="100%" background="images/bar.gif" height="18" class="bar">&nbsp;登陆</td></tr>
			<tr><td width="100%" bgcolor="#E7F4DD" height="86" align="center">
			<table border="0" cellpadding="0" cellspacing="0" width="90%">
				<tr><td width="28%" height="22">账号:</td>
				<td width="72%" height="22"><asp:TextBox id="account" size="12" runat="server" /></td></tr>
				<tr><td width="28%" height="18">密码:</td>
				<td width="72%" height="18"><asp:TextBox id="pass" textMode="password" size="12" runat="server" /></td></tr>
				<tr><td colspan="2" width="100%" align="center" valign="top">
<asp:Label id="mes" runat="server" style="color=red" /><br>
<asp:ImageButton id="subm" runat="server" ImageUrl="images/login.gif" onClick="subm_Click" />&nbsp;
<a href="register.aspx">注册</a></td></tr>
			</table></td></tr>
		</table></td></tr>
	</table>
	</asp:Panel>

	<asp:Panel id="status" align="center" runat="server">
	<table border="0" cellpadding="0" cellspacing="0" width="90%" height="150">
		<tr><td width="100%" align="center">
		<table border="0" cellpadding="0" cellspacing="0" width="90%" height="104">
			<tr><td width="100%" background="images/bar.gif" height="18" class="bar">&nbsp;个人工具箱</td></tr>
			<tr><td width="100%" bgcolor="#E7F4DD" height="86" align="center">
			<table border="0" cellpadding="0" cellspacing="0" width="90%">
				<tr><td width="33%" height="22">账号:</td>
				<td width="67%" height="22"><asp:Label id="Uaccount" runat="server" /></td></tr>
				<tr><td colspan="2" align="left">
				<ul><li><a href="bbs.aspx" class=author>ASP.NET论坛</a></li>
				<li><a href="personal.aspx" class=author>个人资料修改</a></li>
				<li><a href="signoff.aspx">注销</a></li></td></tr>
				<tr><td colspan="2" align="center"><asp:Label id="UlastAccess" runat="server" /></td></tr>
			</table></td></tr>
		</table></td></tr>
	</table>
	</asp:Panel>

	<asp:Panel id="classmate" align="center" runat="server" Visible="true">
	<table border="0" cellpadding="0" cellspacing="0" width="90%" height="150">
		<tr><td width="100%" align="center">
		<table border="0" cellpadding="0" cellspacing="0" width="90%" height="104">
			<tr><td width="100%" background="images/bar.gif" height="18" class="bar">&nbsp;ASP.NET专用工具</td></tr>
			<tr><td width="100%" bgcolor="#E7F4DD" height="86" align="center">
			<table border="0" cellpadding="0" cellspacing="0" width="90%">
				<tr><td>
				<ul><li><asp:HyperLink id="link1" runat="server" text="你的资料修改" CssClass=author /></li>
				<li><a href="picadd.aspx" class=author>上传你的作品</a></li>
				<li><a href="newsshow.aspx?id=10" class=author>使用帮助</a></li></td></tr>
			</table></td></tr>
		</table></td></tr>
	</table>
	</asp:Panel>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -