private void bvg_aply_btn_Click(object sender, RoutedEventArgs e) { List <products> lstp = db1.products.ToList(); order_dtgrid.ItemsSource = lstp; string nm = beverage_cmbbx.Text; if (nm != "") { int qn = qnty_cmbbx.SelectedIndex + 1; int prc = 0; List <list_product> lst_p = db1.list_product.ToList(); foreach (list_product lp in lst_p) { if (lp.name == nm) { prc = lp.price; break; } } //int i = food_cmbbx.Items.Count+ 2 + beverage_cmbbx.SelectedIndex; //prc = lst_p[i].price; 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; } beverage_cmbbx.SelectedIndex = -1; qnty_cmbbx.SelectedIndex = 0; }
private void add_extra_Click(object sender, RoutedEventArgs e) { name = extra_cmbbx.Text; details = location_cmbbx.Text; if (name != "" && details != "") { if (name == "Nothing") { price = 0; } List <list_product> lst_p = db1.list_product.ToList(); foreach (list_product lp in lst_p) { if (lp.name == name) { price = lp.price; break; } } products products = new products { name = name, price = price, quantity = quantity, details = details }; db1.products.Add(products); dataGrid.ItemsSource = db1.products.ToList(); db1.SaveChanges(); } }
private void bvg_aply_btn_Click(object sender, RoutedEventArgs e) { List <products> lstp = db1.products.ToList(); order_dtgrid.ItemsSource = lstp; string nm = beverage_cmbbx.Text; if (nm != "") { int qn = (qnty_cmbbx.SelectedIndex + 1) * 24; int prc = 0; prc += Calculating_price(nm); 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[4].Visibility = Visibility.Collapsed; ////order_dtgrid.Columns[5].Visibility = Visibility.Collapsed; } beverage_cmbbx.SelectedIndex = -1; qnty_cmbbx.SelectedIndex = 0; qnty_lbl.Content = "Quantity:"; }
private void order_dtgrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { prod = (products)order_dtgrid.SelectedItem; } catch { MessageBox.Show("you selected a non-existent product", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void add_product_btn_Click_1(object sender, RoutedEventArgs e) { int price; if (name_add_product.Text != "" && price_add_product.Text != "" && kind_add_product.SelectedItem != null && (add_sell.IsChecked == true || add_buy.IsChecked == true) && add_prd_pack_lsb.SelectedItem != null) { if (checking_name(name_add_product.Text)) { string name = name_add_product.Text; price = Convert.ToInt32(price_add_product.Text); kind_product kp = db1.kind_product.ToArray()[kind_add_product.SelectedIndex]; client_or_supplier cl_or_sp = new client_or_supplier(); int i = 0; if (add_sell.IsChecked == true) { if (add_buy.IsChecked == true) { i = 2; cl_or_sp = db1.client_or_supplier.ToArray()[i]; } else { i = 0; cl_or_sp = db1.client_or_supplier.ToArray()[i]; } } else { if (add_buy.IsChecked == true) { i = 1; cl_or_sp = db1.client_or_supplier.ToArray()[i]; } } products p = new products { name = name, price = price, kind_product = kp, kind_product_id = kind_add_product.SelectedIndex + 1, pack = add_prd_pack_lsb.SelectedItem.ToString().Substring(37), client_or_supplier = cl_or_sp, c_or_s_id = i + 1 }; db1.products.Add(p); db1.SaveChanges(); MessageBox.Show("The product has been added", "Succes", MessageBoxButton.OK, MessageBoxImage.Information); this.Close(); } else { MessageBox.Show("The name of the product is already exist in the system", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Fill all the fields", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } }
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; prc += Calculating_price(size); 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 { prc += Calculating_price(nm); 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; size_cmbbx.Visibility = Visibility.Hidden; 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 <products> lstp = db1.products.ToList(); order_dtgrid.ItemsSource = lstp; string nm = food_cmbbx.Text; int qn = qnty_cmbbx.SelectedIndex + 1; string qnty = (string)qnty_lbl.Content; if (qnty == "Quantity: (8 Units)") { qn *= 8; } else if (qnty == "Quantity: (crates of 30)") { qn *= 30; } else if (qnty == "Quantity: (4 Units)") { qn *= 4; } else { qn *= 1; } int prc = 0; if (nm != "") { prc += Calculating_price(nm); 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[4].Visibility = Visibility.Collapsed; ////order_dtgrid.Columns[5].Visibility = Visibility.Collapsed; } food_cmbbx.SelectedIndex = -1; qnty_cmbbx.SelectedIndex = 0; qnty_lbl.Content = "Quantity:"; }
private void finish_Click(object sender, RoutedEventArgs e) { name = extra_cmbbx.Text; details = location_cmbbx.Text; if (name != "" && details != "") { if (name == "Nothing") { price = 0; } products products = new products { name = name, price = price, quantity = quantity, details = details }; db1.products.Add(products); dataGrid.ItemsSource = db1.products.ToList(); db1.SaveChanges(); this.Close(); } }
private void product_dtgrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { chnge_buy.IsChecked = false; chnge_sell.IsChecked = false; change_prd_pack_lsb.SelectedIndex = -1; pro = (products)product_dtgrid.SelectedItem; name_chnge_product.Text = pro.name; price_chnge_product.Text = pro.price.ToString(); kind_chnge_product.SelectedIndex = pro.kind_product_id - 1; for (int i = 0; i < change_prd_pack_lsb.Items.Count; i++) { if (change_prd_pack_lsb.Items[i].ToString().Substring(37) == pro.pack) { change_prd_pack_lsb.SelectedIndex = i; break; } } switch (pro.c_or_s_id) { case 1: chnge_sell.IsChecked = true; break; case 2: chnge_buy.IsChecked = true; break; case 3: chnge_buy.IsChecked = true; chnge_sell.IsChecked = true; break; } } catch { MessageBox.Show("you selected a non-existent product", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } }