Saturday, 16 June 2018

Shopping Website in ASP.NET Part-2

Shopping Website in ASP.NET Part-2

How to create Shopping Website & How to create Admin Login page with source code.








step:1 create adminlogin.aspx page

.................................................................

<head runat="server">
    <title>Myshopping cart</title>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-5" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script language="javascript" type="text/javascript">
<!--

    function IMG3_onclick() {

    }

    function UL1_onclick() {

    }

// -->
</script>

</head>
<body>
    <form id="form1" runat="server">
      <div id="header">
        <div class="block1">
</div>
        <div class="block2">
            <ul>
<li><a href="#">Specials</a></li>
<li><a href="Search.aspx">Search</a></li>
<li><a href="#">Contact Us</a></li>
<li><a href="Signin.aspx">Create an account</a></li>
<li><a href="Login.aspx">Customer Login</a></li>
</ul>
        </div>
        <div class="block3" style="width: 168px">
            <a href="#"></a>
            <asp:ImageButton ID="ImageButton17" runat="server" ImageUrl="~/images/cart.jpg" />
            <span>Shopping Cart<asp:Label ID="cart" runat="server" Font-Size="Small" ForeColor="Red"
                Text="*"></asp:Label></span> &nbsp;&nbsp;
        
        </div>
    <a href="#"><img src="images/name.jpg" alt="" width="396" height="117" /></a><img src="images/pic1.jpg" alt="" height="117" style="width: 360px" /><br />

    <ul class="menu" style="width: 784px">
<li><a href="view.aspx?ref=true"><img src="images/but1.jpg" alt="Home" width="135" height="36" id="IMG2" onclick="return IMG2_onclick()" /></a></li>
<li><a href="Login.aspx"><img src="images/but2.jpg" alt="" width="130" height="36" id="IMG3" onclick="return IMG3_onclick()" /></a></li>
<li><a href="#"><img src="images/but3.jpg" alt="" width="130" height="36" /></a></li>
<li><a href="#"><img src="images/but4.jpg" alt="" width="130" height="36" id="IMG1" onclick="return IMG1_onclick()" /></a></li>
<li><a href="#"><img src="images/but5.jpg" alt="" width="130" height="36" /></a></li>
<li><img src="images/butclean.jpg" alt="" width="111" height="36" /></li>
</ul>
    </div>

    <div id="Div1">
        &nbsp;<div class="left">

                <img src="images/title1.jpg" alt="" width="198" height="30" /><br />

                <ul>
<li class="dots"><a href="robot.aspx">Robot Electrinics</a></li>
<li class="dots"><a href="#">Remote Controls</a></li>
<li class="dots"><a href="#">Programers</a></li>
<li class="dots"><a href="#">Boards</a></li>
<li class="dots"><a href="#">Motors</a></li>
<li class="dots"><a href="#">Batteries</a></li>
<li class="dots"><a href="#">Robots</a></li>
<li class="dots"><a href="#">Micro Controllers</a></li>
<li class="dots"><a href="#">Components</a></li>
<li class="dots"><a href="#">Sensor</a></li>
<li class="dots"><a href="#">Other</a></li>
<li class="dots"><a href="#">Specials..</a></li>
<li class="dots"><a href="#">New Product</a></li>
</ul>

            <img src="images/title2.jpg" alt="" width="198" height="30" /><br />
            <ul>
                &nbsp;<li class="dots"><a href="#">Sale</a></li>
<li class="dots"><a href="#">Pro Order</a></li>
<li><a href="#">Coming Soon</a></li>
</ul>
               </div>


              
    <div id="content">
        &nbsp;

            <div id="footer">
            Copyright &copy;2018 CODER BABA All Rights Reserved / <a href="#" class="powered"><strong>Powered by company name</strong></a><br />
               <a href="#" class="terms">Terms of Use</a> / <a href="#" class="terms">Privacy Policy</a>
            </div><div class="right" style="width: 526px; height: 1px; z-index: 100; left: 326px; position: absolute; top: 260px;">
                            <div class="information">

                             &nbsp;
            <fieldset style="height: 184px" >
            <legend >Administrator Login:</legend>
                <br />
            <table style="width: 232px">
           
    <tr>
        <td style="width: 282px">
            Email Id:</td>
        <td colspan="2" style="width: 139px">
            <asp:TextBox ID="txtemail" runat="server"></asp:TextBox></td>
    </tr>
    <tr>
        <td style="width: 282px; height: 15px">
        </td>
        <td colspan="2" style="width: 139px; height: 15px">
            &nbsp;</td>
    </tr>
    <tr>
        <td style="width: 282px; height: 8px">
            Password:</td>
        <td colspan="2" style="width: 139px; height: 8px">
            <asp:TextBox ID="txtpass" runat="server" TextMode="Password"></asp:TextBox></td>
    </tr>
    <tr>
        <td style="width: 282px; height: 13px">
        </td>
        <td colspan="2" style="width: 139px; height: 13px">
            <asp:Label ID="lblpass" runat="server" ForeColor="Red"></asp:Label>
        </td>
    </tr>
</table>
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                <asp:Button ID="Button2" runat="server" Text="Log In!" Width="120px" /><br />
                <br />
                &nbsp; &nbsp;&nbsp; &nbsp;<br />
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
            </fieldset> &nbsp; &nbsp;&nbsp;<br />
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            <br />
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp;
        </div>
    </div>


    </div>


    </form>
</body>
</html>



Code ( adminlogin.aspx.vb)


