From 74549aa18d569a4d64661351c4dbe34cc8888479 Mon Sep 17 00:00:00 2001 From: kotcheshir73 Date: Sun, 28 Mar 2021 00:23:01 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=B2=D0=BE=D0=B4=20=D1=81=D0=BE?= =?UTF-8?q?=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogics/ErrorMessanger.cs | 30 ++++++ .../Forms/FormDisplayErrors.Designer.cs | 92 +++++++++++++++++++ .../DesktopTools/Forms/FormDisplayErrors.cs | 23 +++++ .../DesktopTools/Forms/FormDisplayErrors.resx | 66 +++++++++++++ .../DepartmentPortalDesctop/FormEnter.cs | 6 +- 5 files changed, 215 insertions(+), 2 deletions(-) create mode 100644 DepartmentPortal/Common/DesktopTools/BusinessLogics/ErrorMessanger.cs create mode 100644 DepartmentPortal/Common/DesktopTools/Forms/FormDisplayErrors.Designer.cs create mode 100644 DepartmentPortal/Common/DesktopTools/Forms/FormDisplayErrors.cs create mode 100644 DepartmentPortal/Common/DesktopTools/Forms/FormDisplayErrors.resx diff --git a/DepartmentPortal/Common/DesktopTools/BusinessLogics/ErrorMessanger.cs b/DepartmentPortal/Common/DesktopTools/BusinessLogics/ErrorMessanger.cs new file mode 100644 index 0000000..ad0da1e --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BusinessLogics/ErrorMessanger.cs @@ -0,0 +1,30 @@ +using DesktopTools.Forms; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace DesktopTools.BusinessLogics +{ + /// + /// Класс, отвечающий за вывод сообщения с ошибками + /// + public static class ErrorMessanger + { + /// + /// Вывод сообщения + /// + /// + /// + public static void PrintErrorMessage(string text, List> result) + { + if (result.Count == 1) + { + MessageBox.Show(result[0].Value, result[0].Key, MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else + { + FormDisplayErrors form = new FormDisplayErrors(); + form.LoadData(text, result); + } + } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/Forms/FormDisplayErrors.Designer.cs b/DepartmentPortal/Common/DesktopTools/Forms/FormDisplayErrors.Designer.cs new file mode 100644 index 0000000..9a8e37d --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/Forms/FormDisplayErrors.Designer.cs @@ -0,0 +1,92 @@ + +namespace DesktopTools.Forms +{ + partial class FormDisplayErrors + { + /// + /// 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.dataGridViewErrors = new System.Windows.Forms.DataGridView(); + this.ColumnKey = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnMessage = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewErrors)).BeginInit(); + this.SuspendLayout(); + // + // dataGridViewErrors + // + this.dataGridViewErrors.AllowUserToAddRows = false; + this.dataGridViewErrors.AllowUserToDeleteRows = false; + this.dataGridViewErrors.AllowUserToResizeRows = false; + this.dataGridViewErrors.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; + this.dataGridViewErrors.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridViewErrors.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ColumnKey, + this.ColumnMessage}); + this.dataGridViewErrors.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewErrors.Location = new System.Drawing.Point(0, 0); + this.dataGridViewErrors.MultiSelect = false; + this.dataGridViewErrors.Name = "dataGridViewErrors"; + this.dataGridViewErrors.ReadOnly = true; + this.dataGridViewErrors.RowHeadersVisible = false; + this.dataGridViewErrors.RowTemplate.Height = 25; + this.dataGridViewErrors.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridViewErrors.Size = new System.Drawing.Size(588, 450); + this.dataGridViewErrors.TabIndex = 0; + // + // ColumnKey + // + this.ColumnKey.HeaderText = "Тип ошибки"; + this.ColumnKey.Name = "ColumnKey"; + this.ColumnKey.ReadOnly = true; + this.ColumnKey.Width = 200; + // + // ColumnMessage + // + this.ColumnMessage.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ColumnMessage.HeaderText = "Сообщение"; + this.ColumnMessage.Name = "ColumnMessage"; + this.ColumnMessage.ReadOnly = true; + // + // FormDisplayErrors + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(588, 450); + this.Controls.Add(this.dataGridViewErrors); + this.Name = "FormDisplayErrors"; + this.Text = "Ошибки"; + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewErrors)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.DataGridView dataGridViewErrors; + private System.Windows.Forms.DataGridViewTextBoxColumn ColumnKey; + private System.Windows.Forms.DataGridViewTextBoxColumn ColumnMessage; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/Forms/FormDisplayErrors.cs b/DepartmentPortal/Common/DesktopTools/Forms/FormDisplayErrors.cs new file mode 100644 index 0000000..5a5f198 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/Forms/FormDisplayErrors.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.Windows.Forms; + +namespace DesktopTools.Forms +{ + public partial class FormDisplayErrors : Form + { + public FormDisplayErrors() + { + InitializeComponent(); + } + + public void LoadData(string text, List> result) + { + Text = text; + foreach (var err in result) + { + dataGridViewErrors.Rows.Add(new object[] { err.Key, err.Value }); + } + ShowDialog(); + } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/Forms/FormDisplayErrors.resx b/DepartmentPortal/Common/DesktopTools/Forms/FormDisplayErrors.resx new file mode 100644 index 0000000..a04e8fe --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/Forms/FormDisplayErrors.resx @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + \ No newline at end of file diff --git a/DepartmentPortal/DepartmentPortalDesctop/FormEnter.cs b/DepartmentPortal/DepartmentPortalDesctop/FormEnter.cs index acfb1b8..e943f88 100644 --- a/DepartmentPortal/DepartmentPortalDesctop/FormEnter.cs +++ b/DepartmentPortal/DepartmentPortalDesctop/FormEnter.cs @@ -1,5 +1,7 @@ -using SecurityBusinessLogic.BusinessLogics; +using DesktopTools.BusinessLogics; +using SecurityBusinessLogic.BusinessLogics; using System; +using System.Collections.Generic; using System.Threading.Tasks; using System.Windows.Forms; @@ -25,7 +27,7 @@ namespace DepartmentPortalDesctop } catch (Exception ex) { - //ErrorMessanger.PrintErrorMessage("При аутентфикации возникла ошибка: ", new List> { new KeyValuePair("Аутентфикация", ex.Message) }); + ErrorMessanger.PrintErrorMessage("При аутентфикации возникла ошибка: ", new List> { new KeyValuePair("Аутентфикация", ex.Message) }); } } }