private void AddItem(object sender, RoutedEventArgs e) { if (ItemBox1.Text != "" || PriceBox1.Text != "") { float price = 0; price = Convert.ToUInt64(PriceBox1.Text); using (var context = new LoginDBEntities()) { var product = new ProductFromStore() { UserName = Person.Login, ProductName = ItemBox1.Text, Price = price }; context.ProductFromStores.Add(product); context.SaveChanges(); ItemBox1.Clear(); PriceBox1.Clear(); } ItemBox1.Text = ""; PriceBox1.Text = ""; } else { MessageBox.Show("Incorrect"); } }
private void Add_in_Main_list(object sender, RoutedEventArgs e) { float price = 0; price = Convert.ToUInt64(Price.Text); using (var context = new LoginDBEntities()) { var product = new ProductFromStore() { UserName = UserName.Text, ProductName = Product.Text, Price = price }; context.ProductFromStores.Add(product); context.SaveChanges(); UserName.Clear(); Product.Clear(); Price.Clear(); MessageBox.Show("You add in main list"); } }