Lab Report - Food Reservation System

Objective

To create a web-based food reservation system using ASP.NET and VB.NET that utilizes cookies to store and retrieve customer information.

Code Files

1. CustomerCookie.aspx

This file contains the front-end design of the Food Reservation System, including the form and styling.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="CustomerCookie.aspx.vb" Inherits="CustomerCookie" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Food Reservation System</title>
    <style>
        /* General Body Styles */
        body, html {
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
            font-family: 'Arial', sans-serif;
            color: #333;
            line-height: 1.6;
        }

        /* Header Styles */
        .header {
            background-color: #FF6347; /* Tomato Red */
            color: white;
            text-align: center;
            font-size: 36px;
            padding: 30px 0;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        /* Form Styling */
        #form1 {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 30px;
            gap: 20px;
        }

        label {
            font-weight: 600;
            color: #FF6347; /* Tomato Red */
            font-size: 18px;
        }

        .textbox {
            padding: 12px;
            width: 100%;
            max-width: 350px;
            border-radius: 8px;
            border: 1px solid #ccc;
            font-size: 16px;
            margin-top: 5px;
            box-sizing: border-box;
            transition: all 0.3s ease;
        }

        .textbox:focus {
            outline: none;
            border-color: #FF6347;
            box-shadow: 0 0 5px rgba(255, 99, 71, 0.6);
        }

        .messageBox {
            background-color: #fff8e1; /* Light yellow */
            padding: 15px;
            border-radius: 8px;
            width: 100%;
            max-width: 400px;
            text-align: center;
            font-size: 18px;
            border: 1px solid #FF6347;
        }

        .button {
            padding: 12px 25px;
            background-color: #FF6347;
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 18px;
            transition: all 0.3s ease;
            box-sizing: border-box;
        }

        .button:hover {
            background-color: #e55347; /* Darker red */
            transform: translateY(-2px);
        }

        .button:active {
            transform: translateY(2px);
        }

        /* Responsive Styling */
        @media (max-width: 600px) {
            .header {
                font-size: 28px;
                padding: 20px 0;
            }

            .textbox, .button {
                width: 90%;
            }
        }
    </style>
</head>
<body>
    <div class="header">Food Reservation System</div>

    <form id="form1" runat="server">
        <asp:Label ID="lblMessage" runat="server" CssClass="messageBox" Text="Welcome to the Food Reservation System!"></asp:Label>

        <div class="form-container">
            <label for="txtName">Enter your Name:</label>
            <asp:TextBox ID="txtName" runat="server" CssClass="textbox" placeholder="Your Name" />
        </div>

        <asp:Button ID="btnCreateCookie" runat="server" Text="Reserve Table" CssClass="button" OnClick="btnCreateCookie_Click" />
    </form>
</body>
</html>
        

2. CustomerCookie.aspx.vb

This file contains the back-end logic for handling cookies and displaying personalized messages.

Imports System.Web

Partial Class CustomerCookie
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        ' Check if the cookie already exists
        If Request.Cookies("CustomerName") IsNot Nothing Then
            ' If cookie exists, display the name stored in the cookie
            lblMessage.Text = "Welcome back, " & Request.Cookies("CustomerName").Value
        End If
    End Sub

    Protected Sub btnCreateCookie_Click(sender As Object, e As EventArgs)
        ' Check if the user has entered a name
        If Not String.IsNullOrEmpty(txtName.Text) Then
            ' Create a new cookie for the customer with their name
            Dim customerCookie As New HttpCookie("CustomerName")
            customerCookie.Value = txtName.Text
            customerCookie.Expires = DateTime.Now.AddDays(30) ' Set the cookie to expire in 30 days

            ' Add the cookie to the response
            Response.Cookies.Add(customerCookie)

            ' Display a personalized message
            lblMessage.Text = "Hello, " & txtName.Text & "! Your reservation is confirmed."
        Else
            ' If no name is entered, display an error message
            lblMessage.Text = "Please enter your name to proceed."
        End If
    End Sub
End Class
        

Summary

The project demonstrates the use of ASP.NET and VB.NET to create a simple food reservation system. The system uses cookies to store and retrieve customer names, providing a personalized experience for returning users.

Web hosting by Somee.com