//编辑 private void editTool_Click(object sender, EventArgs e) { if (dgv.CurrentCell == null) { GeneralClass.printErrorMsg("没有选择行!"); return; } string id = dgv.Rows[dgv.CurrentCell.RowIndex].Cells[0].Value.ToString(); var customer = db.Customer.FirstOrDefault(x => x.id.ToString() == id); CustomerForm editCustomer = new CustomerForm(db, customer); if (editCustomer.ShowDialog() == DialogResult.OK) { dgv_show(); } }
//新增客户 private void addTool_Click(object sender, EventArgs e) { int rindex = -1; int cindex = -1; if (dgvCustomerList.CurrentCell != null) { rindex = dgvCustomerList.CurrentCell.RowIndex; cindex = dgvCustomerList.CurrentCell.ColumnIndex; } var form = new CustomerForm(db, null); if (form.ShowDialog() == DialogResult.OK) { dgvCustomer_show(); if (rindex != -1 && cindex != -1) dgvCustomerList.CurrentCell = dgvCustomerList[cindex, rindex]; } }
//编辑客户 private void editTool_Click(object sender, EventArgs e) { if (dgvCustomerList.CurrentCell == null) { BathClass.printErrorMsg("需要选择行!"); return; } int rindex = dgvCustomerList.CurrentCell.RowIndex; int cindex = dgvCustomerList.CurrentCell.ColumnIndex; var p = db.Customer.FirstOrDefault(x => x.name == dgvCustomerList.CurrentRow.Cells[0].Value.ToString()); var form = new CustomerForm(db, p); if (form.ShowDialog() == DialogResult.OK) { dgvCustomer_show(); dgvCustomerList.CurrentCell = dgvCustomerList[cindex, rindex]; } }
//新增客户 private void addTool_Click(object sender, EventArgs e) { int rindex = -1; int cindex = -1; if (dgvCustomerList.CurrentCell != null) { rindex = dgvCustomerList.CurrentCell.RowIndex; cindex = dgvCustomerList.CurrentCell.ColumnIndex; } var form = new CustomerForm(db, null); if (form.ShowDialog() == DialogResult.OK) { dgvCustomer_show(); if (rindex != -1 && cindex != -1) { dgvCustomerList.CurrentCell = dgvCustomerList[cindex, rindex]; } } }
//编辑 private void editTool_Click(object sender, EventArgs e) { if (dgv.CurrentCell == null) { GeneralClass.printErrorMsg("没有选择行!"); return; } string id = dgv.Rows[dgv.CurrentCell.RowIndex].Cells[0].Value.ToString(); var customer = db.Customer.FirstOrDefault(x => x.id.ToString() == id); CustomerForm editCustomer = new CustomerForm(db, customer); if (editCustomer.ShowDialog() == DialogResult.OK) dgv_show(); }
//新增 private void addTool_Click(object sender, EventArgs e) { CustomerForm customerForm = new CustomerForm(db, null); if (customerForm.ShowDialog() == DialogResult.OK) dgv_show(); }