private void AddItem(object sender, RoutedEventArgs e) { if (ItemBox.Text != "" || PriceBox.Text != "") { float price = 0; price = Convert.ToUInt64(PriceBox.Text); using (var context = new LoginDBEntities()) { var product = new ProductFromPeople() { UserName = Person.Login, ProductName = ItemBox.Text, Price = price }; context.ProductFromPeoples.Add(product); context.SaveChanges(); ItemBox.Clear(); PriceBox.Clear(); MessageBox.Show("Wait , when admin to add your thing to the main list"); } } else { MessageBox.Show("Incorrect"); } }
private void AddBtn_Click(object sender, RoutedEventArgs e) { string ItemName = ItemBox.Text; string DateOfSale = DateBox.Text; string Country = CountryBox.Text; string Currency = CurrencyBox.Text; if (!float.TryParse(PriceBox.Text, out float NetPrice) & float.TryParse(VATbox.Text, out float VAT)) { MessageBox.Show("Net Price and VAT fields can only contain numbers!"); } con.InsertSales(ItemName, Country, Currency, DateOfSale, NetPrice, VAT); MessageBox.Show("Sale has been added."); ItemBox.Clear(); DateBox.Clear(); CountryBox.Clear(); CurrencyBox.Clear(); PriceBox.Clear(); VATbox.Clear(); }