//*********************************************************************** /// <summary> /// This is the function that will handle when the delete button is clicked on the users page /// It will make sure that the admin user will not be deleted /// </summary> /// <param name="sender">This is the paramater for sender</param> /// <param name="e">This is the paramater for EventAtgs</param> private void usersDelete_Click(object sender, EventArgs e) { DataLayer.User.Users selectedUser = (DataLayer.User.Users)usersListBox.SelectedValue; DataLayer.User users = new DataLayer.User(); int getUserID = selectedUser.UserID; DialogResult result = MessageBox.Show("Are You Sure You Want To Delete?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { if (getUserID != adminID) { try { users.DeleteUsers(getUserID); //reload the log table to display new log data List <DataLayer.User.Users> appsList = users.GetList(); appsList.Insert(0, new DataLayer.User.Users() { UserName = "******" }); usersListBox.DataSource = appsList; // apps.GetList(); usersListBox.DisplayMember = "UserName"; } catch (SqlException sqlex) { DisplayErrorMessage(sqlex.Message); } } else { MessageBox.Show("Cannt Delete Admin User"); } } else if (result == DialogResult.No) { MessageBox.Show("Delete Has Been Cancled"); } else if (result == DialogResult.Cancel) { MessageBox.Show("Delete Has Been Cancled"); } }
/// <summary> /// This is the function that handles the even when a new user is selected on the user list box /// </summary> /// <param name="sender">This is the paramater for sender</param> /// <param name="e">This is the paramater for EventAtgs</param> private void usersListBox_SelectedIndexChanged(object sender, EventArgs e) { DataLayer.User.Users selectedUser = (DataLayer.User.Users)usersListBox.SelectedValue; if (selectedUser.UserID != 0) { userIDTextBox.Text = selectedUser.UserID.ToString(); userNameTextBox.Text = selectedUser.UserName; emailTextBox.Text = selectedUser.UserEmail; userTelTextBox.Text = selectedUser.UserTel; } else { userIDTextBox.Text = null; userNameTextBox.Text = null; emailTextBox.Text = null; userTelTextBox.Text = null; } }