private void EditItem() { app.OrderDetails orderItem = itemsBindingSource.Current as app.OrderDetails; //选中itemsBindingSource.Current对象 if (orderItem == null) { MessageBox.Show("请选择一个订单项进行修改"); return; } FormItemsEdit formItemEdit = new FormItemsEdit(orderItem); if (formItemEdit.ShowDialog() == DialogResult.OK) { itemsBindingSource.ResetBindings(false); } }
private void add_Click(object sender, EventArgs e) { FormItemsEdit formItemEdit = new FormItemsEdit(new app.OrderDetails()); //FormItemsEdit formItemEdit = new FormItemEdit(new OrderDetail()); try { if (formItemEdit.ShowDialog() == DialogResult.OK) { CurrentOrder.AddItem(formItemEdit.OrderItem); itemsBindingSource.ResetBindings(false); } } catch (Exception e2) { MessageBox.Show(e2.Message); } }