Esempio n. 1
0
        private void btnUsersEdit_Click(object sender, EventArgs e)
        {
            // get current selected item
            Dictionary <int, FormUser> updatedList = new Dictionary <int, FormUser>();

            foreach (DataGridViewRow row in dataGridViewUsers.Rows)
            {
                if (row.Cells[0].Value != null &&
                    (bool)row.Cells[0].Value)
                {
                    int    userId   = (int)row.Cells[1].Value;
                    string username = (string)row.Cells[3].Value;

                    FormUser formUser = new FormUser(username);
                    formUser.Text = "Edit User";
                    formUser.SetGroups(userPresenter.GetGroupsList());
                    formUser.DisplayName       = (string)row.Cells[2].Value;
                    formUser.UserName          = username;
                    formUser.Password          = (string)row.Cells[4].Value;
                    formUser.SelectedGroupName = (string)row.Cells[5].Value;

                    if (formUser.ShowDialog(this) == System.Windows.Forms.DialogResult.OK &&
                        formUser.IsDirty)
                    {
                        // add to database
                        updatedList.Add(userId, formUser);
                    }
                }
            }

            foreach (KeyValuePair <int, FormUser> data in updatedList)
            {
                userPresenter.EditUser(data.Key, data.Value.DisplayName, data.Value.UserName, data.Value.Password, data.Value.SelectedGroupId);
            }
        }
Esempio n. 2
0
        private void btnUsersAdd_Click(object sender, EventArgs e)
        {
            // show the form user
            FormUser formUser = new FormUser(String.Empty);

            formUser.Text = "Add User";
            formUser.SetGroups(userPresenter.GetGroupsList());
            if (formUser.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                // add to database
                userPresenter.AddUser(formUser.DisplayName, formUser.UserName, formUser.Password, formUser.SelectedGroupId);
            }
        }