private void button1_Click_1(object sender, EventArgs e) { try { //if (clientLogic.SelectedClient == null) // throw new Exception("NIEY!!!>_< UpdateButton"); if (dataGridView1.CurrentRow != null) { DataGridViewRow row = dataGridView1.CurrentRow; ZakazModel zakaz = 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()), }; zakazLogic.Delete(zakaz); UpdateDataSet(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex >= 0) { DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; ZakazModel zakaz = new ZakazModel() { Id = Int32.Parse(row.Cells["Id"].Value.ToString()), Id_service = Int32.Parse(row.Cells["Id_service"].Value.ToString()), Id_manager = Int32.Parse(row.Cells["Id_manager"].Value.ToString()), Id_material = Int32.Parse(row.Cells["Id_material"].Value.ToString()), Id_client = Int32.Parse(row.Cells["Id_client"].Value.ToString()), DateOfIssue = DateTime.Parse(row.Cells["DateOfIssue"].Value.ToString()), CirculationTerm = Int32.Parse(row.Cells["CirculationTerm"].Value.ToString()), Width = float.Parse(row.Cells["Width"].Value.ToString()), Height = float.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()), }; zakazLogic.SelectedZakaz = zakaz; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка"); } }
public void Add(ZakazModel zakaz) { try { bd.Material.Add(new Material { Material1 = zakaz.Material, Price = zakaz.Price_material, }); bd.SaveChanges(); bd.Order.Add(new Order { Id = zakaz.Id, 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, }); bd.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка"); } }
public void UpdateZakaz(ZakazModel c) { Zakaz c1 = db.Zakaz.Where(i => i.Id == c.Id).FirstOrDefault(); db.Entry(toZakaz(c1, c)).State = EntityState.Modified; db.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, "Ошибка"); } }
public void Delete(ZakazModel model) { Material material = bd.Material.FirstOrDefault(c => c.Id.Equals(model.Id_material)); Services cervices = bd.Services.FirstOrDefault(c => c.Id.Equals(model.Id_service)); Order order = bd.Order.FirstOrDefault(c => c.Id.Equals(model.Id)); bd.Material.Remove(material); bd.Services.Remove(cervices); bd.Order.Remove(order); bd.SaveChanges(); }
public Zakaz toZakaz(Zakaz z, ZakazModel z1) { z.Id = z1.Id; z.Km = z1.Km; z.Gruz = z1.Gruz; z.Operator = z1.Operator; z.Price_gruz = z1.Price_gruz; z.Status = z1.Status; z.Tip_gruza = z1.Tip_gruza; z.Dostavka = z1.Dostavka; z.DataVruchenia = z1.DataVruchenia; z.Client = z1.Client; return(z); }
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(); }
private void button1_Click(object sender, EventArgs e) { model = new ZakazModel() { Service = serviceComboBox.Text, Material = materialComboBox.Text, DateOfIssue = date.Value, CirculationTerm = Int32.Parse(SrokTextBox.Text), Width = Int32.Parse(widthTextBox.Text), Height = Int32.Parse(HeightTextBox.Text), kol = Int32.Parse(KolTextBox.Text), Id_manager = ManagerSingleton.Instance().Id, Id_client = clientModel.Id, Id_material = zakazLogic.Materiales.FirstOrDefault(m => m.Material1.Equals(materialComboBox.Text)).Id, Id_service = zakazLogic.Services.FirstOrDefault(s => s.Service.Equals(serviceComboBox.Text)).Id, }; zakazLogic.Add(model); }
private async void button2_Click(object sender, EventArgs e) { try { if (dataGridView1.CurrentRow != null) { DataGridViewRow row = dataGridView1.CurrentRow; using (var context = new Model1()) { 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(); }
public UpdateZakaz(ZakazModel zakazModel) { InitializeComponent(); zakazLogic = new ZakazLogic(); model = zakazModel; }
public void DeleteZakaz(ZakazModel s) { db.Zakaz.Remove(db.Zakaz.Find(s.Id)); }
public void addZakaz(ZakazModel z) { db.Zakaz.Add(toZakaz(new Zakaz(), z)); }