From 51a2bb4ee98bd5771a600bea798062e441e68bbb Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Mon, 23 May 2022 21:08:30 +0300 Subject: [PATCH 01/14] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D1=82=20=D1=84=D0=BE=D1=80=D0=BC=D1=83=20=D1=81=20?= =?UTF-8?q?=D0=B6=D1=83=D1=80=D0=BD=D0=B0=D0=BB=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Authorization.cs | 5 + AwesomeEmailExtractor.csproj | 9 ++ Globals.cs | 3 + JournalForm.Designer.cs | 174 +++++++++++++++++++++++++++++++++++ JournalForm.cs | 43 +++++++++ JournalForm.resx | 120 ++++++++++++++++++++++++ Logs.cs | 58 +++++++----- MainForm.Designer.cs | 12 ++- MainForm.cs | 6 ++ 9 files changed, 408 insertions(+), 22 deletions(-) create mode 100644 JournalForm.Designer.cs create mode 100644 JournalForm.cs create mode 100644 JournalForm.resx diff --git a/Authorization.cs b/Authorization.cs index 81f550d..deec387 100644 --- a/Authorization.cs +++ b/Authorization.cs @@ -113,6 +113,11 @@ namespace AwesomeEmailExtractor command.ExecuteNonQuery(); } + + new public string ToString() + { + return this.Login; + } } public class AdminUtils diff --git a/AwesomeEmailExtractor.csproj b/AwesomeEmailExtractor.csproj index d078b5e..35b5fad 100644 --- a/AwesomeEmailExtractor.csproj +++ b/AwesomeEmailExtractor.csproj @@ -86,6 +86,12 @@ + + Form + + + JournalForm.cs + Form @@ -110,6 +116,9 @@ AuthorizationForm.cs + + JournalForm.cs + MainForm.cs diff --git a/Globals.cs b/Globals.cs index 9ba88dd..a953706 100644 --- a/Globals.cs +++ b/Globals.cs @@ -72,6 +72,9 @@ namespace AwesomeEmailExtractor command.CommandText = "CREATE TABLE IF NOT EXISTS logs (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, date TEXT NOT NULL, action INTEGER NOT NULL, message TEXT NOT NULL, FOREIGN KEY(action) REFERENCES logs_actions(id));"; command.ExecuteNonQuery(); + command.CommandText = "ATTACH DATABASE @dbpath AS appDB"; + command.Parameters.AddWithValue("@dbpath", Globals.getAppDatabase()); + command.ExecuteNonQuery(); } public static void CreateTables() diff --git a/JournalForm.Designer.cs b/JournalForm.Designer.cs new file mode 100644 index 0000000..443a006 --- /dev/null +++ b/JournalForm.Designer.cs @@ -0,0 +1,174 @@ +namespace AwesomeEmailExtractor +{ + partial class JournalForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.panel1 = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.dataLabel = new System.Windows.Forms.Label(); + this.actionLabel = new System.Windows.Forms.Label(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.panel1.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // dataGridView1 + // + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView1.Location = new System.Drawing.Point(10, 10); + this.dataGridView1.MultiSelect = false; + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(414, 451); + this.dataGridView1.TabIndex = 0; + this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged); + // + // panel1 + // + this.panel1.Controls.Add(this.tableLayoutPanel1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Right; + this.panel1.Location = new System.Drawing.Point(424, 10); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(458, 451); + this.panel1.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(13, 10); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(36, 13); + this.label1.TabIndex = 2; + this.label1.Text = "Дата:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(13, 30); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(54, 13); + this.label2.TabIndex = 3; + this.label2.Text = "Событие:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(13, 50); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(68, 13); + this.label3.TabIndex = 4; + this.label3.Text = "Сообщение:"; + // + // dataLabel + // + this.dataLabel.AutoSize = true; + this.dataLabel.Location = new System.Drawing.Point(141, 10); + this.dataLabel.Name = "dataLabel"; + this.dataLabel.Size = new System.Drawing.Size(54, 13); + this.dataLabel.TabIndex = 5; + this.dataLabel.Text = "dataLabel"; + // + // actionLabel + // + this.actionLabel.AutoSize = true; + this.actionLabel.Location = new System.Drawing.Point(141, 30); + this.actionLabel.Name = "actionLabel"; + this.actionLabel.Size = new System.Drawing.Size(62, 13); + this.actionLabel.TabIndex = 6; + this.actionLabel.Text = "actionLabel"; + // + // richTextBox1 + // + this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.richTextBox1.Location = new System.Drawing.Point(141, 53); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.Size = new System.Drawing.Size(304, 385); + this.richTextBox1.TabIndex = 7; + this.richTextBox1.Text = ""; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 29.2876F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 70.7124F)); + this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.label3, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.richTextBox1, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.dataLabel, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.actionLabel, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(10); + this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(458, 451); + this.tableLayoutPanel1.TabIndex = 8; + // + // JournalForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(892, 471); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.panel1); + this.Name = "JournalForm"; + this.Padding = new System.Windows.Forms.Padding(10); + this.Text = "Журнал"; + this.Load += new System.EventHandler(this.JournalForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.panel1.ResumeLayout(false); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.Label dataLabel; + private System.Windows.Forms.Label actionLabel; + private System.Windows.Forms.Label label2; + } +} \ No newline at end of file diff --git a/JournalForm.cs b/JournalForm.cs new file mode 100644 index 0000000..55208ab --- /dev/null +++ b/JournalForm.cs @@ -0,0 +1,43 @@ +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 JournalForm : Form + { + public JournalForm() + { + InitializeComponent(); + } + + private void JournalForm_Load(object sender, EventArgs e) + { + var logs = Logs.GetLogsList(Globals.currentUser); + + dataGridView1.DataSource = logs; + dataGridView1.Columns[0].Visible = false; + dataGridView1.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + + private void dataGridView1_SelectionChanged(object sender, EventArgs e) + { + if (dataGridView1.SelectedRows.Count > 0) + { + dataLabel.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); + actionLabel.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); + richTextBox1.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString(); + } else { + dataLabel.Text = ""; + actionLabel.Text = ""; + richTextBox1.Text = ""; + } + } + } +} diff --git a/JournalForm.resx b/JournalForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/JournalForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Logs.cs b/Logs.cs index 9b0a52d..e9f61a3 100644 --- a/Logs.cs +++ b/Logs.cs @@ -10,10 +10,10 @@ namespace AwesomeEmailExtractor public class Logs { public class LogData { - public User user; - public string date; - public Action action; - public string message; + public User User { get; set; } + public string Date { get; set; } + public Action Action { get; set; } + public string Message { get; set; } } public enum Action @@ -37,33 +37,49 @@ namespace AwesomeEmailExtractor command.ExecuteNonQuery(); } - public static List GetLogs(User user) + public static List GetLogsList(User user) { - SqliteCommand command = new SqliteCommand(); - command.Connection = Globals.logsDb; - - command.CommandText = "SELECT date, action, message FROM logs WHERE user_id = @user_id ORDER BY date DESC"; - command.Parameters.AddWithValue("@user_id", user.ID); - - SqliteDataReader reader = command.ExecuteReader(); + SqliteDataReader reader = GetLogsDataReader(user); List logs = new List(); while (reader.Read()) { logs.Add(new LogData() { - user = user, - date = reader.GetString(0), - action = (Action)reader.GetInt32(1), - message = reader.GetString(2) + User = user, + Date = reader.GetString(0), + Action = (Action)reader.GetInt32(1), + Message = reader.GetString(2) }); } + reader.Close(); + return logs; } - public static List GetLogs() + private static SqliteDataReader GetLogsDataReader(User user) { + if (Globals.currentUser.ID != user.ID && Globals.currentUser.Role != UserRoles.ADMIN) + { + throw new Exception("У вас нет прав на просмотр логов"); + } + + SqliteCommand command = new SqliteCommand(); + command.Connection = Globals.logsDb; + command.CommandText = "SELECT date, action, message FROM logs WHERE user_id = @user_id ORDER BY date DESC"; + command.Parameters.AddWithValue("@user_id", user.ID); + + return command.ExecuteReader(); + } + + public static List GetLogsList() + { + if (Globals.currentUser.Role != UserRoles.ADMIN) + { + throw new Exception("У вас нет прав на просмотр логов"); + } + SqliteCommand command = new SqliteCommand(); command.Connection = Globals.logsDb; command.CommandText = "ATTACH DATABASE @dbpath AS appDB"; @@ -87,10 +103,10 @@ namespace AwesomeEmailExtractor { logs.Add(new LogData() { - user = new User(reader.GetInt32(0), reader.GetString(1), (UserRoles)reader.GetInt32(2)), - date = reader.GetString(3), - action = (Action)reader.GetInt32(4), - message = reader.GetString(5) + User = new User(reader.GetInt32(0), reader.GetString(1), (UserRoles)reader.GetInt32(2)), + Date = reader.GetString(3), + Action = (Action)reader.GetInt32(4), + Message = reader.GetString(5) }); } diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index f949bab..75c2d4b 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -41,6 +41,7 @@ this.administrationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.journalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.resultStatusStrip.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -57,7 +58,7 @@ "bob@example.com"}); this.uniqueListBox.Location = new System.Drawing.Point(424, 32); this.uniqueListBox.Name = "uniqueListBox"; - this.uniqueListBox.Size = new System.Drawing.Size(225, 304); + this.uniqueListBox.Size = new System.Drawing.Size(225, 324); this.uniqueListBox.TabIndex = 0; // // sourceRichTextBox @@ -133,6 +134,7 @@ // аккаунтToolStripMenuItem // this.аккаунтToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.journalToolStripMenuItem, this.settingsToolStripMenuItem, this.administrationToolStripMenuItem, this.exitToolStripMenuItem}); @@ -166,6 +168,13 @@ this.helpToolStripMenuItem.Size = new System.Drawing.Size(65, 20); this.helpToolStripMenuItem.Text = "Справка"; // + // journalToolStripMenuItem + // + this.journalToolStripMenuItem.Name = "journalToolStripMenuItem"; + this.journalToolStripMenuItem.Size = new System.Drawing.Size(189, 22); + this.journalToolStripMenuItem.Text = "Журнал"; + this.journalToolStripMenuItem.Click += new System.EventHandler(this.journalToolStripMenuItem_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -205,6 +214,7 @@ private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem administrationToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem journalToolStripMenuItem; } } diff --git a/MainForm.cs b/MainForm.cs index 5ebee65..4a6e3e8 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -68,5 +68,11 @@ namespace AwesomeEmailExtractor AuthorizationForm authorization = FormManager.Current.CreateForm(); FormManager.Current.Navigate(this, authorization); } + + private void journalToolStripMenuItem_Click(object sender, EventArgs e) + { + JournalForm journalForm = FormManager.Current.CreateForm(); + journalForm.ShowDialog(this); + } } } From d386e8338a8a81854c31406da6b888d3c908e240 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Mon, 23 May 2022 21:47:09 +0300 Subject: [PATCH 02/14] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D1=82=20=D1=84=D0=BE=D1=80=D0=BC=D1=83=20=D0=B0?= =?UTF-8?q?=D0=B4=D0=BC=D0=B8=D0=BD=D0=B8=D1=81=D1=82=D1=80=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AdministrationForm.Designer.cs | 139 +++++++++++++++++++++++++++++++++ AdministrationForm.cs | 53 +++++++++++++ AdministrationForm.resx | 120 ++++++++++++++++++++++++++++ AwesomeEmailExtractor.csproj | 9 +++ MainForm.Designer.cs | 17 ++-- MainForm.cs | 6 ++ 6 files changed, 336 insertions(+), 8 deletions(-) create mode 100644 AdministrationForm.Designer.cs create mode 100644 AdministrationForm.cs create mode 100644 AdministrationForm.resx diff --git a/AdministrationForm.Designer.cs b/AdministrationForm.Designer.cs new file mode 100644 index 0000000..0573f14 --- /dev/null +++ b/AdministrationForm.Designer.cs @@ -0,0 +1,139 @@ +namespace AwesomeEmailExtractor +{ + partial class AdministrationForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.mainTabControl = new System.Windows.Forms.TabControl(); + this.mainSettingsTabPage = new System.Windows.Forms.TabPage(); + this.label1 = new System.Windows.Forms.Label(); + this.browseButton = new System.Windows.Forms.Button(); + this.pathToJournalTextBox = new System.Windows.Forms.TextBox(); + this.usersTabPage = new System.Windows.Forms.TabPage(); + this.journalTabPage = new System.Windows.Forms.TabPage(); + this.mainTabControl.SuspendLayout(); + this.mainSettingsTabPage.SuspendLayout(); + this.SuspendLayout(); + // + // mainTabControl + // + this.mainTabControl.Controls.Add(this.mainSettingsTabPage); + this.mainTabControl.Controls.Add(this.usersTabPage); + this.mainTabControl.Controls.Add(this.journalTabPage); + this.mainTabControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.mainTabControl.Location = new System.Drawing.Point(0, 0); + this.mainTabControl.Name = "mainTabControl"; + this.mainTabControl.SelectedIndex = 0; + this.mainTabControl.Size = new System.Drawing.Size(800, 450); + this.mainTabControl.TabIndex = 0; + // + // mainSettingsTabPage + // + this.mainSettingsTabPage.Controls.Add(this.label1); + this.mainSettingsTabPage.Controls.Add(this.browseButton); + this.mainSettingsTabPage.Controls.Add(this.pathToJournalTextBox); + this.mainSettingsTabPage.Location = new System.Drawing.Point(4, 22); + this.mainSettingsTabPage.Name = "mainSettingsTabPage"; + this.mainSettingsTabPage.Padding = new System.Windows.Forms.Padding(3); + this.mainSettingsTabPage.Size = new System.Drawing.Size(792, 424); + this.mainSettingsTabPage.TabIndex = 0; + this.mainSettingsTabPage.Text = "Общие настройки"; + this.mainSettingsTabPage.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(8, 12); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(140, 13); + this.label1.TabIndex = 2; + this.label1.Text = "Путь к файлу с журналом:"; + // + // browseButton + // + this.browseButton.Location = new System.Drawing.Point(678, 26); + this.browseButton.Name = "browseButton"; + this.browseButton.Size = new System.Drawing.Size(106, 23); + this.browseButton.TabIndex = 1; + this.browseButton.Text = "Обзор"; + this.browseButton.UseVisualStyleBackColor = true; + this.browseButton.Click += new System.EventHandler(this.browseButton_Click); + // + // pathToJournalTextBox + // + this.pathToJournalTextBox.Enabled = false; + this.pathToJournalTextBox.Location = new System.Drawing.Point(8, 28); + this.pathToJournalTextBox.Name = "pathToJournalTextBox"; + this.pathToJournalTextBox.Size = new System.Drawing.Size(664, 20); + this.pathToJournalTextBox.TabIndex = 0; + // + // usersTabPage + // + this.usersTabPage.Location = new System.Drawing.Point(4, 22); + this.usersTabPage.Name = "usersTabPage"; + this.usersTabPage.Padding = new System.Windows.Forms.Padding(3); + this.usersTabPage.Size = new System.Drawing.Size(792, 424); + this.usersTabPage.TabIndex = 1; + this.usersTabPage.Text = "Пользователи"; + this.usersTabPage.UseVisualStyleBackColor = true; + // + // journalTabPage + // + this.journalTabPage.Location = new System.Drawing.Point(4, 22); + this.journalTabPage.Name = "journalTabPage"; + this.journalTabPage.Size = new System.Drawing.Size(792, 424); + this.journalTabPage.TabIndex = 2; + this.journalTabPage.Text = "Журнал"; + this.journalTabPage.UseVisualStyleBackColor = true; + // + // AdministrationForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.mainTabControl); + this.Name = "AdministrationForm"; + this.Text = "Администрирование"; + this.Load += new System.EventHandler(this.AdministrationForm_Load); + this.mainTabControl.ResumeLayout(false); + this.mainSettingsTabPage.ResumeLayout(false); + this.mainSettingsTabPage.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TabControl mainTabControl; + private System.Windows.Forms.TabPage mainSettingsTabPage; + private System.Windows.Forms.TabPage usersTabPage; + private System.Windows.Forms.TabPage journalTabPage; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button browseButton; + private System.Windows.Forms.TextBox pathToJournalTextBox; + } +} \ No newline at end of file diff --git a/AdministrationForm.cs b/AdministrationForm.cs new file mode 100644 index 0000000..b08089a --- /dev/null +++ b/AdministrationForm.cs @@ -0,0 +1,53 @@ +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; +using Microsoft.Data.Sqlite; + +namespace AwesomeEmailExtractor +{ + public partial class AdministrationForm : Form + { + public AdministrationForm() + { + InitializeComponent(); + } + + private void AdministrationForm_Load(object sender, EventArgs e) + { + + SqliteCommand command = new SqliteCommand(); + command.Connection = Globals.db; + command.CommandText = "SELECT * FROM app_settings"; + + var reader = command.ExecuteReader(); + + var Row = reader.Read(); + + pathToJournalTextBox.Text = reader.GetString(0); + } + + private void browseButton_Click(object sender, EventArgs e) + { + FileDialog dialog = new SaveFileDialog(); + dialog.Filter = "SQLite база с журналом (*.db)|*.db"; + + if (dialog.ShowDialog() == DialogResult.OK) + { + pathToJournalTextBox.Text = dialog.FileName; + + SqliteCommand command = new SqliteCommand(); + command.Connection = Globals.db; + command.CommandText = "UPDATE app_settings SET logs_db_path = @path"; + command.Parameters.AddWithValue("@path", pathToJournalTextBox.Text); + command.ExecuteNonQuery(); + } + + } + } +} diff --git a/AdministrationForm.resx b/AdministrationForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/AdministrationForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/AwesomeEmailExtractor.csproj b/AwesomeEmailExtractor.csproj index 35b5fad..488936e 100644 --- a/AwesomeEmailExtractor.csproj +++ b/AwesomeEmailExtractor.csproj @@ -76,6 +76,12 @@ + + Form + + + AdministrationForm.cs + Form @@ -113,6 +119,9 @@ SettingsForm.cs + + AdministrationForm.cs + AuthorizationForm.cs diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 75c2d4b..19645ee 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -37,11 +37,11 @@ this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.аккаунтToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.journalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.administrationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.journalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.resultStatusStrip.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -142,6 +142,13 @@ this.аккаунтToolStripMenuItem.Size = new System.Drawing.Size(63, 20); this.аккаунтToolStripMenuItem.Text = "Аккаунт"; // + // journalToolStripMenuItem + // + this.journalToolStripMenuItem.Name = "journalToolStripMenuItem"; + this.journalToolStripMenuItem.Size = new System.Drawing.Size(189, 22); + this.journalToolStripMenuItem.Text = "Журнал"; + this.journalToolStripMenuItem.Click += new System.EventHandler(this.journalToolStripMenuItem_Click); + // // settingsToolStripMenuItem // this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; @@ -154,6 +161,7 @@ this.administrationToolStripMenuItem.Name = "administrationToolStripMenuItem"; this.administrationToolStripMenuItem.Size = new System.Drawing.Size(189, 22); this.administrationToolStripMenuItem.Text = "Администрирование"; + this.administrationToolStripMenuItem.Click += new System.EventHandler(this.administrationToolStripMenuItem_Click); // // exitToolStripMenuItem // @@ -168,13 +176,6 @@ this.helpToolStripMenuItem.Size = new System.Drawing.Size(65, 20); this.helpToolStripMenuItem.Text = "Справка"; // - // journalToolStripMenuItem - // - this.journalToolStripMenuItem.Name = "journalToolStripMenuItem"; - this.journalToolStripMenuItem.Size = new System.Drawing.Size(189, 22); - this.journalToolStripMenuItem.Text = "Журнал"; - this.journalToolStripMenuItem.Click += new System.EventHandler(this.journalToolStripMenuItem_Click); - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/MainForm.cs b/MainForm.cs index 4a6e3e8..acb76cb 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -74,5 +74,11 @@ namespace AwesomeEmailExtractor JournalForm journalForm = FormManager.Current.CreateForm(); journalForm.ShowDialog(this); } + + private void administrationToolStripMenuItem_Click(object sender, EventArgs e) + { + AdministrationForm administrationForm = FormManager.Current.CreateForm(); + administrationForm.ShowDialog(this); + } } } From 4527f07c89bdb3fe02fcc8006221b93e13a189e7 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 09:09:56 +0300 Subject: [PATCH 03/14] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D1=82=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AdministrationForm.Designer.cs | 83 ++++++++++++++++++ AdministrationForm.cs | 31 +++++++ Authorization.cs | 48 ++++++++-- AwesomeEmailExtractor.csproj | 9 ++ EditUserForm.Designer.cs | 154 +++++++++++++++++++++++++++++++++ EditUserForm.cs | 55 ++++++++++++ EditUserForm.resx | 120 +++++++++++++++++++++++++ 7 files changed, 491 insertions(+), 9 deletions(-) create mode 100644 EditUserForm.Designer.cs create mode 100644 EditUserForm.cs create mode 100644 EditUserForm.resx diff --git a/AdministrationForm.Designer.cs b/AdministrationForm.Designer.cs index 0573f14..28fcfd1 100644 --- a/AdministrationForm.Designer.cs +++ b/AdministrationForm.Designer.cs @@ -34,9 +34,20 @@ this.browseButton = new System.Windows.Forms.Button(); this.pathToJournalTextBox = new System.Windows.Forms.TextBox(); this.usersTabPage = new System.Windows.Forms.TabPage(); + this.usersDataGridView = new System.Windows.Forms.DataGridView(); this.journalTabPage = new System.Windows.Forms.TabPage(); + this.panel1 = new System.Windows.Forms.Panel(); + this.journalDataGridView = new System.Windows.Forms.DataGridView(); + this.editUserButton = new System.Windows.Forms.Button(); + this.panel2 = new System.Windows.Forms.Panel(); + this.deleteUserButton = new System.Windows.Forms.Button(); this.mainTabControl.SuspendLayout(); this.mainSettingsTabPage.SuspendLayout(); + this.usersTabPage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.usersDataGridView)).BeginInit(); + this.journalTabPage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.journalDataGridView)).BeginInit(); + this.panel2.SuspendLayout(); this.SuspendLayout(); // // mainTabControl @@ -93,6 +104,8 @@ // // usersTabPage // + this.usersTabPage.Controls.Add(this.usersDataGridView); + this.usersTabPage.Controls.Add(this.panel2); this.usersTabPage.Location = new System.Drawing.Point(4, 22); this.usersTabPage.Name = "usersTabPage"; this.usersTabPage.Padding = new System.Windows.Forms.Padding(3); @@ -101,14 +114,73 @@ this.usersTabPage.Text = "Пользователи"; this.usersTabPage.UseVisualStyleBackColor = true; // + // usersDataGridView + // + this.usersDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.usersDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; + this.usersDataGridView.Location = new System.Drawing.Point(3, 31); + this.usersDataGridView.Name = "usersDataGridView"; + this.usersDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.usersDataGridView.Size = new System.Drawing.Size(786, 390); + this.usersDataGridView.TabIndex = 0; + // // journalTabPage // + this.journalTabPage.Controls.Add(this.panel1); + this.journalTabPage.Controls.Add(this.journalDataGridView); this.journalTabPage.Location = new System.Drawing.Point(4, 22); this.journalTabPage.Name = "journalTabPage"; this.journalTabPage.Size = new System.Drawing.Size(792, 424); this.journalTabPage.TabIndex = 2; this.journalTabPage.Text = "Журнал"; this.journalTabPage.UseVisualStyleBackColor = true; + this.journalTabPage.Click += new System.EventHandler(this.journalTabPage_Click); + // + // panel1 + // + this.panel1.Dock = System.Windows.Forms.DockStyle.Right; + this.panel1.Location = new System.Drawing.Point(497, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(295, 424); + this.panel1.TabIndex = 1; + // + // journalDataGridView + // + this.journalDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.journalDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; + this.journalDataGridView.Location = new System.Drawing.Point(0, 0); + this.journalDataGridView.Name = "journalDataGridView"; + this.journalDataGridView.Size = new System.Drawing.Size(792, 424); + this.journalDataGridView.TabIndex = 0; + // + // editUserButton + // + this.editUserButton.Location = new System.Drawing.Point(3, 3); + this.editUserButton.Name = "editUserButton"; + this.editUserButton.Size = new System.Drawing.Size(131, 20); + this.editUserButton.TabIndex = 1; + this.editUserButton.Text = "Редактировать"; + this.editUserButton.UseVisualStyleBackColor = true; + this.editUserButton.Click += new System.EventHandler(this.editUserButton_Click); + // + // panel2 + // + this.panel2.Controls.Add(this.deleteUserButton); + this.panel2.Controls.Add(this.editUserButton); + this.panel2.Dock = System.Windows.Forms.DockStyle.Top; + this.panel2.Location = new System.Drawing.Point(3, 3); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(786, 28); + this.panel2.TabIndex = 2; + // + // deleteUserButton + // + this.deleteUserButton.Location = new System.Drawing.Point(140, 3); + this.deleteUserButton.Name = "deleteUserButton"; + this.deleteUserButton.Size = new System.Drawing.Size(131, 20); + this.deleteUserButton.TabIndex = 2; + this.deleteUserButton.Text = "Удалить"; + this.deleteUserButton.UseVisualStyleBackColor = true; // // AdministrationForm // @@ -122,6 +194,11 @@ this.mainTabControl.ResumeLayout(false); this.mainSettingsTabPage.ResumeLayout(false); this.mainSettingsTabPage.PerformLayout(); + this.usersTabPage.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.usersDataGridView)).EndInit(); + this.journalTabPage.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.journalDataGridView)).EndInit(); + this.panel2.ResumeLayout(false); this.ResumeLayout(false); } @@ -135,5 +212,11 @@ private System.Windows.Forms.Label label1; private System.Windows.Forms.Button browseButton; private System.Windows.Forms.TextBox pathToJournalTextBox; + private System.Windows.Forms.DataGridView usersDataGridView; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.DataGridView journalDataGridView; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Button deleteUserButton; + private System.Windows.Forms.Button editUserButton; } } \ No newline at end of file diff --git a/AdministrationForm.cs b/AdministrationForm.cs index b08089a..b05cdcf 100644 --- a/AdministrationForm.cs +++ b/AdministrationForm.cs @@ -30,6 +30,12 @@ namespace AwesomeEmailExtractor var Row = reader.Read(); pathToJournalTextBox.Text = reader.GetString(0); + + AdminUtils adminUtils = new AdminUtils(Globals.currentUser); + + var users = adminUtils.GetAllUsers(); + + usersDataGridView.DataSource = users; } private void browseButton_Click(object sender, EventArgs e) @@ -49,5 +55,30 @@ namespace AwesomeEmailExtractor } } + + private void journalTabPage_Click(object sender, EventArgs e) + { + + } + + private void editUserButton_Click(object sender, EventArgs e) + { + if (usersDataGridView.SelectedRows.Count == 1) + { + var user = usersDataGridView.SelectedRows[0].DataBoundItem as User; + + var form = new EditUserForm(); + form.User = user; + + form.ShowDialog(); + + AdminUtils adminUtils = new AdminUtils(Globals.currentUser); + var users = adminUtils.GetAllUsers(); + usersDataGridView.DataSource = users; + } else + { + MessageBox.Show("Выберите 1 пользователя для редактирования!"); + } + } } } diff --git a/Authorization.cs b/Authorization.cs index deec387..1b8bd7c 100644 --- a/Authorization.cs +++ b/Authorization.cs @@ -86,7 +86,14 @@ namespace AwesomeEmailExtractor Login = login; Role = role; } - + + public User(User user) + { + ID = user.ID; + Login = user.Login; + Role = user.Role; + } + public void Delete() { SqliteCommand command = new SqliteCommand(); @@ -130,11 +137,6 @@ namespace AwesomeEmailExtractor } public void setRole(string login, UserRoles role) { - if (User.Role != UserRoles.ADMIN) - { - throw new Exception("Недостаточно прав!"); - } - SqliteCommand command = new SqliteCommand(); command.Connection = Globals.db; command.CommandText = "UPDATE users SET role_id = @role WHERE login = @login"; @@ -147,7 +149,6 @@ namespace AwesomeEmailExtractor command.ExecuteNonQuery(); } - public void deleteUser(string login) { if (User.Role != UserRoles.ADMIN) @@ -164,7 +165,7 @@ namespace AwesomeEmailExtractor command.ExecuteNonQuery(); } - public List getAllUsers() + public List GetAllUsers() { if (User.Role != UserRoles.ADMIN) { @@ -173,7 +174,7 @@ namespace AwesomeEmailExtractor SqliteCommand command = new SqliteCommand(); command.Connection = Globals.db; - command.CommandText = "SELECT * FROM users"; + command.CommandText = "SELECT id, login, role_id FROM users"; SqliteDataReader reader = command.ExecuteReader(); @@ -186,5 +187,34 @@ namespace AwesomeEmailExtractor return users; } + + public void editUser(User user) + { + if (User.Role != UserRoles.ADMIN) + { + throw new Exception("Недостаточно прав!"); + } + + SqliteCommand command = new SqliteCommand(); + command.Connection = Globals.db; + command.CommandText = "UPDATE users SET login = @login, role_id = @role_id WHERE id = @id"; + + SqliteParameter idParam = new SqliteParameter("@id", user.ID); + command.Parameters.Add(idParam); + + SqliteParameter loginParam = new SqliteParameter("@login", user.Login); + command.Parameters.Add(loginParam); + + SqliteParameter roleParam = new SqliteParameter("@role_id", user.Role); + command.Parameters.Add(roleParam); + + command.ExecuteNonQuery(); + } + + public void editUser(User user, string password) + { + editUser(user); + user.ChangePassword(password); + } } } diff --git a/AwesomeEmailExtractor.csproj b/AwesomeEmailExtractor.csproj index 488936e..aabfb10 100644 --- a/AwesomeEmailExtractor.csproj +++ b/AwesomeEmailExtractor.csproj @@ -89,6 +89,12 @@ AuthorizationForm.cs + + Form + + + EditUserForm.cs + @@ -125,6 +131,9 @@ AuthorizationForm.cs + + EditUserForm.cs + JournalForm.cs diff --git a/EditUserForm.Designer.cs b/EditUserForm.Designer.cs new file mode 100644 index 0000000..9901122 --- /dev/null +++ b/EditUserForm.Designer.cs @@ -0,0 +1,154 @@ +namespace AwesomeEmailExtractor +{ + partial class EditUserForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.idTextBox = new System.Windows.Forms.TextBox(); + this.loginTextBox = new System.Windows.Forms.TextBox(); + this.passwordTextBox = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.submitButton = new System.Windows.Forms.Button(); + this.roleComboBox = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // idTextBox + // + this.idTextBox.Enabled = false; + this.idTextBox.Location = new System.Drawing.Point(65, 8); + this.idTextBox.Name = "idTextBox"; + this.idTextBox.Size = new System.Drawing.Size(129, 20); + this.idTextBox.TabIndex = 0; + // + // loginTextBox + // + this.loginTextBox.Location = new System.Drawing.Point(65, 34); + this.loginTextBox.Name = "loginTextBox"; + this.loginTextBox.Size = new System.Drawing.Size(129, 20); + this.loginTextBox.TabIndex = 1; + // + // passwordTextBox + // + this.passwordTextBox.Location = new System.Drawing.Point(65, 60); + this.passwordTextBox.Name = "passwordTextBox"; + this.passwordTextBox.Size = new System.Drawing.Size(129, 20); + this.passwordTextBox.TabIndex = 2; + this.passwordTextBox.UseSystemPasswordChar = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(14, 11); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(21, 13); + this.label1.TabIndex = 3; + this.label1.Text = "ID:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(14, 37); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(41, 13); + this.label2.TabIndex = 4; + this.label2.Text = "Логин:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(14, 63); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(48, 13); + this.label3.TabIndex = 5; + this.label3.Text = "Пароль:"; + // + // submitButton + // + this.submitButton.Location = new System.Drawing.Point(17, 118); + this.submitButton.Name = "submitButton"; + this.submitButton.Size = new System.Drawing.Size(177, 23); + this.submitButton.TabIndex = 6; + this.submitButton.Text = "Подтвердить"; + this.submitButton.UseVisualStyleBackColor = true; + this.submitButton.Click += new System.EventHandler(this.submitButton_Click); + // + // roleComboBox + // + this.roleComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.roleComboBox.FormattingEnabled = true; + this.roleComboBox.Location = new System.Drawing.Point(65, 86); + this.roleComboBox.Name = "roleComboBox"; + this.roleComboBox.Size = new System.Drawing.Size(129, 21); + this.roleComboBox.TabIndex = 7; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(17, 89); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(35, 13); + this.label4.TabIndex = 8; + this.label4.Text = "Роль:"; + // + // EditUserForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(210, 153); + this.Controls.Add(this.label4); + this.Controls.Add(this.roleComboBox); + this.Controls.Add(this.submitButton); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.passwordTextBox); + this.Controls.Add(this.loginTextBox); + this.Controls.Add(this.idTextBox); + this.Name = "EditUserForm"; + this.Text = "Редактирование"; + this.Load += new System.EventHandler(this.EditUserForm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox idTextBox; + private System.Windows.Forms.TextBox loginTextBox; + private System.Windows.Forms.TextBox passwordTextBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button submitButton; + private System.Windows.Forms.ComboBox roleComboBox; + private System.Windows.Forms.Label label4; + } +} \ No newline at end of file diff --git a/EditUserForm.cs b/EditUserForm.cs new file mode 100644 index 0000000..73024ba --- /dev/null +++ b/EditUserForm.cs @@ -0,0 +1,55 @@ +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) + { + AdminUtils adminUtils = new AdminUtils(Globals.currentUser); + + User editedUser = new User(User.ID, loginTextBox.Text, (UserRoles)roleComboBox.SelectedIndex); + + if (passwordTextBox.Text != "") + { + adminUtils.editUser(editedUser, passwordTextBox.Text); + } + else + { + + adminUtils.editUser(editedUser); + } + + this.Close(); + } + } +} diff --git a/EditUserForm.resx b/EditUserForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/EditUserForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file From 0f6d88a4ada15302135fafc7ea8fffaf70565503 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 10:02:57 +0300 Subject: [PATCH 04/14] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D1=8F?= =?UTF-8?q?=D0=B5=D1=82=20=D0=B2=D0=B8=D0=B4=20=D1=82=D0=B0=D0=B1=D0=BB?= =?UTF-8?q?=D0=B8=D1=86=D1=8B=20=D1=81=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AdministrationForm.Designer.cs | 1 + AdministrationForm.cs | 58 +++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/AdministrationForm.Designer.cs b/AdministrationForm.Designer.cs index 28fcfd1..d8f15ad 100644 --- a/AdministrationForm.Designer.cs +++ b/AdministrationForm.Designer.cs @@ -181,6 +181,7 @@ this.deleteUserButton.TabIndex = 2; this.deleteUserButton.Text = "Удалить"; this.deleteUserButton.UseVisualStyleBackColor = true; + this.deleteUserButton.Click += new System.EventHandler(this.deleteUserButton_Click); // // AdministrationForm // diff --git a/AdministrationForm.cs b/AdministrationForm.cs index b05cdcf..0c51b88 100644 --- a/AdministrationForm.cs +++ b/AdministrationForm.cs @@ -34,8 +34,15 @@ namespace AwesomeEmailExtractor AdminUtils adminUtils = new AdminUtils(Globals.currentUser); var users = adminUtils.GetAllUsers(); + usersDataGridView.DataSource = users; - usersDataGridView.DataSource = users; + List columns = new List() { "ID", "Логин", "Роль" }; + + for (int i = 0; i < usersDataGridView.Columns.Count; i++) + { + usersDataGridView.Columns[i].HeaderText = columns[i]; + usersDataGridView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } } private void browseButton_Click(object sender, EventArgs e) @@ -80,5 +87,54 @@ namespace AwesomeEmailExtractor MessageBox.Show("Выберите 1 пользователя для редактирования!"); } } + + private void deleteUserButton_Click(object sender, EventArgs e) + { + bool selfDelete = false; + + if (usersDataGridView.SelectedRows.Count > 0) + { + DialogResult result = MessageBox.Show("Вы уверены что хотите удалить аккаунты?", "Удаление аккаунтов", MessageBoxButtons.YesNo); + + if (result == DialogResult.Yes) + { + for (int i = 0; i < usersDataGridView.SelectedRows.Count; i++) + { + var user = usersDataGridView.SelectedRows[i].DataBoundItem as User; + if (user.ID != Globals.currentUser.ID) + { + user.Delete(); + } + else + { + selfDelete = true; + } + } + + if (selfDelete) + { + DialogResult result2 = MessageBox.Show("Вы уверены что хотите удалить СВОЙ аккаунт?", "Удаление аккаунта", MessageBoxButtons.YesNo); + + if (result2 == DialogResult.Yes) + { + Globals.currentUser.Delete(); + MessageBox.Show("Аккаунт удален!"); + + this.Close(); + + AuthorizationForm authorization = FormManager.Current.CreateForm(); + FormManager.Current.Navigate(this.Owner, authorization); + } + } + } + AdminUtils adminUtils = new AdminUtils(Globals.currentUser); + var users = adminUtils.GetAllUsers(); + usersDataGridView.DataSource = users; + } + else + { + MessageBox.Show("Выберите хотя бы одного пользователя для удаления!"); + } + } } } From 51b75c35c534c1e37788fafc40e2bb7f0e18c432 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 12:41:18 +0300 Subject: [PATCH 05/14] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D1=82=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=B8=D0=B7=20?= =?UTF-8?q?=D0=B6=D1=83=D1=80=D0=BD=D0=B2=D0=B0=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AdministrationForm.Designer.cs | 192 ++++++++++++++++++++++++++++++--- AdministrationForm.cs | 67 +++++++++++- AdministrationForm.resx | 6 ++ Authorization.cs | 4 +- AwesomeEmailExtractor.csproj | 1 + JournalForm.cs | 11 +- Logs.cs | 59 +++++++--- 7 files changed, 303 insertions(+), 37 deletions(-) diff --git a/AdministrationForm.Designer.cs b/AdministrationForm.Designer.cs index d8f15ad..9e33c60 100644 --- a/AdministrationForm.Designer.cs +++ b/AdministrationForm.Designer.cs @@ -41,13 +41,30 @@ this.editUserButton = new System.Windows.Forms.Button(); this.panel2 = new System.Windows.Forms.Panel(); this.deleteUserButton = new System.Windows.Forms.Button(); + this.sqliteCommand1 = new Microsoft.Data.Sqlite.SqliteCommand(); + this.panel3 = new System.Windows.Forms.Panel(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.messageRichTextBox = new System.Windows.Forms.RichTextBox(); + this.panel4 = new System.Windows.Forms.Panel(); + this.deleteJournalButton = new System.Windows.Forms.Button(); + this.dateLabel = new System.Windows.Forms.Label(); + this.userLabel = new System.Windows.Forms.Label(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.actionLabel = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); this.mainTabControl.SuspendLayout(); this.mainSettingsTabPage.SuspendLayout(); this.usersTabPage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.usersDataGridView)).BeginInit(); this.journalTabPage.SuspendLayout(); + this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.journalDataGridView)).BeginInit(); this.panel2.SuspendLayout(); + this.panel3.SuspendLayout(); + this.panel4.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // mainTabControl @@ -59,7 +76,7 @@ this.mainTabControl.Location = new System.Drawing.Point(0, 0); this.mainTabControl.Name = "mainTabControl"; this.mainTabControl.SelectedIndex = 0; - this.mainTabControl.Size = new System.Drawing.Size(800, 450); + this.mainTabControl.Size = new System.Drawing.Size(998, 557); this.mainTabControl.TabIndex = 0; // // mainSettingsTabPage @@ -70,7 +87,7 @@ this.mainSettingsTabPage.Location = new System.Drawing.Point(4, 22); this.mainSettingsTabPage.Name = "mainSettingsTabPage"; this.mainSettingsTabPage.Padding = new System.Windows.Forms.Padding(3); - this.mainSettingsTabPage.Size = new System.Drawing.Size(792, 424); + this.mainSettingsTabPage.Size = new System.Drawing.Size(990, 531); this.mainSettingsTabPage.TabIndex = 0; this.mainSettingsTabPage.Text = "Общие настройки"; this.mainSettingsTabPage.UseVisualStyleBackColor = true; @@ -109,7 +126,7 @@ this.usersTabPage.Location = new System.Drawing.Point(4, 22); this.usersTabPage.Name = "usersTabPage"; this.usersTabPage.Padding = new System.Windows.Forms.Padding(3); - this.usersTabPage.Size = new System.Drawing.Size(792, 424); + this.usersTabPage.Size = new System.Drawing.Size(990, 531); this.usersTabPage.TabIndex = 1; this.usersTabPage.Text = "Пользователи"; this.usersTabPage.UseVisualStyleBackColor = true; @@ -121,16 +138,16 @@ this.usersDataGridView.Location = new System.Drawing.Point(3, 31); this.usersDataGridView.Name = "usersDataGridView"; this.usersDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.usersDataGridView.Size = new System.Drawing.Size(786, 390); + this.usersDataGridView.Size = new System.Drawing.Size(984, 497); this.usersDataGridView.TabIndex = 0; // // journalTabPage // + this.journalTabPage.Controls.Add(this.panel3); this.journalTabPage.Controls.Add(this.panel1); - this.journalTabPage.Controls.Add(this.journalDataGridView); this.journalTabPage.Location = new System.Drawing.Point(4, 22); this.journalTabPage.Name = "journalTabPage"; - this.journalTabPage.Size = new System.Drawing.Size(792, 424); + this.journalTabPage.Size = new System.Drawing.Size(990, 531); this.journalTabPage.TabIndex = 2; this.journalTabPage.Text = "Журнал"; this.journalTabPage.UseVisualStyleBackColor = true; @@ -138,20 +155,24 @@ // // panel1 // + this.panel1.Controls.Add(this.tableLayoutPanel1); this.panel1.Dock = System.Windows.Forms.DockStyle.Right; - this.panel1.Location = new System.Drawing.Point(497, 0); + this.panel1.Location = new System.Drawing.Point(536, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(295, 424); + this.panel1.Size = new System.Drawing.Size(454, 531); this.panel1.TabIndex = 1; // // journalDataGridView // this.journalDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.journalDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; - this.journalDataGridView.Location = new System.Drawing.Point(0, 0); + this.journalDataGridView.Location = new System.Drawing.Point(0, 37); this.journalDataGridView.Name = "journalDataGridView"; - this.journalDataGridView.Size = new System.Drawing.Size(792, 424); + this.journalDataGridView.ReadOnly = true; + this.journalDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.journalDataGridView.Size = new System.Drawing.Size(536, 494); this.journalDataGridView.TabIndex = 0; + this.journalDataGridView.SelectionChanged += new System.EventHandler(this.journalDataGridView_SelectionChanged); // // editUserButton // @@ -170,7 +191,7 @@ this.panel2.Dock = System.Windows.Forms.DockStyle.Top; this.panel2.Location = new System.Drawing.Point(3, 3); this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(786, 28); + this.panel2.Size = new System.Drawing.Size(984, 28); this.panel2.TabIndex = 2; // // deleteUserButton @@ -183,11 +204,140 @@ this.deleteUserButton.UseVisualStyleBackColor = true; this.deleteUserButton.Click += new System.EventHandler(this.deleteUserButton_Click); // + // sqliteCommand1 + // + this.sqliteCommand1.CommandTimeout = 30; + this.sqliteCommand1.Connection = null; + this.sqliteCommand1.Transaction = null; + this.sqliteCommand1.UpdatedRowSource = System.Data.UpdateRowSource.None; + // + // panel3 + // + this.panel3.Controls.Add(this.journalDataGridView); + this.panel3.Controls.Add(this.panel4); + this.panel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel3.Location = new System.Drawing.Point(0, 0); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(536, 531); + this.panel3.TabIndex = 2; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(3, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(36, 13); + this.label2.TabIndex = 0; + this.label2.Text = "Дата:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(3, 30); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(83, 13); + this.label3.TabIndex = 1; + this.label3.Text = "Пользователь:"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(3, 60); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(54, 13); + this.label4.TabIndex = 2; + this.label4.Text = "Событие:"; + // + // messageRichTextBox + // + this.messageRichTextBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.messageRichTextBox.Location = new System.Drawing.Point(103, 93); + this.messageRichTextBox.Name = "messageRichTextBox"; + this.messageRichTextBox.Size = new System.Drawing.Size(348, 435); + this.messageRichTextBox.TabIndex = 3; + this.messageRichTextBox.Text = ""; + // + // panel4 + // + this.panel4.Controls.Add(this.deleteJournalButton); + this.panel4.Dock = System.Windows.Forms.DockStyle.Top; + this.panel4.Location = new System.Drawing.Point(0, 0); + this.panel4.Name = "panel4"; + this.panel4.Size = new System.Drawing.Size(536, 37); + this.panel4.TabIndex = 1; + // + // deleteJournalButton + // + this.deleteJournalButton.Location = new System.Drawing.Point(8, 3); + this.deleteJournalButton.Name = "deleteJournalButton"; + this.deleteJournalButton.Size = new System.Drawing.Size(131, 20); + this.deleteJournalButton.TabIndex = 3; + this.deleteJournalButton.Text = "Удалить"; + this.deleteJournalButton.UseVisualStyleBackColor = true; + this.deleteJournalButton.Click += new System.EventHandler(this.deleteJournalButton_Click); + // + // dateLabel + // + this.dateLabel.AutoSize = true; + this.dateLabel.Location = new System.Drawing.Point(103, 0); + this.dateLabel.Name = "dateLabel"; + this.dateLabel.Size = new System.Drawing.Size(0, 13); + this.dateLabel.TabIndex = 4; + // + // userLabel + // + this.userLabel.AutoSize = true; + this.userLabel.Location = new System.Drawing.Point(103, 30); + this.userLabel.Name = "userLabel"; + this.userLabel.Size = new System.Drawing.Size(0, 13); + this.userLabel.TabIndex = 5; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.label2, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.messageRichTextBox, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.userLabel, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.label4, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.dateLabel, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.label3, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.actionLabel, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.label5, 0, 3); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(454, 531); + this.tableLayoutPanel1.TabIndex = 6; + // + // actionLabel + // + this.actionLabel.AutoSize = true; + this.actionLabel.Location = new System.Drawing.Point(103, 60); + this.actionLabel.Name = "actionLabel"; + this.actionLabel.Size = new System.Drawing.Size(0, 13); + this.actionLabel.TabIndex = 6; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(3, 90); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(68, 13); + this.label5.TabIndex = 7; + this.label5.Text = "Сообщение:"; + // // AdministrationForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(998, 557); this.Controls.Add(this.mainTabControl); this.Name = "AdministrationForm"; this.Text = "Администрирование"; @@ -198,8 +348,13 @@ this.usersTabPage.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.usersDataGridView)).EndInit(); this.journalTabPage.ResumeLayout(false); + this.panel1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.journalDataGridView)).EndInit(); this.panel2.ResumeLayout(false); + this.panel3.ResumeLayout(false); + this.panel4.ResumeLayout(false); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); this.ResumeLayout(false); } @@ -219,5 +374,18 @@ private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Button deleteUserButton; private System.Windows.Forms.Button editUserButton; + private System.Windows.Forms.Panel panel3; + private Microsoft.Data.Sqlite.SqliteCommand sqliteCommand1; + private System.Windows.Forms.Panel panel4; + private System.Windows.Forms.RichTextBox messageRichTextBox; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button deleteJournalButton; + private System.Windows.Forms.Label userLabel; + private System.Windows.Forms.Label dateLabel; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label actionLabel; + private System.Windows.Forms.Label label5; } } \ No newline at end of file diff --git a/AdministrationForm.cs b/AdministrationForm.cs index 0c51b88..27cb6fb 100644 --- a/AdministrationForm.cs +++ b/AdministrationForm.cs @@ -43,6 +43,17 @@ namespace AwesomeEmailExtractor usersDataGridView.Columns[i].HeaderText = columns[i]; usersDataGridView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } + + var logs = Logs.GetLogsList(); + journalDataGridView.DataSource = logs; + + columns = new List() { "ID", "Пользователь", "Дата", "Событие", "Сообщение" }; + + for (int i = 0; i < journalDataGridView.Columns.Count; i++) + { + journalDataGridView.Columns[i].HeaderText = columns[i]; + journalDataGridView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } } private void browseButton_Click(object sender, EventArgs e) @@ -68,6 +79,26 @@ namespace AwesomeEmailExtractor } + private void journalDataGridView_SelectionChanged(object sender, EventArgs e) + { + if (journalDataGridView.SelectedRows.Count > 0) + { + var row = journalDataGridView.SelectedRows[0].DataBoundItem as Logs.LogData; + + dateLabel.Text = row.Date; + userLabel.Text = $"{row.User.Login} ({row.User.ID}) - {row.User.Role}"; + actionLabel.Text = row.Action.ToString(); + messageRichTextBox.Text = row.Message; + } + else + { + dateLabel.Text = ""; + actionLabel.Text = ""; + userLabel.Text = ""; + messageRichTextBox.Text = ""; + } + } + private void editUserButton_Click(object sender, EventArgs e) { if (usersDataGridView.SelectedRows.Count == 1) @@ -82,6 +113,9 @@ namespace AwesomeEmailExtractor AdminUtils adminUtils = new AdminUtils(Globals.currentUser); var users = adminUtils.GetAllUsers(); usersDataGridView.DataSource = users; + + var logs = Logs.GetLogsList(); + journalDataGridView.DataSource = logs; } else { MessageBox.Show("Выберите 1 пользователя для редактирования!"); @@ -126,15 +160,42 @@ namespace AwesomeEmailExtractor FormManager.Current.Navigate(this.Owner, authorization); } } + + AdminUtils adminUtils = new AdminUtils(Globals.currentUser); + var users = adminUtils.GetAllUsers(); + usersDataGridView.DataSource = users; + + var logs = Logs.GetLogsList(); + journalDataGridView.DataSource = logs; } - AdminUtils adminUtils = new AdminUtils(Globals.currentUser); - var users = adminUtils.GetAllUsers(); - usersDataGridView.DataSource = users; } else { MessageBox.Show("Выберите хотя бы одного пользователя для удаления!"); } } + + private void deleteJournalButton_Click(object sender, EventArgs e) + { + if (journalDataGridView.SelectedRows.Count > 0) + { + DialogResult result = MessageBox.Show("Вы уверены что хотите удалить записи в журнале?", "Удаление записей в журнале", MessageBoxButtons.YesNo); + + if (result == DialogResult.Yes) + { + for (int i = 0; i < journalDataGridView.SelectedRows.Count; i++) + { + var logData = journalDataGridView.SelectedRows[i].DataBoundItem as Logs.LogData; + logData.Delete(); + } + var logs = Logs.GetLogsList(); + journalDataGridView.DataSource = logs; + } + } + else + { + MessageBox.Show("Выберите хотя бы одну запись для удаления!"); + } + } } } diff --git a/AdministrationForm.resx b/AdministrationForm.resx index 1af7de1..56dd26f 100644 --- a/AdministrationForm.resx +++ b/AdministrationForm.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + False + + + 17, 17 + \ No newline at end of file diff --git a/Authorization.cs b/Authorization.cs index 1b8bd7c..71c3b5a 100644 --- a/Authorization.cs +++ b/Authorization.cs @@ -121,9 +121,9 @@ namespace AwesomeEmailExtractor command.ExecuteNonQuery(); } - new public string ToString() + public override string ToString() { - return this.Login; + return Login; } } diff --git a/AwesomeEmailExtractor.csproj b/AwesomeEmailExtractor.csproj index aabfb10..d43c5bf 100644 --- a/AwesomeEmailExtractor.csproj +++ b/AwesomeEmailExtractor.csproj @@ -127,6 +127,7 @@ AdministrationForm.cs + Designer AuthorizationForm.cs diff --git a/JournalForm.cs b/JournalForm.cs index 55208ab..b45e7bd 100644 --- a/JournalForm.cs +++ b/JournalForm.cs @@ -22,17 +22,18 @@ namespace AwesomeEmailExtractor var logs = Logs.GetLogsList(Globals.currentUser); dataGridView1.DataSource = logs; - dataGridView1.Columns[0].Visible = false; - dataGridView1.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + // dataGridView1.Columns["id"].Visible = false; + // dataGridView1.Columns[1].Visible = false; + dataGridView1.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } private void dataGridView1_SelectionChanged(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { - dataLabel.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); - actionLabel.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); - richTextBox1.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString(); + dataLabel.Text = dataGridView1.SelectedRows[0].Cells["date"].Value.ToString(); + actionLabel.Text = dataGridView1.SelectedRows[0].Cells["action"].Value.ToString(); + richTextBox1.Text = dataGridView1.SelectedRows[0].Cells["message"].Value.ToString(); } else { dataLabel.Text = ""; actionLabel.Text = ""; diff --git a/Logs.cs b/Logs.cs index e9f61a3..79e6250 100644 --- a/Logs.cs +++ b/Logs.cs @@ -10,10 +10,23 @@ namespace AwesomeEmailExtractor public class Logs { public class LogData { + public int ID { get; set; } public User User { get; set; } public string Date { get; set; } public Action Action { get; set; } public string Message { get; set; } + + public void Delete() + { + SqliteCommand command = new SqliteCommand(); + command.Connection = Globals.logsDb; + command.CommandText = "DELETE FROM logs WHERE id = @id;"; + + SqliteParameter idParam = new SqliteParameter("@id", ID); + command.Parameters.Add(idParam); + + command.ExecuteNonQuery(); + } } public enum Action @@ -46,10 +59,11 @@ namespace AwesomeEmailExtractor { logs.Add(new LogData() { + ID = Convert.ToInt32(reader["id"]), User = user, - Date = reader.GetString(0), - Action = (Action)reader.GetInt32(1), - Message = reader.GetString(2) + Date = Convert.ToString(reader["date"]), + Action = (Action)Convert.ToInt32(reader["action"]), + Message = Convert.ToString(reader["message"]), }); } @@ -67,7 +81,7 @@ namespace AwesomeEmailExtractor SqliteCommand command = new SqliteCommand(); command.Connection = Globals.logsDb; - command.CommandText = "SELECT date, action, message FROM logs WHERE user_id = @user_id ORDER BY date DESC"; + command.CommandText = "SELECT id, date, action, message FROM logs WHERE user_id = @user_id ORDER BY date DESC"; command.Parameters.AddWithValue("@user_id", user.ID); return command.ExecuteReader(); @@ -82,19 +96,17 @@ namespace AwesomeEmailExtractor SqliteCommand command = new SqliteCommand(); command.Connection = Globals.logsDb; - command.CommandText = "ATTACH DATABASE @dbpath AS appDB"; - command.Parameters.AddWithValue("@dbpath", Globals.getAppDatabase()); - command.ExecuteNonQuery(); command.CommandText = @" - SELECT + SELECT + logs.id, user_id, - CASE WHEN appDB.users.login is NULL THEN 'Deleted_' || user_id ELSE appDB.users.login END AS login - appDB.users.role, + CASE WHEN appDB.users.login is NULL THEN 'Deleted_' || user_id ELSE appDB.users.login END AS login, + CASE WHEN appDB.users.role_id is NULL THEN 0 ELSE appDB.users.role_id END AS role_id, date, action, message - from logs LEFT JOIN appDB.users on logs.user_id = appDB.users.id ORDER BY date DESC"; + from logs LEFT JOIN appDB.users on logs.user_id = appDB.users.id ORDER BY date DESC;"; SqliteDataReader reader = command.ExecuteReader(); @@ -103,10 +115,15 @@ namespace AwesomeEmailExtractor { logs.Add(new LogData() { - User = new User(reader.GetInt32(0), reader.GetString(1), (UserRoles)reader.GetInt32(2)), - Date = reader.GetString(3), - Action = (Action)reader.GetInt32(4), - Message = reader.GetString(5) + ID = Convert.ToInt32(reader["id"]), + User = new User( + Convert.ToInt32(reader["user_id"]), + Convert.ToString(reader["login"]), + (UserRoles)Convert.ToInt32(reader["role_id"]) + ), + Date = Convert.ToString(reader["date"]), + Action = (Action)Convert.ToInt32(reader["action"]), + Message = Convert.ToString(reader["message"]) }); } @@ -137,5 +154,17 @@ namespace AwesomeEmailExtractor return ""; } + + public static void DeleteLog(LogData logData) + { + SqliteCommand command = new SqliteCommand(); + command.Connection = Globals.logsDb; + + command.CommandText = "DELETE FROM logsDB WHERE id = @id"; + + command.Parameters.AddWithValue("@id", logData.ID); + + command.ExecuteNonQuery(); + } } } From 8f85c25a622cfd3ad795aa16f3bb5dbebe9d4542 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 13:01:28 +0300 Subject: [PATCH 06/14] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D1=82=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20DeleteAccount=20=D0=B8=20ChangePassword?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Globals.cs | 5 +---- Logs.cs | 12 +++++++++++- SettingsForm.cs | 2 ++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Globals.cs b/Globals.cs index a953706..940c8ae 100644 --- a/Globals.cs +++ b/Globals.cs @@ -66,10 +66,7 @@ namespace AwesomeEmailExtractor command.CommandText = "CREATE TABLE IF NOT EXISTS logs_actions (id INTEGER PRIMARY KEY, name TEXT NOT NULL)"; command.ExecuteNonQuery(); - command.CommandText = "INSERT OR IGNORE INTO logs_actions (id, name) VALUES (0, 'Выполнение'), (1, 'Вход'), (2, 'Регистрация');"; - command.ExecuteNonQuery(); - - command.CommandText = "CREATE TABLE IF NOT EXISTS logs (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, date TEXT NOT NULL, action INTEGER NOT NULL, message TEXT NOT NULL, FOREIGN KEY(action) REFERENCES logs_actions(id));"; + command.CommandText = "CREATE TABLE IF NOT EXISTS logs (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, date TEXT NOT NULL, action INTEGER NOT NULL, message TEXT NOT NULL);"; command.ExecuteNonQuery(); command.CommandText = "ATTACH DATABASE @dbpath AS appDB"; diff --git a/Logs.cs b/Logs.cs index 79e6250..059a1b1 100644 --- a/Logs.cs +++ b/Logs.cs @@ -33,7 +33,9 @@ namespace AwesomeEmailExtractor { Execute, Login, - Registration + Registration, + DeleteAccount, + ChangePassword } public static void Log(User user, Action action, Dictionary options) @@ -151,6 +153,14 @@ namespace AwesomeEmailExtractor { return "Пользователь зарегистрировался в системе."; } + if (action == Action.DeleteAccount) + { + return "Пользователь удалил аккаунт из системы."; + } + if (action == Action.ChangePassword) + { + return "Пользователь сменил пароль."; + } return ""; } diff --git a/SettingsForm.cs b/SettingsForm.cs index 9d3aaac..287829d 100644 --- a/SettingsForm.cs +++ b/SettingsForm.cs @@ -24,6 +24,7 @@ namespace AwesomeEmailExtractor if (result == DialogResult.Yes) { Globals.currentUser.Delete(); + Logs.Log(Globals.currentUser, Logs.Action.DeleteAccount, new Dictionary()); MessageBox.Show("Аккаунт удален!"); this.Close(); @@ -42,6 +43,7 @@ namespace AwesomeEmailExtractor } Globals.currentUser.ChangePassword(entryNewPassword.Text); + Logs.Log(Globals.currentUser, Logs.Action.ChangePassword, new Dictionary()); MessageBox.Show("Пароль изменен!"); } } From 7d71bfeb46950fdaf16685006185e97fb3f79f4d Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 13:19:07 +0300 Subject: [PATCH 07/14] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D1=82=20=D1=8D=D0=BA=D1=81=D0=BF=D0=BE=D1=80=D1=82?= =?UTF-8?q?=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82=D0=B0?= =?UTF-8?q?=20=D0=B2=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MainForm.Designer.cs | 11 +++++++++++ MainForm.cs | 29 +++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 19645ee..fe132ee 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -42,6 +42,7 @@ this.administrationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.exportResultToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.resultStatusStrip.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -127,6 +128,8 @@ // // fileToolStripMenuItem // + this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.exportResultToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(48, 20); this.fileToolStripMenuItem.Text = "Файл"; @@ -176,6 +179,13 @@ this.helpToolStripMenuItem.Size = new System.Drawing.Size(65, 20); this.helpToolStripMenuItem.Text = "Справка"; // + // exportResultToolStripMenuItem + // + this.exportResultToolStripMenuItem.Name = "exportResultToolStripMenuItem"; + this.exportResultToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.exportResultToolStripMenuItem.Text = "Экспортировать результат"; + this.exportResultToolStripMenuItem.Click += new System.EventHandler(this.exportResultToolStripMenuItem_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -216,6 +226,7 @@ private System.Windows.Forms.ToolStripMenuItem administrationToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem journalToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem exportResultToolStripMenuItem; } } diff --git a/MainForm.cs b/MainForm.cs index acb76cb..84fbdc6 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -12,6 +12,9 @@ namespace AwesomeEmailExtractor { public partial class MainForm : Form { + public int count; + public List uniqueEmails; + public MainForm() { InitializeComponent(); @@ -36,10 +39,10 @@ namespace AwesomeEmailExtractor uniqueListBox.DataSource = null; // Объявляем список уникальных e-mail-ов - List uniqueEmails = new List(); + uniqueEmails = new List(); // Вызываем метод для извлечения e-mail-ов - int count = ExtactEmailsAlgorithm.Extract(sourceText, out uniqueEmails); + count = ExtactEmailsAlgorithm.Extract(sourceText, out uniqueEmails); // Выводим результат toolStripStatusLabel.Text = "Успех!"; @@ -80,5 +83,27 @@ namespace AwesomeEmailExtractor AdministrationForm administrationForm = FormManager.Current.CreateForm(); administrationForm.ShowDialog(this); } + + private void exportResultToolStripMenuItem_Click(object sender, EventArgs e) + { + // Показать окно с выбором файла + SaveFileDialog saveFileDialog = new SaveFileDialog(); + saveFileDialog.Filter = "Текстовый файл (*.txt)|*.txt"; + saveFileDialog.FileName = "Результат.txt"; + + var res = saveFileDialog.ShowDialog(); + + + // Сохранить результат в файл + if (res == DialogResult.OK) + { + string fileName = saveFileDialog.FileName; + string resultText = $"Количество e-mail-ов в тексте: {count}\nСписок уникальных e-mail-ов:\n{string.Join("\n", uniqueEmails)}"; + + System.IO.File.WriteAllText(fileName, resultText); + + MessageBox.Show("E-mail-ы успешно сохранены в файл", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } } } From a35c382c4b908ff3bec0301fffe5689c795f937b Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 13:49:52 +0300 Subject: [PATCH 08/14] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D1=82=20=D1=84=D0=BE=D1=80=D0=BC=D1=83=20=D0=B0?= =?UTF-8?q?=D0=B4=D0=BC=D0=B8=D0=BD=D0=B8=D1=81=D1=82=D1=80=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Authorization.cs | 2 +- AuthorizationForm.cs | 6 ++++++ EditUserForm.cs | 6 ++++++ RegistrationForm.cs | 6 ++++++ SettingsForm.cs | 6 ++++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Authorization.cs b/Authorization.cs index 71c3b5a..e64cfa9 100644 --- a/Authorization.cs +++ b/Authorization.cs @@ -28,7 +28,7 @@ namespace AwesomeEmailExtractor return new User(reader.GetInt32(0), reader.GetString(1), (UserRoles)reader.GetInt32(2)); } - throw new Exception("Пользователь не найден!"); + throw new Exception("Неверные данные для входа!"); } public static User Register(string login, string password) diff --git a/AuthorizationForm.cs b/AuthorizationForm.cs index 741cb61..cee06d7 100644 --- a/AuthorizationForm.cs +++ b/AuthorizationForm.cs @@ -21,6 +21,12 @@ namespace AwesomeEmailExtractor { try { + if (string.IsNullOrEmpty(entryLogin.Text) || string.IsNullOrEmpty(entryPassword.Text)) + { + MessageBox.Show("Введите логин и пароль"); + return; + } + Globals.currentUser = Authorization.Login(entryLogin.Text, entryPassword.Text); Logs.Log(Globals.currentUser, Logs.Action.Login, new Dictionary()); diff --git a/EditUserForm.cs b/EditUserForm.cs index 73024ba..91b4fbc 100644 --- a/EditUserForm.cs +++ b/EditUserForm.cs @@ -35,6 +35,12 @@ namespace AwesomeEmailExtractor private void submitButton_Click(object sender, EventArgs e) { + if (loginTextBox.Text.Length == 0) + { + MessageBox.Show("Логин не может быть пустым!"); + return; + } + AdminUtils adminUtils = new AdminUtils(Globals.currentUser); User editedUser = new User(User.ID, loginTextBox.Text, (UserRoles)roleComboBox.SelectedIndex); diff --git a/RegistrationForm.cs b/RegistrationForm.cs index 308f39b..f576b67 100644 --- a/RegistrationForm.cs +++ b/RegistrationForm.cs @@ -19,6 +19,12 @@ namespace AwesomeEmailExtractor private void registerButton_Click(object sender, EventArgs e) { + if (string.IsNullOrEmpty(entryLogin.Text) || string.IsNullOrEmpty(entryPassword.Text)) + { + MessageBox.Show("Введите логин и пароль!"); + return; + } + if (!string.Equals(entryPassword.Text, entryRePassword.Text)) { MessageBox.Show("Пароли не совпадают!"); diff --git a/SettingsForm.cs b/SettingsForm.cs index 287829d..1cde078 100644 --- a/SettingsForm.cs +++ b/SettingsForm.cs @@ -36,6 +36,12 @@ namespace AwesomeEmailExtractor private void changePasswordButton_Click(object sender, EventArgs e) { + if (string.IsNullOrEmpty(entryNewPassword.Text)) + { + MessageBox.Show("Введите пароль!"); + return; + } + if (!string.Equals(entryNewPassword.Text, entryRePassword.Text)) { MessageBox.Show("Пароли не совпадают!"); From 97da2e21f68a81afbf689b0bcb50ad59e7db73b6 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 14:30:12 +0300 Subject: [PATCH 09/14] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D1=82=20=D0=BC=D0=B5=D0=BD=D1=8E=20=D1=81=D0=BE=20?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AwesomeEmailExtractor.csproj | 9 +++ HelpForm.Designer.cs | 75 ++++++++++++++++++++ HelpForm.cs | 20 ++++++ HelpForm.resx | 128 +++++++++++++++++++++++++++++++++++ MainForm.Designer.cs | 17 ++--- MainForm.cs | 6 ++ 6 files changed, 247 insertions(+), 8 deletions(-) create mode 100644 HelpForm.Designer.cs create mode 100644 HelpForm.cs create mode 100644 HelpForm.resx diff --git a/AwesomeEmailExtractor.csproj b/AwesomeEmailExtractor.csproj index d43c5bf..27aeed3 100644 --- a/AwesomeEmailExtractor.csproj +++ b/AwesomeEmailExtractor.csproj @@ -98,6 +98,12 @@ + + Form + + + HelpForm.cs + Form @@ -135,6 +141,9 @@ EditUserForm.cs + + HelpForm.cs + JournalForm.cs diff --git a/HelpForm.Designer.cs b/HelpForm.Designer.cs new file mode 100644 index 0000000..8a6551f --- /dev/null +++ b/HelpForm.Designer.cs @@ -0,0 +1,75 @@ +namespace AwesomeEmailExtractor +{ + partial class HelpForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HelpForm)); + this.label1 = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label1.Location = new System.Drawing.Point(3, 9); + this.label1.Name = "label1"; + this.label1.Padding = new System.Windows.Forms.Padding(5); + this.label1.Size = new System.Drawing.Size(649, 358); + this.label1.TabIndex = 0; + this.label1.Text = resources.GetString("label1.Text"); + // + // panel1 + // + this.panel1.Controls.Add(this.label1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(652, 393); + this.panel1.TabIndex = 1; + // + // HelpForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(652, 393); + this.Controls.Add(this.panel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Name = "HelpForm"; + this.Text = "Справка"; + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel panel1; + } +} \ No newline at end of file diff --git a/HelpForm.cs b/HelpForm.cs new file mode 100644 index 0000000..e1d6279 --- /dev/null +++ b/HelpForm.cs @@ -0,0 +1,20 @@ +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 HelpForm : Form + { + public HelpForm() + { + InitializeComponent(); + } + } +} diff --git a/HelpForm.resx b/HelpForm.resx new file mode 100644 index 0000000..391bb3d --- /dev/null +++ b/HelpForm.resx @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Программный продукт AwesomeEmailExtractor будет востребован в тех случаях, когда необхимо из текста получить список уникальных e-mail-ов. +Для того, чтобы получить список, необходимо ввести исходный текст и нажать кнопку "Выполнить". После этого, в правой части окна появится список из уникальных e-mail-ов. +При необходимости можно экспортировать результат выполнения программы с помощью меню "Файл" > "Экспортировать результат". +Во время своей работы программа ведет журнал активности пользователя. Это может быть полезно, чтобы узнать, какие до этого были результаты выполнения. "Аккаунт" -> "Журнал". +Для смены пароля или удаления аккаунта необходимо выбрать в меню "Аккаунт" -> "Настройки". +Для администраторов доступны некоторые особые возможности, их можно найти в меню "Аккаунт" -> "Администрирование". + + \ No newline at end of file diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index fe132ee..78b89f7 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -36,13 +36,13 @@ this.toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.exportResultToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.аккаунтToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.journalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.administrationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.exportResultToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.resultStatusStrip.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -134,6 +134,13 @@ this.fileToolStripMenuItem.Size = new System.Drawing.Size(48, 20); this.fileToolStripMenuItem.Text = "Файл"; // + // exportResultToolStripMenuItem + // + this.exportResultToolStripMenuItem.Name = "exportResultToolStripMenuItem"; + this.exportResultToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.exportResultToolStripMenuItem.Text = "Экспортировать результат"; + this.exportResultToolStripMenuItem.Click += new System.EventHandler(this.exportResultToolStripMenuItem_Click); + // // аккаунтToolStripMenuItem // this.аккаунтToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -178,13 +185,7 @@ this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; this.helpToolStripMenuItem.Size = new System.Drawing.Size(65, 20); this.helpToolStripMenuItem.Text = "Справка"; - // - // exportResultToolStripMenuItem - // - this.exportResultToolStripMenuItem.Name = "exportResultToolStripMenuItem"; - this.exportResultToolStripMenuItem.Size = new System.Drawing.Size(219, 22); - this.exportResultToolStripMenuItem.Text = "Экспортировать результат"; - this.exportResultToolStripMenuItem.Click += new System.EventHandler(this.exportResultToolStripMenuItem_Click); + this.helpToolStripMenuItem.Click += new System.EventHandler(this.helpToolStripMenuItem_Click); // // MainForm // diff --git a/MainForm.cs b/MainForm.cs index 84fbdc6..4c66113 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -105,5 +105,11 @@ namespace AwesomeEmailExtractor MessageBox.Show("E-mail-ы успешно сохранены в файл", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } } + + private void helpToolStripMenuItem_Click(object sender, EventArgs e) + { + HelpForm helpForm = FormManager.Current.CreateForm(); + helpForm.ShowDialog(this); + } } } From 6b1ae5fa2046897c01ebbf844ca1f75aeeaeae78 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 15:04:22 +0300 Subject: [PATCH 10/14] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=80=D0=B5=D0=B3=D1=83=D0=BB=D1=8F=D1=80=D0=BD=D0=BE?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ExtactEmailsAlgorithm.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExtactEmailsAlgorithm.cs b/ExtactEmailsAlgorithm.cs index 4509198..c7831f1 100644 --- a/ExtactEmailsAlgorithm.cs +++ b/ExtactEmailsAlgorithm.cs @@ -12,7 +12,7 @@ namespace AwesomeEmailExtractor public static int Extract(string inputText, out List uniqueEmails) { // Регулярное выражение для поиска почтовых адресов - string pattern = @"\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b"; + string pattern = "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"; // Находим каждый почтовый адрес в тексте var matches = Regex.Matches(inputText, pattern, RegexOptions.IgnoreCase); From c1c87bd76da44df9be6f0c35660b98d02b8a84eb Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 15:25:44 +0300 Subject: [PATCH 11/14] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D1=8F=D0=B5=D1=82=20MessageBox=20=D0=B8=20=D1=82=D0=B0?= =?UTF-8?q?=D0=B1=D0=BB=D0=B8=D1=86=D1=83=20=D0=B2=20=D0=B6=D1=83=D1=80?= =?UTF-8?q?=D0=BD=D0=B0=D0=BB=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EditUserForm.cs | 2 +- JournalForm.cs | 15 ++++++++++++--- MainForm.Designer.cs | 13 ++++--------- RegistrationForm.cs | 4 ++-- SettingsForm.cs | 10 +++++----- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/EditUserForm.cs b/EditUserForm.cs index 91b4fbc..49a170b 100644 --- a/EditUserForm.cs +++ b/EditUserForm.cs @@ -37,7 +37,7 @@ namespace AwesomeEmailExtractor { if (loginTextBox.Text.Length == 0) { - MessageBox.Show("Логин не может быть пустым!"); + MessageBox.Show("Логин не может быть пустым!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } diff --git a/JournalForm.cs b/JournalForm.cs index b45e7bd..fbec8ef 100644 --- a/JournalForm.cs +++ b/JournalForm.cs @@ -22,9 +22,18 @@ namespace AwesomeEmailExtractor var logs = Logs.GetLogsList(Globals.currentUser); dataGridView1.DataSource = logs; - // dataGridView1.Columns["id"].Visible = false; - // dataGridView1.Columns[1].Visible = false; - dataGridView1.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + + List columns = new List() { "Дата", "Событие", "Сообщение" }; + + dataGridView1.Columns["id"].Visible = false; + dataGridView1.Columns["user"].Visible = false; + + for (int i = 0; i < columns.Count; i++) + { + dataGridView1.Columns[i + 2].HeaderText = columns[i]; + }; + + dataGridView1.Columns["message"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } private void dataGridView1_SelectionChanged(object sender, EventArgs e) diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 78b89f7..1d8aaed 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -54,9 +54,6 @@ this.uniqueListBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.uniqueListBox.FormattingEnabled = true; this.uniqueListBox.ItemHeight = 20; - this.uniqueListBox.Items.AddRange(new object[] { - "alice@example.com", - "bob@example.com"}); this.uniqueListBox.Location = new System.Drawing.Point(424, 32); this.uniqueListBox.Name = "uniqueListBox"; this.uniqueListBox.Size = new System.Drawing.Size(225, 324); @@ -72,8 +69,7 @@ this.sourceRichTextBox.Name = "sourceRichTextBox"; this.sourceRichTextBox.Size = new System.Drawing.Size(406, 288); this.sourceRichTextBox.TabIndex = 1; - this.sourceRichTextBox.Text = "Алиса (alice@example.com) послылает Бобу (bob@example.com) сообщение.\nАдрес bob@e" + - "xample.com Алиса нашла на сайте example.com"; + this.sourceRichTextBox.Text = ""; // // executeButton // @@ -95,9 +91,9 @@ this.resultCountLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.resultCountLabel.Location = new System.Drawing.Point(12, 323); this.resultCountLabel.Name = "resultCountLabel"; - this.resultCountLabel.Size = new System.Drawing.Size(303, 24); + this.resultCountLabel.Size = new System.Drawing.Size(361, 24); this.resultCountLabel.TabIndex = 3; - this.resultCountLabel.Text = "Количество e-mail-ов в тексте: 3"; + this.resultCountLabel.Text = "Ввелите текст и нажмите \"Выполнить\""; // // resultStatusStrip // @@ -111,8 +107,7 @@ // toolStripStatusLabel // this.toolStripStatusLabel.Name = "toolStripStatusLabel"; - this.toolStripStatusLabel.Size = new System.Drawing.Size(42, 17); - this.toolStripStatusLabel.Text = "Успех!"; + this.toolStripStatusLabel.Size = new System.Drawing.Size(0, 17); // // menuStrip1 // diff --git a/RegistrationForm.cs b/RegistrationForm.cs index f576b67..5844b5e 100644 --- a/RegistrationForm.cs +++ b/RegistrationForm.cs @@ -21,13 +21,13 @@ namespace AwesomeEmailExtractor { if (string.IsNullOrEmpty(entryLogin.Text) || string.IsNullOrEmpty(entryPassword.Text)) { - MessageBox.Show("Введите логин и пароль!"); + MessageBox.Show("Введите логин и пароль!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!string.Equals(entryPassword.Text, entryRePassword.Text)) { - MessageBox.Show("Пароли не совпадают!"); + MessageBox.Show("Пароли не совпадают!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } diff --git a/SettingsForm.cs b/SettingsForm.cs index 1cde078..d131561 100644 --- a/SettingsForm.cs +++ b/SettingsForm.cs @@ -19,13 +19,13 @@ namespace AwesomeEmailExtractor private void deleteAccountButton_Click(object sender, EventArgs e) { - DialogResult result = MessageBox.Show("Вы уверены что хотите удалить аккаунт?", "Удаление аккаунта", MessageBoxButtons.YesNo); + DialogResult result = MessageBox.Show("Вы уверены что хотите удалить аккаунт?", "Удаление аккаунта", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { Globals.currentUser.Delete(); Logs.Log(Globals.currentUser, Logs.Action.DeleteAccount, new Dictionary()); - MessageBox.Show("Аккаунт удален!"); + MessageBox.Show("Аккаунт удален!", "Аккаунт удален", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); @@ -38,19 +38,19 @@ namespace AwesomeEmailExtractor { if (string.IsNullOrEmpty(entryNewPassword.Text)) { - MessageBox.Show("Введите пароль!"); + MessageBox.Show("Введите пароль!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!string.Equals(entryNewPassword.Text, entryRePassword.Text)) { - MessageBox.Show("Пароли не совпадают!"); + MessageBox.Show("Пароли не совпадают!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Globals.currentUser.ChangePassword(entryNewPassword.Text); Logs.Log(Globals.currentUser, Logs.Action.ChangePassword, new Dictionary()); - MessageBox.Show("Пароль изменен!"); + MessageBox.Show("Пароль изменен!", "Пароль изменен", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } From 0b969c28b5e0b9e6341e5c8c8cc52fce6ff1b7ce Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 15:37:05 +0300 Subject: [PATCH 12/14] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D1=8F=D0=B5=D1=82=20=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BD=D0=B5=D0=B4=D0=BE=D1=80=D0=BE=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AdministrationForm.cs | 12 ++++++------ AuthorizationForm.cs | 4 ++-- EditUserForm.Designer.cs | 1 + HelpForm.Designer.cs | 1 + MainForm.Designer.cs | 4 ++-- RegistrationForm.Designer.cs | 1 + RegistrationForm.cs | 2 +- SettingsForm.Designer.cs | 1 + 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/AdministrationForm.cs b/AdministrationForm.cs index 27cb6fb..a8cae5f 100644 --- a/AdministrationForm.cs +++ b/AdministrationForm.cs @@ -128,7 +128,7 @@ namespace AwesomeEmailExtractor if (usersDataGridView.SelectedRows.Count > 0) { - DialogResult result = MessageBox.Show("Вы уверены что хотите удалить аккаунты?", "Удаление аккаунтов", MessageBoxButtons.YesNo); + DialogResult result = MessageBox.Show("Вы уверены что хотите удалить аккаунты?", "Удаление аккаунтов", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { @@ -147,12 +147,12 @@ namespace AwesomeEmailExtractor if (selfDelete) { - DialogResult result2 = MessageBox.Show("Вы уверены что хотите удалить СВОЙ аккаунт?", "Удаление аккаунта", MessageBoxButtons.YesNo); + DialogResult result2 = MessageBox.Show("Вы уверены что хотите удалить СВОЙ аккаунт?", "Удаление аккаунта", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result2 == DialogResult.Yes) { Globals.currentUser.Delete(); - MessageBox.Show("Аккаунт удален!"); + MessageBox.Show("Аккаунт удален!", "Аккаунт удален", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); @@ -171,7 +171,7 @@ namespace AwesomeEmailExtractor } else { - MessageBox.Show("Выберите хотя бы одного пользователя для удаления!"); + MessageBox.Show("Выберите хотя бы одного пользователя для удаления!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -179,7 +179,7 @@ namespace AwesomeEmailExtractor { if (journalDataGridView.SelectedRows.Count > 0) { - DialogResult result = MessageBox.Show("Вы уверены что хотите удалить записи в журнале?", "Удаление записей в журнале", MessageBoxButtons.YesNo); + DialogResult result = MessageBox.Show("Вы уверены что хотите удалить записи в журнале?", "Удаление записей в журнале", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { @@ -194,7 +194,7 @@ namespace AwesomeEmailExtractor } else { - MessageBox.Show("Выберите хотя бы одну запись для удаления!"); + MessageBox.Show("Выберите хотя бы одну запись для удаления!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } diff --git a/AuthorizationForm.cs b/AuthorizationForm.cs index cee06d7..c90e44d 100644 --- a/AuthorizationForm.cs +++ b/AuthorizationForm.cs @@ -23,7 +23,7 @@ namespace AwesomeEmailExtractor { if (string.IsNullOrEmpty(entryLogin.Text) || string.IsNullOrEmpty(entryPassword.Text)) { - MessageBox.Show("Введите логин и пароль"); + MessageBox.Show("Введите логин и пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } @@ -35,7 +35,7 @@ namespace AwesomeEmailExtractor } catch (Exception ex) { - MessageBox.Show(ex.Message); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/EditUserForm.Designer.cs b/EditUserForm.Designer.cs index 9901122..8ab7af2 100644 --- a/EditUserForm.Designer.cs +++ b/EditUserForm.Designer.cs @@ -131,6 +131,7 @@ this.Controls.Add(this.passwordTextBox); this.Controls.Add(this.loginTextBox); this.Controls.Add(this.idTextBox); + this.MaximizeBox = false; this.Name = "EditUserForm"; this.Text = "Редактирование"; this.Load += new System.EventHandler(this.EditUserForm_Load); diff --git a/HelpForm.Designer.cs b/HelpForm.Designer.cs index 8a6551f..3a5fd06 100644 --- a/HelpForm.Designer.cs +++ b/HelpForm.Designer.cs @@ -60,6 +60,7 @@ this.ClientSize = new System.Drawing.Size(652, 393); this.Controls.Add(this.panel1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; this.Name = "HelpForm"; this.Text = "Справка"; this.panel1.ResumeLayout(false); diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 1d8aaed..97b90ae 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -91,9 +91,9 @@ this.resultCountLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.resultCountLabel.Location = new System.Drawing.Point(12, 323); this.resultCountLabel.Name = "resultCountLabel"; - this.resultCountLabel.Size = new System.Drawing.Size(361, 24); + this.resultCountLabel.Size = new System.Drawing.Size(363, 24); this.resultCountLabel.TabIndex = 3; - this.resultCountLabel.Text = "Ввелите текст и нажмите \"Выполнить\""; + this.resultCountLabel.Text = "Введите текст и нажмите \"Выполнить\""; // // resultStatusStrip // diff --git a/RegistrationForm.Designer.cs b/RegistrationForm.Designer.cs index 7fe7ef6..67bec00 100644 --- a/RegistrationForm.Designer.cs +++ b/RegistrationForm.Designer.cs @@ -139,6 +139,7 @@ this.Controls.Add(this.registerButton); this.Controls.Add(this.loginButton); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; this.Name = "RegistrationForm"; this.Text = "Зарегистрироваться"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.RegistrationForm_FormClosed); diff --git a/RegistrationForm.cs b/RegistrationForm.cs index 5844b5e..2811cd5 100644 --- a/RegistrationForm.cs +++ b/RegistrationForm.cs @@ -41,7 +41,7 @@ namespace AwesomeEmailExtractor } catch (Exception ex) { - MessageBox.Show(ex.Message); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } diff --git a/SettingsForm.Designer.cs b/SettingsForm.Designer.cs index e4c61bf..eaa86a8 100644 --- a/SettingsForm.Designer.cs +++ b/SettingsForm.Designer.cs @@ -104,6 +104,7 @@ this.Controls.Add(this.entryNewPassword); this.Controls.Add(this.changePasswordButton); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; this.Name = "SettingsForm"; this.Text = "Настройки"; this.ResumeLayout(false); From fbb645930c2183a4d1bd5ca5f7bd8c38d05f28cd Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 16:09:19 +0300 Subject: [PATCH 13/14] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D1=8F?= =?UTF-8?q?=D0=B5=D1=82=20=D0=B7=D0=B0=D0=B3=D0=BE=D0=BB=D0=BE=D0=B2=D0=BE?= =?UTF-8?q?=D0=BA=20=D0=B3=D0=BB=D0=B0=D0=B2=D0=BD=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=BE=D0=BA=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MainForm.Designer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 97b90ae..027b542 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -196,7 +196,7 @@ this.MainMenuStrip = this.menuStrip1; this.MinimumSize = new System.Drawing.Size(642, 438); this.Name = "MainForm"; - this.Text = "Main Form"; + this.Text = "Главное окно"; this.resultStatusStrip.ResumeLayout(false); this.resultStatusStrip.PerformLayout(); this.menuStrip1.ResumeLayout(false); From caaf57b46e64be3619b7de90c8af1f056dae80b9 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 24 May 2022 16:13:22 +0300 Subject: [PATCH 14/14] =?UTF-8?q?=D1=83=D0=B1=D0=B8=D1=80=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D1=83?= =?UTF-8?q?=D0=B5=D0=BC=D0=BE=D1=81=D1=82=D1=8C=20=D0=BF=D0=BE=D0=BB=D1=8F?= =?UTF-8?q?=20=D1=81=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #36 --- AdministrationForm.Designer.cs | 227 +++++++++++++++++---------------- JournalForm.Designer.cs | 115 ++++++++--------- 2 files changed, 172 insertions(+), 170 deletions(-) diff --git a/AdministrationForm.Designer.cs b/AdministrationForm.Designer.cs index 9e33c60..57697b1 100644 --- a/AdministrationForm.Designer.cs +++ b/AdministrationForm.Designer.cs @@ -35,35 +35,35 @@ this.pathToJournalTextBox = new System.Windows.Forms.TextBox(); this.usersTabPage = new System.Windows.Forms.TabPage(); this.usersDataGridView = new System.Windows.Forms.DataGridView(); - this.journalTabPage = new System.Windows.Forms.TabPage(); - this.panel1 = new System.Windows.Forms.Panel(); - this.journalDataGridView = new System.Windows.Forms.DataGridView(); - this.editUserButton = new System.Windows.Forms.Button(); this.panel2 = new System.Windows.Forms.Panel(); this.deleteUserButton = new System.Windows.Forms.Button(); - this.sqliteCommand1 = new Microsoft.Data.Sqlite.SqliteCommand(); + this.editUserButton = new System.Windows.Forms.Button(); + this.journalTabPage = new System.Windows.Forms.TabPage(); this.panel3 = new System.Windows.Forms.Panel(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.messageRichTextBox = new System.Windows.Forms.RichTextBox(); + this.journalDataGridView = new System.Windows.Forms.DataGridView(); this.panel4 = new System.Windows.Forms.Panel(); this.deleteJournalButton = new System.Windows.Forms.Button(); - this.dateLabel = new System.Windows.Forms.Label(); - this.userLabel = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label2 = new System.Windows.Forms.Label(); + this.messageRichTextBox = new System.Windows.Forms.RichTextBox(); + this.userLabel = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.dateLabel = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); this.actionLabel = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); + this.sqliteCommand1 = new Microsoft.Data.Sqlite.SqliteCommand(); this.mainTabControl.SuspendLayout(); this.mainSettingsTabPage.SuspendLayout(); this.usersTabPage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.usersDataGridView)).BeginInit(); - this.journalTabPage.SuspendLayout(); - this.panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.journalDataGridView)).BeginInit(); this.panel2.SuspendLayout(); + this.journalTabPage.SuspendLayout(); this.panel3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.journalDataGridView)).BeginInit(); this.panel4.SuspendLayout(); + this.panel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // @@ -141,49 +141,6 @@ this.usersDataGridView.Size = new System.Drawing.Size(984, 497); this.usersDataGridView.TabIndex = 0; // - // journalTabPage - // - this.journalTabPage.Controls.Add(this.panel3); - this.journalTabPage.Controls.Add(this.panel1); - this.journalTabPage.Location = new System.Drawing.Point(4, 22); - this.journalTabPage.Name = "journalTabPage"; - this.journalTabPage.Size = new System.Drawing.Size(990, 531); - this.journalTabPage.TabIndex = 2; - this.journalTabPage.Text = "Журнал"; - this.journalTabPage.UseVisualStyleBackColor = true; - this.journalTabPage.Click += new System.EventHandler(this.journalTabPage_Click); - // - // panel1 - // - this.panel1.Controls.Add(this.tableLayoutPanel1); - this.panel1.Dock = System.Windows.Forms.DockStyle.Right; - this.panel1.Location = new System.Drawing.Point(536, 0); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(454, 531); - this.panel1.TabIndex = 1; - // - // journalDataGridView - // - this.journalDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.journalDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; - this.journalDataGridView.Location = new System.Drawing.Point(0, 37); - this.journalDataGridView.Name = "journalDataGridView"; - this.journalDataGridView.ReadOnly = true; - this.journalDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.journalDataGridView.Size = new System.Drawing.Size(536, 494); - this.journalDataGridView.TabIndex = 0; - this.journalDataGridView.SelectionChanged += new System.EventHandler(this.journalDataGridView_SelectionChanged); - // - // editUserButton - // - this.editUserButton.Location = new System.Drawing.Point(3, 3); - this.editUserButton.Name = "editUserButton"; - this.editUserButton.Size = new System.Drawing.Size(131, 20); - this.editUserButton.TabIndex = 1; - this.editUserButton.Text = "Редактировать"; - this.editUserButton.UseVisualStyleBackColor = true; - this.editUserButton.Click += new System.EventHandler(this.editUserButton_Click); - // // panel2 // this.panel2.Controls.Add(this.deleteUserButton); @@ -204,12 +161,27 @@ this.deleteUserButton.UseVisualStyleBackColor = true; this.deleteUserButton.Click += new System.EventHandler(this.deleteUserButton_Click); // - // sqliteCommand1 + // editUserButton // - this.sqliteCommand1.CommandTimeout = 30; - this.sqliteCommand1.Connection = null; - this.sqliteCommand1.Transaction = null; - this.sqliteCommand1.UpdatedRowSource = System.Data.UpdateRowSource.None; + this.editUserButton.Location = new System.Drawing.Point(3, 3); + this.editUserButton.Name = "editUserButton"; + this.editUserButton.Size = new System.Drawing.Size(131, 20); + this.editUserButton.TabIndex = 1; + this.editUserButton.Text = "Редактировать"; + this.editUserButton.UseVisualStyleBackColor = true; + this.editUserButton.Click += new System.EventHandler(this.editUserButton_Click); + // + // journalTabPage + // + this.journalTabPage.Controls.Add(this.panel3); + this.journalTabPage.Controls.Add(this.panel1); + this.journalTabPage.Location = new System.Drawing.Point(4, 22); + this.journalTabPage.Name = "journalTabPage"; + this.journalTabPage.Size = new System.Drawing.Size(990, 531); + this.journalTabPage.TabIndex = 2; + this.journalTabPage.Text = "Журнал"; + this.journalTabPage.UseVisualStyleBackColor = true; + this.journalTabPage.Click += new System.EventHandler(this.journalTabPage_Click); // // panel3 // @@ -221,41 +193,17 @@ this.panel3.Size = new System.Drawing.Size(536, 531); this.panel3.TabIndex = 2; // - // label2 + // journalDataGridView // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(3, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(36, 13); - this.label2.TabIndex = 0; - this.label2.Text = "Дата:"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 30); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(83, 13); - this.label3.TabIndex = 1; - this.label3.Text = "Пользователь:"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(3, 60); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(54, 13); - this.label4.TabIndex = 2; - this.label4.Text = "Событие:"; - // - // messageRichTextBox - // - this.messageRichTextBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.messageRichTextBox.Location = new System.Drawing.Point(103, 93); - this.messageRichTextBox.Name = "messageRichTextBox"; - this.messageRichTextBox.Size = new System.Drawing.Size(348, 435); - this.messageRichTextBox.TabIndex = 3; - this.messageRichTextBox.Text = ""; + this.journalDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.journalDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; + this.journalDataGridView.Location = new System.Drawing.Point(0, 37); + this.journalDataGridView.Name = "journalDataGridView"; + this.journalDataGridView.ReadOnly = true; + this.journalDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.journalDataGridView.Size = new System.Drawing.Size(536, 494); + this.journalDataGridView.TabIndex = 0; + this.journalDataGridView.SelectionChanged += new System.EventHandler(this.journalDataGridView_SelectionChanged); // // panel4 // @@ -276,21 +224,14 @@ this.deleteJournalButton.UseVisualStyleBackColor = true; this.deleteJournalButton.Click += new System.EventHandler(this.deleteJournalButton_Click); // - // dateLabel + // panel1 // - this.dateLabel.AutoSize = true; - this.dateLabel.Location = new System.Drawing.Point(103, 0); - this.dateLabel.Name = "dateLabel"; - this.dateLabel.Size = new System.Drawing.Size(0, 13); - this.dateLabel.TabIndex = 4; - // - // userLabel - // - this.userLabel.AutoSize = true; - this.userLabel.Location = new System.Drawing.Point(103, 30); - this.userLabel.Name = "userLabel"; - this.userLabel.Size = new System.Drawing.Size(0, 13); - this.userLabel.TabIndex = 5; + this.panel1.Controls.Add(this.tableLayoutPanel1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Right; + this.panel1.Location = new System.Drawing.Point(536, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(454, 531); + this.panel1.TabIndex = 1; // // tableLayoutPanel1 // @@ -316,6 +257,59 @@ this.tableLayoutPanel1.Size = new System.Drawing.Size(454, 531); this.tableLayoutPanel1.TabIndex = 6; // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(3, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(36, 13); + this.label2.TabIndex = 0; + this.label2.Text = "Дата:"; + // + // messageRichTextBox + // + this.messageRichTextBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.messageRichTextBox.Location = new System.Drawing.Point(103, 93); + this.messageRichTextBox.Name = "messageRichTextBox"; + this.messageRichTextBox.ReadOnly = true; + this.messageRichTextBox.Size = new System.Drawing.Size(348, 435); + this.messageRichTextBox.TabIndex = 3; + this.messageRichTextBox.Text = ""; + // + // userLabel + // + this.userLabel.AutoSize = true; + this.userLabel.Location = new System.Drawing.Point(103, 30); + this.userLabel.Name = "userLabel"; + this.userLabel.Size = new System.Drawing.Size(0, 13); + this.userLabel.TabIndex = 5; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(3, 60); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(54, 13); + this.label4.TabIndex = 2; + this.label4.Text = "Событие:"; + // + // dateLabel + // + this.dateLabel.AutoSize = true; + this.dateLabel.Location = new System.Drawing.Point(103, 0); + this.dateLabel.Name = "dateLabel"; + this.dateLabel.Size = new System.Drawing.Size(0, 13); + this.dateLabel.TabIndex = 4; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(3, 30); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(83, 13); + this.label3.TabIndex = 1; + this.label3.Text = "Пользователь:"; + // // actionLabel // this.actionLabel.AutoSize = true; @@ -333,6 +327,13 @@ this.label5.TabIndex = 7; this.label5.Text = "Сообщение:"; // + // sqliteCommand1 + // + this.sqliteCommand1.CommandTimeout = 30; + this.sqliteCommand1.Connection = null; + this.sqliteCommand1.Transaction = null; + this.sqliteCommand1.UpdatedRowSource = System.Data.UpdateRowSource.None; + // // AdministrationForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -347,12 +348,12 @@ this.mainSettingsTabPage.PerformLayout(); this.usersTabPage.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.usersDataGridView)).EndInit(); - this.journalTabPage.ResumeLayout(false); - this.panel1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.journalDataGridView)).EndInit(); this.panel2.ResumeLayout(false); + this.journalTabPage.ResumeLayout(false); this.panel3.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.journalDataGridView)).EndInit(); this.panel4.ResumeLayout(false); + this.panel1.ResumeLayout(false); this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); this.ResumeLayout(false); diff --git a/JournalForm.Designer.cs b/JournalForm.Designer.cs index 443a006..918a063 100644 --- a/JournalForm.Designer.cs +++ b/JournalForm.Designer.cs @@ -30,13 +30,13 @@ { this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.panel1 = new System.Windows.Forms.Panel(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.dataLabel = new System.Windows.Forms.Label(); this.actionLabel = new System.Windows.Forms.Label(); - this.richTextBox1 = new System.Windows.Forms.RichTextBox(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label2 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.panel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); @@ -64,60 +64,6 @@ this.panel1.Size = new System.Drawing.Size(458, 451); this.panel1.TabIndex = 1; // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(13, 10); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(36, 13); - this.label1.TabIndex = 2; - this.label1.Text = "Дата:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(13, 30); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(54, 13); - this.label2.TabIndex = 3; - this.label2.Text = "Событие:"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(13, 50); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(68, 13); - this.label3.TabIndex = 4; - this.label3.Text = "Сообщение:"; - // - // dataLabel - // - this.dataLabel.AutoSize = true; - this.dataLabel.Location = new System.Drawing.Point(141, 10); - this.dataLabel.Name = "dataLabel"; - this.dataLabel.Size = new System.Drawing.Size(54, 13); - this.dataLabel.TabIndex = 5; - this.dataLabel.Text = "dataLabel"; - // - // actionLabel - // - this.actionLabel.AutoSize = true; - this.actionLabel.Location = new System.Drawing.Point(141, 30); - this.actionLabel.Name = "actionLabel"; - this.actionLabel.Size = new System.Drawing.Size(62, 13); - this.actionLabel.TabIndex = 6; - this.actionLabel.Text = "actionLabel"; - // - // richTextBox1 - // - this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.richTextBox1.Location = new System.Drawing.Point(141, 53); - this.richTextBox1.Name = "richTextBox1"; - this.richTextBox1.Size = new System.Drawing.Size(304, 385); - this.richTextBox1.TabIndex = 7; - this.richTextBox1.Text = ""; - // // tableLayoutPanel1 // this.tableLayoutPanel1.ColumnCount = 2; @@ -140,6 +86,61 @@ this.tableLayoutPanel1.Size = new System.Drawing.Size(458, 451); this.tableLayoutPanel1.TabIndex = 8; // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(13, 10); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(36, 13); + this.label1.TabIndex = 2; + this.label1.Text = "Дата:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(13, 50); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(68, 13); + this.label3.TabIndex = 4; + this.label3.Text = "Сообщение:"; + // + // richTextBox1 + // + this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.richTextBox1.Location = new System.Drawing.Point(141, 53); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.ReadOnly = true; + this.richTextBox1.Size = new System.Drawing.Size(304, 385); + this.richTextBox1.TabIndex = 7; + this.richTextBox1.Text = ""; + // + // dataLabel + // + this.dataLabel.AutoSize = true; + this.dataLabel.Location = new System.Drawing.Point(141, 10); + this.dataLabel.Name = "dataLabel"; + this.dataLabel.Size = new System.Drawing.Size(54, 13); + this.dataLabel.TabIndex = 5; + this.dataLabel.Text = "dataLabel"; + // + // actionLabel + // + this.actionLabel.AutoSize = true; + this.actionLabel.Location = new System.Drawing.Point(141, 30); + this.actionLabel.Name = "actionLabel"; + this.actionLabel.Size = new System.Drawing.Size(62, 13); + this.actionLabel.TabIndex = 6; + this.actionLabel.Text = "actionLabel"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(13, 30); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(54, 13); + this.label2.TabIndex = 3; + this.label2.Text = "Событие:"; + // // JournalForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);