........................................................
Imports System.Data
Imports System.Data.SqlClient
Partial Class adminlogin
    Inherits System.Web.UI.Page

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim conn As New SqlConnection
        Dim constr As String

        constr = "Data Source=DELL-PC;Initial Catalog=myshopping;Integrated Security=True"
        conn.ConnectionString = constr
        conn.Open()
        Dim sql = "select * from Admin1 where Name='" & txtemail.Text & "' and pass='" & txtpass.Text & "'"

        Dim comm As New SqlCommand(sql, conn)
        Dim dr As SqlDataReader

        dr = comm.ExecuteReader
        If dr.Read() Then
            Session("Admin") = txtemail.Text
            Response.Redirect("admin.aspx")
        Else
            lblpass.Text = "Enter Valid Admin Id and Password!"
        End If
        conn.Close()
    End Sub
End Class



Step 2: create a new webpage ( admin.aspx ) :

...............................................................................

 <head runat="server">
    <title>Admin Home</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-5" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script language="javascript" type="text/javascript">
<!--

    function IMG1_onclick() {

    }

// -->
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="header">
<div class="block1">
<ul>
<li>
<img src="images/square.jpg" alt="" width="11" height="11" class="squ" />
Choose Language : 
<a href="#"><img src="images/flag1.jpg" alt="" width="20" height="14" /></a>
<a href="#"><img src="images/flag2.jpg" alt="" width="20" height="14" /></a>
<a href="#"><img src="images/flag3.jpg" alt="" width="20" height="14" /></a>
</li>
<li>
<img src="images/square.jpg" alt="" width="11" height="11" class="squ" />
Currencies :
<select class="select">
<option value="">US Dollar</option>
<option value="">US Dollar</option>
                        <option value="">INR</option>
</select>
</li>
</ul>
</div>
<div class="block2">
<ul>
<li><a href="#">Specials</a></li>
<li><a href="#">Search</a></li>
<li><a href="#">Contact Us</a></li>
<li><a href="#">Create an account</a></li>
<li><a href="#">Customer Login</a></li>
                <li><a href="#"> 
                   </a> </li>
</ul>
</div>
<div class="block3" style="width: 168px">
<a href="#"></a>&nbsp;
</div>
<a href="#"><img src="images/name.jpg" alt="" width="396" height="117" id="IMG1" language="javascript" onclick="return IMG1_onclick()" runat="server" /></a><img src="images/pic1.jpg" alt="" height="117" style="width: 360px" /><br />

<ul class="menu" style="width: 784px">
<li><a href="Default.aspx"></a></li>
<li><a href="Login.aspx"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li>&nbsp;</li></ul>
</div>
<div id="content">
     Welcome :<asp:Label ID="Al" runat="server" Text="Label" Font-Bold="True" ForeColor="Red"></asp:Label>
        <br />
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;
        <asp:Button ID="btnhome" runat="server" Text="Home" Width="112px" />
        &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; 
        <asp:Button ID="btnadd" runat="server" Text="Add Item" Width="112px" />
        &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; 
        <asp:Button ID="Button1" runat="server" Text="Reports" Width="112px" />&nbsp;&nbsp;
        &nbsp;
        <asp:Button ID="Button2" runat="server" Text="Paid Report" Width="112px" /><br />
        <asp:Label ID="Label1" runat="server" Font-Size="Larger" Text="Search:"></asp:Label>
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Name Wise:<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
        &nbsp;&nbsp; Category Wise:
        <asp:DropDownList ID="cmbcat" runat="server" Width="152px">
            <asp:ListItem>Robot Electronics</asp:ListItem>
            <asp:ListItem>Remote Controls</asp:ListItem>
            <asp:ListItem>Programers</asp:ListItem>
            <asp:ListItem>Boards</asp:ListItem>
            <asp:ListItem>Motors</asp:ListItem>
            <asp:ListItem>Batteries</asp:ListItem>
            <asp:ListItem>Robots</asp:ListItem>
            <asp:ListItem>Micro Controllers</asp:ListItem>
            <asp:ListItem Value="Components"></asp:ListItem>
            <asp:ListItem>Sensor</asp:ListItem>
            <asp:ListItem>Other</asp:ListItem>
            <asp:ListItem>Specials</asp:ListItem>
            <asp:ListItem>New Product</asp:ListItem>
        </asp:DropDownList>
        &nbsp; &nbsp;
        <asp:Button ID="btnshow" runat="server" Text="Show" Width="96px" />
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<asp:LinkButton
            ID="LinkButton1" runat="server" Font-Size="Medium">Log Out</asp:LinkButton><br />
        <br />
        <br />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
            AutoGenerateSelectButton="True" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None"
            BorderWidth="1px" CellPadding="3" GridLines="Horizontal" Height="16px" Width="272px" AllowPaging="True">
            <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
            <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
            <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
            <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
            <AlternatingRowStyle BackColor="#F7F7F7" />
        </asp:GridView>
        <br />
</div>


    <div id="footer">
            Copyright &copy;2018 CODER BABA All Rights Reserved / <a href="#" class="powered"><strong>Powered by company name</strong></a><br />
               <a href="#" class="terms">Terms of Use</a> / <a href="#" class="terms">Privacy Policy</a>
            </div>
    </form>
</body>
</html>



Dynamic Code  admin.aspx.vb:

.......................................................


Partial Class admin
    Inherits System.Web.UI.Page

    Protected Sub btnadd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnadd.Click

    End Sub

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

        If Session("Admin") = "" Then
            Response.Redirect("Expire.aspx")

        Else
            Al.Text = Session("Admin").ToString()


        End If
    End Sub

    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        If Session("Admin") = "" Then
            Response.Redirect("expire.aspx")
        Else
            Session.Remove("Admin")
            Response.Redirect("adminlogin.aspx")
        End If
    End Sub
End Class




Download Source code : Click Here



1 comment:

  1. Sir, I need to create project for applying leaves before one month in vb.net with SQL...please help

    ReplyDelete

Popular Posts