private void customerDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { AddCustomerUi addCustomerUi = new AddCustomerUi(this); if (customerDataGridView.Columns[e.ColumnIndex].Name == "Edit") { try { if (e.RowIndex >= 0) { if (customerDataGridView.CurrentRow != null) { customerDataGridView.CurrentRow.Selected = true; } addCustomerUi.customerId = Convert.ToInt32(customerDataGridView.Rows[e.RowIndex].Cells[1].Value); addCustomerUi.codeTextBox.Text = customerDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString(); addCustomerUi.nameTextBox.Text = customerDataGridView.Rows[e.RowIndex].Cells[3].Value.ToString(); addCustomerUi.addressTextBox.Text = customerDataGridView.Rows[e.RowIndex].Cells[4].Value.ToString(); addCustomerUi.emailTextBox.Text = customerDataGridView.Rows[e.RowIndex].Cells[5].Value.ToString(); addCustomerUi.contactTextBox.Text = customerDataGridView.Rows[e.RowIndex].Cells[6].Value.ToString(); addCustomerUi.loyaltyPointTextBox.Text = customerDataGridView.Rows[e.RowIndex].Cells[7].Value.ToString(); addCustomerUi.saveOrUpdateButton.Text = @"Update"; addCustomerUi.Show(); } } catch (Exception exception) { MessageBox.Show(exception.Message); } } }
private void addCustomerButton_Click(object sender, EventArgs e) { AddCustomerUi addCustomerUi = new AddCustomerUi(this); addCustomerUi.Show(); }