You are on page 1of 14

GROUP 6

Muhartsal Raihan
(2020010082)
Hafizh Zaldy Alviansyah
(2020010049)

Restaurant input
menu
SYSTEM SUMARRY:
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.

2
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));
 
myCommand.Parameters["@UserID"].Value = TextBox1.Text;
myCommand.Parameters["@Passwd"].Value = TextBox2.Text;
 
sda.Fill(dt);
int i = myCommand.ExecuteNonQuery();
if (dt.Rows.Count > 0)
{
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();
}
}
}
3
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();
}

4
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);
}
}
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();
}
 
}
6
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; 7
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();
}
 

}
} 8
Login page

9
Product page

10
Product detail page

11
Update Product page

12
Example Anti virus software

13
THANKYOU

14

You might also like