コード例 #1
0
ファイル: fMain.cs プロジェクト: bonino97/GestionClientes
        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();
            }
        }
コード例 #2
0
ファイル: fMain.cs プロジェクト: bonino97/GestionClientes
        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();
            }
        }