Exemplo n.º 1
0
        private void btnDeleteUser_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewUser.SelectedItems.Count > 0)
                {
                    DialogResult result = MessageBox.Show("Are you sure you want to delete the selected record?", "Training Information Management System", MessageBoxButtons.YesNo);
                    if (result == DialogResult.OK)
                    {
                        BusinessLogic.UserManager userManager = new BusinessLogic.UserManager();
                        BusinessEntity.UserEntity newUser     = new BusinessEntity.UserEntity();

                        newUser.ID       = int.Parse(listViewUser.SelectedItems[0].SubItems[0].Text);
                        newUser.Username = txtUsername.Text;
                        newUser.Password = txtPassword.Text;

                        userManager.Delete(newUser);

                        MessageBox.Show("User Information Deleted Successfully.");
                        LoadUsers();
                    }
                }
                else
                {
                    MessageBox.Show("Please select a user from the list first.");
                }
            }
            catch (Exception ex)
            {
                //save to log table
                MessageBox.Show("Delete Failed, Please try again.");
            }
        }
Exemplo n.º 2
0
        private void btnUpdateUser_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsValidUser())
                {
                    BusinessLogic.UserManager userManager = new BusinessLogic.UserManager();
                    BusinessEntity.UserEntity newUser     = new BusinessEntity.UserEntity();

                    newUser.ID       = int.Parse(listViewUser.SelectedItems[0].SubItems[0].Text);
                    newUser.Username = txtUsername.Text;
                    newUser.Password = ClassSecurity.HashString(txtPassword.Text).ToString();

                    userManager.Update(newUser);

                    MessageBox.Show("User Information Updated Successfully.");
                    LoadUsers();
                }
            }
            catch (Exception ex)
            {
                //save to log table
                MessageBox.Show("Update Failed, Please try again.");
            }
        }
Exemplo n.º 3
0
        private void btnSaveUser_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsValidUser())
                {
                    BusinessLogic.UserManager userManager = new BusinessLogic.UserManager();
                    BusinessEntity.UserEntity user        = new BusinessEntity.UserEntity();
                    user.Username = txtUsername.Text;
                    user.Password = ClassSecurity.HashString(txtPassword.Text).ToString();

                    userManager.Save(user);

                    MessageBox.Show("User Information Saved Successfully.");
                    LoadUsers();
                }
            }
            catch (Exception ex)
            {
                //save to log table
                MessageBox.Show("Save Failed, Please try again.");
            }
        }