private void gridAddress_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } Address address = new Address(); address.CustomerID = Convert.ToInt32(gridAddress.SelectedRows[0].Cells["CustomerID"].Value.ToString()); address.AddressID = Convert.ToInt32(gridAddress.SelectedRows[0].Cells["AddressID"].Value.ToString()); address.AddressType = gridAddress.SelectedRows[0].Cells["AddressType"].Value.ToString(); address.AddressLine1 = gridAddress.SelectedRows[0].Cells["AddressLine1"].Value.ToString(); address.AddressLine2 = gridAddress.SelectedRows[0].Cells["AddressLine2"].Value.ToString(); address.City = gridAddress.SelectedRows[0].Cells["City"].Value.ToString(); address.StateProvince = gridAddress.SelectedRows[0].Cells["StateProvince"].Value.ToString(); address.CountryRegion = gridAddress.SelectedRows[0].Cells["CountryRegion"].Value.ToString(); address.PostalCode = gridAddress.SelectedRows[0].Cells["PostalCode"].Value.ToString(); using (Form form = new frmAddressDetail(address)) { form.ShowDialog(this); } FetchAddresses(); }
private void btnAddAddress_Click(object sender, EventArgs e) { Address address = new Address(); address.CustomerID = this.customer.CustomerID; using (Form form = new frmAddressDetail(address, false)) { form.ShowDialog(this); } FetchAddresses(); }