Example #1
0
        private void AddUser()
        {
            var userForm = new UserForm();

            userForm.listAllRewards = rewardList.ToList();
            if (userForm.ShowDialog() == DialogResult.OK)
            {
                var user = new User(userList.Count == 0 ? 0 : userList.Max(u => u.ID) + 1, userForm.FirstName, userForm.LastName, userForm.Birthdate, userForm.RewardsList);
                userList.Add(user);
            }
        }
Example #2
0
        private void ctlFileInsertUser_Click(object sender, EventArgs e)
        {
            UserForm newUserForm = new UserForm();

            if (newUserForm.ShowDialog(this) == DialogResult.OK)
            {
                userService.CreateNewUser
                (
                    newUserForm.FirstName,
                    newUserForm.LastName,
                    newUserForm.BirthDay
                );
            }
            UpdateUserDataGridView();
        }
Example #3
0
        private void RegisterNewUser()
        {
            UserForm form = new UserForm();

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                User user = new User();
                user.ID        = form.ID;
                user.FirstName = form.FirstName;
                user.LastName  = form.LastName;
                user.Birthdate = form.Birthdate;

                _users.Add(user);
            }
        }
Example #4
0
        private void EditSelectedUser()
        {
            if (ctlUsers.SelectedCells.Count > 0)
            {
                User user = (User)ctlUsers.SelectedCells[0].OwningRow.DataBoundItem;

                UserForm form = new UserForm(user);
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    user.ID        = form.ID;
                    user.FirstName = form.FirstName;
                    user.LastName  = form.LastName;
                    user.Birthdate = form.Birthdate;
                }
            }
        }
Example #5
0
 private void EditUser()
 {
     if (ctlUserGrid.SelectedCells.Count != 0)
     {
         var user     = userList.First(u => u.ID == SelectedEntityID(ctlUserGrid));
         var userForm = new UserForm(user);
         userForm.listAllRewards = rewardList.ToList();
         if (userForm.ShowDialog() == DialogResult.OK)
         {
             user.FirstName   = userForm.FirstName;
             user.LastName    = userForm.LastName;
             user.Birthdate   = userForm.Birthdate;
             user.RewardsList = userForm.RewardsList;
         }
     }
     else
     {
         MessageBox.Show($"Вы не выбрали пользователя для редактирования.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }