Problemsheet-2: Register - Aspx
Problemsheet-2: Register - Aspx
Q.1: - Develop website in ASP.NET Website for “Automobile EMI (Equated monthly
Instalments) Management System” with following functionality along with login
according to the user. (Validate all thefields) Use Following tables:
1. Login (Login name, password)
2. CarLoan (CarLoanID,CarName,Customername,Address,City, EmailID,
Installment_of_EMI,EMI_Years, Rate_Interest_loan) Provide following facilities:
1. Provide Login facility; sign up (Registration) facility.
2. Display Report according to CarLoanID.
Register.aspx:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Register</title>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/6.5.0/css/all.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-
[email protected]/font/bootstrap-icons.css"/>
<link href="Content\bootstrap.css" rel="stylesheet" />
<style> .regForm { width:40%; margin: 100px auto;
}
</style>
</head>
<body>
<form id="form1" class="regForm form p-3 border rounded bg-warning bgopacity-50"
runat="server">
<div>
<h2>Registration</h2>
<asp:TextBox ID="txtNewLogin" CssClass="form-control" runat="server"
placeholder="Username" Required="true" /> <br />
<asp:TextBox ID="txtNewPassword" CssClass="form-control" runat="server"
placeholder="Password" TextMode="Password" Required="true" /> <br /> <asp:TextBox
ID="txtPhone" CssClass="form-control" runat="server" placeholder="Phone No" Required="true" />
<br />
<asp:TextBox ID="txtDOB" CssClass="form-control" runat="server" placeholder="DOB(YYYY-MM-
DD)" Required="true" /> <br />
1
2302020101417
Problemsheet-2
</html>
Register.aspx.
cs:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Register</title>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/6.5.0/css/all.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-
[email protected]/font/bootstrap-icons.css"/>
<link href="Content\bootstrap.css" rel="stylesheet" />
<style> .regForm
{ width:40%;
margin: 100px auto;
}
</style>
</head>
<body>
<form id="form1" class="regForm form p-3 border rounded bg-warning bgopacity-50"
runat="server">
<div>
<h2>Registration</h2>
<asp:TextBox ID="txtNewLogin" CssClass="form-control" runat="server"
placeholder="Username" Required="true" /> <br />
<asp:TextBox ID="txtNewPassword" CssClass="form-control" runat="server"
placeholder="Password" TextMode="Password" Required="true" /> <br /> <asp:TextBox
ID="txtPhone" CssClass="form-control" runat="server" placeholder="Phone No" Required="true" />
<br />
<asp:TextBox ID="txtDOB" CssClass="form-control" runat="server" placeholder="DOB(YYYY-MM-
DD)" Required="true" /> <br />
login.aspx:
2
2302020101417
Problemsheet-2
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Login - Automobile EMI System</title>
<!-- FontAwesome Icons -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/6.5.0/css/all.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-
[email protected]/font/bootstrap-icons.css"/>
<link href="Content\bootstrap.css" rel="stylesheet" />
<style>
body {
font-family: Arial; background-color:
#f5f5f5;
}
.login-container { width:
300px; margin: 100px auto;
background: white;
padding: 20px; border-
radius: 10px;
box-shadow: 2px 2px 10px rgba(0,0,0,0.2);
}
.input-icon
{ position: relative;
}
.input-icon i
{ position: absolute;
top: 2px; left: 2px;
color: #888;
}
.input-icon input { padding-
left: 40px; width: 100%;
margin-bottom: 15px;
}
.btn-login { width: 100%;
background-color: #007bff; color:
white; padding: 10px;
border: none; border-radius: 5px;
font-size: 16px;
}
.btn-login i { margin-right:
5px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="login-container">
<h2 style="text-align:center;">Login</h2>
<div class="input-icon">
<i class="fas fa-user bg-danger text-white border rounded p-2 "></i> <asp:TextBox
ID="txtLogin" CssClass="form-control" runat="server" placeholder="Username"></asp:TextBox>
</div>
3
2302020101417
Problemsheet-2
<div class="input-icon">
<i class="fas fa-lock bg-danger text-white border rounded p-2 "></i> <asp:TextBox
ID="txtPassword" CssClass="form-control" runat="server"
TextMode="Password" placeholder="Password"></asp:TextBox>
</div>
</div>
</form>
</body>
</html>
login.aspx:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Login - Automobile EMI System</title>
<!-- FontAwesome Icons -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/6.5.0/css/all.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-
[email protected]/font/bootstrap-icons.css"/>
<link href="Content\bootstrap.css" rel="stylesheet" />
<style> body {
font-family: Arial; background-color: #f5f5f5;
}
.login-container { width: 300px; margin: 100px auto; background: white;
padding: 20px; border-radius: 10px;
box-shadow: 2px 2px 10px rgba(0,0,0,0.2);
}
.input-icon { position: relative;
}
.input-icon i { position: absolute; top: 2px; left: 2px; color: #888;
}
.input-icon input { padding-left: 40px; width: 100%; margin-bottom: 15px;
}
.btn-login { width: 100%; background-color: #007bff; color: white;
padding: 10px; border: none; border-radius: 5px; font-size: 16px;
}
.btn-login i { margin-right: 5px;
}
</style>
</head>
4
2302020101417
Problemsheet-2
<body>
<form id="form1" runat="server">
<div class="login-container">
<h2 style="text-align:center;">Login</h2>
<div class="input-icon">
<i class="fas fa-user bg-danger text-white border rounded p-2 "></i> <asp:TextBox
ID="txtLogin" CssClass="form-control" runat="server" placeholder="Username"></asp:TextBox>
</div>
<div class="input-icon">
<i class="fas fa-lock bg-danger text-white border rounded p-2 "></i> <asp:TextBox
ID="txtPassword" CssClass="form-control" runat="server"
TextMode="Password" placeholder="Password"></asp:TextBox>
</div>
</div>
</form>
</body>
</html>
login.aspx.cs:
using System;
using System.Collections.Generic; using System.Data.SqlClient; using System.Linq; using
System.Web; using System.Web.UI;
using System.Web.UI.WebControls;
namespace AutomobileEmiManagementSystem
{
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data
Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\DotNetProjects\\AutomobileEmi
ManagementSystem\\App_Data\\automobile_info_db.mdf;Integrated Security=True");
SqlCommand cmd = new SqlCommand("SELECT * FROM Login WHERE LoginName=@login
AND Password=@pass", con);
5
2302020101417
Problemsheet-2
cmd.Parameters.AddWithValue("@login", txtLogin.Text);
cmd.Parameters.AddWithValue("@pass", txtPassword.Text); con.Open();
SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read())
{
Session["User"] = txtLogin.Text;
Response.Redirect("Dashboard.aspx");
} else {
lblMessage.Text = "Invalid credentials!";
}
con.Close();
}
}
}
Report.aspx:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Loan Report - Automobile EMI System</title>
<!-- FontAwesome Icons -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/6.5.0/css/all.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-
[email protected]/font/bootstrap-icons.css"/>
<link href="Content\bootstrap.css" rel="stylesheet" />
<style> body {
font-family: Arial; background-color: #f0f2f5;
}
.report-container { width: 70%; margin-top: 100px ; margin-left: 280px ;
background: white; padding: 20px; border-radius: 10px;
box-shadow: 2px 2px 10px rgba(0,0,0,0.2);
}
.btn-search {
background-color: #17a2b8; color: white; padding: 8px 15px; border:
none; border-radius: 5px; font-size: 16px;
}
.btn-search i { margin-right: 5px;
}
.gridview-style { width: 100%;
border-collapse: collapse;
}
.gridview-style th, .gridview-style td { padding: 10px; border: 1px solid #ddd;
text-align: center;
}
6
2302020101417
Problemsheet-2
.gridview-style th { background-color: #007bff; color: white; }
.icon-text { display: flex; align-items: center; justify-content: center;
}
.icon-text i { margin-right: 5px; color: #007bff;
}
<div class="sidebar">
<h2 style="text-align:center;">EMI System</h2>
<a href="Dashboard.aspx"><i class="fas fa-plus-circle"></i>Add Loan</a>
<a href="Report.aspx"><i class="fas fa-file-alt"></i>View Report</a>
<a href="login.aspx"><i class="fas fa-sign-out-alt"></i>Logout</a>
</div>
7
2302020101417
Problemsheet-2
<div class="icon-text">
<i class="fas fa-car"></i>
<%# Eval("CarName") %>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Customer">
<ItemTemplate>
<div class="icon-text">
<i class="fas fa-user"></i>
<%# Eval("CustomerName") %>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<div class="icon-text">
<i class="fas fa-city"></i>
<%# Eval("City") %>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="EMI Installment">
<ItemTemplate>
<div class="icon-text">
<i class="fas fa-rupee-sign"></i>
<%# Eval("Installment_of_EMI") %>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="EMI Years">
<ItemTemplate>
<div class="icon-text">
<i class="fas fa-calendar-alt"></i>
<%# Eval("EMI_Years") %> years
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Rate of Interest">
<ItemTemplate>
<div class="icon-text">
<i class="fas fa-percent"></i>
<%# Eval("Rate_Interest_Loan") %> %
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
8
2302020101417
Problemsheet-2
Report.aspx.cs:
using System;
using System.Collections.Generic; using System.Data.SqlClient; using System.Data; using
System.Linq; using System.Web; using System.Web.UI;
using System.Web.UI.WebControls;
namespace AutomobileEmiManagementSystem
{
public partial class Report : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSearch_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data
Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\DotNetProjects\\AutomobileEmi
ManagementSystem\\App_Data\\automobile_info_db.mdf;Integrated Security=True");
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM CarLoan WHERE CarLoanID=@id",
con);
da.SelectCommand.Parameters.AddWithValue("@id", txtCarLoanID.Text); DataTable dt =
new DataTable();
da.Fill(dt); gvReport.DataSource = dt; gvReport.DataBind();
}
}
}
Dashboard.aspx:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Add Car Loan - Automobile EMI System</title>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/6.5.0/css/all.min.css" />
9
2302020101417
Problemsheet-2
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-
[email protected]/font/bootstrap-icons.css"/>
<link href="Content\bootstrap.css" rel="stylesheet" />
<style> body {
font-family: Arial; background-color: #eef2f7;
}
.dashboard-container { width: 400px; margin: 50px auto; background: white;
padding: 25px; border-radius: 10px;
box-shadow: 2px 2px 12px rgba(0,0,0,0.2);
}
.input-icon { position: relative; margin-bottom: 15px;
}
.input-icon i { position: absolute; top:2px; left: 2px; color: #888;
}
.input-icon input { padding-left: 40px; width: 100%; }
.btn-submit { width: 100%; background-color: #28a745; color: white;
padding: 10px; border: none; border-radius: 5px; font-size: 16px;
}
.btn-submit i { margin-right: 5px;
}
<div class="sidebar">
<h2 style="text-align:center;">EMI System</h2>
<a href="Dashboard.aspx"><i class="fas fa-plus-circle"></i>Add Loan</a>
<a href="Report.aspx"><i class="fas fa-file-alt"></i>View Report</a>
<a href="login.aspx"><i class="fas fa-sign-out-alt"></i>Logout</a>
</div>
10
2302020101417
Problemsheet-2
<div class="main-content">
<div class="dashboard-container">
<h2 style="text-align:center;">Add Car Loan</h2>
<div class="input-icon">
<i class="fas fa-car bg-danger text-white border rounded p-2 "></i> <asp:TextBox
ID="txtCarName" CssClass="form-control" runat="server" placeholder="Car Name"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvCarName" runat="server"
ControlToValidate="txtCarName" ErrorMessage="Car Name Required!" ForeColor="Red"
Display="Dynamic" />
</div>
<div class="input-icon">
<i class="fas fa-user bg-danger text-white border rounded p-2 "></i>
<asp:TextBox ID="txtCustomerName" CssClass="form-control" runat="server"
placeholder="Customer Name"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtCustomerName" ErrorMessage="Customer Name
Required!" ForeColor="Red" Display="Dynamic" />
</div>
<div class="input-icon">
<i class="fas fa-map-marker-alt bg-danger text-white border rounded
p-2 "></i>
<asp:TextBox ID="txtAddress" CssClass="form-control" runat="server"
placeholder="Address"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtAddress" ErrorMessage="Address Required!"
ForeColor="Red" Display="Dynamic" />
</div>
<div class="input-icon">
<i class="fas fa-city bg-danger text-white border rounded p-2 "></i> <asp:TextBox
ID="txtCity" CssClass="form-control" runat="server" placeholder="City"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtCity" ErrorMessage="City Required!"
ForeColor="Red" Display="Dynamic" />
</div>
<div class="input-icon">
<i class="fas fa-envelope bg-danger text-white border rounded p-2 "></i>
<asp:TextBox ID="txtEmailID" CssClass="form-control" runat="server" placeholder="Email
ID"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtEmailID" ErrorMessage="Email Required!"
ForeColor="Red" Display="Dynamic" />
11
2302020101417
Problemsheet-2
</div>
<div class="input-icon">
<i class="fas fa-rupee-sign bg-danger text-white border rounded p-2 "></i>
<asp:TextBox ID="txtInstallment" CssClass="form-control" runat="server"
placeholder="Installment of EMI"></asp:TextBox> <asp:RequiredFieldValidator
ID="RequiredFieldValidator5"
runat="server" ControlToValidate="txtInstallment" ErrorMessage="Installment (Rs.)
Required!" ForeColor="Red" Display="Dynamic" />
</div>
<div class="input-icon">
<i class="fas fa-calendar-alt bg-danger text-white border rounded p-2 "></i>
<asp:TextBox ID="txtYears" CssClass="form-control" runat="server" placeholder="EMI
Years"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="txtYears" ErrorMessage="Years Required!"
ForeColor="Red" Display="Dynamic" />
</div>
<div class="input-icon">
<i class="fas fa-percent bg-danger text-white border rounded p-2
"></i>
<asp:TextBox ID="txtRateInterest" CssClass="form-control" runat="server" placeholder="Rate
of Interest"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator7"
runat="server" ControlToValidate="txtRateInterest" ErrorMessage="Rate of Interest
Required!" ForeColor="Red" Display="Dynamic" />
</div>
Dashboard.aspx.cs:
using System;
using System.Collections.Generic; using System.Data.SqlClient; using System.Linq; using
System.Web; using System.Web.UI;
using System.Web.UI.WebControls;
namespace AutomobileEmiManagementSystem
{
12
2302020101417
Problemsheet-2
public partial class Dashboard : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAddLoan_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data
Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\DotNetProjects\\AutomobileEmi
ManagementSystem\\App_Data\\automobile_info_db.mdf;Integrated Security=True");
SqlCommand cmd = new SqlCommand("INSERT INTO CarLoan (CarName,
CustomerName, Address, City, EmailID, Installment_of_EMI, EMI_Years,
Rate_Interest_Loan) VALUES (@car, @cust, @addr, @city, @email, @emi, @years,
@rate)", con);
cmd.Parameters.AddWithValue("@car", txtCarName.Text);
cmd.Parameters.AddWithValue("@cust", txtCustomerName.Text);
cmd.Parameters.AddWithValue("@addr", txtAddress.Text);
cmd.Parameters.AddWithValue("@city", txtCity.Text);
cmd.Parameters.AddWithValue("@email", txtEmailID.Text);
cmd.Parameters.AddWithValue("@emi", txtInstallment.Text);
cmd.Parameters.AddWithValue("@years", txtYears.Text);
cmd.Parameters.AddWithValue("@rate", txtRateInterest.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
lblMessage.Text = "Loan added successfully!";
}
}
}
OUTPUT:
13
2302020101417
Problemsheet-2
14
2302020101417
Problemsheet-2
Code:
Register.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Register.aspx.cs"
Inherits="OnlineShoppingWebsite.Register" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="Content\bootstrap.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-
[email protected]/font/bootstrap-icons.css"/>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/6.5.0/css/all.min.css"/>
</head>
<body>
<form id="form1" class="form w-50 mt-5 mb-5 m-auto p-3 border rounded" runat="server">
<div>
<h2 class="text-danger text-center"><i class="bi bi-pen"></i>
Registration</h2>
<asp:RequiredFieldValidator ID="rfv1"
ControlToValidate="txtUsername" runat="server" ErrorMessage="Username is
required"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtUsername" class="form-control" runat="server"
placeholder="Username"></asp:TextBox> <br />
15
2302020101417
Problemsheet-2
<asp:RequiredFieldValidator ID="rfv2"
ControlToValidate="txtUsername" runat="server" ErrorMessage="Username is
required"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtPassword" class="form-control" runat="server" placeholder="Password"
TextMode="Password"></asp:TextBox> <br />
<asp:RequiredFieldValidator ID="rfv3"
ControlToValidate="txtUsername" runat="server" ErrorMessage="Username is
required"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtEmail" class="form-control" runat="server"
placeholder="Email"></asp:TextBox><br />
Register.aspx.
using System.Collections.Generic;
using System.Configuration; using
System.Data.SqlClient; using
System.Linq; using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace OnlineShoppingWebsite
{
public partial class Register : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnRegister_Click(object sender, EventArgs e)
{
16
2302020101417
Problemsheet-2
cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
conn.Open(); cmd.ExecuteNonQuery(); conn.Close();
lblMessage.Text = "Registration successful!";
Login.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs"
Inherits="OnlineShoppingWebsite.Login" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Login Page</title>
<link href="Content\bootstrap.css" rel="stylesheet" /> <link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap-
[email protected]/font/bootstrap-icons.css"/>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/6.5.0/css/all.min.css"/>
</head>
<body>
<form id="form1" class="form mt-5 mb-5 m-auto p-3 w-50 border rounded" runat="server">
<div>
</div>
</form>
</body>
</html>
Login.aspx.cs:
17
2302020101417
Problemsheet-2
using System;
using System.Collections.Generic;
using System.Configuration; using
System.Data.SqlClient; using
System.Linq; using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace OnlineShoppingWebsite
{
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlDataReader dr = cmd.ExecuteReader(); if
(dr.Read())
{
Session["UserID"] = dr["UserID"].ToString();
Session["Username"] = dr["Username"].ToString();
Response.Redirect("Home.aspx");
}
else {
lblMessage.Text = "Invalid username or password!";
}
con.Close();
}
}
}
}
Home.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Home.aspx.cs"
Inherits="OnlineShoppingWebsite.Home" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
18
2302020101417
Problemsheet-2
<title></title>
<link href="Content\bootstrap.css" rel="stylesheet" /> <link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap-
[email protected]/font/bootstrap-icons.css"/>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/6.5.0/css/all.min.css"/>
<style>
.contentDiv
{ width:100%;
background-image:url('Img/shoppingImg1.jpg'); background-
position:center; background-size:cover; background-
repeat:no-repeat;
}
.welcometxt { font-size:80px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="container-fluid bg-light">
<div class="row p-3 text-center">
<div class="col-4 border-end">
<h3>Online Shopping Website</h3>
</div>
<div class="col-2"><a href="Home.aspx" class="btn btnoutline-danger"><i class="fa fa-
home"></i> HOME</a></div>
<div class="col-2"><a href="ProductList.aspx" class="btn"><i class="fa fa-bag-
shopping"></i> PRODUCTS</a></div>
<div class="col-2"><a href="OrderList"class="btn"><i class="fa fa-truck-ramp-box"></i>
ORDER</a></div>
<div class="col-2"><a href="OrderList" class="btn"><i class="fa fa-cart-shopping"></i>
CART</a></div>
</div>
</div>
</h1>
</div>
</div>
</form>
</body>
</html>
Home.aspx.cs:
19
2302020101417
Problemsheet-2
using System;
using System.Collections.Generic;
using System.Linq; using
System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;
namespace OnlineShoppingWebsite
{
public partial class Home : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ProductList.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProductList.aspx.cs"
Inherits="OnlineShoppingWebsite.Products" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="Content\bootstrap.css" rel="stylesheet" /> <link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-
icons.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/6.5.0/css/all.min.css"/>
</head>
<body>
<form id="form1" runat="server">
<div>
20
2302020101417
Problemsheet-2
<div class="col-2"><a href="ProductList.aspx" class="btn btnoutline-danger "><i class="fa
fa-bag-shopping"></i> PRODUCTS</a></div> <div class="col-2"><a
href="OrderList"class="btn"><i class="fa fatruck-ramp-box"></i> ORDER</a></div>
<div class="col-2"><a href="OrderList" class="btn"><i class="fa facart-shopping"></i>
CART</a></div>
</div>
</div>
</div>
</div>
</div>
</form>
</body>
</html>
ProductList.as
px.cs:
using System;
using System.Collections.Generic;
using System.Configuration; using
System.Data.SqlClient; using
System.Data; using System.Linq;
using System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;
namespace OnlineShoppingWebsite
{
public partial class Products : System.Web.UI.Page
21
2302020101417
Problemsheet-2
{
if (!IsPostBack)
{
LoadCategories();
}
}
private void LoadCategories()
{
SqlConnection con = new SqlConnection("Data
Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\DotNetProjects\\OnlineShoppin
gWebsite\\App_Data\\OnlineShoppingDb.mdf;Integrated Security=True"); con.Open();
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM
Categories", con);
DataTable dt = new DataTable(); da.Fill(dt);
ddlCategory.DataSource = dt;
ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataValueField =
"CategoryID"; ddlCategory.DataBind();
}
Response.Write("<script>alert('Product Ordered
Successfully');</script>");
}
22
2302020101417
Problemsheet-2
}
OrderList.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrderList.aspx.cs"
Inherits="OnlineShoppingWebsite.OrderList" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="Content\bootstrap.css" rel="stylesheet" /> <link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-
icons.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/6.5.0/css/all.min.css"/>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
23
2302020101417
Problemsheet-2
</div>
</form>
</body>
</html>
OrderList.asp
x.cs:
using System;
using System.Collections.Generic;
using System.Configuration; using
System.Data.SqlClient; using
System.Data; using System.Linq;
using System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;
namespace OnlineShoppingWebsite
{
public partial class OrderList : System.Web.UI.Page
}
private void LoadOrders()
{
SqlConnection con = new SqlConnection("Data
Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\DotNetProjects\\OnlineShoppin
gWebsite\\App_Data\\OnlineShoppingDb.mdf;Integrated Security=True"); SqlDataAdapter da
= new SqlDataAdapter("SELECT Products.ProductName,
Orders.OrderDate FROM Orders INNER JOIN Products ON Orders.ProductID =
Products.ProductID WHERE Orders.UserID=@UserID", con);
da.SelectCommand.Parameters.AddWithValue("@UserID", 1);
DataTable dt = new DataTable();
da.Fill(dt); gvOrders.DataSource = dt;
gvOrders.DataBind();
}
}
OUTPUT:
24
2302020101417
Problemsheet-2
25
2302020101417
Problemsheet-2
26
2302020101417
Problemsheet-2
Return_date) Perform insert, delete and update operations
onBook_issue. Display list of students who must return book today.
Code:
BookIssue.as
px:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BookIssue.aspx.cs"
Inherits="LibraryManagementSystem.BookIssue" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="Content\bootstrap.css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<div>
<h1 class="mt-3 text-danger text-center">Library Management
System</h1>
<div class="mx-5 mt-2 p-3 border rounded">
<asp:TextBox ID="txtIssueNo" CssClass="form-control w-50 m-2" runat="server"
Placeholder="Issue No" />
<asp:TextBox ID="txtRollNo" CssClass="form-control w-50 m-2" runat="server"
Placeholder="Roll No" />
<asp:TextBox ID="txtBookNo" CssClass="form-control w-50 m-2" runat="server"
Placeholder="Book No" />
<asp:TextBox ID="txtIssueDate" CssClass="form-control w-50 m-2" runat="server"
Placeholder="Issue Date" />
<asp:TextBox ID="txtReturnDate" CssClass="form-control w-50 m-2" runat="server"
Placeholder="Return Date" />
<asp:Button ID="btnInsert" CssClass="btn btn-success" runat="server" Text="Insert"
OnClick="btnInsert_Click" />
<asp:Button ID="btnUpdate" CssClass="btn btn-warning" runat="server" Text="Update"
OnClick="btnUpdate_Click" />
<asp:Button ID="btnDelete" CssClass="btn btn-danger" runat="server" Text="Delete"
OnClick="btnDelete_Click" />
<asp:Button ID="btnDueToday" CssClass="btn btn-primary" runat="server"
Text="Due Today" OnClick="btnDueToday_Click" /> <asp:Button ID="btnShowList"
CssClass="btn btn-info" runat="server" Text="Show List" OnClick="btnShowList_Click" />
</div>
</form>
27
2302020101417
Problemsheet-2
</body>
</html>
BookIssue.as
px.cs:
using System;
using System.Collections.Generic;
using System.Configuration; using
System.Data.SqlClient; using
System.Data; using System.Linq;
using System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;
namespace LibraryManagementSystem
{
public partial class BookIssue : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connStr =
ConfigurationManager.ConnectionStrings["LibraryDB"].ConnectionString;
conn.Open();
cmd.ExecuteNonQuery();
lblMsg.Text = "Inserted Successfully!";
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data
Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\DotNetProjects\\LibraryManage
mentSystem\\App_Data\\LibraryDB.mdf;Integrated Security=True");
28
2302020101417
Problemsheet-2
SqlCommand cmd = new SqlCommand(query, conn);
cmd.Parameters.AddWithValue("@IssueNo", txtIssueNo.Text);
cmd.Parameters.AddWithValue("@RollNo", txtRollNo.Text);
cmd.Parameters.AddWithValue("@BookNo", txtBookNo.Text);
cmd.Parameters.AddWithValue("@IssueDate", txtIssueDate.Text);
cmd.Parameters.AddWithValue("@ReturnDate", txtReturnDate.Text);
conn.Open(); cmd.ExecuteNonQuery();
lblMsg.Text = "Updated Successfully!";
}
protected void btnDelete_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data
Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\DotNetProjects\\LibraryManage
mentSystem\\App_Data\\LibraryDB.mdf;Integrated Security=True");
conn.Open(); cmd.ExecuteNonQuery();
lblMsg.Text = "Deleted Successfully!";
}
protected void btnDueToday_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data
Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\DotNetProjects\\LibraryManage
mentSystem\\App_Data\\LibraryDB.mdf;Integrated Security=True");
}
protected void btnShowList_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data
Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\DotNetProjects\\LibraryManage
mentSystem\\App_Data\\LibraryDB.mdf;Integrated Security=True");
29
2302020101417
Problemsheet-2
OUTPUT:
30
2302020101417
Problemsheet-2
31
2302020101417
Problemsheet-2
Q.4: Develop a website for online Shaadi.com using proper validations
in which you must implement Login, Registration web page.
(Implement six different validations)
NOTE: IMPLEMENT MASTER PAGE AND MAINTAIN USER’S STATE
ALSO, APPLY VALIDATION.
CODE:
MasterPage.Master:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs"
Inherits="shadidotcom.MasterPage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Shaadi.com - Find Your Match</title>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="Content\bootstrap.css" rel="stylesheet" />
</head>
<body>
<form id="form2" runat="server">
<div class="container-fluid">
<!-- Header -->
<div class="bg-danger text-white p-3 text-center">
<h1>Shaadi.com</h1>
<p>Find Your Perfect Match</p>
</div>
32
2302020101417
Problemsheet-2
</span>
</div>
</div>
</nav>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js
"></script>
</body>
</html>
MasterPage.Master.cs:
using System;
using System.Collections.Generic;
using System.Linq; using
System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;
namespace shadidotcom
{
public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Username"] != null)
{
lblUser.Text = "Welcome, " + Session["Username"].ToString(); btnLogout.Visible =
true;
}
else {
lblUser.Text = ""; btnLogout.Visible = false;
}
}
protected void BtnLogout_Click(object sender, EventArgs e)
{
Session.Clear();
Response.Redirect("Login.aspx");
}
33
2302020101417
Problemsheet-2
Register.aspx:
<%@ Page Title="Register" MasterPageFile="~/MasterPage.master" Language="C#"
AutoEventWireup="true" CodeBehind="Register.aspx.cs"
Inherits="shadidotcom.Register" %>
Register.aspx.cs:
using System;
34
2302020101417
Problemsheet-2
using System.Collections.Generic;
using System.Configuration; using
System.Data.SqlClient; using
System.Drawing; using
System.Linq; using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace shadidotcom
{
public partial class Register : System.Web.UI.Page
{
con.Open();
string checkUser = "SELECT COUNT(*) FROM Users WHERE Email=@Email"; using
(SqlCommand checkCmd = new SqlCommand(checkUser, con))
{
checkCmd.Parameters.AddWithValue("@Email", txtEmail.Text);
cmd.ExecuteNonQuery();
Response.Redirect("Login.aspx");
}
protected void CvEmail_ServerValidate(object source,
System.Web.UI.WebControls.ServerValidateEventArgs args)
{
SqlConnection con = new SqlConnection("Data
Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\DotNetProjects\\shadidotcom\\
App_Data\\shaadiDB.mdf;Integrated Security=True");
35
2302020101417
Problemsheet-2
con.Open();
string query = "SELECT COUNT(*) FROM Users WHERE Email=@Email";
SqlCommand cmd = new SqlCommand(query, con);
cmd.Parameters.AddWithValue("@Email", args.Value); int count =
(int)cmd.ExecuteScalar(); args.IsValid = count == 0;
}
}
Login.aspx:
<%@ Page Title="Login" MasterPageFile="~/MasterPage.master" Language="C#"
AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="shadidotcom.Login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentHolder" runat="server">
<div class="container mt-4">
<h2 class="text-center text-primary">Login</h2>
<div class="col-md-6 mx-auto">
Login.aspx.cs:
using System;
using System.Collections.Generic;
using System.Configuration; using
System.Data.SqlClient; using
System.Linq; using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace shadidotcom
{
36
2302020101417
Problemsheet-2
protected void Page_Load(object sender, EventArgs e)
{
}
protected void BtnLogin_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data
Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\DotNetProjects\\shadidotcom\\
App_Data\\shaadiDB.mdf;Integrated Security=True");
con.Open();
string query = "SELECT Username FROM Users WHERE
Username=@Username AND Password=@Password";
SqlCommand cmd = new SqlCommand(query, con);
cmd.Parameters.AddWithValue("@Username", txtUsername.Text);
cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
Home.aspx:
Home.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq; using
37
2302020101417
Problemsheet-2
System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;
namespace shadidotcom
{
public partial class Home : System.Web.UI.Page
}
}
OUTPUT:
38
2302020101417
Problemsheet-2
Welcome t0 Shaadi.com
Welcome t0 Shaadi.com
39
2302020101417
Problemsheet-2
40
2302020101417