Hi
masters
i have to store logintime and logout time in database......here is th whole code. kindly suggest where to add code for this.
plz help
<%@ Page Language="VB" EnableViewState="true" AutoEventWireup="true" AspCompat="true" Explicit="false" Strict="false" Inherits="myPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server" >
Protected Sub login1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
on error resume next
Dim rs As ADODB.Recordset = cnn.Execute("select (select is_section from offices where office_code=users.office_code) as iss,(select section_code from offices where office_code=users.office_code) as scode,users.* from users where user_code='" & ComboUser.SelectedItem.Value & "'")
If rs.EOF Then
msgtd.Text = "Invalid User Name."
Else
If rs("user_password").Value <> txPwd.Text Then
msgtd.Text = "Wrong Password. Please Try Again."
Else
msgtd.Text = "<a href=# onclick=""var tm=window.open('splash.aspx','FT','toolbar=no,location=no,menubar=no,status=yes,scrollbar=yes,resizable=yes,left=0,top=0,width='+screen.availWidth+',height='+screen.availHeight);return false;"">Click Here if Software does not open automatically.</a> "
Session("district") = ComboDist.Text
Session("username") = ComboUser.SelectedItem.Text
Session("logged") = True
Session("user") = IIf(IsDBNull(rs.Fields("user_code").Value), "", rs.Fields("user_code").Value)
Session("pwd") = IIf(IsDBNull(rs.Fields("user_password").Value), "", rs.Fields("user_password").Value)
Session("office") = IIf(IsDBNull(rs.Fields("office_code").Value), "", rs.Fields("office_code").Value)
Session("level") = IIf(IsDBNull(rs.Fields("user_level").Value), 0, rs.Fields("user_level").Value)
Session("issection") = IIf(IsDBNull(rs.Fields("iss").Value), "", rs.Fields("iss").Value)
Session("scode") = IIf(IsDBNull(rs.Fields("scode").Value), "", rs.Fields("scode").Value)
Session("dept") = ComboDist.SelectedValue
Response.Write("<script>" & vbCrLf)
Response.Write("var tm=window.open('splash.aspx','FT','toolbar=no,location=no,menubar=no,status=yes,scrollbar=yes,resizable=yes,left=0,top=0,width='+screen.availWidth+',height='+screen.availHeight);" & vbCrLf)
Response.Write("//tm.document.all('tabmain').height=tm.document.body.scrollHeight;</" & "script>" & vbCrLf)
End If
End If
End Sub
Protected Sub ComboDist_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim sSQL As String = "select user_name,user_code from users where office_code in (select OFFICE_CODE from offices where DEPARTMENT_CODE='" & ComboDist.SelectedValue & "') and user_password<>'N' order by user_name"
RStoCombo(sSQL, 0, 1, ComboUser, ComboUser.Text)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
msgtd.Text = ""
If Request("op") = "postback" and comboDist.selectedValue="" Then
comboDist.selectedValue=request("dept")
ComboDist_SelectedIndexChanged(sender,e)
comboUser.text=request("user_code")
End If
If Request("op") = "lg" Then
msgtd.Text = "You have logged out successfully."
End If
If Request("op") = "inv" Then
Session.Abandon()
msgtd.Text = "Invalid login"
End If
If txPwd.Text <> "" Then
login1_Click(sender, e)
End If
End Sub
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
On Error Resume Next
DBInit()
RStoCombo("select department_name,department_code from departments order by department_name", 0, 1, ComboDist, "")
End Sub
Protected Sub ComboUser_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
On Error Resume Next
'response.write("select id from users where user_code='" & ComboUser.SelectedValue & "'")
rst1 = cnn.execute("select id from users where user_code='" & ComboUser.SelectedValue & "'")
'My.Computer.FileSystem.WriteAllBytes(Server.MapPath("~/data/userpic.jpg"), rst1(0).value, False)
Image1.ImageUrl = "~/inc/getfile.aspx?doctype=jpg&id=" & rst1(0).value & "&file=users-user_picture"
End Sub
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
CloseDB()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>File-Tracker::Login</title>
<link rel="Stylesheet" href="inc/htmlstyle.css" />
<script type="text/javascript" language="javascript"src="inc/cookie.js"></script>
<%if request("op")="" then%>
<script type="text/javascript" language="javascript">
document.location.href='login.aspx?op=postback&dept='+Get_Cookie( 'ftdept' )+'&user_code='+Get_Cookie( 'ftuser' );
</script>
<%end if%>
</head>
<body>
<form id="frmScan" runat="server">
<div>
<div align="center">
<table border="0" style="border-collapse: collapse" width="471" id="table1" bordercolor="#339933" background="images/bg8.jpg">
<tr>
<td height="35" background="images/bg6.gif" style="border-style: solid; border-width: 1px">
<p align="center"><b><font color="#FFFFFF" size="2">
</font></b></td>
</tr>
<tr>
<td height="252" style="border-style:solid; border-width:1px; " valign="top">
<div align="center">
<table border="0" style="border-collapse: collapse" width="84%" id="table2" height="268">
<tr>
<td width="40%"> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td width="40%" style="text-align: left; height: 38px;">
Department</td>
<td style="text-align: left; height: 38px;" colspan="2">
<asp:DropDownList ID="ComboDist" runat="server" CssClass="tx" EnableViewState="False" Width="191px" AutoPostBack="True" OnSelectedIndexChanged="ComboDist_SelectedIndexChanged">
</asp:DropDownList></td>
</tr>
<tr>
<td width="40%" style="text-align: left; height: 29px;"> User Name</td>
<td style="height: 29px; text-align: left" colspan="2">
<asp:DropDownList ID="ComboUser" runat="server" Width="193px" CssClass="tx" OnSelectedIndexChanged="ComboUser_SelectedIndexChanged">
</asp:DropDownList></td>
</tr>
<tr>
<td width="40%" style="text-align: left" height="36"> Password</td>
<td style="text-align: left" height="36" colspan="2">
<asp:TextBox ID="txPwd" runat="server" Width="120px" CssClass="tx" TextMode="Password" EnableTheming="True"></asp:TextBox></td>
</tr>
<tr>
<td width="40%" style="text-align: left" height="93" valign="top">
Photo</td>
<td style="border-style:solid; border-width:1px; text-align: left" height="94" valign="top" width="22%" bordercolor="#4AA1D2" bgcolor="#FFFFFF">
<asp:Image runat="server" Width="85px" ID="Image1" Height="90px" ImageUrl="~/images/photo.jpg"></asp:Image>
</td>
<td style="text-align: left; border-left-style:solid; border-left-width:1px" height="93" valign="top" width="36%">
</td>
</tr>
<tr>
<td colspan="3" height="53">
<p align="center">
<asp:Button ID="login1" onclientclick="Set_Cookie( 'ftdept', document.all('comboDist').value, '30', '/', '', '' );Set_Cookie( 'ftuser', document.all('comboUser').value, '30', '/', '', '' );" runat="server" Text="Login" OnClick="login1_Click" />
c</td>
</tr>
</table></div>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" style="height: 17px">
<p align="center" />
<asp:Label ID="msgtd" runat="server" ForeColor="Red"></asp:Label>
</td>
</tr>
</table>
</div>
</div>
<p align="center"> </p>
<asp:Panel ID="Panel1" runat="server" Width="981px">
<font color="#800000" face="MS Shell Dlg" size="3"><strong>
<marquee behaviour="scroll" bgcolor="#FFFFFF" direction="left"
height="24" loop="0" scrollamount="6" scrolldelay="90"
style="height: 22px; top: 386px; left: 10px; ; width: 981px;"> For Smooth Functioning Of The Application Please Remove All Proxy Settings. For Best Performance Please Use Internet Explorer 6</marquee>
</strong>
</font>
</asp:Panel>
<font color="#800000" face="MS Shell Dlg" size="3"><strong>
<asp:Panel ID="Panel2" runat="server"
style="top: 445px; left: 10px; ; height: 19px"
Width="980px">
<marquee align="top" behaviour="scroll" bgcolor="#FFFFFF" direction="left" height="24" loop="0" scrollamount="6" scrolldelay="95"></marquee>
</asp:Panel>
</strong>
</font>
<font color="#800000" face="MS Shell Dlg" size="3"><strong>
<asp:Panel ID="Panel3" runat="server"
style="top: 420px; left: 10px; ; height: 19px; width: 983px;"
Width="983px">
</asp:Panel>
</strong>
</font>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
<font color="#800000" face="MS Shell Dlg" size="3"><strong>
<asp:Panel ID="Panel4" runat="server"
style="top: 492px; left: 10px; ; height: 19px"
Width="980px">
<marquee align="top" behaviour="scroll" bgcolor="#FFFFFF" direction="left" height="24" loop="0" scrollamount="6" scrolldelay="95">A presentation has been added in the application under Presentation Tab which is self describing in nature. Please check the same.</marquee>
</asp:Panel>
</strong>
</font>
</form>
</body>
</html>
thanks and regard love4csharp
No comments:
Post a Comment