private void EditCustomer() { if (lstCustomer.SelectedIndices.Count == 0) { return; } int selectedIndex = lstCustomer.SelectedIndices[0]; Customer customer = _customerManager.Customers[selectedIndex]; fCustomer formCustomer = new fCustomer(); formCustomer.EditingCustomer = new Customer() { Name = customer.Name, LastName = customer.LastName, Address = customer.Address }; if (formCustomer.ShowDialog() == DialogResult.OK) { _customerManager.SetCustomer(selectedIndex, formCustomer.EditingCustomer); btnRefresh.PerformClick(); } }
private void btnNew_Click(object sender, EventArgs e) { fCustomer formCustomer = new fCustomer(); formCustomer.EditingCustomer = new Customer(); if (formCustomer.ShowDialog() == DialogResult.OK) { Customer newCustomer = formCustomer.EditingCustomer; _customerManager.AddCustomer(newCustomer.Name, newCustomer.LastName, newCustomer.Address); btnRefresh.PerformClick(); } }