private void Add_button() { if (New_Order_Details.Count != 0) { List <New_order_details> nod_list = new List <New_order_details>(); for (int i = 0; i < New_Order_Details.Count; i++) { nod_list.Add(New_Order_Details[i]); } int asd = Row_num; nod_list[Row_num].Count += 1; New_Order_Details.Clear(); for (int i = 0; i < nod_list.Count; i++) { New_Order_Details.Add(new Model.New_order_details { Food = nod_list[i].Food, Count = nod_list[i].Count, Food_ID = nod_list[i].Food_ID, Price = nod_list[i].Price }); } } else if (Details2.Count != 0) { Select_State(); if (state_global == "In Progress") { List <New_order_details> list = new List <New_order_details>(); for (int i = 0; i < Details2.Count; i++) { list.Add(Details2[i]); } list[Row_num].Count += 1; Details2.Clear(); for (int i = 0; i < list.Count; i++) { Details2.Add(new Model.New_order_details { Food = list[i].Food, Count = list[i].Count, Food_ID = list[i].Food_ID, Price = list[i].Price }); } Sum_Prices(); } else if (state_global == "Completed") { Display_Message = "Not editable! Order completed!"; } else { Display_Message = "Not editable! Order canceled!"; } } }
private void Delete_from_newO() { if (New_Order_Details.Count != 0) { New_Order_Details.RemoveAt(Row_num); } else { Display_Message = "The list is empty."; } }
private void View_NewOrder_Window() { if (_is_waiter == true || _is_manager == true) { New_Order_Details.Clear(); GetAllWorkers(); Select_foodlist(); this.DisplayPage = new New_Order(); } else { Display_Message = "You have to log in first!"; } }
private void NewO_Add_button() { bool empty = true; bool n = true; bool z = true; for (int i = 0; i < New_Order_Details.Count; i++) { int u = New_Order_Details[i].Count; if (New_Order_Details[i].Food.Equals(Selected_food) && z == true) { New_Order_Details.RemoveAt(i); New_Order_Details.Add(new Model.New_order_details { Food = Selected_food, Count = Selected_Count + u, Food_ID = Selected_food_index + 1, Price = ListofFood[Selected_food_index + 1].Price }); n = true; z = false; empty = false; } else { n = false; } } if ((n == false && z == true) || empty == true) { New_Order_Details.Add(new Model.New_order_details { Food = Selected_food, Count = Selected_Count, Food_ID = Selected_food_index + 1, Price = ListofFood[Selected_food_index + 1].Price }); } }
private void Select_Details() { GetAllWorkers(); Select_foodlist(); New_Order_Details.Clear(); conn = new MySqlConnection("Server=localhost;Database=szakdoga_db;Uid=root;Pwd=;SslMode=none"); string q_select = String.Format("SELECT od.ID, od.Order_no, o.Table_no, f.Name as Food, SUM(f.Price * od.Count) as Price, o.Cancel_Reason, w.Realname as Waiter, o.Customer, o.State FROM order_details od INNER JOIN food_list f ON f.Food_ID = od.Food INNER JOIN orders o ON o.Order_no = od.Order_no INNER JOIN workers w ON w.Worker_ID = o.Waiter GROUP BY Order_no LIMIT {0},1 ", Row_num_order); try { conn.Open(); MySqlCommand cmd = new MySqlCommand(q_select, conn); MySqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { Details.Add(new Model.Order_details_model { ID = Convert.ToInt32(dataReader["ID"]), Order_no = Convert.ToInt32(dataReader["Order_no"]), Table_no = Convert.ToInt32(dataReader["Table_no"]), Food = (dataReader["Food"].ToString()), Price = Convert.ToInt32(dataReader["Price"]), C_Reason = (dataReader["Cancel_Reason"].ToString()), Waiter = (dataReader["Waiter"].ToString()), Customer = (dataReader["Customer"].ToString()), State = (dataReader["State"].ToString()) }); } dataReader.Close(); Select_More_Details(); conn.Close(); } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } }