/// <summary> /// get all the items from the db /// </summary> public void ConnectToAccess() { conn = new OleDbConnection(); conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data source= nuwaymenu.mdb;"; try { conn.Open(); cmd = new OleDbCommand(selectString, conn); reader = cmd.ExecuteReader(); while (reader.Read()) { //string st = reader["Item"].ToString() + "-" + reader["Description"] + " $" + reader["Price"]; NuWayMenuItem nwmi = new NuWayMenuItem(reader["Item"].ToString(), reader["Description"].ToString(), "$" + reader["Price"]); items.Add(nwmi); } } catch (Exception ex) { MessageBox.Show("Failed to connect to data source"); } finally { conn.Close(); } }
/// <summary> /// Opens the save meal dialog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bSaveMeal_Click(object sender, EventArgs e) { //Must have at least one item to create a savemeal. if (lbOrder.Items.Count > 0) { string currentMeal = ""; foreach (NuWayMenuItem item in lbOrder.Items) { currentMeal += item.ToString() + ";"; } saveMeal.MealSelect = currentMeal; saveMeal.ShowDialog(); } else { MessageBox.Show("No meal to save."); } ======= //lb.Items.Clear(); List<string> spans = scope.GetVariable("l"); lb.BeginUpdate(); try { double price; for (int i = 0; i < lb.Items.Count; i++) { lb.SelectedIndex = i; price = double.Parse((lb.Items[i] as NuWayMenuItem).ItemPrice.Substring(1)); if (currentLang.CompareTo(lang)!= 0) { if (currentLang.CompareTo("en") == 0) price = price * exchange; else price = price / exchange; } NuWayMenuItem tempNMI = new NuWayMenuItem(spans[i], (lb.Items[i] as NuWayMenuItem).ItemDesc, "$" + price); lb.ClearSelected(); lb.SelectedIndex = i; lb.Items[i] = tempNMI; } } finally { lb.EndUpdate(); lb.Refresh(); } if (lb.Items.Count > 0) lb.SelectedIndex = 0; //for(int i=0; i<spans.Count; i++) // lb.Items.Add(spans[i] + "" + pairs[i].b); }