Пример #1
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridViewUsers.CurrentRow == null)
                {
                    return;
                }

                User            user         = (User)dataGridViewUsers.CurrentRow.DataBoundItem;
                FormAddEditUser formEditUser = new FormAddEditUser(user);

                DialogResult dr = formEditUser.ShowDialog();
                if (dr == DialogResult.Abort)
                {
                    do
                    {
                        dr = formEditUser.ShowDialog();
                    } while (dr != DialogResult.OK && dr != DialogResult.Cancel);
                }
                if (dr == DialogResult.OK)
                {
                    userRepository.Update(user);
                    RefreshControls();
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Something wrong happened in the Users Form :", ex);
            }
        }
Пример #2
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            try
            {
                User            user        = new User();
                FormAddEditUser formAddUser = new FormAddEditUser(user);

                DialogResult dr = formAddUser.ShowDialog();
                if (dr == DialogResult.Abort)
                {
                    do
                    {
                        dr = formAddUser.ShowDialog();
                    } while (dr != DialogResult.OK && dr != DialogResult.Cancel);
                }
                if (dr == DialogResult.OK)
                {
                    userRepository.Insert(user);
                    RefreshControls();
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Something wrong happened in the Users Form :", ex);
            }
        }