0% found this document useful (0 votes)
7 views

Code

The document outlines the implementation of a login and user registration system using ASP.NET. The login page includes fields for username and password, with validation for input, while the registration page collects user details such as registration ID, full name, email, and mobile number, also with validation. Both pages utilize a SQL database connection for data handling and user authentication.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Code

The document outlines the implementation of a login and user registration system using ASP.NET. The login page includes fields for username and password, with validation for input, while the registration page collects user details such as registration ID, full name, email, and mobile number, also with validation. Both pages utilize a SQL database connection for data handling and user authentication.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 32

1) Login

Aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs"


Inherits="HOSTEL.Login" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
body {
margin: 0;
padding: 0;
}

.auto-style1 {
width: 100%;
border: 2px solid #000000;
margin-left: 0px;
margin-top: 0px;
height: 555px;
}

.auto-style3 {
height: 46px;
width: 510px;
}

.auto-style6 {
height: 46px;
width: 327px;
}

.auto-style8 {
height: 57px;
}

.auto-style9 {
height: 117px;
}

.auto-style10 {
margin-left: 0px;
}

.auto-style13 {
height: 55px;
width: 327px;
}

.auto-style14 {
height: 55px;
width: 510px;
}
.auto-style15 {
height: 86px;
width: 327px;
}

.auto-style16 {
height: 86px;
width: 510px;
}

.auto-style17 {
height: 30px;
width: 327px;
}

.auto-style18 {
height: 30px;
width: 510px;
}

.auto-style19 {
width: 327px;
height: 26px;
}

.auto-style20 {
width: 510px;
height: 26px;
}

.midnightblue-button {
background-color: midnightblue;
color: white;
}

.auto-style21 {
margin-top: 29px;
}

.auto-style23 {
font-weight: bold;
}

.form-container {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.auto-style24 {
width: 9px;
}
</style>
</head>
<body>
<form id="form1" runat="server" class="auto-style10">
<table class="auto-style1">
<tr>
<td class="auto-style24" style="font-family: Algerian; font-size:
xx-large; font-style: inherit; font-variant: normal" rowspan="9">
&nbsp;</td>
<td class="auto-style9" colspan="2" style="font-family: Algerian;
font-size: xx-large; font-style: inherit; font-variant: normal; background-color:
steelblue;">
<asp:Image ID="Image4" runat="server" CssClass="auto-style21"
Height="86px" ImageUrl="~/Images/login.jpg" Width="138px" />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
LOGIN
</td>
</tr>
<tr>
<td class="auto-style19"></td>
<td class="auto-style20"></td>
</tr>
<tr>
<td class="auto-style15">
<asp:Image ID="Image2" runat="server" CssClass="auto-style10"
Height="43px" ImageUrl="~/Images/username.jpg" Width="50px" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong><asp:Label
ID="Label1" runat="server" Text="UserName"></asp:Label>
</strong>
</td>
<td class="auto-style16">
<asp:TextBox ID="TextBox1" runat="server" Height="38px"
Width="326px"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="TextBox1RequiredValidator"
runat="server"
ControlToValidate="TextBox1"
ErrorMessage="Enter UserName"
ForeColor="Red">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style17"></td>
<td class="auto-style18"></td>
</tr>
<tr>
<td class="auto-style13">
<asp:Image ID="Image3" runat="server" Height="54px"
ImageUrl="~/Images/password.png" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong><asp:Label
ID="Label2" runat="server" Text="Password"></asp:Label>
</strong>
</td>
<td class="auto-style14">
<asp:TextBox ID="TextBox2" runat="server" Height="39px"
Width="325px" CssClass="auto-style23"></asp:TextBox>
<br />
<br />
<asp:RegularExpressionValidator
ID="RegularExpressionValidator2" runat="server" ControlToValidate="TextBox2"
ErrorMessage="Password must contain only integers"
ForeColor="Red"
ValidationExpression="^\d+$">
</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="auto-style6"></td>
<td class="auto-style3">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label3" runat="server" Text="label"
Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style8" colspan="2">

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
sp;&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;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Height="56px"
OnClick="Button1_Click" Text="LOGIN" Width="134px" CssClass="midnightblue-button"
/>
</td>
</tr>
<tr>
<td class="auto-style19"></td>
<td class="auto-style20"></td>
</tr>
<tr>
<td class="auto-style19"></td>
<td class="auto-style20"></td>
</tr>
</table>
</form>
</body>
</html>

CS:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace HOSTEL
{
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
SqlConnection connection = new SqlConnection(@"Data Source=(localdb)\
MSSQLLocalDB;Initial Catalog=HOSTEL;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
public void openconnection()
{

if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();

}
}
public void closeconnection()
{
if (connection.State == System.Data.ConnectionState.Open)
{
connection.Close();

}
}
public void executeQuery(String query)
{
try
{
openconnection();
cmd = new SqlCommand(query, connection);
if (cmd.ExecuteNonQuery() == 1)
{
Label3.Text = "Login Successfull";
}
else
{
Label3.Text = "please enter correct username and
password .......";
}

}
catch (Exception ex)
{
Label3.Text = ex.Message;
}
finally
{
closeconnection();
}
}

protected void Button1_Click(object sender, EventArgs e)


{

connection.Open();
String insertquery = "INSERT INTO Login Values('" +
this.TextBox1.Text + "','" + this.TextBox2.Text + "')";

executeQuery(insertquery);
connection.Close();
Response.Redirect("Registration.aspx");

public void cleartexbox()


{
TextBox1.Text = "";
TextBox2.Text = "";
}
}
}

2) User registration

aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Registration.aspx.cs"


Inherits="HOSTEL.Registration" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">

.forestgreen-button {
background-color: forestgreen;
}
.auto-style2 {
width: 99%;
height: 638px;
margin-bottom: 0px;
}
.auto-style5 {
height: 78px;
}
.auto-style6 {
height: 48px;
}
.auto-style7 {
height: 47px;
}
.midnightblue-button {
background-color: midnightblue;
color: white; /* Optionally, set the text color to white for better
visibility */
}
.auto-style8 {
height: 29px;
}
.auto-style9 {
width: 267px;
}
.auto-style10 {
height: 48px;
width: 267px;
}
.auto-style11 {
height: 47px;
width: 267px;
}
.auto-style12 {
height: 29px;
width: 267px;
}
.auto-style17 {
width: 296px;
}
.auto-style18 {
height: 48px;
width: 296px;
}
.auto-style19 {
height: 47px;
width: 296px;
}
.auto-style20 {
height: 29px;
width: 296px;
}
.auto-style22 {
width: 257px;
}
.auto-style23 {
height: 48px;
width: 257px;
}
.auto-style24 {
height: 47px;
width: 257px;
}
.auto-style25 {
height: 29px;
width: 257px;
}
</style>
</head>
<body style="height: 705px; width: 1297px; margin-left: 69px">
<form id="form1" runat="server" style="border: 2px solid black; padding:
10px;">
<table class="auto-style2">
<tr>
<td rowspan="11">
&nbsp;</td>
<td class="auto-style5" colspan="4" style="font-family: Algerian;
font-size: xx-large; font-style: inherit; font-variant: normal; background-
color:mediumvioletred; color: white;">&nbsp;&nbsp;&nbsp;&nbsp;<asp:Image
ID="Image2" runat="server" Height="79px" ImageUrl="~/Images/hostel4.jpg"
Width="162px" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; User
&nbsp;REGISTRATION</td>
</tr>
<tr>
<td class="auto-style9">&nbsp;</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style22">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="auto-style10">
<strong>
<asp:Label ID="Label1" runat="server" Text="Registration
ID"></asp:Label>
</strong>
</td>
<td class="auto-style18">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="TextBox1RequiredValidator"
runat="server"
ControlToValidate="TextBox1"
ErrorMessage="Enter ID"
ForeColor="Red">
</asp:RequiredFieldValidator>
</td>
<td class="auto-style23">
<strong>
&nbsp;
<asp:Label ID="Label7" runat="server"
Text="City"></asp:Label>
</strong>
</td>
<td class="auto-style6">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox7" runat="server"
Height="27px"></asp:TextBox>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server"
ControlToValidate="TextBox7"
ErrorMessage="Enter City"
ForeColor="Red">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style10">
<strong>
<asp:Label ID="Label2" runat="server" Text="Full
Name"></asp:Label>
</strong>
</td>
<td class="auto-style18">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="TextBox2"
ErrorMessage="Enter Full Name"
ForeColor="Red">
</asp:RequiredFieldValidator>
</td>
<td class="auto-style23">
<strong>
&nbsp;<asp:Label ID="Label8" runat="server"
Text="Taluka"></asp:Label>
</strong>
</td>
<td class="auto-style6">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox8" runat="server"></asp:TextBox>

<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

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


