protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if ((Session["LoggedInUserName"] != null)) { LinkButton LinkButton1 = (LinkButton)Master.FindControl("LinkButton1"); LinkButton1.Visible = false; LinkButton LinkButton2 = (LinkButton)Master.FindControl("LinkButton2"); LinkButton2.Visible = true; Label Welcome_label = (Label)Master.FindControl("Welcome_label"); Welcome_label.Text = "Welcome " + Session["LoggedInUserName"]; Welcome_label.Visible = true; LinkButton LinkButton3 = (LinkButton)Master.FindControl("LinkButton3"); LinkButton3.Visible = true; } else { LinkButton LinkButton1 = (LinkButton)Master.FindControl("LinkButton1"); LinkButton1.Visible = true; LinkButton LinkButton2 = (LinkButton)Master.FindControl("LinkButton2"); LinkButton2.Visible = false; LinkButton LinkButton3 = (LinkButton)Master.FindControl("LinkButton3"); LinkButton3.Visible = false; } string RestaurantId = Request.QueryString["RestaurantId"]; // string RestaurantId = "2"; try { resConn.SqlConnectionObj.Open(); string query2 = String.Format("Select RestaurantId, RestaurantName, RestaurantAddress, RestaurantPhone, RestaurantMinOrder, CONVERT (VARCHAR(8), OpeningHour, 108) AS OpeningHour, CONVERT (VARCHAR(8), ClosingHour, 108) AS ClosingHour,DeliveryFee from Restaurant_tbl where RestaurantId={0}", RestaurantId); resConn.SqlCommandObj.CommandText = query2; SqlDataReader reader = resConn.SqlCommandObj.ExecuteReader(); while (reader.Read()) { Label5.Text = reader.GetString(1).ToString(); Label7.Text = reader.GetString(2).ToString(); Label10.Text = reader.GetString(3).ToString(); Label12.Text = reader.GetString(4).ToString() + "TK."; Label14.Text = reader.GetInt32(7).ToString(); Label23.Text = " TK."; Label18.Text = reader.GetString(5).ToString(); Label19.Text = reader.GetString(6).ToString(); } resConn.SqlConnectionObj.Close(); Image2.ImageUrl = "~/HandlerImg.ashx?restId=" + RestaurantId; //cheking if rest is closed CheckStatus aCheck = new CheckStatus(); bool UserValid = aCheck.CheckUser(Request.QueryString["RestaurantId"]); if (UserValid) { Label20.Text = "Restaurant is Open"; } else { /*ei khane ei label ta thakbe plus restaurant j close tao ekta alert dia dekhabe, page e ashar shathe shathe*/ Label20.Text = "Restaurant Already Closed!!!"; } } catch (Exception ex) { throw new Exception("Error occurred during user save operation. Try again", ex); } finally { if (resConn.SqlConnectionObj != null && resConn.SqlConnectionObj.State == ConnectionState.Open) { resConn.SqlConnectionObj.Close(); } } GetReviews(); } }
protected void LinkButton1_Command(object sender, CommandEventArgs e) { CheckStatus aCheck = new CheckStatus(); bool restOpen = aCheck.CheckUser(Request.QueryString["RestaurantId"]); string rId = Request.QueryString["RestaurantId"]; if (restOpen) { if ((Session["LoggedInUserName"] != null)) { String FoodName = e.CommandArgument.ToString(); Food item = new Food(); string Cost = item.getPrice(FoodName, rId); double cost = Convert.ToDouble(Cost); double total = 0; if (Convert.ToInt32(NoOfItem.Text) == 0) { I1.Text = FoodName; P1.Text = cost.ToString(); tk1.Text = "tk"; NoOfItem.Text = Convert.ToString(Convert.ToInt32(NoOfItem.Text) + 1); //n1.Text = "1"; //s1.Text = "X"; //total = cost; //Total.Text = total+""; item1DropdownList.Visible = true; DeletItem1.Visible = true; } else if (Convert.ToInt32(NoOfItem.Text) == 1) { if (I1.Text == FoodName) { //n1.Text = Convert.ToString(Convert.ToInt32(n1.Text) + 1); Label3.Text = "Food Item alresdy Exists"; } else { I2.Text = FoodName; P2.Text = cost.ToString(); tk2.Text = "tk"; NoOfItem.Text = Convert.ToString(Convert.ToInt32(NoOfItem.Text) + 1); //n2.Text = "1"; //s2.Text = "X"; DeletItem2.Visible = true; item2DropdownList.Visible = true; } //Total.Text = Convert.ToString(Convert.ToDouble(Total.Text)+cost); //total = total + cost; //Total.Text = total + " tk"; } else if (Convert.ToInt32(NoOfItem.Text) == 2) { if (I1.Text == FoodName) { Label3.Text = "Food Item alresdy Exists"; //n1.Text = Convert.ToString(Convert.ToInt32(n1.Text) + 1); } else if (I2.Text == FoodName) { Label3.Text = "Food Item alresdy Exists"; //n2.Text = Convert.ToString(Convert.ToInt32(n2.Text) + 1); } else { I3.Text = FoodName; P3.Text = Cost.ToString(); tk3.Text = "tk"; //n3.Text = "1"; //s3.Text = "X"; NoOfItem.Text = Convert.ToString(Convert.ToInt32(NoOfItem.Text) + 1); DeletItem3.Visible = true; item3DropdownList.Visible = true; } //Total.Text = Convert.ToString(Convert.ToDouble(Total.Text) + cost); //total = total + cost; //Total.Text = total + " tk"; } else if (Convert.ToInt32(NoOfItem.Text) == 3) { if (I1.Text == FoodName) { Label3.Text = "Food Item alresdy Exists"; //n1.Text = Convert.ToString(Convert.ToInt32(n1.Text) + 1); } else if (I2.Text == FoodName) { Label3.Text = "Food Item alresdy Exists"; //n2.Text = Convert.ToString(Convert.ToInt32(n2.Text) + 1); } else if (I3.Text == FoodName) { Label3.Text = "Food Item alresdy Exists"; //n3.Text = Convert.ToString(Convert.ToInt32(n2.Text) + 1); } else { I4.Text = FoodName; P4.Text = Cost.ToString(); tk4.Text = "tk"; NoOfItem.Text = Convert.ToString(Convert.ToInt32(NoOfItem.Text) + 1); //n4.Text = "1"; //s4.Text = "X"; DeletItem4.Visible = true; item4DropdownList.Visible = true; } //Total.Text = Convert.ToString(Convert.ToDouble(Total.Text) + cost); //total = total + cost; //Total.Text = total + " tk"; } else if (Convert.ToInt32(NoOfItem.Text) == 4) { if (I1.Text == FoodName) { //n1.Text = Convert.ToString(Convert.ToInt32(n1.Text) + 1); } else if (I2.Text == FoodName) { //n2.Text = Convert.ToString(Convert.ToInt32(n2.Text) + 1); } else if (I3.Text == FoodName) { //n3.Text = Convert.ToString(Convert.ToInt32(n2.Text) + 1); } else if (I4.Text == FoodName) { //n4.Text = Convert.ToString(Convert.ToInt32(n2.Text) + 1); } else { I5.Text = FoodName; P5.Text = cost.ToString(); tk5.Text = "tk"; NoOfItem.Text = Convert.ToString(Convert.ToInt32(NoOfItem.Text) + 1); //n5.Text = "1"; //s5.Text = "X"; DeletItem5.Visible = true; item5DropdownList.Visible = true; } //Total.Text = Convert.ToString(Convert.ToDouble(Total.Text) + cost); //total = total + cost; //Total.Text = total + " tk"; } else if (Convert.ToInt32(NoOfItem.Text) == 5) { if (I1.Text == FoodName) { //n1.Text = Convert.ToString(Convert.ToInt32(n1.Text) + 1); //Label3.Text = "Food Item alresdy Exists"; Page.ClientScript.RegisterClientScriptBlock(typeof(Page), Guid.NewGuid().ToString(), "alert('Food Item alresdy Exists')", true); Total.Text = Convert.ToString(Convert.ToDouble(Total.Text) + cost); } else if (I2.Text == FoodName) { //n2.Text = Convert.ToString(Convert.ToInt32(n2.Text) + 1); //Label3.Text = "Food Item alresdy Exists"; Page.ClientScript.RegisterClientScriptBlock(typeof(Page), Guid.NewGuid().ToString(), "alert('Food Item alresdy Exists')", true); Total.Text = Convert.ToString(Convert.ToDouble(Total.Text) + cost); } else if (I3.Text == FoodName) { //n3.Text = Convert.ToString(Convert.ToInt32(n2.Text) + 1); //Label3.Text = "Food Item alresdy Exists"; Page.ClientScript.RegisterClientScriptBlock(typeof(Page), Guid.NewGuid().ToString(), "alert('Food Item alresdy Exists')", true); Total.Text = Convert.ToString(Convert.ToDouble(Total.Text) + cost); } else if (I4.Text == FoodName) { //n4.Text = Convert.ToString(Convert.ToInt32(n2.Text) + 1); Page.ClientScript.RegisterClientScriptBlock(typeof(Page), Guid.NewGuid().ToString(), "alert('Food Item alresdy Exists')", true); //Total.Text = Convert.ToString(Convert.ToDouble(Total.Text) + cost); } else if (I5.Text == FoodName) { //n5.Text = Convert.ToString(Convert.ToInt32(n2.Text) + 1); Page.ClientScript.RegisterClientScriptBlock(typeof(Page), Guid.NewGuid().ToString(), "alert('Food Item alresdy Exists')", true); //Total.Text = Convert.ToString(Convert.ToDouble(Total.Text) + cost); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Page), Guid.NewGuid().ToString(), "alert('Too many items selected')", true); } } CalculateTotal(); } else { /*ei khane ekta alert dia dekhabe j user logged in na and alert dekhanor por login page e pathai dibe(pathanor ta niche kora ase)*/ //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('You have to Login to Order')", true); //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Only alert Message');", true); //ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true); // ShowMsg(); // Page.ClientScript.RegisterClientScriptBlock(typeof(Page), Guid.NewGuid().ToString(), "alert('You have to login to order')", true); string RestId = Request.QueryString["RestaurantId"]; var url = String.Format("~/Login_Page.aspx?RestaurantId={0}", RestId); Response.Redirect(url); } } else { /*ei khane restaurant j close, linkbutton e press korai alert dibe ekta alert dia dekhabe, page e ashar shathe shathe*/ Page.ClientScript.RegisterClientScriptBlock(typeof(Page), Guid.NewGuid().ToString(), "alert('Restaurant already closed!!!')", true); } }