private void Button_Click_1(object sender, RoutedEventArgs e) { if (dataGriPriduct.SelectedItem != null) { Products Produc = dataGriPriduct.SelectedItem as Products; // Используем LINQ to Entities для обновления базы данных Products pro = db.Products .Where(p => p.Id == Produc.Id) .Single <Products>(); //обновление pro.Name = Produc.Name; pro.Brand = Produc.Brand; pro.Catalogue_num = Produc.Catalogue_num; pro.Category = Produc.Category; pro.Color = Produc.Color; pro.ART = Produc.ART; pro.Price_first = Produc.Price_first; pro.Price_sale = Produc.Price_sale; pro.Product_rest = Produc.Product_rest; db.SaveChanges(); _renewControlls(); } }
private void ButAdd_Click(object sender, RoutedEventArgs e) { using (ShopAutoEntities db = new ShopAutoEntities()) { try { Employee emp = (new Employee() { Post = tbPosition.Text, FIO = tbName.Text + " " + tbfamile.Text + " " + tbochesvo.Text, Date_start = Convert.ToDateTime(DateStart.Text), Birthday = Convert.ToDateTime(tbbirdDay.Text), Passport_data = tbPassportData.Text, Phone1 = tbPhone.Text, Phone2 = tbPhone2.Text }); db.Employee.Add(emp); db.SaveChanges(); Users us = (new Users() { Login = tbLogin.Text, Password = tbPassword.Text }); db.Users.Add(us); db.SaveChanges(); this.Hide(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } }
private void Button_Click(object sender, RoutedEventArgs e) { using (ShopAutoEntities db = new ShopAutoEntities()) { // Binding binding = new Binding(); try { Products Prod = (new Products() { Name = tbName.Text, Brand = AllBrand, Category = ComboBoxCategory.Text, ART = tbArt.Text, Catalogue_num = tbCatalogNum.Text, Manufacturer = tbManufacturer.Text, Price_first = Convert.ToDecimal(tbPriceFirst.Text), Price_sale = Convert.ToDecimal(tbPriceFirst.Text), Color = tbColor.Text, Product_rest = Convert.ToInt32(tbProductRest.Text) }); db.Products.Add(Prod); db.SaveChanges(); this.Close(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } }
private void button_Click(object sender, RoutedEventArgs e) { if (tbCategory.Text != " ") { using (ShopAutoEntities db1 = new ShopAutoEntities()) { try { ProductCategorry ProCa = (new ProductCategorry() { CategoryExtra = tbCategory.Text }); db1.ProductCategorry.Add(ProCa); db1.SaveChanges(); ShowCategory(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } tbCategory.Text = " "; } }
private void Button_Click(object sender, RoutedEventArgs e) { Employee ct = (Employee)DataContext; // Используем LINQ to Entities для обновления базы данных ShopAutoEntities db = new ShopAutoEntities(); Employee ct1 = db.Employee .Where(p => p.Id == ct.Id) .Single <Employee>(); //обновление ct1.Date_end = Calendar1.DisplayDate; db.SaveChanges(); this.Hide(); }
private void Button_Click_1(object sender, RoutedEventArgs e) { if (DataGridCategory.SelectedItem != null) { ProductCategorry CategoreProd = DataGridCategory.SelectedItem as ProductCategorry; // Используем LINQ to Entities для обновления базы данных ShopAutoEntities db = new ShopAutoEntities(); ProductCategorry pro = db.ProductCategorry .Where(p => p.Id == CategoreProd.Id) .Single <ProductCategorry>(); //обновление db.ProductCategorry.Remove(pro); db.SaveChanges(); ShowCategory(); } }
private void ButAdd_Click(object sender, RoutedEventArgs e) { Employee ct = (Employee)DataContext; // Используем LINQ to Entities для обновления базы данных ShopAutoEntities db = new ShopAutoEntities(); Employee ct1 = db.Employee .Where(p => p.Id == ct.Id) .Single <Employee>(); //обновление ct1.FIO = ct.FIO; ct1.Birthday = ct.Birthday; ct1.Date_start = ct.Date_start; ct1.Passport_data = ct.Passport_data; ct1.Phone1 = ct.Phone1; ct1.Phone2 = ct.Phone2; ct1.Post = ct.Post; db.SaveChanges(); this.Hide(); }