private void order_details_dtgrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { prod = (order_details)order_details_dtgrid.SelectedItem; } catch { MessageBox.Show("you selected a non-existent product", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void add_extra_Click(object sender, RoutedEventArgs e) { order_details details_order = new order_details(); name = extra_cmbbx.Text; details = location_cmbbx.Text; if (name != "" && details != "") { List <products> lst_p = db1.products.ToList(); foreach (products lp in lst_p) { if (lp.name == name) { details_order.products_id = lp.Id; break; } } details_order.quantity = quantity; details_order.details = details = details + ", " + notes_txb.Text; db1.order_details.Add(details_order); dataGrid.ItemsSource = db1.order_details.ToList(); db1.SaveChanges(); MessageBox.Show("The Extra was added", "Added", MessageBoxButton.OK, MessageBoxImage.Information); extra_cmbbx.SelectedIndex = -1; location_cmbbx.SelectedIndex = -1; notes_txb.Text = ""; extra_lbl.Foreground = Brushes.Black; location_lbl.Foreground = Brushes.Black; } else { if (name == "") { extra_lbl.Foreground = Brushes.Red; if (details == "") { location_lbl.Foreground = Brushes.Red; } else { location_lbl.Foreground = Brushes.Black; } } else { extra_lbl.Foreground = Brushes.Black; if (details == "") { location_lbl.Foreground = Brushes.Red; } } } }
private void finish_Click(object sender, RoutedEventArgs e) { order_details details_order = new order_details(); name = extra_cmbbx.Text; details = location_cmbbx.Text; if (name != "" && details != "") { List <products> lst_p = db1.products.ToList(); foreach (products lp in lst_p) { if (lp.name == name) { details_order.products_id = lp.Id; break; } } details_order.quantity = quantity; details_order.details = details = details + ", " + notes_txb.Text; db1.order_details.Add(details_order); dataGrid.ItemsSource = db1.order_details.ToList(); db1.SaveChanges(); this.Close(); } else { if (name == "") { extra_lbl.Foreground = Brushes.Red; if (details == "") { location_lbl.Foreground = Brushes.Red; } else { location_lbl.Foreground = Brushes.Black; } } else { extra_lbl.Foreground = Brushes.Black; if (details == "") { location_lbl.Foreground = Brushes.Red; } } } }
private void bvg_aply_btn_Click(object sender, RoutedEventArgs e) { string nm = beverage_cmbbx.Text; if (nm != "" && qnty_txb.Text != "") { int qn = Convert.ToInt32(qnty_txb.Text); List <products> lst_p = db1.products.ToList(); order_details details_order = new order_details(); foreach (products prod in lst_p) { if (prod.name == nm) { details_order.products_id = prod.Id; break; } } details_order.details = notes_txb.Text; details_order.quantity = qn; db1.order_details.Add(details_order); db1.SaveChanges(); order_details_dtgrid.ItemsSource = db1.order_details.ToList(); order_details_dtgrid.Columns[0].Visibility = Visibility.Collapsed; order_details_dtgrid.Columns[4].Visibility = Visibility.Collapsed; order_details_dtgrid.Columns[5].Visibility = Visibility.Collapsed; beverage_cmbbx.SelectedIndex = -1; qnty_txb.Clear(); notes_txb.Text = ""; qnty_lbl.Foreground = Brushes.Black; beverage_lbl.Foreground = Brushes.Black; qnty_lbl.Visibility = Visibility.Collapsed; qnty_txb.Visibility = Visibility.Collapsed; } else { if (nm != "") { qnty_lbl.Foreground = Brushes.Red; } else { beverage_lbl.Foreground = Brushes.Red; } } }
private void beverage_cmbbx_SelectionChanged(object sender, SelectionChangedEventArgs e) { qnty_lbl.Content = "Quantity:"; qnty_lbl.Foreground = Brushes.Black; qnty_txb.Visibility = Visibility.Visible; qnty_lbl.Visibility = Visibility.Visible; var bv = beverage_cmbbx.SelectedItem; order_details details_order = new order_details(); List <products> lst_p = db1.products.ToList(); if (bv != null) { foreach (products prod in lst_p) { if (bv.ToString() == prod.name) { details_order.products_id = prod.Id; details_order.products = prod; qnty_lbl.Content += " " + details_order.products.pack; break; } } } }
private void fd_aply_btn_Click(object sender, RoutedEventArgs e) { List <order_details> lstp = db1.order_details.ToList(); order_details_dtgrid.ItemsSource = lstp; order_details_dtgrid.Columns[0].Visibility = Visibility.Collapsed; order_details_dtgrid.Columns[4].Visibility = Visibility.Collapsed; order_details_dtgrid.Columns[5].Visibility = Visibility.Collapsed; string nm = food_cmbbx.Text; string qnty = qnty_txb.Text; order_details details_order = new order_details(); if (supplier_name_txb.Text != "") { supplier_name_lbl.Foreground = Brushes.Black; if (nm != "" && qnty_txb.Text != "") { qnty_lbl.Foreground = Brushes.Black; food_lbl.Foreground = Brushes.Black; List <products> lst_p = db1.products.ToList(); foreach (products prod in lst_p) { if (prod.name == nm) { details_order.products_id = prod.Id; details_order.products = prod; break; } } int qn = Convert.ToInt32(qnty_txb.Text); string quantity = details_order.products.pack.ToString(); if (quantity == "8 units") { qn *= 8; } else if (quantity == "crates of 30") { qn *= 30; } else if (quantity == "4 units") { qn *= 4; } else { qn *= 1; } details_order.details = notes_txb.Text; details_order.quantity = qn; db1.order_details.Add(details_order); db1.SaveChanges(); order_details_dtgrid.ItemsSource = db1.order_details.ToList(); order_details_dtgrid.Columns[0].Visibility = Visibility.Collapsed; order_details_dtgrid.Columns[4].Visibility = Visibility.Collapsed; order_details_dtgrid.Columns[5].Visibility = Visibility.Collapsed; food_cmbbx.SelectedIndex = -1; qnty_txb.Clear(); qnty_lbl.Content = "Quantity:"; qnty_lbl.Foreground = Brushes.Black; supplier_name_lbl.Foreground = Brushes.Black; qnty_lbl.Visibility = Visibility.Collapsed; qnty_txb.Visibility = Visibility.Collapsed; notes_txb.Text = ""; } else { if (nm != "") { qnty_lbl.Foreground = Brushes.Red; food_lbl.Foreground = Brushes.Black; } else { food_lbl.Foreground = Brushes.Red; } } } else { supplier_name_lbl.Foreground = Brushes.Red; if (nm == "") { food_lbl.Foreground = Brushes.Red; } else { food_lbl.Foreground = Brushes.Black; } if (qnty == "") { qnty_lbl.Foreground = Brushes.Red; } else { qnty_lbl.Foreground = Brushes.Black; } } }
private void fd_aply_btn_Click(object sender, RoutedEventArgs e) { List <order_details> lstp = db1.order_details.ToList(); order_details_dtgrid.ItemsSource = lstp; order_details_dtgrid.Columns[0].Visibility = Visibility.Collapsed; order_details_dtgrid.Columns[4].Visibility = Visibility.Collapsed; order_details_dtgrid.Columns[5].Visibility = Visibility.Collapsed; string nm = food_cmbbx.Text; if (nm != "" && qnty_txb.Text != "") { qnty_lbl.Foreground = Brushes.Black; food_lbl.Foreground = Brushes.Black; int qn = Convert.ToInt32(qnty_txb.Text); order_details details_order = new order_details(); if (nm.Contains("Pizza")) { if (dgh_type_cmbbx.Text != "") { List <products> lst_p = db1.products.ToList(); foreach (products prod in lst_p) { if (prod.name == nm) { details_order.products_id = prod.Id; details_order.products = prod; break; } } details_order.quantity = qn; details_order.details = dgh_type_cmbbx.Text + ", " + notes_txb.Text; db1.order_details.Add(details_order); db1.SaveChanges(); Pizza pz = new Pizza(qn, db1, order_details_dtgrid); pz.ShowDialog(); order_details_dtgrid.ItemsSource = db1.order_details.ToList(); order_details_dtgrid.Columns[0].Visibility = Visibility.Collapsed; order_details_dtgrid.Columns[4].Visibility = Visibility.Collapsed; order_details_dtgrid.Columns[5].Visibility = Visibility.Collapsed; dgh_type_cmbbx.Visibility = Visibility.Collapsed; dgh_type_cmbbx.SelectedIndex = -1; dgh_type_lbl.Visibility = Visibility.Collapsed; food_cmbbx.SelectedIndex = -1; qnty_txb.Clear(); notes_txb.Text = ""; dgh_type_lbl.Foreground = Brushes.Black; qnty_lbl.Visibility = Visibility.Collapsed; qnty_txb.Visibility = Visibility.Collapsed; } else { dgh_type_lbl.Foreground = Brushes.Red; } } else { List <products> lst_p = db1.products.ToList(); foreach (products prod in lst_p) { if (prod.name == nm) { details_order.products_id = prod.Id; details_order.products = prod; break; } } details_order.quantity = qn; details_order.details = notes_txb.Text; db1.order_details.Add(details_order); db1.SaveChanges(); order_details_dtgrid.ItemsSource = db1.order_details.ToList(); order_details_dtgrid.Columns[0].Visibility = Visibility.Collapsed; order_details_dtgrid.Columns[4].Visibility = Visibility.Collapsed; order_details_dtgrid.Columns[5].Visibility = Visibility.Collapsed; dgh_type_cmbbx.Visibility = Visibility.Collapsed; dgh_type_cmbbx.SelectedIndex = -1; dgh_type_lbl.Visibility = Visibility.Collapsed; food_cmbbx.SelectedIndex = -1; qnty_txb.Clear(); notes_txb.Text = ""; dgh_type_lbl.Foreground = Brushes.Black; qnty_lbl.Visibility = Visibility.Collapsed; qnty_txb.Visibility = Visibility.Collapsed; } } else { if (nm != "") { food_lbl.Foreground = Brushes.Black; qnty_lbl.Foreground = Brushes.Red; if (nm.Contains("Pizza")) { if (dgh_type_cmbbx.SelectedIndex == -1) { dgh_type_lbl.Foreground = Brushes.Red; } else { dgh_type_lbl.Foreground = Brushes.Black; } } } else { food_lbl.Foreground = Brushes.Red; } } }