private void 增加订单ToolStripMenuItem_Click(object sender, EventArgs e) { Form_addOrder addOrderForm = new Form_addOrder(); DialogResult dialogResult = addOrderForm.ShowDialog(); if (dialogResult == DialogResult.OK) { //将addOrderForm的订单添加到os1中 bindingSource1.List.Add(addOrderForm.addOrder); } }
private void 增加订单ToolStripMenuItem_Click(object sender, EventArgs e) { Form_addOrder addOrderForm = new Form_addOrder(); DialogResult dialogResult = addOrderForm.ShowDialog(); if (dialogResult == DialogResult.OK) { using (var db = new OrderModel()) { db.Orders.Add(addOrderForm.addOrder); db.SaveChanges(); bindingSource1.DataSource = db.Orders.ToList <Order>(); } //将addOrderForm的订单添加到os1中 // bindingSource1.List.Add(addOrderForm.addOrder); } }