ControlToValidate="TextBox8"
ErrorMessage="Enter Taluka"
ForeColor="Red">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style10">
<strong>
<asp:Label ID="Label3" runat="server" Text="Email
ID"></asp:Label>
</strong>
</td>
<td class="auto-style18">
<asp:TextBox ID="TextBox3" runat="server" Height="25px"
Width="168px" TextMode="MultiLine"></asp:TextBox>
<br />
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox3"
ErrorMessage="Please enter a valid email ID" ForeColor="Red"
ValidationExpression="\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\
b">
</asp:RegularExpressionValidator>
</td>
<td class="auto-style23">
<strong>
<asp:Label ID="Label9" runat="server"
Text="District"></asp:Label>
</strong>
</td>
<td class="auto-style6">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox9" runat="server"
Height="25px"></asp:TextBox>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="TextBox9"
ErrorMessage="Enter District"
ForeColor="Red">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style10">
<strong>
<asp:Label ID="Label4" runat="server" Text="Mobile
Number"></asp:Label>
</strong>
</td>
<td class="auto-style18">
<asp:TextBox ID="TextBox4" runat="server"
TextMode="MultiLine" Width="168px" Height="26px"></asp:TextBox>
<br />
<asp:RegularExpressionValidator ID="MobileNumberValidator"
runat="server"
ControlToValidate="TextBox4"
ErrorMessage="Enter Specified Range "
ValidationExpression="^\d{10}$"
ForeColor="Red" />
</td>
<td class="auto-style23">
<strong>
<asp:Label ID="Label10" runat="server"
Text="Pincode"></asp:Label>
</strong>
</td>
<td class="auto-style6">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox10" runat="server" Width="168px"
Height="24px"></asp:TextBox>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator3" runat="server" ControlToValidate="TextBox10"
ErrorMessage=" Pincode must be an 6-digit number"
ForeColor="Red"
ValidationExpression="^\d{6}$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="auto-style11">
<strong>
<asp:Label ID="Label5" runat="server" Text="DOB"></asp:Label>
</strong>
</td>
<td class="auto-style19">
<asp:TextBox ID="TextBox5" runat="server"
type="date"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator6"
runat="server"
ControlToValidate="TextBox5"
ErrorMessage="Select Calender DOB"
ForeColor="Red">
</asp:RequiredFieldValidator>
</td>
<td class="auto-style24"></td>
<td class="auto-style7"></td>
</tr>
<tr>
<td class="auto-style11">
<strong>
<asp:Label ID="Label6" runat="server" Text="Age"></asp:Label>
</strong>
</td>
<td class="auto-style19">
<asp:TextBox ID="TextBox6" runat="server"
Height="25px"></asp:TextBox>
<br />
&nbsp;&nbsp;&nbsp;
<asp:RequiredFieldValidator ID="RequiredFieldValidator7"
runat="server"
ControlToValidate="TextBox6"
ErrorMessage="Enter Age"
ForeColor="Red">
</asp:RequiredFieldValidator>
</td>
<td class="auto-style24">
<asp:Label ID="Label11" runat="server"
Text="Label"></asp:Label>
</td>
<td class="auto-style7"></td>
</tr>
<tr>
<td class="auto-style12"></td>
<td class="auto-style20"></td>
<td class="auto-style25"></td>
<td class="auto-style8"></td>
</tr>
<tr>
<td class="auto-style6"
colspan="4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
sp;&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;&nb
sp;&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;&nb
sp;&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;&nb
sp;&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;&nb
sp;&nbsp;&nbsp; &nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Height="63px"
Text="REGISTER" Width="195px" CssClass="midnightblue-button"
OnClick="Button1_Click1" />
&nbsp; &nbsp;</td>
</tr>
<tr>
<td class="auto-style9">&nbsp;</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style22">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>

CS:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace HOSTEL
{
public partial class Registration : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
SqlConnection connection = new SqlConnection(@"Data Source=(localdb)\
MSSQLLocalDB;Initial Catalog=HOSTEL;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
public void openconnection()
{

if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();

}
}
public void closeconnection()
{
if (connection.State == System.Data.ConnectionState.Open)
{
connection.Close();

}
}
public void executeQuery(String query)
{
try
{
openconnection();
cmd = new SqlCommand(query, connection);
if (cmd.ExecuteNonQuery() == 1)
{
Label11.Text = "Registration Successfull";
}
else
{
Label11.Text = "Query Not Executed";
}

}
catch (Exception ex)
{
Label11.Text = ex.Message;
}
finally
{
closeconnection();
}
}

protected void Button1_Click1(object sender, EventArgs e)


{
connection.Open();
DateTime dateValue;
if (DateTime.TryParse(this.TextBox5.Text, out dateValue))
{
String insertquery = "INSERT INTO Registration Values('" +
Convert.ToInt32(this.TextBox1.Text) + "','" + this.TextBox2.Text + "','" +
this.TextBox3.Text + "','" + Convert.ToInt64(this.TextBox4.Text) + "','" +
dateValue.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
Convert.ToInt32(this.TextBox6.Text) + "','" + this.TextBox7.Text + "','" +
this.TextBox8.Text + "','" + this.TextBox9.Text + "','" +
Convert.ToInt32(this.TextBox10.Text) + "')";
executeQuery(insertquery);
connection.Close();

}
Response.Redirect("hostelhighlights.aspx");
}
public void cleartexbox()
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = " ";
TextBox5.Text = " ";
TextBox6.Text = " ";
TextBox7.Text = " ";
TextBox8.Text = " ";
TextBox9.Text = " ";
TextBox10.Text = " ";
}

