private void fd_aply_btn_Click(object sender, RoutedEventArgs e) { List <products> lstp = db1.products.ToList(); order_dtgrid.ItemsSource = lstp; string nm = food_cmbbx.Text; int qn = qnty_cmbbx.SelectedIndex + 1; int prc = 0; if (nm != "") { if (nm == "Pizza") { if (dgh_type_cmbbx.Text != "" && size_cmbbx.Text != "") { string size = size_cmbbx.Text; size = nm + " " + size; List <list_product> lst_p = db1.list_product.ToList(); foreach (list_product lp in lst_p) { if (lp.name == size) { prc = lp.price; break; } } products products = new products { name = size, price = prc, quantity = qn, details = dgh_type_cmbbx.Text }; Pizza pz = new Pizza(qn, db1, order_dtgrid); db1.products.Add(products); db1.SaveChanges(); pz.ShowDialog(); order_dtgrid.ItemsSource = db1.products.ToList(); ////order_dtgrid.Columns[5].Visibility = Visibility.Collapsed; } } else { List <list_product> lst_p = db1.list_product.ToList(); foreach (list_product lp in lst_p) { if (lp.name == nm) { prc = lp.price; break; } } products p = new products { name = nm, quantity = qn, price = prc }; db1.products.Add(p); db1.SaveChanges(); order_dtgrid.ItemsSource = db1.products.ToList(); ////order_dtgrid.Columns[5].Visibility = Visibility.Collapsed; } } dgh_type_cmbbx.Visibility = Visibility.Hidden; dgh_type_cmbbx.SelectedIndex = -1; size_cmbbx.Visibility = Visibility.Hidden; size_cmbbx.SelectedIndex = -1; size_lbl.Visibility = Visibility.Hidden; dgh_type_lbl.Visibility = Visibility.Hidden; food_cmbbx.SelectedIndex = -1; qnty_cmbbx.SelectedIndex = 0; }
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; } } }