You are on page 1of 21

Restaurant Input Menu With ASP.

NET

Group 6

Names : -Muhartsal Raihan

-Hafizh Zaldy Alviansyah

Class : 4WD1

CEP CCIT

FAKULTAS TEKNIK UNIVERSITAS INDONESIA

2021
PROJECT ON

Restaurant Input Menu With ASP.NET

Developed by

1. Muhartsal Raihan
2. Hafizh Zaldy Alviansyah

2
Restaurant Input Menu With ASP.NET

Batch Code : -

Start Date : 09/05/2022


End Date : 19/05/2022

Name of Faculty : Indah Ayu

Names of Developer :

1. Muhartsal Raihan
2. Hafizh Zaldy Alviansyah

Date of Submission: 20/05/2022

3
CERTIFICATE

This is to certify that this report titled “Restaurant Input Menu With ASP.NET“ embodies
the original work done by Muhartsal Raihan and Hafizh Zaldy Alviansyah. Project in
partial fulfillment of their course requirement at NIIT.

Coordinator:

Indah Ayu

4
ACKNOWLEDGEMENT

Praise and gratitude the author goes to the presence of God Almighty for His blessings
and grace, we were able to complete this project task both in the form of presentations and
papers on time.

The author also thanks Indah Ayu and other lecturers for all their guidance to
complete it. Thank you to fellow students who have supported, and also thank you to fellow
education staff at CCIT-FT UI. Project Paper entitled “Restaurant Input Menu With ASP.Net”
which the author submitted as a requirement for Project assignment in 2022.

Finally, the author hopes that this paper can be useful for all and also add a better
insight into the operating system. The author realizes that it is still not perfect. Therefore, the
author expects all suggestions and criticisms from readers that are constructive for the
perfection of this paper. Hopefully this paper can provide many benefits for readers.

5
System Analysis

System summary:
Restaurant Input Menu is an ASP.Net based program from Visual Studio Community
2017.With this Restaurant Input Menu program, users can add new restaurant menus and can
change the contents of the existing food menu list. This program uses a programming
language that combines ASP and XHTML to get more structured and ordered coding results.

To get a more attractive web appearance, we use an open source html, css, java script
framework from bootstrap to design responsive websites easily and quickly.

Before using this program, the user is required to enter login authentication on the
login page. If the user has successfully entered the login identity, then they will be directed to
the product filling page. On the product filling page, users are required to fill in complete
restaurant menu data, such as ID, menu name, menu category, and menu entry date.
If you have filled in the complete data, press the save button to save the data. Then the newly
entered product data will appear at the bottom of the website.

6
LOGIN IMPLEMENTATION

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.Configuration;
using System.Data;

namespace WebsiteCth
{
public partial class Login : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["myCon"].ConnectionString;

protected void Page_Load(object sender, EventArgs e)


{
}

protected void Button1_Click(object sender, EventArgs e)


{
SqlConnection sqlconn = new SqlConnection(connStr);
sqlconn.Open();
DataTable dt = new DataTable();

SqlCommand myCommand = new SqlCommand("select * from Login where UserID = @UserID and
Passwd=@Passwd", sqlconn);
SqlDataAdapter sda = new SqlDataAdapter(myCommand);
myCommand.Parameters.Add(new SqlParameter("@UserID", SqlDbType.VarChar, 25));
myCommand.Parameters.Add(new SqlParameter("@Passwd", SqlDbType.VarChar, 25));
r
myCommand.Parameters["@UserID"].Value = TextBox1.Text;
myCommand.Parameters["@Passwd"].Value = TextBox2.Text;

sda.Fill(dt);
int i = myCommand.ExecuteNonQuery();
if (dt.Rows.Count > 0)
{
a Session["UserID"] = TextBox1.Text;
Response.Redirect("Product.aspx");
Session.RemoveAll();
}
else
{
TextBox1.Text = "";
Response.Write("<script>alert('User Name or Password Incorrect')</script>");
}
sqlconn.Close();
}
}
}

7
PRODUCT IMPLEMENTATION

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.Configuration;
using System.Data;

namespace WebsiteCth
{
public partial class Product : System.Web.UI.Page
{
string connStr =
ConfigurationManager.ConnectionStrings["myCon"].ConnectionString;

protected void Page_Load(object sender, EventArgs e)


{
if (Session["UserID"] == null)
{
Response.Redirect("Login.aspx");
}

if (!IsPostBack)
{
DisplayRecord();
isiDropDownList();
TextBox1.Text = generateID();
Label8.Text = (string)Session["UserID"];
}
}

protected void Calendar1_SelectionChanged(object sender, EventArgs e)


{
TextBox5.Text = Calendar1.SelectedDate.ToShortDateString();
}

8
protected void Button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection sqlconn = new SqlConnection(connStr);
SqlCommand sqlinsert = new SqlCommand("insert into Product values(@ProductID,
@ProductName, @ProductPrice, @ProductCategory, @TotalProduct, @DateIn)", sqlconn);

sqlconn.Open();

sqlinsert.Parameters.Add(new SqlParameter("@ProductID", SqlDbType.VarChar,


5));
sqlinsert.Parameters.Add(new SqlParameter("@ProductName", SqlDbType.VarChar,
50));
sqlinsert.Parameters.Add(new SqlParameter("@ProductPrice", SqlDbType.Money));
sqlinsert.Parameters.Add(new SqlParameter("@ProductCategory",
SqlDbType.VarChar, 50));
sqlinsert.Parameters.Add(new SqlParameter("@TotalProduct", SqlDbType.Int));
sqlinsert.Parameters.Add(new SqlParameter("@DateIn",
SqlDbType.SmallDateTime));

sqlinsert.Parameters["@ProductID"].Value = TextBox1.Text;
sqlinsert.Parameters["@ProductName"].Value = TextBox2.Text;
sqlinsert.Parameters["@ProductPrice"].Value = Convert.ToInt32(TextBox3.Text);
//sqlinsert.Parameters["@ProductCategory"].Value =
DropDownList1.SelectedValue;
sqlinsert.Parameters["@ProductCategory"].Value = TextBox6.Text;
sqlinsert.Parameters["@TotalProduct"].Value =
Convert.ToInt32(TextBox4.Text); ;
sqlinsert.Parameters["@DateIn"].Value = TextBox5.Text;

sqlinsert.ExecuteNonQuery();
sqlconn.Close();
Response.Write("<script>alert('Sukses')</script>");
clearData();
TextBox1.Text = generateID();
DisplayRecord();

}
catch (Exception ex)
{
string msg = "Insert Error:";
msg += ex.Message;
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", "alert('" +
ex.Message + "');", true);
}
}

9
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("DetailProduct.aspx");
}

protected void isiDropDownList()


{
DropDownList1.Items.Add(new ListItem("--Select Category--", ""));
DropDownList1.AppendDataBoundItems = true;

SqlConnection con = new SqlConnection(connStr);


SqlCommand cmd = new SqlCommand("select * from Category", con);

try
{
con.Open();
DropDownList1.DataSource = cmd.ExecuteReader();
DropDownList1.DataTextField = "IDCategory";
DropDownList1.DataValueField = "IDCategory";
DropDownList1.DataBind();
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}

10
protected string generateID()
{
string sID = null;
int ID = 0;
SqlConnection sqlconn = new SqlConnection(connStr);
sqlconn.Open();
DataTable dt = new DataTable();
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("select TOP 1 ProductID from Product
order by ProductID DESC", sqlconn);

myReader = myCommand.ExecuteReader();

if (myReader.Read())
{
sID = (myReader["ProductID"].ToString());
ID = Convert.ToInt32(sID.Substring(1, 4));
ID += 1;

if (ID <= 9)
{
sID = "P000" + ID;
}
else if (ID <= 99)
{
sID = "P00" + ID;
}
else if (ID <= 999)
{
sID = "P0" + ID;
}
else
{
sID = "P" + ID;
}
}
else
{
sID = "P0001";
}
sqlconn.Close();
return sID;
}

11
protected void clearData()
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
DropDownList1.SelectedIndex = 0;
}

public DataTable DisplayRecord()


{
SqlDataAdapter Adp = new SqlDataAdapter("select * from Product", connStr);
DataTable Dt = new DataTable();
Adp.Fill(Dt);
grid1.DataSource = Dt;
grid1.DataBind();
return Dt;
}

protected void OnRowEditing(object sender, GridViewEditEventArgs e)


{
GridViewRow row = grid1.Rows[e.NewEditIndex];
string ProductID = grid1.DataKeys[e.NewEditIndex].Values[0].ToString();
Response.Redirect("UpdateProduct.aspx?ID=" + ProductID);
}

protected void grid1_PageIndexChanging(object sender, GridViewPageEventArgs e)


{
grid1.PageIndex = e.NewPageIndex;
DisplayRecord();
}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)


