Ejemplo n.º 1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     CustomerForm form = new CustomerForm();
     DialogResult r = form.ShowDialog();
     if (r == DialogResult.OK)
     {
         Customer c = form.GetCustomer();
         Database db = DbAccess.GetInstance();
         db.Insert(c);
         listViewCustomer.Items.Add(CreateListViewItem(c));
     }
 }
Ejemplo n.º 2
0
        void Edit()
        {
            if (listViewCustomer.SelectedItems.Count <= 0)
            {
                return;
            }

            ListViewItem item = listViewCustomer.SelectedItems[0];

            Customer c = item.Tag as Customer;

            CustomerForm form = new CustomerForm();
            form.SetCustomer(c);
            DialogResult r = form.ShowDialog();
            if (r == DialogResult.OK)
            {
                db.Update(c);
                UpdateListViewItem(c, item);
            }
        }