public static bool getRestaurant(int id, ref KahnoRestaurant restaurantOBJ) { //checking if restaurant exists SqlConnection conn = new SqlConnection(connectString); conn.Open(); string sqlGetUser = ("SELECT * FROM [RESTAURANT] WHERE RestaurantID = @id"); SqlCommand commquery = new SqlCommand(sqlGetUser, conn); commquery.Parameters.AddWithValue("@id", id); SqlDataReader drquery = commquery.ExecuteReader(); drquery.Read(); if (drquery.HasRows) { restaurantOBJ = new KahnoRestaurant(drquery.GetInt32(0), drquery.GetValue(1).ToString(), drquery.GetValue(2).ToString(), drquery.GetInt32(3)); return(true); } else { return(false); } }
protected void Page_Load(object sender, EventArgs e) { ////////checking if user is logged in, copy paste on every page, will redirect to login if not logged in and create the user object ///Don't use this one yet, we need a better version KahnoUser currentuser = new KahnoUser(); try { currentuser = (KahnoUser)Session["localuser"]; if (currentuser.userid == 0) { Response.Redirect("Login.aspx"); } if (currentuser.isowner == "n") { Response.Redirect("Login.aspx"); } } catch { Response.Redirect("Login.aspx"); } //////////////////////////////////////////////////////////////// try { currentRestaurant = (KahnoRestaurant)Session["currentRestaurant"]; } catch { Response.Redirect("Admin.aspx"); } Label1.Text = "Menu for " + currentRestaurant.restaurantname; }
protected void Page_Load(object sender, EventArgs e) { ////////checking if user is logged in, copy paste on every page, will redirect to login if not logged in and create the user object ///Don't use this one yet, we need a better version KahnoUser currentuser = new KahnoUser(); currentuser = (KahnoUser)Session["localuser"]; if (currentuser.userid == 0) { Response.Redirect("Login.aspx"); } if (currentuser.restaurantno == 0) { Response.Redirect("CreateRestaurantForm.aspx"); } if (currentuser.isowner == "n") { Response.Redirect("Login.aspx"); } //////////////////////////////////////////////////////////////// /////////////creatign restaurant object /// KahnoRestaurant currentRestaurant = new KahnoRestaurant(); KahnLib.getRestaurant(currentuser.restaurantno, ref currentRestaurant); Session["currentRestaurant"] = currentRestaurant; ////////////// //Label3.Text = "Welcome " + currentuser.fname + " Your restaurant is " + currentRestaurant.restaurantname + currentuser.restaurantno + (Int32)Session["RID"]; Label3.Text = "Welcome " + currentuser.fname + ", owner of " + currentRestaurant.restaurantname + " with restaurant ID: " + (Int32)Session["RID"]; }
protected void lnkSelect_Click(object sender, EventArgs e) { int restaurantID = Convert.ToInt32((sender as Button).CommandArgument); KahnoRestaurant currentRestaurant = new KahnoRestaurant(); KahnLib.getRestaurant(restaurantID, ref currentRestaurant); Session["currentRestaurant"] = currentRestaurant; Session["restaurantID"] = currentRestaurant.restaurantID; Response.Redirect("RestaurantMenuPage.aspx"); }
protected void Page_Load(object sender, EventArgs e) { KahnoRestaurant currentRestaurant = (KahnoRestaurant)Session["currentRestaurant"]; Heading.InnerText = currentRestaurant.restaurantname; if (IsPostBack == false) { Session["orderCount"] = 0; Session["counter"] = 0; } }
protected void btnConfirm_Click(object sender, EventArgs e) { restaurant = (KahnoRestaurant)Session["currentRestaurant"]; DateTime time = DateTime.Now; string format = "yyyy-MM-dd HH:mm:ss"; string finaltime = time.ToString(format); user = (KahnoUser)Session["localuser"]; int user1 = Convert.ToInt32(user.userid); int restaurantSend = restaurant.restaurantID; //insert into db first then get orderNumber KahnLib.InsertOrder(finaltime, user1, restaurantSend); int orderNumber = KahnLib.getOrderNumber(); List <int> CurrentCart = new List <int>(); List <int> CurrentCartQuantity = new List <int>(); if (Session["list"] != null && Session["CartQuantity"] != null) { CurrentCart = (List <int>)Session["list"]; CurrentCartQuantity = (List <int>)Session["CartQuantity"]; } else { Response.Redirect("Login.aspx"); } double total = 0; int i = 0; foreach (int element in CurrentCart) { total = CurrentCartQuantity[i] * KahnLib.getOrderPrice(CurrentCart[i]); KahnLib.getOrder(CurrentCart[i], CurrentCartQuantity[i]); string connectString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\KahnoDB.mdf;Integrated Security=True;Connect Timeout=30"; SqlConnection conn = new SqlConnection(connectString); conn.Open(); SqlDataAdapter adapter = new SqlDataAdapter(); SqlConnection con = new SqlConnection(connectString); string insert_query = "INSERT INTO [ORDERDETAIL] (Quantity,OrderNumber,PricePaidPerItem,ItemNumber) VALUES(@quantity,@OrderNo,@total,@itemNo)"; SqlCommand comm = new SqlCommand(insert_query, conn); comm.Parameters.AddWithValue("@quantity", CurrentCartQuantity[i]); comm.Parameters.AddWithValue("@OrderNo", orderNumber); comm.Parameters.AddWithValue("@total", total); comm.Parameters.AddWithValue("@itemNo", CurrentCart[i]); comm.ExecuteNonQuery(); con.Close(); comm.Dispose(); i++; } Response.Redirect("Success.aspx"); Session["list"] = null; Session["CartQuantity"] = null; }