protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["login_id"] == null)
                {
                    Response.Redirect("Login.aspx");
                    return;
                }

                DataTable dt  = new DataTable();
                DataTable dt2 = new DataTable();
                DataTable dt3 = new DataTable();
                using (conn)
                {
                    SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM drinks WHERE item_status = 1", conn);
                    ad.Fill(dt);
                    ad = new SqlDataAdapter("SELECT category FROM drinks WHERE item_status = 1 GROUP BY category", conn);
                    ad.Fill(dt2);
                    ad = new SqlDataAdapter("SELECT temperature FROM drinks WHERE item_status = 1 GROUP BY temperature", conn);
                    ad.Fill(dt3);
                }
                DrinkList.DataSource = dt;
                DrinkList.DataBind();
                ddlCategory.DataSource = dt2;
                ddlCategory.DataBind();
                ddlTemperature.DataSource = dt3;
                ddlTemperature.DataBind();
            }
        }
        protected void btnShowAll_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            using (conn)
            {
                SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM drinks WHERE item_status = 1", conn);
                ad.Fill(dt);
            }
            DrinkList.DataSource = dt;
            DrinkList.DataBind();
        }
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            using (conn)
            {
                SqlDataAdapter ad = new SqlDataAdapter(string.Format("SELECT * FROM drinks WHERE item_status = 1 AND category LIKE '{0}' AND temperature LIKE '{1}'", ddlCategory.SelectedItem.Value.ToString(), ddlTemperature.SelectedItem.Value.ToString()), conn);
                ad.Fill(dt);
            }
            DrinkList.DataSource = dt;
            DrinkList.DataBind();
        }
Exemplo n.º 4
0
        protected void CompanyList_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC GetCompanyPoint " + CompanyList.SelectedItem.Value, connection);
                connection.Open();
                Label25.Text = command.ExecuteScalar().ToString();
            }

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC GetCompanyFoods " + CompanyList.SelectedItem.Value + ", 'Soups'", connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                SoupList.DataSource     = reader;
                SoupList.DataTextField  = "FoodName";
                SoupList.DataValueField = "ID";
                SoupList.DataBind();
            }

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC GetCompanyFoods " + CompanyList.SelectedItem.Value + ", 'Main Foods'", connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                MainFoodList.DataSource     = reader;
                MainFoodList.DataTextField  = "FoodName";
                MainFoodList.DataValueField = "ID";
                MainFoodList.DataBind();
            }
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC GetCompanyFoods " + CompanyList.SelectedItem.Value + ", 'Meats'", connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                MeatList.DataSource     = reader;
                MeatList.DataTextField  = "FoodName";
                MeatList.DataValueField = "ID";
                MeatList.DataBind();
            }
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC GetCompanyFoods " + CompanyList.SelectedItem.Value + ", 'Salads'", connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                SaladList.DataSource     = reader;
                SaladList.DataTextField  = "FoodName";
                SaladList.DataValueField = "ID";
                SaladList.DataBind();
            }
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC GetCompanyFoods " + CompanyList.SelectedItem.Value + ", 'Drinks'", connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                DrinkList.DataSource     = reader;
                DrinkList.DataTextField  = "FoodName";
                DrinkList.DataValueField = "ID";
                DrinkList.DataBind();
            }
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC GetCompanyFoods " + CompanyList.SelectedItem.Value + ", 'Desserts'", connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                DessertList.DataSource     = reader;
                DessertList.DataTextField  = "FoodName";
                DessertList.DataValueField = "ID";
                DessertList.DataBind();
            }
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC GetStartHour " + CompanyList.SelectedItem.Value, connection);
                connection.Open();
                if (command.ExecuteScalar() != null)
                {
                    Label29.Text = command.ExecuteScalar().ToString();
                }
            }
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC GetEndHour " + CompanyList.SelectedItem.Value, connection);
                connection.Open();
                if (command.ExecuteScalar() != null)
                {
                    Label31.Text = command.ExecuteScalar().ToString();
                }
            }
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC GetMinimumPrice " + CompanyList.SelectedItem.Value, connection);
                connection.Open();
                if (command.ExecuteScalar() != null)
                {
                    Label33.Text = command.ExecuteScalar().ToString();
                }
            }
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC GetServiceTime " + CompanyList.SelectedItem.Value, connection);
                connection.Open();
                if (command.ExecuteScalar() != null)
                {
                    Label35.Text = command.ExecuteScalar().ToString();
                }
            }
        }
Exemplo n.º 5
0
        protected void PageLoadAttributeInitialization()
        {
            if (Session["bentoList"] == null)
            {
                List <string> bentos = new List <string>()
                {
                    BentoEnum.ChickenCurry.ToString(),
                              BentoEnum.ChickenTeriyaki.ToString(),
                              BentoEnum.CurrySauce.ToString(),
                              BentoEnum.PorkBulgogi.ToString()
                };
                Session["bentoList"] = bentos;
            }


            BentoList.DataSource = from i in (List <string>)Session["bentoList"]
                                   select new ListItem()
            {
                Text  = i,
                Value = i
            };
            BentoList.DataBind();

            if (Session["sushiList"] == null)
            {
                List <string> sushis = new List <string>()
                {
                    SushiEnum.ChumakiSet.ToString(),
                              SushiEnum.HarmonySet.ToString(),
                              SushiEnum.MixedMakiSet.ToString(),
                              SushiEnum.RainBowSet.ToString()
                };
                Session["sushiList"] = sushis;
            }


            SushiList.DataSource = from i in (List <string>)Session["sushiList"]
                                   select new ListItem()
            {
                Text  = i,
                Value = i
            };
            SushiList.DataBind();



            if (Session["drinkList"] == null)
            {
                List <string> drinks = new List <string>()
                {
                    DrinkEnum.Coke.ToString(),
                              DrinkEnum.ZeroCoke.ToString(),
                              DrinkEnum.StillWater.ToString(),
                              DrinkEnum.Fanta.ToString()
                };

                Session["drinkList"] = drinks;
            }

            if (Session["drinkList"] != null)
            {
                DrinkList.DataSource = from i in (List <string>)Session["drinkList"]
                                       select new ListItem()
                {
                    Text  = i,
                    Value = i
                };
                DrinkList.DataBind();
            }


            if (Session["pageIndex"] != null && !string.IsNullOrEmpty(Session["pageIndex"].ToString()))
            {
                purchasedFoodView.PageIndex = (int)Session["pageIndex"];
            }

            if (Session["selectedItem"] != null && !string.IsNullOrEmpty(Session["selectedItem"].ToString()))
            {
                DrinkList.SelectedIndex = DrinkList.Items.IndexOf(DrinkList.Items.FindByText(Session["selectedItem"].ToString()));
            }

            if (Session["items"] == null)
            {
                Debug.WriteLine("Session is null");
                List <Item> listItems = new List <Item>();
                Session["items"] = listItems;
            }

            if (Session["serviceType"] == null)
            {
                ServiceType.Text = ServiceEnum.EATIN.ToString();
                serviceName      = ServiceEnum.EATIN.ToString();
                serviceImg.Src   = "/images/eatin.jpg";
            }
            else
            {
                ServiceType.Text = Session["serviceType"].ToString();
                serviceImg.Src   = Session["serviceImage"].ToString();
            }

            ttlCost.Text                 = "£" + Invoice.CalculateTotalCost((List <Item>)Session["items"]).ToString();
            Session["totalCost"]         = ttlCost.Text;
            Session["serviceType"]       = ServiceType.Text;
            Session["serviceImage"]      = serviceImg.Src;
            purchasedFoodView.DataSource = (List <Item>)Session["items"];
            purchasedFoodView.DataBind();
        }