Jump to content

here please:(

- - - - -

  • Please log in to reply
3 replies to this topic

#1
kiko2max

kiko2max

    Newbie

  • Members
  • PipPip
  • 19 posts
im using asp.net + vb,


help me please....


this is my codes for the design:




<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Login2.aspx.vb" Inherits="Login2" title="Log-in" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

<style type="text/css">

.style17

{

width: 97%;

font-family: "Century Gothic";

background-color: #FFFFCC;

height: 209px;

}

.style29

{

height: 24px;

font-size: xx-large;

color: #CCCCCC;

text-align: left;

}

.style30

{

font-size: small;

}

.style33

{

height: 12px;

}

.style35

{

text-align: right;

width: 435px;

font-size: medium;

color: #160c9d;

}

.style37

{

text-align: right;

width: 435px;

height: 30px;

font-size: medium;

color: #160c9d;

}

.style38

{

height: 30px;

font-size: small;

}

.style39

{

color: #FFFFCC;

}

.style40

{

height: 9px;

text-align: left;

}

</style>

</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

 <table class="style17">

<tr>

<td class="style29" colspan="2" style="background-color: #160c9d">

		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;	    

<span class="style39">Login</span></td>

</tr>

<tr>

<td class="style30" colspan="2">

 </td>

</tr>

<tr>

<td class="style37">

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 

ControlToValidate="txtUserName" ErrorMessage="*"></asp:RequiredFieldValidator>

UserID</td>

<td class="style38">

 

<asp:TextBox ID="txtUserName" runat="server" style="margin-left: 0px" 

Width="179px" MaxLength="10" BorderColor="#99CCFF"></asp:TextBox>

</td>

</tr>

<tr>

<td class="style35">

<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 

ControlToValidate="txtPassword" ErrorMessage="*"></asp:RequiredFieldValidator>

Password</td>

<td class="style30">

 

<asp:TextBox ID="txtPassword" runat="server" style="margin-top: 0px" 

Width="179px" MaxLength="15" TextMode="Password" BorderColor="#99CCFF"></asp:TextBox>

</td>

</tr>

<tr>

<td class="style33" colspan="2">

		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;       

<asp:Button ID="btnsubmit" runat="server" Text="Submit" Width="96px" />

</td>

</tr>

<tr>

<td class="style40" colspan="2">

		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;	   

 <asp:Label 

ID="Label1" runat="server" Text="Label" Visible="False" 

style="font-style: italic"></asp:Label>

</td>

</tr>

<tr>

<td class="style40" colspan="2">

		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 	   

		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p; <asp:Label ID="Label2" runat="server" Text="Label" 

Visible="False" style="font-style: italic"></asp:Label>

		&n bsp;	   &nbs p;		 		&n bsp;    

<asp:Label ID="litUserdata" runat="server" Text=" "></asp:Label>

</td>

</tr>

</table>

 

</asp:Content>



<asp:Content ID="Content14" runat="server" 

contentplaceholderid="ContentPlaceHolder3">

<aspanel ID="Panel5" runat="server" Width="1140px" Height="16px" 

style="background-color: #666666; text-align: left;">

<span class="style22">   

</span>

<span class="style23">Welcome!

<asp:Label ID="lblName" runat="server" style="color: #666666" Text="Name"></asp:Label>

		&n bsp;<asp:LoginName ID="LoginName1" runat="server" FormatString ="Welcome, {0}" />

		&n bsp;	   &nbs p;	 

		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;		 		&n bsp;	   &nbs p;   

	     ;<a href="transmade.aspx"><asp:Label ID="lblTrans" runat="server" 

style="font-size: small; color: #CCCCCC" Text="Transactions Made"></asp:Label></a>

   <span class="style23"><a href="Login2.aspx"><asp:Label ID="lblIn" 

runat="server" style="font-size: small; color: #CCCCCC" Text="Login"></asp:Label>

</a></span> <a href="logout.aspx"><asp:Label ID="lblOut" runat="server" 

style="font-size: small; color: #CCCCCC" Text="Logout"></asp:Label>

</a></span></aspanel>



</asp:Content>












<asp:Content ID="Content15" runat="server" 

contentplaceholderid="ContentPlaceHolder2">

<aspanel ID="Panel1" runat="server" Height="112px" Width="195px">

<span class="style24" style="text-align: left;"> 

<br />

  </span>

<span class="style24" style="text-align: left;">ONLINE CATALOG</span>

<ul id="UL1">

<li><a href="Default.aspx">Basic Search</a></li>

<li><a href="page2.aspx">Advanced Search</a></li>

</ul>

</aspanel>


<aspanel ID="Panel2" runat="server" Height="36px" Width="196px">

<%--<ul id="UL2">

<li><a href="login2.aspx">Login</a></li>

</ul>--%></aspanel>


<aspanel ID="Panel3" runat="server" Height="91px">

<span class="style19"><span class="style20">   TRANSACTIONS</span></span>

<ul id="UL3">

<li><a href="#">Issuance</a>

<ul>

<li><a href="BorrowBook.aspx">Borrow</a></li>

<li><a href="ReturnBook.aspx">Return</a></li>

<li><a href="penaltyStatus.aspx">Penalty Status</a></li>

<%--<li><a href="BookReservation.aspx">Reservation Search</a></li>--%>

</ul>

</li> 


<li><a href="#">Members</a>

<ul>

<li><a href="borrowersregistration.aspx">Member Registration</a></li>

<li><a href="borrow_main.aspx">Members List</a></li>

</ul>

</li> 


</ul>

</aspanel>


<aspanel ID="Panel4" runat="server" Height="266px">

<ul id="UL4">

<li><a href="#">Materials</a>

<ul>

<li><a href="Books.aspx">Book Acquisition</a></li>

<li><a href="cd_main.aspx">Audio-Visual Materials</a></li>

<li><a href="othermatmain.aspx">Periodicals</a></li>

<li><a href="books_main.aspx">Book Collection</a></li>

<li><a href="requestbook.aspx">Book Request</a></li>

</ul>

</li>

<li><a href="#">Librarians</a>

<ul>

<li><a href="borrow_librarian.aspx">Librarian Registration</a></li>

<li><a href="librariandatabase.aspx">Librarians List</a></li>

</ul>

</li>

<li><a href="reports.aspx">Reports</a

<%-- <ul>

<li><a href="#">Borrow's Record</a></li>

<li><a href="#">List of Books</a></li>

<li><a href="#">Today's Book Borrowed</a></li>

<li><a href="#">Overdue Books</a></li>

<li><a href="#">Log Report</a></li>

<li><a href="#">Weed-out Books</a></li>

<li><a href="#">Penalty Report</a></li>

</ul>--%>

</li>

<%-- <li><a href="#">Suppliers</a>

<ul>

<li><a href="Suppliers.aspx">Supplier Registration</a></li>

<li><a href="suppliers_main.aspx">Suppliers List</a></li>

</ul>

</li>

<li><a href="#">Dept. Maintenance</a>

<ul>

<li><a href="dept_main.aspx">For Employees</a></li>

<li><a href="dept_main2.aspx">For Students</a></li>

</ul>

</li>--%>

<li><a href="fine.aspx">Fine Maintenance</a></li>

<li><a href="lib_apruvalReq.aspx">Authorization</a></li>

</ul>

</aspanel>

<br />

<p style="height: 38px">

<br />

</p>


</asp:Content>









This for vb:



Imports System.Data

Imports System.Configuration

Imports System.Collections

Imports System.Web

Imports System.Web.Security

Imports System.Web.UI

Imports System.Web.UI.WebControls

Imports System.Web.UI.WebControls.WebParts

Imports System.Web.UI.HtmlControls

Imports System.Data.SqlClient

Partial Class Login2

Inherits System.Web.UI.Page

Public pcode As String

Public libnum As String

Public Const cnstring As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\lib\App_Da ta\libsys.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

Dim aConfig As ConfigurationSettings

Dim conn As New SqlConnection(aConfig.AppSettings("SqlConn"))

Dim strRequest As String

Dim strReserve As String

Private Sub userlevel()

Panel2.Visible = True

lblOut.Visible = True

lblIn.Visible = False

If pcode = "1" Then

Panel3.Visible = True

Panel4.Visible = True




ElseIf pcode = "2" Then

Panel3.Visible = True

Panel4.Visible = False

ElseIf pcode = "3" Then

Panel3.Visible = False

Panel4.Visible = False

lblTrans.Visible = True

ElseIf pcode = "4" Or pcode Is Nothing Then

Panel3.Visible = False

Panel4.Visible = False

lblTrans.Visible = True

End If

If pcode Is Nothing Then

lblOut.Visible = False

lblTrans.Visible = False

lblIn.Visible = True

End If

End Sub

Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsubmit.Click

Dim sqlQuery As String = "SELECT * from tbl_borrowers where idnum = '" & txtUserName.Text & "'"

' 'Dim conn As New SqlConnection(cnstring)

Dim sda As New SqlDataAdapter(sqlQuery, conn)

Dim dtData As New DataTable()

sda.Fill(dtData)



If dtData.Rows.Count = 0 Then

litUserdata.Text = "Invalid User Name and Password"

Else

' Dim user1 As String = IIf(IsDBNull(dtData.Rows(0)("idnum")), "", dtData.Rows(0)("idnum"))

Dim pword As String = IIf(IsDBNull(dtData.Rows(0)("pw")), "", dtData.Rows(0)("pw"))

Dim log As String = IIf(IsDBNull(dtData.Rows(0)("isLogin")), "", dtData.Rows(0)("isLogin"))

Dim status As String = IIf(IsDBNull(dtData.Rows(0)("isactive")), "", dtData.Rows(0)("isactive"))

If LCase(pword.Trim) <> LCase(txtPassword.Text.Trim) Then

litUserdata.Text = "Invalid Password"

txtPassword.Text = ""

Exit Sub



Else

If status = "Inactive" Then

ClientScript.RegisterStartupScript(Me.GetType(), "key", "alert('You cannot log in.User account is already Inactive.');", True)

Exit Sub

End If

'IBABALIK


'If log <> "1" Then

'Else

' ClientScript.RegisterStartupScript(Me.GetType(), "key", "alert('User is already logged in');", True)

' Exit Sub

'End If

End If


Dim level As String

level = IIf(IsDBNull(dtData.Rows(0)("pos_code")), "", dtData.Rows(0)("pos_code"))

Session("lebel") = level.ToString

Session("idnumber") = txtUserName.Text.ToString.Trim

Session("namelogged") = IIf(IsDBNull(dtData.Rows(0)("fname")), "", dtData.Rows(0)("fname")) & " " & IIf(IsDBNull(dtData.Rows(0)("fname")), "", dtData.Rows(0)("lname"))

userlevel()

Dim cmd As SqlCommand

Dim sql As String

sql = "SELECT count(*) FROM tbl_material_request WHERE (is_apruv= 'N') "



Try

conn.Open()

cmd = New SqlCommand(sql, conn)

Dim count As Int32 = Convert.ToInt32(cmd.ExecuteScalar())

cmd.Dispose()

conn.Close()

If count > 0 Then

'Dim strRequest As String

Label1.Text = count

'ClientScript.RegisterStartupScript(Me.GetType(), "key", "alert('You have " & count & " awaiting request');", True)

' 

End If

Catch ex As Exception

End Try


'================================================= ===

cmd = New SqlCommand

sql = "SELECT count(*) FROM tbl_lib_materials WHERE (status = 'Reserved') "


'cnn = New SqlConnection(My.Settings.ConString)

Try

conn.Open()

cmd = New SqlCommand(sql, conn)

Dim count As Int32 = Convert.ToInt32(cmd.ExecuteScalar())

cmd.Dispose()

conn.Close()

If count > 0 Then

' Dim strReserve As String

Label2.Text = count

'ClientScript.RegisterStartupScript(Me.GetType(), "key", "alert('You have '" & count & "' awaiting request');", True)

' MsgBox("You have '" & count & "' awaiting Book request")

End If




Catch ex As Exception

'MsgBox("Can not open connection !")

End Try

If level.ToString = "1" Then


ClientScript.RegisterStartupScript(Me.GetType(), "key", "alert('You have " & Label1.Text & " awaiting Book request');", True)

ElseIf level.ToString = "2" Then

' MsgBox("You have '" & Label1.Text & "' awaiting Book reservation issuance")

End If


'===========IBABALIK

'Dim UpdateCommand As SqlCommand = New SqlCommand()

'UpdateCommand.Connection = conn


'sql = "Update tbl_borrowers Set islogin = '1' WHERE idnum = '" & txtUserName.Text & "'"

'UpdateCommand.CommandText = sql



'Try

' conn.Open()

' UpdateCommand.ExecuteNonQuery()

'Catch ex As Exception

' Response.Write(ex.ToString())

'Finally

' conn.Close()

'End Try




Session("ULevel") = level.ToString

Server.Transfer("default.ASPX")



End If

' Dim a As String




End Sub



Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If (Not IsPostBack) Then

userlevel()

pcode = Session("ULevel")


Dim sqlQuery As String = "SELECT * from tbllogin"

' Dim conn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\libsys.mdf;Integrated Security=True;User Instance=True")

Dim sda As New SqlDataAdapter(sqlQuery, conn)

Dim dtData As New DataTable()

sda.Fill(dtData)



End If

End Sub



End Class

Attached File  try.jpg   222.17K   9 downloads

#2
Vaielab

Vaielab

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 547 posts
My asp.net is rusty, and my vb is even more rusty, but you could simply use a session to store the name
and on the Page_Load you check if the session exist, if so you set lblName.Text to the session

Maybe you will want to use a masterpage for not being to have to do this on each of your page
Or create a base class that everypage will extends from it

#3
kiko2max

kiko2max

    Newbie

  • Members
  • PipPip
  • 19 posts
can you give me a sample code?

#4
Vaielab

Vaielab

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 547 posts
Exploring Session in ASP.Net - CodeProject

The first 2 code snippet are exactly what you are looking for
The first one save the username to the session
And the second one display it in a label




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users