using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace kursach_2._0.Windows { /// /// Логика взаимодействия для product_insert.xaml /// public partial class product_insert : Window { private dealerContext _context; public product_insert() { InitializeComponent(); _context = new dealerContext(); DP_production_date.SelectedDate = DateTime.Today; } private void ButtonOK_Click(object sender, RoutedEventArgs e) { InsertProduct(TB_id_distributor.Text, TB_product_name.Text, TB_product_type.Text, (DateTime)DP_production_date.SelectedDate, TB_warranty.Text, TB_wholesale_price.Text, TB_retail_price.Text); // обновить то бишь Load } public bool InsertProduct(string id_distributor, string product_name, string product_type, DateTime production_date, string warranty, string wholesale_price, string retail_price) { if (string.IsNullOrWhiteSpace(product_name) || string.IsNullOrWhiteSpace(product_type) || (string.IsNullOrWhiteSpace(warranty))) return false; products products = new products() { id_distributor = int.Parse(id_distributor), product_name = product_name, product_type = product_type, production_date = production_date, warranty = warranty, wholesale_price = int.Parse(wholesale_price), retail_price = int.Parse(retail_price) }; _context.products.Add(products); _context.SaveChanges(); return true; } } }