public static List<menu_items> GetMenu(int Rest_ID) { List<menu_items> menu_list = new List<menu_items>(); DataSet1.MenuDataTable orders; DataSet1TableAdapters.MenuTableAdapter adapter = new DataSet1TableAdapters.MenuTableAdapter(); orders = adapter.GetMenuById(Rest_ID); for (int i = 0; i < orders.Rows.Count; i++) { menu_items menuObj = new menu_items(Convert.ToInt32(orders[i][1]), (string)orders[i][2], (string)orders[i][3], (double)orders[i][4], (string)orders[i][5], (string)orders[i][6]); //convert my objects into JSON menu_list.Add(menuObj); } return menu_list; }
protected void Page_Load(object sender, EventArgs e) { //creating table in ASP, really should create it in JS to stop the double query, but I'll do it l8r coz im lazy int rest = Convert.ToInt32(Request.QueryString["rest"]); DataSet1.MenuDataTable orders; //The query returns every column, but I only wanna use a few, so I declare those here DataSet1TableAdapters.MenuTableAdapter adapter = new DataSet1TableAdapters.MenuTableAdapter(); orders = adapter.GetMenuById(rest); // Get groups List<string> tabs = new List<string>(); for (int i = 0; i < orders.Rows.Count; i++) { // orders[i]["Category"]; // Does item belong to new category if (!tabs.Contains(orders[i]["Category"])) { // Add tab tabs.Add(orders[i]["Category"].ToString()); tabsLit.Text += "<paper-tab>" + orders[i]["Category"] + "</paper-tab>"; // Add iron page div HtmlGenericControl newDiv = new HtmlGenericControl("div"); newDiv.ID = orders[i]["Category"].ToString(); newDiv.Attributes["class"] += "menu-cat"; menuPH.Controls.Add(newDiv); } // Locate appropriate iron page div HtmlGenericControl foundDiv = (HtmlGenericControl)menuPH.FindControl(orders[i]["Category"].ToString()); if (foundDiv != null) { // Add menu item to div foundDiv.InnerHtml += "<paper-card class=\"menu-item\" heading=\"" + orders[i]["Item_Name"] + "\" onclick=\"AddItem(" + i + ");\"><paper-ripple></paper-ripple><div class=\"card-content\">$" + String.Format("{0:0.00}", orders[i]["Price"]) + "</div></paper-card>"; } } // Set title to current Restaurant name DataSet1TableAdapters.RestaurantTableAdapter nameLoader = new DataSet1TableAdapters.RestaurantTableAdapter(); string restName = nameLoader.GetRestNameByID(rest); Master.restaurantNameBox.Text = restName; }
private DataSet1.MenuDataTable GetMenuById(int Rest_ID) { DataSet1TableAdapters.MenuTableAdapter adapter = new DataSet1TableAdapters.MenuTableAdapter(); return adapter.GetMenuById(Rest_ID); }