private void button5_Click(object sender, EventArgs e) { changes = new NSAChanges(); NSAMenuItem resultItem = new NSAMenuItem(customizeItem); List <NSAComponent> finalComponents = new List <NSAComponent>(); if (customizeItem.BreadIndex > -1 && BreadList.SelectedItems.Count > 0) { finalComponents.Add((NSAComponent)BreadList.SelectedItems[0].Tag); resultItem.BreadIndex = 0; } resultItem.Extrascost = 0.0; foreach (Object customComponent in OtherListBox.CheckedItems) { finalComponents.Add((NSAComponent)customComponent); if (((NSAComponent)customComponent).Name == "Avocado") { resultItem.Extrascost = 1.0; } } resultItem.Components = finalComponents; changes.FinishedItem = resultItem; changes.OriginalItem = OriginalIndex; Hide(); }
public NSAMenuItem getKidsMeal() { StringBuilder query = new StringBuilder(); NSAMenuItem newItem = null; query.Clear(); query.Append("SELECT name, menutypeid "); query.Append("FROM menuitem "); query.Append("WHERE name = 'Kids Meal' AND menutypeid = 0 AND storeid = "); query.Append(StoreNumber.ToString()); query.Append(";"); MySqlDataReader menuItemReader = CustomQuery(query.ToString()); if (menuItemReader != null) { menuItemReader.Read(); newItem = new NSAMenuItem(); newItem.Name = (string)menuItemReader["name"]; newItem.CategoryID = (int)menuItemReader["menutypeid"]; } menuItemReader.Close(); return(newItem); }
private void addItemToOrder(NSAMenuItem item) { item.GenerateItem(componentsList); //item.getComponents(db, componentsList); currentOrder.AddItem(new NSAMenuItem(item)); UpdateOrderView(); }
public bool Equals(NSAMenuItem p) { // If parameter is null return false: if ((object)p == null) { return(false); } // Return true if the Ids match: return(Id == p.Id && components == p.components); }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { foreach (ListViewItem t in menuListView.SelectedItems) { ((NSAMenuItem)t.Tag).getComponents(db, componentsList); addItemToOrder((NSAMenuItem)t.Tag); //ask add about making combo if entree is sandwich or salad - TRAE if (((NSAMenuItem)t.Tag).CategoryID == 1 || ((NSAMenuItem)t.Tag).CategoryID == 2) { //make sure that the number of discounts and combo drinks are less than the number of entrees before adding more. if (CanHaveComboDiscount()) { //Ask to make combo - "Make this entree a combo for a 1.00 discount?" DataParser dataParser = new DataParser(ci); //parses displays them in the users language DialogResult result = MessageBox.Show(rm.GetString("askmakecombo", ci), rm.GetString("makecombocaption", ci), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { //get the drink combo item and add it to the order NSAMenuItem newComboItem = db.getComboDrink(); addItemToOrder(newComboItem); //Get the drink combo Discount and add it to the order NSAMenuItem newComboDiscount = db.getComboDrinkDiscount(); addItemToOrder(newComboDiscount); } } } if (checkKidsMeal()) { if (String.IsNullOrWhiteSpace(kidsnum_store.Text)) { kidsnum_store.Text = "0"; } DataParser dataParser = new DataParser(ci); //parses displays them in the users language if (counter < Convert.ToInt32(kidsnum_store.Text)) { DialogResult result = MessageBox.Show("Do you want to add kid meal to your entree?", "free kids meal", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { counter++; NSAMenuItem newKidsMeal = db.getKidsMeal(); addItemToOrder(newKidsMeal); } } } UpdateOrderView(); } }
//Clone constructor public NSAMenuItem(NSAMenuItem a) { id = a.id; name = a.name; price = a.price; menuType = a.menuType; components = a.components; image = a.image; categoryID = a.categoryID; breadIndex = a.breadIndex; extrascost = a.extrascost; }
//check if it's a kids meal day private bool checkKidsMeal() { bool kidsmeal = false; NSAMenuItem checkKids = db.getKidsMeal(); string dt = DateTime.Now.DayOfWeek.ToString(); if (dt == "Monday" || dt == "Tuesday" || dt == "Wednesday" || dt == "Thursday" || dt == "Friday" || dt == "Saturday" || dt == "Sunday") { kidsmeal = true; } return(kidsmeal); }
private void button7_Click(object sender, EventArgs e) { if (account != null && OrderView.SelectedItems.Count > 0) { Console.WriteLine("button7 : " + (int)OrderView.SelectedItems[0].Tag); NSAMenuItem faveitem = (NSAMenuItem)currentOrder.Items[(int)OrderView.SelectedItems[0].Tag]; MySqlCommand cmd2 = new MySqlCommand(String.Format("INSERT INTO favoriteitems (storeid, loyaltyid, name, price, menuitemid) VALUES ({0}, {1}, '{2}', {3}, {4});", db.StoreNumber1, account.getAccountNumber(), faveitem.Name, faveitem.Price, faveitem.Id), db.Connection1); cmd2.ExecuteReader().Close(); long favitemid = cmd2.LastInsertedId; foreach (NSAComponent comp in faveitem.Components) { MySqlCommand cmd3 = new MySqlCommand(("INSERT INTO favoriteitemcomponents (favoriteitemid, storeid, compontentid) VALUES (" + favitemid + ", " + db.StoreNumber1 + ", " + comp.ComponentID + ");"), db.Connection1); cmd3.ExecuteReader().Close(); } } }
public NSAMenuItem[] getMenuItems() { MySqlDataReader menuItemReader = CustomQuery("SELECT menuitemid, name, price, menutypeid FROM menuitem WHERE storeid = " + StoreNumber.ToString() + " and deleted = 0;"); List <NSAMenuItem> itemList = new List <NSAMenuItem>(); if (menuItemReader != null) { while (menuItemReader.Read()) { NSAMenuItem newItem = new NSAMenuItem(); newItem.Name = (string)menuItemReader["name"]; newItem.Id = (int)menuItemReader["menuitemid"]; newItem.CategoryID = (int)menuItemReader["menutypeid"]; newItem.Price = (float)menuItemReader["price"]; itemList.Add(newItem); } } menuItemReader.Close(); return(itemList.ToArray()); }
private bool CanHaveComboDiscount() { // need to check if the current order is eligiable for another combo. discount. bool canDiscount = false; int numEntrees = 0; int numComboDrinks = 0; int numDiscounts = 0; NSAMenuItem newComboItem = db.getComboDrink(); NSAMenuItem newDiscountItem = db.getDiscountItem(); // count how may of the various items we have. for (int i = 0; i < currentOrder.Items.Count; i++) { if ((int)currentOrder.Items.ElementAt(i).CategoryID == 1 || (int)currentOrder.Items.ElementAt(i).CategoryID == 2) { numEntrees++; } if ((int)currentOrder.Items.ElementAt(i).Id == newComboItem.Id) { numComboDrinks++; } if ((int)currentOrder.Items.ElementAt(i).Id == newDiscountItem.Id) { numDiscounts++; } } if (numEntrees > numComboDrinks && numEntrees > numDiscounts) { canDiscount = true; } return(canDiscount); }
public NSAMenuItem getDiscountItem() { //there is a menuitem in the database called Discount that will beused to keep track of the discounts //the ID for this item may vary from store to store but the type will be unassigned. //the generic doscount will have a price of $0 for the discount StringBuilder query = new StringBuilder(); NSAMenuItem newItem = null; //Build the query to get the item in question query.Clear(); query.Append("SELECT menuitemid, name, menutypeid "); query.Append("FROM menuitem "); query.Append("WHERE name = 'Discount' AND menutypeid = 0 AND storeid = "); query.Append(StoreNumber.ToString()); query.Append(";"); //run the query MySqlDataReader menuItemReader = CustomQuery(query.ToString()); //if resuts build item if (menuItemReader != null) { menuItemReader.Read(); newItem = new NSAMenuItem(); newItem.Name = (string)menuItemReader["name"]; newItem.Id = (int)menuItemReader["menuitemid"]; newItem.CategoryID = (int)menuItemReader["menutypeid"]; newItem.Price = 0; //the default discount is 0 } //close reader menuItemReader.Close(); //return item ... will be null if the item is not found return(newItem); }
public NSAMenuItem getComboDrinkDiscount() { //get a discount item that has the combo drink discount. float Discount = 0; NSAMenuItem newItem = null; StringBuilder query = new StringBuilder(); //get teh proper discount amount query.Append("SELECT storeid,discountamount FROM combodrinkmenuid WHERE storeid = "); query.Append(StoreNumber.ToString()); query.Append(";"); MySqlDataReader menuItemReader = CustomQuery(query.ToString()); if (menuItemReader != null) { if (menuItemReader.Read()) { Discount = (float)menuItemReader["discountamount"]; } } menuItemReader.Close(); //get a generic discount item newItem = getDiscountItem(); //if the discount item exists then replace teh discount cost. if (newItem != null) { newItem.Price = -1 * Discount; } return(newItem); }
public NSAMenuItem getComboDrink() { //get the item to be added to the "combo" return NULL item if item isnt found NSAMenuItem newItem = null; //build query StringBuilder query = new StringBuilder(); query.Append("SELECT m.menuitemid, m.name, m.price, m.menutypeid, c.discountamount "); query.Append("FROM menuitem m join combodrinkmenuid c on m.storeid = c.storeid AND m.menuitemid = c.menuitemid "); query.Append("WHERE m.storeid = "); query.Append(StoreNumber.ToString()); query.Append(";"); //execute query MySqlDataReader menuItemReader = CustomQuery(query.ToString()); //if we found a discount item build the item to retuen if (menuItemReader != null) { newItem = new NSAMenuItem(); if (menuItemReader.Read()) { newItem.Name = (string)menuItemReader["name"]; newItem.Id = (int)menuItemReader["menuitemid"]; newItem.CategoryID = (int)menuItemReader["menutypeid"]; //Combo newItem.Price = (float)menuItemReader["price"]; } } menuItemReader.Close(); //return the item will be null return(newItem); }
public void AddItem(NSAMenuItem item) { items.Add(item); }
private void removeItemFromOrder(NSAMenuItem item) { }