public void Add1(ClientModel client) { try { db.Person.Add(new Person { Surname = client.SurName, Name = client.Name, Patronymic = client.Patronymic, }); db.Company.Add(new Company { Name = client.CompanyName, Adress = client.CompanyAdress }); db.SaveChanges(); db.Client.Add(new Client { Email = client.Email, Person_id = db.Person.Local.Last().Id, Company_id = db.Company.Local.Last().Id, Phone = client.Phone }); db.SaveChanges(); } catch (Exception ex) { MessageBox.Show("Ошибка", ex.Message); } }
public void Update(ZakazModel model) { Material material = bd.Material.FirstOrDefault(p => p.Price.Equals(model.Price_material)); var orderForUpdate = bd.Order.FirstOrDefault(order => order.Id.Equals(model.Id)); orderForUpdate.Id_material = model.Id_material; orderForUpdate.Id_service = model.Id_service; orderForUpdate.DateOfIssue = model.DateOfIssue; orderForUpdate.СirculationTerm = model.CirculationTerm; orderForUpdate.Width = model.Width; orderForUpdate.Height = model.Height; orderForUpdate.kol = model.kol; material.Price = model.Price_material; bd.SaveChanges(); }
public void Add(ZakazModel zakaz) { using (var context = new EnityContext()) { context.Material.Add(new Material { Price = zakaz.Price_material, }); context.SaveChanges(); } using (var context = new EnityContext()) { context.Order.Add(new Order { DateOfIssue = zakaz.DateOfIssue, СirculationTerm = zakaz.CirculationTerm, Width = zakaz.Width, Height = zakaz.Height, kol = zakaz.kol, id_manager = zakaz.Id_manager, Id_client = zakaz.Id_client, Id_service = zakaz.Id_service, Id_material = zakaz.Id_material, }); context.SaveChanges(); } try { } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка"); } }