3) Room related details


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="roominfo.aspx.cs"
Inherits="HOSTEL.roominfo" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
body {
margin: 0;
padding: 0;
}

.auto-style1 {
width: 100%;
border: 2px solid #000000;
margin-left: 0px;
margin-top: 0px;
height: 555px;
}

.auto-style9 {
height: 117px;
}

.auto-style10 {
margin-left: 0px;
}

.auto-style19 {
width: 173px;
height: 26px;
}

.auto-style20 {
width: 510px;
height: 26px;
}

.midnightblue-button {
background-color: midnightblue;
color: white;
}

.auto-style21 {
margin-top: 29px;
}

.form-container {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.auto-style35 {
width: 173px;
height: 39px;
}
.auto-style36 {
width: 510px;
height: 39px;
}
.auto-style37 {
width: 173px;
height: 38px;
}
.auto-style38 {
width: 510px;
height: 38px;
}
.auto-style39 {
width: 173px;
height: 40px;
}
.auto-style40 {
width: 510px;
height: 40px;
}
.auto-style41 {
height: 26px;
}
.auto-style42 {
width: 8px;
}
.auto-style43 {
margin-bottom: 23px;
}
.auto-style44 {
margin-bottom: 9px;
}
</style>
</head>
<body>
<form id="form1" runat="server" class="auto-style10">
<table class="auto-style1">
<tr>
<td style="font-family: Algerian; font-size: xx-large; font-
style: inherit; font-variant: normal" rowspan="16" class="auto-style42">
&nbsp;</td>
<td class="auto-style9" colspan="2" style="font-family: Algerian;
font-size: xx-large; font-style: inherit; font-variant: normal; background-color:
lightskyblue;">
<asp:Image ID="Image4" runat="server" CssClass="auto-style21"
Height="86px" ImageUrl="~/Images/hotel1.jpg" Width="138px" />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;roo
m related information</td>
</tr>
<tr>
<td class="auto-style19"></td>
<td class="auto-style20"></td>
</tr>
<tr>
<td class="auto-style35">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong><asp:Label
ID="Label1" runat="server" Text="Room No"></asp:Label>
</strong>
</td>
<td class="auto-style36">
<asp:TextBox ID="TextBox1" runat="server" Height="27px"
Width="162px" CssClass="auto-style44"></asp:TextBox>
<br />
</td>
</tr>
<tr>
<td class="auto-style35"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label2" runat="server"
Text="Seater"></asp:Label>
</strong></td>
<td class="auto-style36">
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style37"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label3" runat="server" Text="Food
Status"></asp:Label>
</strong></td>
<td class="auto-style38">
<strong>
<asp:RadioButton ID="RadioButton1" runat="server"
Text="Without Food" OnCheckedChanged="RadioButton1_CheckedChanged" />
</strong>&nbsp;&nbsp;&nbsp; <strong>
<asp:RadioButton ID="RadioButton2" runat="server" Text="With
Food(Rs2000 per month extra)" OnCheckedChanged="RadioButton2_CheckedChanged" />
</strong>
<asp:TextBox ID="TextBox13" runat="server"
Visible="False"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style37"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label4" runat="server" Text="Applay
Date"></asp:Label>
</strong></td>
<td class="auto-style38">
<asp:TextBox ID="TextBox3" runat="server" CssClass="auto-
style43" type="date" Height="25px" Width="159px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style35"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label6" runat="server" Text="Stay
Date"></asp:Label>
</strong></td>
<td class="auto-style36">
<asp:TextBox ID="TextBox5" runat="server" type="date"
Height="25px" Width="154px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style39"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label7" runat="server"
Text="Duration"></asp:Label>
</strong></td>
<td class="auto-style40">
<asp:TextBox ID="TextBox6" runat="server" Height="26px"
Width="155px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style39"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label10" runat="server" Text="Food
Fees"></asp:Label>
</strong></td>
<td class="auto-style40">
<asp:TextBox ID="TextBox8" runat="server" Height="25px"
Width="152px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style39"><strong>&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label11" runat="server" Text="Hostel
Fees"></asp:Label>
</strong></td>
<td class="auto-style40">
<asp:TextBox ID="TextBox9" runat="server" Height="24px"
Width="149px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style39"><strong>&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label12" runat="server" Text="Monthy
Fees"></asp:Label>
</strong></td>
<td class="auto-style40">
<asp:TextBox ID="TextBox10" runat="server" Height="25px"
Width="147px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style39"><strong>&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label14" runat="server" Text="Total
Fees"></asp:Label>
</strong></td>
<td class="auto-style40">
<asp:TextBox ID="TextBox12" runat="server" Height="25px"
Width="148px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style39">&nbsp;</td>
<td class="auto-style40">
&nbsp;</td>
</tr>
<tr>
<td class="auto-style41"
colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
sp;&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; <strong>
<asp:Button ID="Button1" runat="server" BackColor="#003399"
ForeColor="White" Height="51px" Text="SUBMIT" Width="127px"
OnClick="Button1_Click" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </strong>
<asp:Label ID="Label9" runat="server"
Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style19"></td>
<td class="auto-style20"></td>
</tr>
<tr>
<td class="auto-style41"
colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
</tr>
</table>
</form>
</body>
</html>

CS:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace HOSTEL
{
public partial class roominfo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
SqlConnection connection = new SqlConnection(@"Data Source=(localdb)\
MSSQLLocalDB;Initial Catalog=HOSTEL;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
public void openconnection()
{

if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
}
public void closeconnection()
{
if (connection.State == System.Data.ConnectionState.Open)
{
connection.Close();

}
}
public void executeQuery(String query)
{
try
{
openconnection();
cmd = new SqlCommand(query, connection);
if (cmd.ExecuteNonQuery() == 1)
{
Label9.Text = "Payment Successfull";
}
else
{
Label9.Text = "Enable to Pay";
}

}
catch (Exception ex)
{
Label9.Text = ex.Message;
}
finally
{
closeconnection();
}
}

protected void Button1_Click(object sender, EventArgs e)


{
DateTime dateValue3, dateValue5;

// Try parsing the values from TextBox3 and TextBox5


if (DateTime.TryParse(this.TextBox3.Text, out dateValue3) &&
DateTime.TryParse(this.TextBox5.Text, out dateValue5))
{
// Use only the date part (yyyy-MM-dd) for both TextBox3 and
TextBox5
string dateFormatted3 = dateValue3.ToString("yyyy-MM-dd");
string dateFormatted5 = dateValue5.ToString("yyyy-MM-dd");

// Construct the insert query with formatted dates


string insertquery = "INSERT INTO roominfo VALUES('"
+ Convert.ToInt32(this.TextBox1.Text) + "','"
+ Convert.ToInt32(this.TextBox7.Text) + "','"
+ this.TextBox13.Text + "','"
+ dateFormatted3 + "','" // Applay Date
+ dateFormatted5 + "','" // Stay Date
+ this.TextBox6.Text + "','"
+ Convert.ToInt32(this.TextBox8.Text) + "','"
+ Convert.ToInt32(this.TextBox9.Text) + "','"
+ Convert.ToInt32(this.TextBox10.Text) + "','"
+ Convert.ToInt32(this.TextBox12.Text) + "')";

// Execute the query


executeQuery(insertquery);

// Redirect after insertion


Response.Redirect("Requi.aspx");
}
}

protected void RadioButton1_CheckedChanged(object sender, EventArgs e)


{
if (RadioButton1.Checked == true)
{
TextBox13.Text = "Without Food";
}
}

protected void RadioButton2_CheckedChanged(object sender, EventArgs e)


{
if (RadioButton1.Checked == true)
{
TextBox13.Text = "With Food(Rs2000 per month extra)";
}
}
}
}
4) <%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="hostelhighlights.aspx.cs" Inherits="HOSTEL.hostelhighlights" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
margin-left: 0px;
margin-right: 0px;
}
.auto-style5 {
height: 51px;
width: 1198px;
}
.auto-style7 {
width: 1198px;
height: 39px;
}
.auto-style8 {
height: 26px;
width: 1198px;
}
.auto-style10 {
height: 60px;
width: 1198px;
}
.midnightblue-button {
background-color: midnightblue;
color: white; /* Optionally, set the text color to white for better
visibility */
}
.auto-style11 {
height: 20px;
width: 1198px;
}
.auto-style12 {
height: 15px;
width: 1198px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" CssClass="auto-style1"
Heght="1087px" ImageUrl="~/Images/hostel.jpg" Width="1190px" style="border: 2px
solid black;">
<table>
<tr>
<td style="font-family: Algerian; font-size: xx-large;
font-style: inherit; font-variant: normal" class="auto-
style8">&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;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
</tr>
<tr>
<td style="font-family: Algerian; font-size: xx-large;
font-style: inherit; font-variant: normal; background-color: midnightblue; color:
white;" class="auto-style7">&nbsp;&nbsp; Hostel Highlights</td>
</tr>
<tr>
<td style="font-family: Algerian; font-size: xx-large;
font-style: inherit; font-variant: normal" class="auto-style8"></td>
</tr>
<tr>
<td style="font-family: inherit; font-variant: normal;
background-color: darkred;" class="auto-style5">
&nbsp;&nbsp;&nbsp;
<strong>
<asp:Label ID="Label1" runat="server"
Text="HOSTEL FACILITIES" ForeColor="White"></asp:Label>
</strong>
</td>
</tr>
<tr>
<td class="auto-style11" style="font-family:inherit;
font-variant: normal"></td>
</tr>
<tr>
<td style="font-family: inherit; font-variant: normal;
background-color: #96b6d8;" class="auto-style5">
&nbsp;
<strong>
<asp:Label ID="Label2" runat="server" Text="1.
24/7 WiFi" ForeColor="Black"></asp:Label>
</strong>
</td>
</tr>
<tr>
<td class="auto-style11" style="font-family: inherit;
font-variant: normal"></td>
</tr>
<tr>
<td class="auto-style5" style="font-family: inherit;
background-color: #96b6d8;">
<strong>&nbsp;
<asp:Label ID="Label3" runat="server" Text="2.
Spacious Rooms"></asp:Label>
</strong>
</td>
</tr>
<tr>
<td class="auto-style11" style="font-family: inherit;
font-variant: normal"></td>
</tr>
<tr>
<td style="font-family: inherit; font-variant: normal;
background-color: darkred;" class="auto-style5">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<strong>
<asp:Label ID="Label4" runat="server"
Text="ADDITIONAL SERVICES" ForeColor="White"></asp:Label>
</strong>
</td>
</tr>
<tr>
<td class="auto-style11" style="font-family: inherit;
font-variant: normal"></td>
</tr>
<tr>
<td style="font-family: inherit; font-variant: normal;
background-color: #96b6d8;">
<strong>
<asp:Label ID="Label5" runat="server" Text="1.
Laundry Service"></asp:Label>
</strong>
</td>
</tr>
<tr>
<td class="auto-style11" style="font-family: inherit;
font-variant: normal"></td>
</tr>
<tr>
<td style="font-family: inherit; font-variant: normal;
background-color: #96b6d8;">
<strong>
<asp:Label ID="Label6" runat="server" Text="2.
Security & CCTV Surveillance"></asp:Label>
</strong>
</td>
</tr>
<tr>
<td class="auto-style12" style="font-family: inherit;
font-variant: normal"></td>
</tr>
<tr>
<td style="font-family: inherit; font-variant: normal;
background-color: #96b6d8;">
<strong>
<asp:Label ID="Label7" runat="server" Text="3.
Common Room & Entertainment"></asp:Label>
</strong>
</td>
</tr>
<tr>
<td class="auto-style11" style="font-family: inherit;
font-variant: normal"></td>
</tr>
<tr>
<td class="auto-style10" style="font-family: inherit;
font-variant:
normal">&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;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<strong>
<asp:Button ID="Button1" runat="server"
CssClass="midnightblue-button" Height="56px" Text="NEXT" Width="158px"
OnClick="Button1_Click" />
</strong>&nbsp;</td>
</tr>
<tr>
<td class="auto-style8" style="font-family: inherit;
font-variant: normal">&nbsp;</td>
</tr>
</table>
</asp:Panel>
</div>
</form>
</body>
</html>

CS:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HOSTEL
{
public partial class hostelhighlights : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}

protected void Button1_Click(object sender, EventArgs e)


{
Response.Redirect("roominfo.aspx");
}
}
}

