Esempio n. 1
0
        private void btnNewPhone_Click(object sender, EventArgs e)
        {
            if (bsUsers.Current == null)
            {
                return;
            }

            DataRowView user     = (DataRowView)bsUsers.Current;
            DataRowView newPhone = (DataRowView)bsPhones.AddNew();

            newPhone["user_id"] = user["id"];

            frmPhone     editForm = new frmPhone(newPhone);
            DialogResult result   = editForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                bsPhones.EndEdit();
                phonesTableAdapter.Update(dsPhoneBook);

                dsPhoneBook.Phones.Clear();
                phonesTableAdapter.Fill(dsPhoneBook.Phones);
            }
            else
            {
                bsPhones.CancelEdit();
            }

            AdjustControlsAvailability();
        }
Esempio n. 2
0
        private void btnEditPhone_Click(object sender, EventArgs e)
        {
            if (bsPhones.Current == null)
            {
                return;
            }

            DataRowView newPhone = (DataRowView)bsPhones.Current;

            frmPhone     editForm = new frmPhone(newPhone);
            DialogResult result   = editForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                bsPhones.EndEdit();
                phonesTableAdapter.Update(dsPhoneBook);
            }
            else
            {
                bsPhones.CancelEdit();
            }
        }