добавляет форму администрирования

This commit is contained in:
Maxim Slipenko 2022-05-23 21:47:09 +03:00
parent c5abaad465
commit d386e8338a
Signed by: Maks1mS
GPG Key ID: 7461AF39A8705FB8
6 changed files with 336 additions and 8 deletions

139
AdministrationForm.Designer.cs generated Normal file
View File

@ -0,0 +1,139 @@
namespace AwesomeEmailExtractor
{
partial class AdministrationForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

53
AdministrationForm.cs Normal file
View File

@ -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();
}
}
}
}

120
AdministrationForm.resx Normal file
View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -76,6 +76,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AdministrationForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="AdministrationForm.Designer.cs">
<DependentUpon>AdministrationForm.cs</DependentUpon>
</Compile>
<Compile Include="Authorization.cs" />
<Compile Include="AuthorizationForm.cs">
<SubType>Form</SubType>
@ -113,6 +119,9 @@
<Compile Include="SettingsForm.Designer.cs">
<DependentUpon>SettingsForm.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="AdministrationForm.resx">
<DependentUpon>AdministrationForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="AuthorizationForm.resx">
<DependentUpon>AuthorizationForm.cs</DependentUpon>
</EmbeddedResource>

17
MainForm.Designer.cs generated
View File

@ -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);

View File

@ -74,5 +74,11 @@ namespace AwesomeEmailExtractor
JournalForm journalForm = FormManager.Current.CreateForm<JournalForm>();
journalForm.ShowDialog(this);
}
private void administrationToolStripMenuItem_Click(object sender, EventArgs e)
{
AdministrationForm administrationForm = FormManager.Current.CreateForm<AdministrationForm>();
administrationForm.ShowDialog(this);
}
}
}