5) Payment:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="payment.aspx.cs"


Inherits="HOSTEL.payment" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
margin-left: 9px;
}
.auto-style2 {
width: 100%;
}
.auto-style3 {
height: 52px;
}
.auto-style12 {
width: 258px;
}
.auto-style13 {
height: 52px;
width: 258px;
}
.auto-style14 {
width: 268px;
}
.auto-style15 {
height: 52px;
width: 268px;
}
.auto-style16 {
width: 292px;
}
.auto-style17 {
height: 52px;
width: 292px;
}
.auto-style18 {
width: 258px;
height: 49px;
}
.auto-style19 {
width: 268px;
height: 49px;
}
.auto-style20 {
width: 292px;
height: 49px;
}
.auto-style21 {
height: 49px;
}
.midnightblue-button {
background-color: midnightblue;
color: white; /* Optionally, set the text color to white for better
visibility */
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" CssClass="auto-style1"
Height="1266px" Width="1044px" style="border: 2px solid black;">
<table class="auto-style2">
<tr>
<td class="auto-style3" colspan="4" style="font-family:
Algerian; font-size: xx-large; font-style: inherit; font-variant: normal;
background-color: midnightblue; color: white;"
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&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;ON
LINE PAYMENT</td>
</tr>
<tr>
<td class="auto-style12"></td>
<td class="auto-style14"></td>
<td class="auto-style16"></td>
<td></td>
</tr>
<tr>
<td class="auto-style3" colspan="4" style="font-family:
Algerian; font-size: x-large; background-color: deepskyblue; color:
white;">&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;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Select Payment Option</td>
</tr>
<tr>
<td class="auto-style12"></td>
<td class="auto-style14"></td>
<td class="auto-style16"></td>
<td></td>
</tr>
<tr>
<td class="auto-style18"><strong>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
sp;&nbsp;
<asp:Label ID="Label8" runat="server" Text="Payment
Option"></asp:Label>
</strong></td>
<td class="auto-style19">
<asp:TextBox ID="TextBox7" runat="server"
Visible="False"></asp:TextBox>
</td>
<td class="auto-style20"></td>
<td class="auto-style21"></td>
</tr>
<tr>
<td class="auto-style13">
<asp:Image ID="Image5" runat="server" Height="91px"
ImageUrl="~/Images/credit.jpg" Width="116px" />
<br />
<strong>
<asp:RadioButton ID="RadioButton1" runat="server"
Text="Credit Card" OnCheckedChanged="RadioButton1_CheckedChanged" />
&nbsp;&nbsp;&nbsp;&nbsp;
</strong>
</td>
<td class="auto-style15">
<asp:Image ID="Image6" runat="server" Height="91px"
ImageUrl="~/Images/netbanking.jpg" Width="116px" />
<br />
<strong>
<asp:RadioButton ID="RadioButton2" runat="server"
Text="Net Banking" OnCheckedChanged="RadioButton2_CheckedChanged" />
&nbsp;&nbsp;
</strong>
</td>
<td class="auto-style17">
<asp:Image ID="Image7" runat="server" Height="91px"
ImageUrl="~/Images/paypal.jpg" Width="116px" />
<br />
<strong>
<asp:RadioButton ID="RadioButton3" runat="server"
Text="PayPal" OnCheckedChanged="RadioButton3_CheckedChanged" />
&nbsp;<br /> &nbsp;&nbsp;
</strong>
</td>
<td class="auto-style3">
<asp:Image ID="Image8" runat="server" Height="91px"
ImageUrl="C:\asp.net\RRS\RRS\RRS\Images\debit.jpg" Width="116px" />
<br />
<strong>
<asp:RadioButton ID="RadioButton4" runat="server"
Text="Debit Card" OnCheckedChanged="RadioButton4_CheckedChanged" />
&nbsp;
<br />
&nbsp;</strong></td>
</tr>
<tr>
<td class="auto-style13">&nbsp;</td>
<td class="auto-style15">&nbsp;</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style3" colspan="4" style="font-family:
Algerian; font-size: x-large; background-color: deepskyblue; color:
white;">&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;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Personal
Information</td>
</tr>
<tr>
<td class="auto-style13">&nbsp;</td>
<td class="auto-style15">&nbsp;</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style13">
<strong>
<asp:Label ID="Label1" runat="server" Text="Email
Address"></asp:Label>
</strong>
</td>
<td class="auto-style15">
<asp:TextBox ID="TextBox1" runat="server"
Height="28px" Width="168px" TextMode="MultiLine"></asp:TextBox>
<br />
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="Please enter a valid email address" ForeColor="Red"
ValidationExpression="\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\
b">
</asp:RegularExpressionValidator>
</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style13">
<strong>
<asp:Label ID="Label2" runat="server" Text="Full
Name"></asp:Label>
</strong>
</td>
<td class="auto-style15">
<asp:TextBox ID="TextBox2" runat="server"
Height="28px" TextMode="MultiLine" Width="169px"></asp:TextBox>
</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style13">&nbsp;</td>
<td class="auto-style15">&nbsp;</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style3" colspan="4" style="font-family:
Algerian; font-size: x-large; background-color: deepskyblue; color:
white;">&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;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Credit Card
Information</td>
</tr>
<tr>
<td class="auto-style13">&nbsp;</td>
<td class="auto-style15">&nbsp;</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style13"><strong>
<asp:Label ID="Label3" runat="server"
Text="CardHolder Name"></asp:Label>
</strong></td>
<td class="auto-style15">&nbsp;</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style3" colspan="2">
<asp:TextBox ID="TextBox3" runat="server"
Width="168px" Height="27px" TextMode="MultiLine"></asp:TextBox>
</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style13"><strong>
<asp:Label ID="Label4" runat="server" Text="Card
Number"></asp:Label>
</strong></td>
<td class="auto-style15">&nbsp;</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style3" colspan="2">
<asp:TextBox ID="TextBox4" runat="server"
Width="170px" Height="28px" TextMode="MultiLine"></asp:TextBox>
</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style13"></td>
<td class="auto-style15"></td>
<td class="auto-style17"></td>
<td class="auto-style3"></td>
</tr>
<tr>
<td class="auto-style13"><strong>
<asp:Label ID="Label5" runat="server" Text="CVV
Number"></asp:Label>
</strong></td>
<td class="auto-style15">
<asp:TextBox ID="TextBox5" runat="server"
Width="171px" Height="29px"></asp:TextBox>
<br />
&nbsp;<asp:RangeValidator ID="RangeValidator1"
runat="server" ControlToValidate="TextBox5"
ErrorMessage="Enter value in specified range" ForeColor="Red"
MaximumValue="999" MinimumValue="100"
SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style13"><strong>
<asp:Label ID="Label6" runat="server" Text=" Total
Rs."></asp:Label>
</strong></td>
<td class="auto-style15">
<asp:TextBox ID="TextBox6" runat="server"
Height="29px" Width="171px"></asp:TextBox>
</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style13"></td>
<td class="auto-style15">
<asp:Button ID="Button1" runat="server" Height="46px"
Text="PAY" Width="130px" CssClass="midnightblue-button"
OnClick="Button1_Click"/>
</td>
<td class="auto-style17">
<asp:Label ID="Label9" runat="server"
Text="Label"></asp:Label>
</td>
<td class="auto-style3"></td>
</tr>
<tr>
<td class="auto-style13">&nbsp;</td>
<td class="auto-style15">&nbsp;</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
<tr>
<td class="auto-style13">&nbsp;</td>
<td class="auto-style15">&nbsp;</td>
<td class="auto-style17">&nbsp;</td>
<td class="auto-style3">&nbsp;</td>
</tr>
</table>
</asp:Panel>
</div>
</form>
</body>
</html>

CS:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace HOSTEL
{
public partial class payment : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
SqlConnection connection = new SqlConnection(@"Data Source=(localdb)\
MSSQLLocalDB;Initial Catalog=HOSTEL;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
public void openconnection()
{

if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();

}
}
public void closeconnection()
{
if (connection.State == System.Data.ConnectionState.Open)
{
connection.Close();

}
}
public void executeQuery(String query)
{
try
{
openconnection();
cmd = new SqlCommand(query, connection);
if (cmd.ExecuteNonQuery() == 1)
{
Label9.Text = "Payment Successfull";
}
else
{
Label9.Text = "Enable to Pay";
}

}
catch (Exception ex)
{
Label9.Text = ex.Message;
}
finally
{
closeconnection();
}
}

protected void Button1_Click(object sender, EventArgs e)


{
connection.Open();
String insertquery = "INSERT INTO Payment VALUES('" +
this.TextBox7.Text + "','" + this.TextBox1.Text + "','" + this.TextBox2.Text +
"','" + this.TextBox3.Text + "','" + Convert.ToInt64(this.TextBox4.Text) + "','"
+ Convert.ToInt32(this.TextBox5.Text) + "','" +
Convert.ToInt32(this.TextBox6.Text) + "')";

executeQuery(insertquery);
connection.Close();https://localhost:44314/payment.aspx.cs
Response.Redirect("PreviousQue.aspx");
}

protected void RadioButton1_CheckedChanged(object sender, EventArgs e)


{
if (RadioButton1.Checked == true)
{
TextBox7.Text = "Credit Card";
}
}

protected void RadioButton2_CheckedChanged(object sender, EventArgs e)


{
if (RadioButton2.Checked == true)
{
TextBox7.Text = "Net Banking";
}
}

protected void RadioButton3_CheckedChanged(object sender, EventArgs e)


{
if (RadioButton3.Checked == true)
{
TextBox7.Text = "PayPal";
}
}

protected void RadioButton4_CheckedChanged(object sender, EventArgs e)


{
if (RadioButton4.Checked == true)
{
TextBox7.Text = "Debit Card";
}
}

}
}

You might also like