protected void Button_Submit_Click(object sender, EventArgs e) { Page.Validate(); if (Page.IsValid == true) { FoodOrdersEntities context = new FoodOrdersEntities(); string name = TextBox_Name.Text; string dish = DropDownList_Food.Text; string size = RadioButtonList_Size.Text; Order o = new Order(); o.CustomerName = name; o.Dish = dish; o.Size = size; // check if each item in CheckBoxList is selected if (CheckBoxList_Spices.Items[0].Selected == true) { o.Chili = true; } if (CheckBoxList_Spices.Items[1].Selected == true) { o.Pepper = true; } if (CheckBoxList_Spices.Items[2].Selected == true) { o.MoreSalt = true; } context.Orders.Add(o); context.SaveChanges(); Label_Result.Text = "Success!"; } }
public static List <Order> GetSummaryList() { FoodOrdersEntities context = new FoodOrdersEntities(); var query = from x in context.Orders select x; return(query.ToList <Order>()); }
public static List <Order> GetNameList(string name) { FoodOrdersEntities context = new FoodOrdersEntities(); var query = from x in context.Orders where x.CustomerName == name select x; return(query.ToList <Order>()); }
public static void DeleteRow(int row) { // Get OrderID of selected row FoodOrdersEntities context = new FoodOrdersEntities(); var query = from x in context.Orders where x.OrderID == row select x; Order o = query.First(); context.Orders.Remove(o); context.SaveChanges(); }
public static void UpdateRow(int id, string cname, string dish, string size, bool chili, bool pepper, bool moresalt) { FoodOrdersEntities context = new FoodOrdersEntities(); var query = from x in context.Orders where x.OrderID == id select x; Order o = query.First(); o.OrderID = id; o.CustomerName = cname; o.Dish = dish; o.Size = size; o.Chili = chili; o.Pepper = pepper; o.MoreSalt = moresalt; context.SaveChanges(); }