private void OnEdit() { FrmCustomerEdit dlg = new FrmCustomerEdit(); dlg.bNew = false; string id = custView.GetFocusedRowCellValue("ID").ToString(); CustomerHelper ch = new CustomerHelper(); dlg.customer = ch.GetCustomerByID(id); if (dlg.ShowDialog() == DialogResult.Cancel) { return; } if (dlg.bNew == false) { custGridView.UpdateCustomer(custView.FocusedRowHandle, dlg.customer); return; } if (custView.FocusedRowHandle < 0) { custGridView.InsertCustomer(0, dlg.customer); } else { custGridView.InsertCustomer(custView.FocusedRowHandle + 1, dlg.customer); } }
private void btnAdd_Click(object sender, EventArgs e) { FrmCustomerEdit dlg = new FrmCustomerEdit(); dlg.bNew = true; if (dlg.ShowDialog() == DialogResult.Cancel) { return; } if (custView.FocusedRowHandle < 0) { custGridView.InsertCustomer(0, dlg.customer); } else { custGridView.InsertCustomer(custView.FocusedRowHandle + 1, dlg.customer); } }