public DeleteDictionaryWindow(int id) { InitializeComponent(); using (var db = new groceryContext()) { Dictionary = db.Dictionary.FirstOrDefault(domain => domain.IdDictionary == id); } text.Text += Dictionary?.NameDictionary; }
public UpdateDictionaryWindow(int item) { InitializeComponent(); Item = item; using (var db = new groceryContext()) { nameDictioanary.Text = db.Dictionary.FirstOrDefault(domain => domain.IdDictionary == Item).NameDictionary; } }
public DeleteProviderWindow(int id) { InitializeComponent(); using (var db = new groceryContext()) { Provider = db.Provider.FirstOrDefault(domain => domain.IdProvider == id); } text.Text += Provider?.DenomintaionProvider; }
public List <ProductModel> FullProducts() { using (var db = new groceryContext()) { return(db.Product.Select(domain => new ProductModel { NameProduct = db.Dictionary.FirstOrDefault(dictionaryDomain => dictionaryDomain.IdDictionary == domain.IdDictionary).NameDictionary, IdProduct = domain.IdProduct }).ToList()); } }
private void Button_Click(object sender, RoutedEventArgs e) { using (var db = new groceryContext()) { db.Provider.Remove(Provider); db.SaveChanges(); } deleteProvider?.Invoke(); this.Close(); }
private void Button_Click(object sender, RoutedEventArgs e) { using (var db = new groceryContext()) { db.Dictionary.Remove(Dictionary); db.SaveChanges(); } deleteDictionary?.Invoke(); this.Close(); }
public List <ProviderModel> FullProvider() { using (var db = new groceryContext()) { return(db.Provider.Select(domain => new ProviderModel { NameProvider = domain.NameProvider, IdProvider = domain.IdProvider }).ToList()); } }
private void Add_Click(object sender, RoutedEventArgs e) { using (var db = new groceryContext()) { var oldDictionary = db.Dictionary.FirstOrDefault(domain => domain.IdDictionary == Item); oldDictionary.NameDictionary = nameDictioanary.Text; db.SaveChanges(); } this.Close(); }
public List <DictionaryModel> FullModel() { using (var db = new groceryContext()) { return(db.Dictionary.Select(domain => new DictionaryModel { IdDictionary = domain.IdDictionary, NameDictionary = domain.NameDictionary }).ToList()); } }
private void Add_Click(object sender, RoutedEventArgs e) { using (var db = new groceryContext()) { db.Dictionary.Add(new DictionaryDomain { NameDictionary = nameDictioanary.Text }); db.SaveChanges(); } addDictionary?.Invoke(); this.Close(); }
public List <ProductModel> FullModel() { using (var db = new groceryContext()) { return(db.Product.Select(domain => new ProductModel { IdProduct = domain.IdProduct, CountProduct = domain.CountProduct, NameProduct = db.Dictionary.FirstOrDefault(dictionaryDomain => dictionaryDomain.IdDictionary == domain.IdDictionary).NameDictionary, PriceProduct = domain.Price, RestProduct = domain.RestProduct, ShelfLifeProduct = domain.ShelfLifeProduct }).ToList()); } }
public List <SaleModel> FullModel() { using (var db = new groceryContext()) { var sales = db.Sale .Include(t => t.IdProductNavigation) .ThenInclude(p => p.IdDictionaryNavigation).ToList(); return(sales.Select(domain => new SaleModel { IdSale = domain.IdSale, CountSale = domain.CountSale, DateSale = domain.DataSale, Product = domain.IdProductNavigation }).ToList()); } }
public List <WaybillModel> FullModel() { using (var db = new groceryContext()) { return(db.Waybill.Select(domain => new WaybillModel { IdWaybill = domain.IdWaybill, NameProvider = db.Provider.FirstOrDefault(providerDomain => providerDomain.IdProvider == domain.IdProvider).NameProvider, DateWaybill = domain.IdData, ProductModels = domain.Product.Select(productDomain => new ProductModel { NameProduct = db.Dictionary.FirstOrDefault(dictionaryDomain => dictionaryDomain.IdDictionary == productDomain.IdDictionary).NameDictionary }).ToList() }).ToList()); } }
public List <ProviderModel> FullModel() { using (var db = new groceryContext()) { return(db.Provider.Select(domain => new ProviderModel { IdProvider = domain.IdProvider, DenomintaionProvider = domain.DenomintaionProvider, NameProvider = domain.NameProvider, SurnameProvider = domain.SurnameProvider, PatronymicProvider = domain.PatronymicProvider, CityProvider = domain.CityProvider, FaxProvider = domain.FaxProvider, PhoneProvider = domain.PhoneProvider }).ToList()); } }
private void Denomintation_LostFocus(object sender, RoutedEventArgs e) { var textBox = (TextBox)sender; var selected = (ProviderModel)database.SelectedItem; using (var db = new groceryContext()) { var provider = db.Provider.FirstOrDefault(domain => selected.IdProvider == domain.IdProvider); switch (textBox.Name) { case "denomintation": provider.DenomintaionProvider = textBox.Text; break; case "name": provider.NameProvider = textBox.Text; break; case "surname": provider.SurnameProvider = textBox.Text; break; case "patronymic": provider.PatronymicProvider = textBox.Text; break; case "phone": provider.PhoneProvider = textBox.Text; break; case "fax": provider.FaxProvider = textBox.Text; break; case "city": provider.CityProvider = textBox.Text; break; } db.SaveChanges(); } }
private void Button_Click(object sender, RoutedEventArgs e) { using (var db = new groceryContext()) { db.Provider.Add(new ProviderDomain { PatronymicProvider = patronymic.Text, DenomintaionProvider = denomintation.Text, CityProvider = city.Text, FaxProvider = fax.Text, NameProvider = name.Text, PhoneProvider = phone.Text, SurnameProvider = surname.Text }); db.SaveChanges(); } addProvider?.Invoke(); this.Close(); }
private void Button_Click(object sender, RoutedEventArgs e) { using (var db = new groceryContext()) { var product = (from DictionaryModel productsSelectedItem in products.SelectedItems select new ProductDomain { IdDictionary = productsSelectedItem.IdDictionary, RestProduct = int.Parse(count.Text), CountProduct = int.Parse(count.Text), ShelfLifeProduct = DateTime.Parse(date.Text), IdDictionaryNavigation = db.Dictionary.FirstOrDefault(domain => domain.IdDictionary == productsSelectedItem.IdDictionary), Price = decimal.Parse(price.Text) }).ToList(); db.Product.AddRange(product); var waybill = new WaybillDomain { IdData = DateTime.Now, IdProvider = int.Parse(providers.SelectedValue.ToString()), IdProviderNavigation = db.Provider.FirstOrDefault(domain => domain.IdProvider == int.Parse(providers.SelectedValue.ToString())), Product = product }; db.Waybill.Add(waybill); foreach (var productDomain in product) { productDomain.IdWaybillNavigation = waybill; } db.SaveChanges(); addWaybill?.Invoke(); this.Close(); } }
private void Button_Click(object sender, RoutedEventArgs e) { using (var db = new groceryContext()) { var sell = new SaleDomain { IdProductNavigation = db.Product.FirstOrDefault(domain => domain.IdProduct == int.Parse(products.SelectedValue.ToString())), IdProduct = int.Parse(products.SelectedValue.ToString()), DataSale = DateTime.Now, CountSale = int.Parse(count.Text) }; var product = db.Product.FirstOrDefault(domain => domain.IdProduct == int.Parse(products.SelectedValue.ToString())); product.RestProduct -= int.Parse(count.Text); db.Sale.Add(sell); db.SaveChanges(); sellProduct?.Invoke(); this.Close(); } }