{
SqlConnection con = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("select CategoryName from Category where
IDCategory=@IDCategory", con);

cmd.Parameters.Add(new SqlParameter("@IDCategory", SqlDbType.VarChar,5));


cmd.Parameters["@IDCategory"].Value = DropDownList1.SelectedItem.Value;

con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
TextBox6.Text = sdr[0].ToString();
}

12
PRODUCT DETAIL IMPLEMENTATION

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.Configuration;
using System.Data;

namespace WebsiteCth
{
public partial class DetailProduct : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["myCon"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserID"] == null)
Response.Redirect("Login.aspx");
if (!IsPostBack)
{
DisplayRecord();
}
}
public DataTable DisplayRecord()
{
SqlDataAdapter Adp = new SqlDataAdapter("select * from Product", connStr);
DataTable Dt = new DataTable();
Adp.Fill(Dt);
grid1.DataSource = Dt;
grid1.DataBind();
return Dt;
}
protected void OnRowEditing(object sender, GridViewEditEventArgs e)
{
GridViewRow row = grid1.Rows[e.NewEditIndex];
int ProductID = Convert.ToInt32(grid1.DataKeys[e.NewEditIndex].Values[0]);
Response.Redirect("UpdateProduct.aspx?ID="+ProductID);
}

protected void grid1_SelectedIndexChanged(object sender, EventArgs e)


{
GridViewRow row = grid1.SelectedRow;
}

protected void Button1_Click(object sender, EventArgs e)


{
Session.RemoveAll();
Response.Redirect("Login.aspx");
}

}
}

13
UPDATE PRODUCT IMPLEMENTATION

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.Configuration;
using System.Data;

namespace WebsiteCth
{
public partial class UpdateProduct : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["myCon"].ConnectionString;
string s;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserID"] == null)
Response.Redirect("Login.aspx");

if (!IsPostBack)
{
isiDropDownList();
s = Request.QueryString["ID"];
SqlConnection sqlconn = new SqlConnection(connStr);
sqlconn.Open();
DataTable dt = new DataTable();
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("select * from Product where ProductID =
@ProductID", sqlconn);

myCommand.Parameters.Add(new SqlParameter("@ProductID", SqlDbType.VarChar, 5));


myCommand.Parameters["@ProductID"].Value = s;

myReader = myCommand.ExecuteReader();

while (myReader.Read())
{
TextBox1.Text = (myReader["ProductID"].ToString());
TextBox2.Text = (myReader["ProductName"].ToString());
TextBox3.Text = (myReader["ProductPrice"].ToString());
DropDownList1.Text = (myReader["ProductCategory"].ToString());
TextBox4.Text = (myReader["TotalProduct"].ToString());
TextBox5.Text = (myReader["DateIn"].ToString());
}
sqlconn.Close();
}
}

14
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection sqlconn = new SqlConnection(connStr);
SqlCommand sqledit = new SqlCommand("update Product set ProductName= @ProductName,
ProductPrice = @ProductPrice, ProductCategory=@ProductCategory, TotalProduct=@TotalProduct where
ProductID = @ProductID", sqlconn);

DataTable dtCustomer = new DataTable();


sqlconn.Open();
sqledit.Parameters.Add(new SqlParameter("@ProductName", SqlDbType.VarChar, 25));
sqledit.Parameters.Add(new SqlParameter("@ProductPrice", SqlDbType.Money));
sqledit.Parameters.Add(new SqlParameter("@ProductCategory", SqlDbType.VarChar, 25));
sqledit.Parameters.Add(new SqlParameter("@TotalProduct", SqlDbType.Int));
sqledit.Parameters.Add(new SqlParameter("@ProductID", SqlDbType.VarChar, 5));

sqledit.Parameters["@ProductName"].Value = TextBox2.Text;
sqledit.Parameters["@ProductPrice"].Value = Convert.ToInt32(TextBox3.Text);
sqledit.Parameters["@ProductCategory"].Value = DropDownList1.SelectedValue;
sqledit.Parameters["@TotalProduct"].Value = Convert.ToInt32(TextBox4.Text);
sqledit.Parameters["@ProductID"].Value = TextBox1.Text;

sqledit.ExecuteNonQuery();
sqlconn.Close();

ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Data has been


updated');window.location ='DetailProduct.aspx';", true);

}
protected void isiDropDownList()
{
DropDownList1.Items.Add(new ListItem("--Select Category--", ""));
DropDownList1.AppendDataBoundItems = true;

SqlConnection con = new SqlConnection(connStr);


SqlCommand cmd = new SqlCommand("select CategoryName from Category", con);

try
{
con.Open();
DropDownList1.DataSource = cmd.ExecuteReader();
DropDownList1.DataTextField = "CategoryName";
DropDownList1.DataValueField = "CategoryName";
DropDownList1.DataBind();
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}

15
INTERFACE DESIGN

Login Page

16
INTERFACE DESIGN

Product Page

17
INTERFACE DESIGN

Product Detail Page

18
INTERFACE DESIGN

Update Product Page

19
ERD DIAGRAM

20
CONFIGURATION

Hardware: ATI Radeon AMD A8 4500-APU HD Graphic

Operating System: Windows 7

Software: Microsoft Visual Studio 2017,SQL Server Management Studio 2014

PROJECT FILE DETAILS

S.No File Name Remarks


Restaurant Input Menu With ASP The Microsoft Word Document Of
Net.docx Makalah Project 2 Semester 4 CEP
CCIT FTUI

21

You might also like