From d386e8338a8a81854c31406da6b888d3c908e240 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Mon, 23 May 2022 21:47:09 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D1=82=20=D1=84=D0=BE=D1=80=D0=BC=D1=83=20=D0=B0=D0=B4?= =?UTF-8?q?=D0=BC=D0=B8=D0=BD=D0=B8=D1=81=D1=82=D1=80=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=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); + } } }