Beispiel #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            fOwnersAdd   add    = new fOwnersAdd();
            DialogResult result = add.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }
            Owners owner = new Owners();

            owner.FIO      = add.tbFIO.Text;
            owner.Passport = add.tbPassport.Text;
            context.Owners.Add(owner);
            context.SaveChanges();
            MessageBox.Show("Запись выполнена");
            LoadData();
        }
Beispiel #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            Owners     owner = context.Owners.Find(dgvData.SelectedCells[0].Value);
            fOwnersAdd add   = new fOwnersAdd();

            add.tbFIO.Text      = owner.FIO;
            add.tbPassport.Text = owner.Passport;
            DialogResult result = add.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }
            owner.FIO      = add.tbFIO.Text;
            owner.Passport = add.tbPassport.Text;
            context.SaveChanges();
            MessageBox.Show("Сохранение выполнено");
            LoadData();
        }