private void btnSingUpForm_Click(object sender, EventArgs e) { if (txtSingUpPassword.Text == txtSingUpConfirm.Text) { createdProfile.passwordUsers = txtSingUpPassword.Text; if (IsValidDataSingUp()) { createdProfile.firstNameUsers = txtSingUpFirstName.Text; createdProfile.lastNameUsers = txtSingUpLastName.Text; createdProfile.emailUsers = txtSingUpEmail.Text; createdProfile.phoneUsers = txtSingUpPhone.Text; createdProfile.passwordUsers = EncriptString.Encrypt(txtSingUpPassword.Text, "testEncript"); createdProfile.roleUsers = "user"; createdProfile.updatedUsers = DateTime.Today; createdProfile.createdUsers = DateTime.Today; createdProfile.approvedUsers = "0"; this.creativityProfile = createdProfile; UsersDB_Class.CreateProfile(createdProfile); MessageBox.Show("Please wait for approval."); txtSingUpClear(); } } else { MessageBox.Show("Password and confirm password do not match", Title); txtSingUpPassword.Clear(); txtSingUpConfirm.Clear(); } }
private void btnLoginAdmin_Click(object sender, EventArgs e) ///////////// { if (IsValidDataAdmin()) { UsersClass admin; admin = UsersDB_Class.GetAdmin(txtEmailAdmin.Text); if (admin == null) { MessageBox.Show("Email incorrect!", Title); txtEmailAdmin.Clear(); txtEmailAdmin.Focus(); } else { string textboxPassword = EncriptString.Decrypt(admin.passwordUsers, "testEncript"); if (txtPasswordAdmin.Text == textboxPassword) { Admin modifFormAdmin = new Admin(); modifFormAdmin.Show(); this.Hide(); } else { MessageBox.Show("Password incorrect!", Title); txtPasswordAdmin.Clear(); txtPasswordAdmin.Focus(); } } } }
private void FillListView() { lstUsersList.Columns[0].ListView.Font = new Font(lstUsersList.Columns[0].ListView.Font, FontStyle.Bold); lstUsersList.Items.Clear(); List <UsersClass> users = new List <UsersClass>(); users = UsersDB_Class.GetUsers(); foreach (UsersClass user in users) { string[] row = { user.firstNameUsers, user.lastNameUsers, user.emailUsers, user.phoneUsers, user.createdUsers.ToString("d"), user.updatedUsers.ToString("d") }; ListViewItem listUser = new ListViewItem(row); listUser.Font = new Font(listUser.Font, FontStyle.Regular); lstUsersList.Items.Add(listUser); } }
private void btnLoginLogin_Click(object sender, EventArgs e) { if (IsValidData()) { UsersClass user; user = UsersDB_Class.GetUser(txtEmailLogin.Text); if (user == null) { MessageBox.Show("Email incorrect!", Title); txtEmailLogin.Clear(); txtEmailLogin.Focus(); } else { int user_id = user.userID; // Дешифровка пароля из базы данных и сравнивание с введенным паролем из текстбокса string textboxPassword = EncriptString.Decrypt(user.passwordUsers, "testEncript"); if (txtPasswordLodin.Text == textboxPassword) { Users modifFormUsers = new Users(user_id); modifFormUsers.Show(); this.Hide(); } else { MessageBox.Show("Password incorrect!", Title); txtPasswordLodin.Clear(); txtPasswordLodin.Focus(); } } } }
private void btnDeleteUsers_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { DialogResult result1 = MessageBox.Show("Delete " + "User" + "?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result1 == DialogResult.Yes) { ListViewItem item = listView1.SelectedItems[0]; int userID = Convert.ToInt32(item.SubItems[9].Text); bool result = UsersDB_Class.DeleteUsers(userID); if (result) { FillListView(); MessageBox.Show("User deleted"); } else { MessageBox.Show("Error"); } } } else { MessageBox.Show("Please select an user in a list "); } }
private void ModifyProfile_Click(object sender, EventArgs e) { ModifyProfile modifyProfile = new ModifyProfile(user_id); var result = modifyProfile.ShowDialog(); if (result == DialogResult.OK) { UsersClass modified = modifyProfile.modify; bool returnedResult = UsersDB_Class.ChangeUsers(modified); if (returnedResult) { FillListView(); MessageBox.Show("User changed"); } else { MessageBox.Show("Error"); } } }
private void btnCreateAdmin_Click(object sender, EventArgs e) { CreateAdmin createAdmin = new CreateAdmin(); var result = createAdmin.ShowDialog(); if (result == DialogResult.OK) { UsersClass createdAdmin = createAdmin.creativity; bool returnedResult = UsersDB_Class.CreateAdmin(createdAdmin); if (returnedResult) { FillListView(); MessageBox.Show("Admin created"); } else { MessageBox.Show("Error"); } } }
private void ModifyProfile_Load(object sender, EventArgs e) { user = UsersDB_Class.GetUserByID(user_id.ToString()); txtModifyProfileFirstName.Text = user.firstNameUsers; txtModifyProfileLastName.Text = user.lastNameUsers; txtModifyProfileEmail.Text = user.emailUsers; txtModifyProfilePhone.Text = user.phoneUsers; if (txtModifyProfilePassword.Text != null) { txtModifyProfilePassword.ForeColor = Color.Black; txtModifyProfilePassword.Text = ""; txtModifyProfilePassword.PasswordChar = '*'; } if (txtModifyProfileConfirm.Text != null) { txtModifyProfileConfirm.ForeColor = Color.Black; txtModifyProfileConfirm.Text = ""; txtModifyProfileConfirm.PasswordChar = '*'; } }
private void ApproveUsers_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { ListViewItem item = listView1.SelectedItems[0]; int userID = Convert.ToInt32(item.SubItems[9].Text); bool result = UsersDB_Class.ApproveUsers(userID); if (result) { FillListView(); MessageBox.Show("User approved"); } else { MessageBox.Show("Error"); } } else { MessageBox.Show("Please select an user in a list"); } }
private void btnChangeUsers_Click(object sender, EventArgs e) { UsersClass userChange = new UsersClass(); if (listView1.SelectedItems.Count > 0) { ListViewItem item = listView1.SelectedItems[0]; userChange.firstNameUsers = item.SubItems[0].Text; userChange.lastNameUsers = item.SubItems[1].Text; userChange.phoneUsers = item.SubItems[2].Text; userChange.emailUsers = item.SubItems[3].Text; userChange.createdUsers = Convert.ToDateTime(item.SubItems[5].Text); userChange.updatedUsers = Convert.ToDateTime(item.SubItems[6].Text); userChange.roleUsers = item.SubItems[7].Text; userChange.passwordUsers = item.SubItems[8].Text; userChange.userID = Convert.ToInt32(item.SubItems[9].Text); Change_users updateUser = new Change_users(userChange); var result = updateUser.ShowDialog(); if (result == DialogResult.OK) { UsersClass changedUser = updateUser.changes; bool returnedResult = UsersDB_Class.ChangeUsers(userChange); if (returnedResult) { FillListView(); MessageBox.Show("User changed"); } else { MessageBox.Show("Error"); } } } else { MessageBox.Show("Please select an user in a list "); } }
private void FillListView() { listView1.Columns[0].ListView.Font = new Font(listView1.Columns[0].ListView.Font, FontStyle.Bold); listView1.Items.Clear(); List <UsersClass> users = new List <UsersClass>(); users = UsersDB_Class.GetUsers(); foreach (UsersClass user in users) { if (user.approvedUsers == "0") { user.approvedUsers = "waiting"; } else { user.approvedUsers = "approved"; } string[] row = { user.firstNameUsers, user.lastNameUsers, user.phoneUsers, user.emailUsers, user.approvedUsers, user.createdUsers.ToString("d"), user.updatedUsers.ToString("d"), user.roleUsers, user.passwordUsers, user.userID.ToString() }; ListViewItem listUser = new ListViewItem(row); listUser.Font = new Font(listUser.Font, FontStyle.Regular); listView1.Items.Add(listUser); } }