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, "Ошибка"); } }
public ZakazLogic() { bd = new EnityContext(); Zakaz = new List <ZakazModel>(); Services = new List <Services>(); Materiales = new List <Material>(); }
public override IEnumerable <DynamicNode> GetDynamicNodeCollection(ISiteMapNode node) { using (var db = new EnityContext()) { // Create a node for each news article foreach (var news in db.News) { var dynamicNode = new DynamicNode(); dynamicNode.Title = news.Title; dynamicNode.ParentKey = "News"; dynamicNode.RouteValues.Add("id", news.Id); yield return(dynamicNode); } } }
private async void button2_Click(object sender, EventArgs e) { try { if (dataGridView1.CurrentRow != null) { DataGridViewRow row = dataGridView1.CurrentRow; using (var context = new EnityContext()) { ZakazModel model = new ZakazModel() { Id = Int32.Parse(row.Cells["Id"].Value.ToString()), Id_client = Int32.Parse(row.Cells["Id_client"].Value.ToString()), Id_manager = Int32.Parse(row.Cells["Id_material"].Value.ToString()), Id_material = Int32.Parse(row.Cells["Id_material"].Value.ToString()), Id_service = Int32.Parse(row.Cells["Id_service"].Value.ToString()), DateOfIssue = DateTime.Parse(row.Cells["DateOfIssue"].Value.ToString()), CirculationTerm = Int32.Parse(row.Cells["CirculationTerm"].Value.ToString()), Width = Int32.Parse(row.Cells["Width"].Value.ToString()), Height = Int32.Parse(row.Cells["Height"].Value.ToString()), kol = Int32.Parse(row.Cells["kol"].Value.ToString()), Material = row.Cells["Material"].Value.ToString(), Service = row.Cells["Service"].Value.ToString(), Price_material = float.Parse(row.Cells["Price_material"].Value.ToString()), }; await context.Order.LoadAsync(); // model.Id = context.Order.Local.First(c=>c.Id.Equals(Id)).Id; zakazLogic.SelectedZakaz = model; } } new UpdateZakaz(zakazLogic.SelectedZakaz).ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message); } //UpdateDataSet(); }
private void Autoriz() { try { using (var db = new EnityContext()) { Manager manager = db.Manager.FirstOrDefault(IsCurrentUser); if (manager == null) { throw new Exception("NYET!!!>_<"); } ManagerSingleton.Instance(manager); this.Hide(); new Information().ShowDialog(); this.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private async void UpdateButton_Click(object sender, EventArgs e) { try { // if (clientLogic.SelectedClient == null) // throw new Exception("NIEY!!!>_< UpdateButton"); if (dataGridView1.CurrentRow != null) { DataGridViewRow row = dataGridView1.CurrentRow; using (var context = new EnityContext()) { ClientModel client = new ClientModel() { Name = row.Cells["ClientName"].Value.ToString(), SurName = row.Cells["Surname"].Value.ToString(), Patronymic = row.Cells["Patronymic"].Value.ToString(), CompanyAdress = row.Cells["CompanyAdress"].Value.ToString(), Phone = row.Cells["PhoneColumn"].Value.ToString(), Email = row.Cells["Email"].Value.ToString(), CompanyName = row.Cells["CompanyName"].Value.ToString(), CompanyId = Int32.Parse(row.Cells["CompanyId"].Value.ToString()), Id = Int32.Parse(row.Cells["ClientId"].Value.ToString()), }; await context.Client.LoadAsync(); client.PersonId = context.Client.Local.First(c => c.Id.Equals(client.Id)).Person_id; clientLogic.SelectedClient = client; } } new Updateinf(clientLogic.SelectedClient).ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ClientLogic() { db = new EnityContext(); Clients = new List <ClientModel>(); }