2022-05-24 09:09:56 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace AwesomeEmailExtractor
|
|
|
|
|
{
|
|
|
|
|
public partial class EditUserForm : Form
|
|
|
|
|
{
|
|
|
|
|
public User User { get; set; }
|
|
|
|
|
|
|
|
|
|
public EditUserForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void EditUserForm_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
idTextBox.Text = User.ID.ToString();
|
|
|
|
|
loginTextBox.Text = User.Login;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
roleComboBox.Items.Add(UserRoles.DEFAULT.ToString());
|
|
|
|
|
roleComboBox.Items.Add(UserRoles.ADMIN.ToString());
|
|
|
|
|
|
|
|
|
|
roleComboBox.SelectedIndex = (int)User.Role;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void submitButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2022-05-24 13:49:52 +03:00
|
|
|
|
if (loginTextBox.Text.Length == 0)
|
|
|
|
|
{
|
2022-05-24 15:25:44 +03:00
|
|
|
|
MessageBox.Show("Логин не может быть пустым!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2022-05-24 13:49:52 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 09:09:56 +03:00
|
|
|
|
AdminUtils adminUtils = new AdminUtils(Globals.currentUser);
|
|
|
|
|
|
|
|
|
|
User editedUser = new User(User.ID, loginTextBox.Text, (UserRoles)roleComboBox.SelectedIndex);
|
|
|
|
|
|
2022-05-25 08:23:03 +03:00
|
|
|
|
try
|
2022-05-24 09:09:56 +03:00
|
|
|
|
{
|
2022-05-25 08:23:03 +03:00
|
|
|
|
|
|
|
|
|
if (passwordTextBox.Text != "")
|
|
|
|
|
{
|
|
|
|
|
adminUtils.editUser(editedUser, passwordTextBox.Text);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
adminUtils.editUser(editedUser);
|
|
|
|
|
}
|
2022-05-24 09:09:56 +03:00
|
|
|
|
}
|
2022-05-25 08:23:03 +03:00
|
|
|
|
catch (Exception ex)
|
2022-05-24 09:09:56 +03:00
|
|
|
|
{
|
2022-05-25 08:23:03 +03:00
|
|
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
return;
|
2022-05-24 09:09:56 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|