コード例 #1
0
        private void btnAddNewCustomer_Click(object sender, EventArgs e)
        {
            var dialog = new CustomerDialog();
            var result = dialog.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                var customer = dialog.Customer;

                SupportService.Customers.Add(customer);

                this.cboCustomer.Items.Clear();

                var customers = SupportService.Customers.GetAll();

                foreach (var c in customers)
                {
                    this.cboCustomer.Items.Add(c);

                    if (c.Id == customer.Id)
                    {
                        this.cboCustomer.SelectedItem = c;
                    }
                }
            }
        }
コード例 #2
0
        private void btnEditCustomer_Click(object sender, EventArgs e)
        {
            if (!CheckCustomerSelected())
            {
                return;
            }

            var dialog = new CustomerDialog((Customer)cboCustomer.SelectedItem);
            var result = dialog.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                this.cboCustomer.Items[this.cboCustomer.SelectedIndex] = dialog.Customer;
            }
        }