From 7d11805cc87d711f536537334e24e2362b3d8dea Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Wed, 3 Dec 2025 23:49:43 +0300 Subject: [PATCH 01/14] =?UTF-8?q?=D0=BD=D0=B0=D0=B8=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HelpDesk/HelpDesk.Common/IProvider.cs | 10 +- HelpDesk/HelpDesk.Common/JsonStorage.cs | 80 ++++---- .../{TrubleTicket.cs => TroubleTicket.cs} | 6 +- .../AddTroubleTicketForm.Designer.cs | 131 ++++++++++++ ...eTicketForm.cs => AddTroubleTicketForm.cs} | 22 +- ...ketForm.resx => AddTroubleTicketForm.resx} | 0 .../AddTrubleTicketForm.Designer.cs | 131 ------------ ...igner.cs => AuthorizationForm.Designer.cs} | 134 ++++++------- ...horizationFrom.cs => AuthorizationForm.cs} | 14 +- ...zationFrom.resx => AuthorizationForm.resx} | 0 .../EditUserForm.Designer.cs | 176 ++++++++-------- .../ExportForm.Designer.cs | 66 +++--- HelpDesk/HelpDeskWinFormsApp/ExportForm.cs | 10 +- .../HelpDeskWinFormsApp/MainForm.Designer.cs | 48 ++--- HelpDesk/HelpDeskWinFormsApp/MainForm.cs | 189 +++++++++--------- .../RegistrationForm.Designer.cs | 110 +++++----- .../TroubleTicketForm.Designer.cs | 185 +++++++++++++++++ ...ubleTicketForm.cs => TroubleTicketForm.cs} | 44 ++-- ...TicketForm.resx => TroubleTicketForm.resx} | 0 .../TrubleTicketForm.Designer.cs | 185 ----------------- 20 files changed, 770 insertions(+), 771 deletions(-) rename HelpDesk/HelpDesk.Common/Models/{TrubleTicket.cs => TroubleTicket.cs} (77%) create mode 100644 HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.Designer.cs rename HelpDesk/HelpDeskWinFormsApp/{AddTrubleTicketForm.cs => AddTroubleTicketForm.cs} (55%) rename HelpDesk/HelpDeskWinFormsApp/{AddTrubleTicketForm.resx => AddTroubleTicketForm.resx} (100%) delete mode 100644 HelpDesk/HelpDeskWinFormsApp/AddTrubleTicketForm.Designer.cs rename HelpDesk/HelpDeskWinFormsApp/{AuthorizationFrom.Designer.cs => AuthorizationForm.Designer.cs} (54%) rename HelpDesk/HelpDeskWinFormsApp/{AuthorizationFrom.cs => AuthorizationForm.cs} (82%) rename HelpDesk/HelpDeskWinFormsApp/{AuthorizationFrom.resx => AuthorizationForm.resx} (100%) create mode 100644 HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.Designer.cs rename HelpDesk/HelpDeskWinFormsApp/{TrubleTicketForm.cs => TroubleTicketForm.cs} (51%) rename HelpDesk/HelpDeskWinFormsApp/{TrubleTicketForm.resx => TroubleTicketForm.resx} (100%) delete mode 100644 HelpDesk/HelpDeskWinFormsApp/TrubleTicketForm.Designer.cs diff --git a/HelpDesk/HelpDesk.Common/IProvider.cs b/HelpDesk/HelpDesk.Common/IProvider.cs index 3a35786..4f6f71a 100644 --- a/HelpDesk/HelpDesk.Common/IProvider.cs +++ b/HelpDesk/HelpDesk.Common/IProvider.cs @@ -10,11 +10,11 @@ public interface IProvider User GetUser(int id); void AddUser(User user); List GetAllUsers(); - void AddTrubleTicket(TrubleTicket trubleTicket); - List GetAllTrubleTickets(); - TrubleTicket GetTrubleTicket(int id); - void ResolveTrubleTicket(int id, string status, string resolve, int resolveUserId); - void ChangeStatusTrubleTicket(int id, string staatus, int resolveUserId); + void AddTroubleTicket(TroubleTicket trubleTicket); + List GetAllTroubleTickets(); + TroubleTicket GetTroubleTicket(int id); + void ResolveTroubleTicket(int id, string status, string resolve, int resolveUserId); + void ChangeStatusTroubleTicket(int id, string staatus, int resolveUserId); void ChangeUserToEmployee(User user, string function, string department); void ChangeEmployeeToUser(User user); void UpdateUser(User user); diff --git a/HelpDesk/HelpDesk.Common/JsonStorage.cs b/HelpDesk/HelpDesk.Common/JsonStorage.cs index 3b786a7..b649600 100644 --- a/HelpDesk/HelpDesk.Common/JsonStorage.cs +++ b/HelpDesk/HelpDesk.Common/JsonStorage.cs @@ -8,7 +8,7 @@ namespace HelpDesk.Common public class JsonStorage : IProvider { private string usersFileName = "users.json"; - private string trubleTicketsFileName = "trubleTicket.json"; + private string troubleTicketsFileName = "troubleTicket.json"; public bool IsCorrectLoginPassword(string login, string password) { @@ -100,89 +100,89 @@ public List GetAllUsers() return JsonProvider.Deserialize(usersFileName); } - public void AddTrubleTicket(TrubleTicket trubleTicket) + public void AddTroubleTicket(TroubleTicket troubleTicket) { - var trubleTickets = JsonProvider.Deserialize(trubleTicketsFileName); + var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName); - if (trubleTickets == null) + if (troubleTickets == null) { - trubleTickets = new List { trubleTicket }; + troubleTickets = new List { troubleTicket }; } else { - trubleTicket.Id = trubleTickets.Max(x => x.Id) + 1; + troubleTicket.Id = troubleTickets.Max(x => x.Id) + 1; - trubleTickets.Add(trubleTicket); + troubleTickets.Add(troubleTicket); } - JsonProvider.Serialize(trubleTickets, trubleTicketsFileName); + JsonProvider.Serialize(troubleTickets, troubleTicketsFileName); } - public List GetAllTrubleTickets() + public List GetAllTroubleTickets() { - var trubleTickets = JsonProvider.Deserialize(trubleTicketsFileName); + var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName); - if (trubleTickets == null) + if (troubleTickets == null) { - return new List(); + return new List(); } else { - return JsonProvider.Deserialize(trubleTicketsFileName); + return JsonProvider.Deserialize(troubleTicketsFileName); } } - public TrubleTicket GetTrubleTicket(int id) + public TroubleTicket GetTroubleTicket(int id) { - var trubleTickets = JsonProvider.Deserialize(trubleTicketsFileName); + var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName); - if (trubleTickets == null) + if (troubleTickets == null) { - return new TrubleTicket(); + return new TroubleTicket(); } else { - var trubleTicket = trubleTickets.FirstOrDefault(t => t.Id == id); + var troubleTicket = troubleTickets.FirstOrDefault(t => t.Id == id); - return trubleTicket; + return troubleTicket; } } - public void ResolveTrubleTicket(int id, string status, string resolve, int resolveUserId) + public void ResolveTroubleTicket(int id, string status, string resolve, int resolveUserId) { - var trubleTickets = GetAllTrubleTickets(); - var trubleTicket = GetTrubleTicket(id); + var troubleTickets = GetAllTroubleTickets(); + var troubleTicket = GetTroubleTicket(id); - trubleTickets.RemoveAll(x => x.Id == id); + troubleTickets.RemoveAll(x => x.Id == id); - trubleTicket.IsSolved = true; - trubleTicket.Status = status; - trubleTicket.Resolve = resolve; - trubleTicket.ResolveTime = DateTime.Now; - trubleTicket.ResolveUser = resolveUserId; + troubleTicket.IsSolved = true; + troubleTicket.Status = status; + troubleTicket.Resolve = resolve; + troubleTicket.ResolveTime = DateTime.Now; + troubleTicket.ResolveUser = resolveUserId; - trubleTickets.Add(trubleTicket); + troubleTickets.Add(troubleTicket); - var sortedTrubleTickets = trubleTickets.OrderBy(x => x.Id).ToList(); + var sortedTroubleTickets = troubleTickets.OrderBy(x => x.Id).ToList(); - JsonProvider.Serialize(sortedTrubleTickets, trubleTicketsFileName); + JsonProvider.Serialize(sortedTroubleTickets, troubleTicketsFileName); } - public void ChangeStatusTrubleTicket(int id, string status, int resolveUserId) + public void ChangeStatusTroubleTicket(int id, string status, int resolveUserId) { - var trubleTickets = GetAllTrubleTickets(); - var trubleTicket = GetTrubleTicket(id); + var troubleTickets = GetAllTroubleTickets(); + var troubleTicket = GetTroubleTicket(id); - trubleTickets.RemoveAll(x => x.Id == id); + troubleTickets.RemoveAll(x => x.Id == id); - trubleTicket.Status = status; - trubleTicket.ResolveUser = resolveUserId; + troubleTicket.Status = status; + troubleTicket.ResolveUser = resolveUserId; - trubleTickets.Add(trubleTicket); + troubleTickets.Add(troubleTicket); - var sortedTrubleTickets = trubleTickets.OrderBy(x => x.Id).ToList(); + var sortedTroubleTickets = troubleTickets.OrderBy(x => x.Id).ToList(); - JsonProvider.Serialize(sortedTrubleTickets, trubleTicketsFileName); + JsonProvider.Serialize(sortedTroubleTickets, troubleTicketsFileName); } diff --git a/HelpDesk/HelpDesk.Common/Models/TrubleTicket.cs b/HelpDesk/HelpDesk.Common/Models/TroubleTicket.cs similarity index 77% rename from HelpDesk/HelpDesk.Common/Models/TrubleTicket.cs rename to HelpDesk/HelpDesk.Common/Models/TroubleTicket.cs index 593af05..b30c36c 100644 --- a/HelpDesk/HelpDesk.Common/Models/TrubleTicket.cs +++ b/HelpDesk/HelpDesk.Common/Models/TroubleTicket.cs @@ -3,7 +3,7 @@ namespace HelpDesk.Common.Models { - public class TrubleTicket + public class TroubleTicket { public int Id { get; set; } public string Status { get; set; } @@ -17,10 +17,10 @@ public class TrubleTicket public DateTime Deadline { get; set; } - public TrubleTicket() { } + public TroubleTicket() { } [JsonConstructor] - private TrubleTicket(int id, string status, int createUser, string text, string? resolve, bool isSolved, DateTime created, DateTime? resolveTime, int? resolveUser, DateTime deadline) + private TroubleTicket(int id, string status, int createUser, string text, string? resolve, bool isSolved, DateTime created, DateTime? resolveTime, int? resolveUser, DateTime deadline) { Id = id; Status = status; diff --git a/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.Designer.cs new file mode 100644 index 0000000..400334d --- /dev/null +++ b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.Designer.cs @@ -0,0 +1,131 @@ +namespace HelpDeskWinFormsApp +{ + partial class AddTroubleTicketForm + { + /// + /// 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.loginLabel = new System.Windows.Forms.Label(); + this.userNameTextBox = new System.Windows.Forms.TextBox(); + this.troubleRichLabel = new System.Windows.Forms.Label(); + this.troubleRichTextBox = new System.Windows.Forms.RichTextBox(); + this.createTroubleTicketButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // loginLabel + // + this.loginLabel.AutoSize = true; + this.loginLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.loginLabel.Location = new System.Drawing.Point(12, 9); + this.loginLabel.Name = "loginLabel"; + this.loginLabel.Size = new System.Drawing.Size(192, 30); + this.loginLabel.TabIndex = 0; + this.loginLabel.Text = "Имя пользователя"; + // + // userNameTextBox + // + this.userNameTextBox.Location = new System.Drawing.Point(200, 16); + this.userNameTextBox.Name = "userNameTextBox"; + this.userNameTextBox.ReadOnly = true; + this.userNameTextBox.Size = new System.Drawing.Size(190, 23); + this.userNameTextBox.TabIndex = 1; + // + // troubleRichLabel + // + this.troubleRichLabel.AutoSize = true; + this.troubleRichLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.troubleRichLabel.Location = new System.Drawing.Point(12, 42); + this.troubleRichLabel.Name = "troubleRichLabel"; + this.troubleRichLabel.Size = new System.Drawing.Size(258, 30); + this.troubleRichLabel.TabIndex = 2; + this.troubleRichLabel.Text = "Опишите вашу проблему"; + // + // troubleRichTextBox + // + this.troubleRichTextBox.Location = new System.Drawing.Point(12, 75); + this.troubleRichTextBox.Name = "troubleRichTextBox"; + this.troubleRichTextBox.Size = new System.Drawing.Size(378, 241); + this.troubleRichTextBox.TabIndex = 3; + this.troubleRichTextBox.Text = ""; + this.troubleRichTextBox.TextChanged += new System.EventHandler(this.TroubleRichTextBox_TextChanged); + // + // createTroubleTicketButton + // + this.createTroubleTicketButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.createTroubleTicketButton.Enabled = false; + this.createTroubleTicketButton.Location = new System.Drawing.Point(12, 322); + this.createTroubleTicketButton.Name = "createTrubleTicketButton"; + this.createTroubleTicketButton.Size = new System.Drawing.Size(378, 34); + this.createTroubleTicketButton.TabIndex = 4; + this.createTroubleTicketButton.Text = "&Создать заявку"; + this.createTroubleTicketButton.UseVisualStyleBackColor = true; + // + // cancelButton + // + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(12, 362); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(378, 34); + this.cancelButton.TabIndex = 5; + this.cancelButton.Text = "&Отмена"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // AddTrubleTicketForm + // + this.AcceptButton = this.createTroubleTicketButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.cancelButton; + this.ClientSize = new System.Drawing.Size(402, 404); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.createTroubleTicketButton); + this.Controls.Add(this.troubleRichTextBox); + this.Controls.Add(this.troubleRichLabel); + this.Controls.Add(this.userNameTextBox); + this.Controls.Add(this.loginLabel); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "AddTrubleTicketForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "HelpDesk Создание заявки"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.AddTroubleTicketForm_FormClosing); + this.Shown += new System.EventHandler(this.AddTroubleTicketForm_Shown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label loginLabel; + private System.Windows.Forms.TextBox userNameTextBox; + private System.Windows.Forms.Label troubleRichLabel; + private System.Windows.Forms.RichTextBox troubleRichTextBox; + private System.Windows.Forms.Button createTroubleTicketButton; + private System.Windows.Forms.Button cancelButton; + } +} \ No newline at end of file diff --git a/HelpDesk/HelpDeskWinFormsApp/AddTrubleTicketForm.cs b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs similarity index 55% rename from HelpDesk/HelpDeskWinFormsApp/AddTrubleTicketForm.cs rename to HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs index 306ef5b..eeb702f 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AddTrubleTicketForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs @@ -5,12 +5,12 @@ namespace HelpDeskWinFormsApp { - public partial class AddTrubleTicketForm : Form + public partial class AddTroubleTicketForm : Form { User user; private readonly IProvider provider; - public AddTrubleTicketForm(User user, IProvider provider) + public AddTroubleTicketForm(User user, IProvider provider) { InitializeComponent(); @@ -18,37 +18,37 @@ public AddTrubleTicketForm(User user, IProvider provider) this.user = user; } - private void AddTrubleTicketForm_Shown(object sender, EventArgs e) + private void AddTroubleTicketForm_Shown(object sender, EventArgs e) { userNameTextBox.Text = $"{user.Name} \\ {user.Login}"; } - private void AddTrubleTicketForm_FormClosing(object sender, FormClosingEventArgs e) + private void AddTroubleTicketForm_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult == DialogResult.OK) { - var trubelTicket = new TrubleTicket + var troubelTicket = new TroubleTicket { CreateUser = user.Id, - Text = trubleRichTextBox.Text, + Text = troubleRichTextBox.Text, Status = "Зарегистрирована", Created = DateTime.Now, Deadline = DateTime.Now.AddDays(4) }; - provider.AddTrubleTicket(trubelTicket); + provider.AddTroubleTicket(troubelTicket); } } - private void TrubleRichTextBox_TextChanged(object sender, EventArgs e) + private void TroubleRichTextBox_TextChanged(object sender, EventArgs e) { - if (trubleRichTextBox.Text.Length < 5) + if (troubleRichTextBox.Text.Length < 5) { - createTrubleTicketButton.Enabled = false; + createTroubleTicketButton.Enabled = false; } else { - createTrubleTicketButton.Enabled = true; + createTroubleTicketButton.Enabled = true; } } } diff --git a/HelpDesk/HelpDeskWinFormsApp/AddTrubleTicketForm.resx b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.resx similarity index 100% rename from HelpDesk/HelpDeskWinFormsApp/AddTrubleTicketForm.resx rename to HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.resx diff --git a/HelpDesk/HelpDeskWinFormsApp/AddTrubleTicketForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/AddTrubleTicketForm.Designer.cs deleted file mode 100644 index 569eb44..0000000 --- a/HelpDesk/HelpDeskWinFormsApp/AddTrubleTicketForm.Designer.cs +++ /dev/null @@ -1,131 +0,0 @@ -namespace HelpDeskWinFormsApp -{ - partial class AddTrubleTicketForm - { - /// - /// 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.label1 = new System.Windows.Forms.Label(); - this.userNameTextBox = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.trubleRichTextBox = new System.Windows.Forms.RichTextBox(); - this.createTrubleTicketButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label1.Location = new System.Drawing.Point(12, 9); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(192, 30); - this.label1.TabIndex = 0; - this.label1.Text = "Имя пользователя"; - // - // userNameTextBox - // - this.userNameTextBox.Location = new System.Drawing.Point(200, 16); - this.userNameTextBox.Name = "userNameTextBox"; - this.userNameTextBox.ReadOnly = true; - this.userNameTextBox.Size = new System.Drawing.Size(190, 23); - this.userNameTextBox.TabIndex = 1; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label2.Location = new System.Drawing.Point(12, 42); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(258, 30); - this.label2.TabIndex = 2; - this.label2.Text = "Опишите вашу проблему"; - // - // trubleRichTextBox - // - this.trubleRichTextBox.Location = new System.Drawing.Point(12, 75); - this.trubleRichTextBox.Name = "trubleRichTextBox"; - this.trubleRichTextBox.Size = new System.Drawing.Size(378, 241); - this.trubleRichTextBox.TabIndex = 3; - this.trubleRichTextBox.Text = ""; - this.trubleRichTextBox.TextChanged += new System.EventHandler(this.TrubleRichTextBox_TextChanged); - // - // createTrubleTicketButton - // - this.createTrubleTicketButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.createTrubleTicketButton.Enabled = false; - this.createTrubleTicketButton.Location = new System.Drawing.Point(12, 322); - this.createTrubleTicketButton.Name = "createTrubleTicketButton"; - this.createTrubleTicketButton.Size = new System.Drawing.Size(378, 34); - this.createTrubleTicketButton.TabIndex = 4; - this.createTrubleTicketButton.Text = "&Создать заявку"; - this.createTrubleTicketButton.UseVisualStyleBackColor = true; - // - // cancelButton - // - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(12, 362); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(378, 34); - this.cancelButton.TabIndex = 5; - this.cancelButton.Text = "&Отмена"; - this.cancelButton.UseVisualStyleBackColor = true; - // - // AddTrubleTicketForm - // - this.AcceptButton = this.createTrubleTicketButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(402, 404); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.createTrubleTicketButton); - this.Controls.Add(this.trubleRichTextBox); - this.Controls.Add(this.label2); - this.Controls.Add(this.userNameTextBox); - this.Controls.Add(this.label1); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "AddTrubleTicketForm"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "HelpDesk Создание заявки"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.AddTrubleTicketForm_FormClosing); - this.Shown += new System.EventHandler(this.AddTrubleTicketForm_Shown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox userNameTextBox; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.RichTextBox trubleRichTextBox; - private System.Windows.Forms.Button createTrubleTicketButton; - private System.Windows.Forms.Button cancelButton; - } -} \ No newline at end of file diff --git a/HelpDesk/HelpDeskWinFormsApp/AuthorizationFrom.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.Designer.cs similarity index 54% rename from HelpDesk/HelpDeskWinFormsApp/AuthorizationFrom.Designer.cs rename to HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.Designer.cs index 842e2c2..0a3fcd5 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AuthorizationFrom.Designer.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.Designer.cs @@ -2,7 +2,7 @@ namespace HelpDeskWinFormsApp { - partial class AuthorizationFrom + partial class AuthorizationForm { /// /// Required designer variable. @@ -30,55 +30,55 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - LoginTextBox = new TextBox(); - PasswordTextBox = new TextBox(); - label1 = new Label(); - label2 = new Label(); + loginTextBox = new TextBox(); + passwordTextBox = new TextBox(); + loginLabel = new Label(); + passwordLabel = new Label(); loginButton = new Button(); cancelButton = new Button(); registrationButton = new Button(); - menuStrip1 = new MenuStrip(); - файлToolStripMenuItem = new ToolStripMenuItem(); + mainMenuStrip = new MenuStrip(); + fileToolStripMenuItem = new ToolStripMenuItem(); exitToolStripMenuItem = new ToolStripMenuItem(); - menuStrip1.SuspendLayout(); + mainMenuStrip.SuspendLayout(); SuspendLayout(); // - // LoginTextBox + // loginTextBox // - LoginTextBox.Enabled = false; - LoginTextBox.Location = new System.Drawing.Point(12, 75); - LoginTextBox.Name = "LoginTextBox"; - LoginTextBox.Size = new System.Drawing.Size(279, 23); - LoginTextBox.TabIndex = 0; + loginTextBox.Enabled = false; + loginTextBox.Location = new System.Drawing.Point(12, 75); + loginTextBox.Name = "LoginTextBox"; + loginTextBox.Size = new System.Drawing.Size(279, 23); + loginTextBox.TabIndex = 0; // - // PasswordTextBox + // passwordTextBox // - PasswordTextBox.Enabled = false; - PasswordTextBox.Location = new System.Drawing.Point(12, 139); - PasswordTextBox.Name = "PasswordTextBox"; - PasswordTextBox.Size = new System.Drawing.Size(279, 23); - PasswordTextBox.TabIndex = 1; - PasswordTextBox.UseSystemPasswordChar = true; + passwordTextBox.Enabled = false; + passwordTextBox.Location = new System.Drawing.Point(12, 139); + passwordTextBox.Name = "PasswordTextBox"; + passwordTextBox.Size = new System.Drawing.Size(279, 23); + passwordTextBox.TabIndex = 1; + passwordTextBox.UseSystemPasswordChar = true; // - // label1 + // loginLabel // - label1.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - label1.Location = new System.Drawing.Point(12, 42); - label1.Name = "label1"; - label1.Size = new System.Drawing.Size(279, 30); - label1.TabIndex = 2; - label1.Text = "&Логин"; - label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + loginLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + loginLabel.Location = new System.Drawing.Point(12, 42); + loginLabel.Name = "loginLabel"; + loginLabel.Size = new System.Drawing.Size(279, 30); + loginLabel.TabIndex = 2; + loginLabel.Text = "&Логин"; + loginLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // label2 + // passwordLabel // - label2.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - label2.Location = new System.Drawing.Point(12, 101); - label2.Name = "label2"; - label2.Size = new System.Drawing.Size(279, 35); - label2.TabIndex = 3; - label2.Text = "&Пароль"; - label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + passwordLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + passwordLabel.Location = new System.Drawing.Point(12, 101); + passwordLabel.Name = "passwordLabel"; + passwordLabel.Size = new System.Drawing.Size(279, 35); + passwordLabel.TabIndex = 3; + passwordLabel.Text = "&Пароль"; + passwordLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // loginButton // @@ -112,21 +112,21 @@ private void InitializeComponent() registrationButton.UseVisualStyleBackColor = true; registrationButton.Click += RegistrationButton_Click; // - // menuStrip1 + // mainMenuStrip // - menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem }); - menuStrip1.Location = new System.Drawing.Point(0, 0); - menuStrip1.Name = "menuStrip1"; - menuStrip1.Size = new System.Drawing.Size(303, 24); - menuStrip1.TabIndex = 9; - menuStrip1.Text = "menuStrip1"; + mainMenuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem }); + mainMenuStrip.Location = new System.Drawing.Point(0, 0); + mainMenuStrip.Name = "mainMenuStrip"; + mainMenuStrip.Size = new System.Drawing.Size(303, 24); + mainMenuStrip.TabIndex = 9; + mainMenuStrip.Text = "mainMenuStrip"; // - // файлToolStripMenuItem + // fileToolStripMenuItem // - файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { exitToolStripMenuItem }); - файлToolStripMenuItem.Name = "файлToolStripMenuItem"; - файлToolStripMenuItem.Size = new System.Drawing.Size(48, 20); - файлToolStripMenuItem.Text = "&Файл"; + fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { exitToolStripMenuItem }); + fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + fileToolStripMenuItem.Size = new System.Drawing.Size(48, 20); + fileToolStripMenuItem.Text = "&Файл"; // // exitToolStripMenuItem // @@ -135,7 +135,7 @@ private void InitializeComponent() exitToolStripMenuItem.Text = "&Выход"; exitToolStripMenuItem.Click += ExitToolStripMenuItem_Click; // - // AuthorizationFrom + // AuthorizationForm // AcceptButton = loginButton; AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -146,36 +146,36 @@ private void InitializeComponent() Controls.Add(registrationButton); Controls.Add(cancelButton); Controls.Add(loginButton); - Controls.Add(label2); - Controls.Add(label1); - Controls.Add(PasswordTextBox); - Controls.Add(LoginTextBox); - Controls.Add(menuStrip1); + Controls.Add(passwordLabel); + Controls.Add(loginLabel); + Controls.Add(passwordTextBox); + Controls.Add(loginTextBox); + Controls.Add(mainMenuStrip); FormBorderStyle = FormBorderStyle.FixedDialog; - MainMenuStrip = menuStrip1; - Name = "AuthorizationFrom"; + MainMenuStrip = mainMenuStrip; + Name = "AuthorizationForm"; ShowIcon = false; StartPosition = FormStartPosition.CenterScreen; Text = "HelpDesk Авторизация"; - FormClosing += AuthorizationFrom_FormClosing; - Shown += AuthorizationFrom_Shown; - menuStrip1.ResumeLayout(false); - menuStrip1.PerformLayout(); + FormClosing += AuthorizationForm_FormClosing; + Shown += AuthorizationForm_Shown; + mainMenuStrip.ResumeLayout(false); + mainMenuStrip.PerformLayout(); ResumeLayout(false); PerformLayout(); } #endregion - private Label label1; - private Label label2; + private Label loginLabel; + private Label passwordLabel; private Button loginButton; private Button cancelButton; - public TextBox LoginTextBox; - public TextBox PasswordTextBox; + public TextBox loginTextBox; + public TextBox passwordTextBox; private Button registrationButton; private ContextMenuStrip contextMenuStrip; - private MenuStrip menuStrip1; - private ToolStripMenuItem файлToolStripMenuItem; + private MenuStrip mainMenuStrip; + private ToolStripMenuItem fileToolStripMenuItem; private ToolStripMenuItem exitToolStripMenuItem; } } \ No newline at end of file diff --git a/HelpDesk/HelpDeskWinFormsApp/AuthorizationFrom.cs b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs similarity index 82% rename from HelpDesk/HelpDeskWinFormsApp/AuthorizationFrom.cs rename to HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs index fc8ab91..c3449a2 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AuthorizationFrom.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs @@ -5,31 +5,31 @@ namespace HelpDeskWinFormsApp { - public partial class AuthorizationFrom : Form + public partial class AuthorizationForm : Form { public bool RegistrationChoice = false; private readonly IProvider provider; - public AuthorizationFrom(IProvider provider) + public AuthorizationForm(IProvider provider) { InitializeComponent(); this.provider = provider; } - private void AuthorizationFrom_Shown(object sender, EventArgs e) + private void AuthorizationForm_Shown(object sender, EventArgs e) { AddFirstEmployee(); UnlockTextBox(); } - private void AuthorizationFrom_FormClosing(object sender, FormClosingEventArgs e) + private void AuthorizationForm_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult == DialogResult.Cancel) { return; } - if (!provider.IsCorrectLoginPassword(LoginTextBox.Text, PasswordTextBox.Text)) + if (!provider.IsCorrectLoginPassword(loginTextBox.Text, passwordTextBox.Text)) { e.Cancel = true; MessageBox.Show("Неверный логин или пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -44,8 +44,8 @@ private void RegistrationButton_Click(object sender, EventArgs e) private void UnlockTextBox() { - LoginTextBox.Enabled = true; - PasswordTextBox.Enabled = true; + loginTextBox.Enabled = true; + passwordTextBox.Enabled = true; loginButton.Enabled = true; registrationButton.Enabled = true; } diff --git a/HelpDesk/HelpDeskWinFormsApp/AuthorizationFrom.resx b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.resx similarity index 100% rename from HelpDesk/HelpDeskWinFormsApp/AuthorizationFrom.resx rename to HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.resx diff --git a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.Designer.cs index 2a088ed..7db1ab7 100644 --- a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.Designer.cs +++ b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.Designer.cs @@ -28,35 +28,35 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.label1 = new System.Windows.Forms.Label(); + this.nameLabel = new System.Windows.Forms.Label(); this.nameTextBox = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); + this.loginLabel = new System.Windows.Forms.Label(); this.loginTextBox = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); + this.changePasswordLabel = new System.Windows.Forms.Label(); this.changePasswordTextBox = new System.Windows.Forms.TextBox(); - this.label4 = new System.Windows.Forms.Label(); + this.confurmChangePasswordLabel = new System.Windows.Forms.Label(); this.confurmChangePasswordTextBox = new System.Windows.Forms.TextBox(); - this.label5 = new System.Windows.Forms.Label(); + this.emailLabel = new System.Windows.Forms.Label(); this.emailTextBox = new System.Windows.Forms.TextBox(); - this.label6 = new System.Windows.Forms.Label(); + this.userTypeLabel = new System.Windows.Forms.Label(); this.userTypeComboBox = new System.Windows.Forms.ComboBox(); - this.label7 = new System.Windows.Forms.Label(); - this.label8 = new System.Windows.Forms.Label(); + this.functionLabel = new System.Windows.Forms.Label(); + this.deparmentLabel = new System.Windows.Forms.Label(); this.saveButton = new System.Windows.Forms.Button(); this.cancelButton = new System.Windows.Forms.Button(); this.functionComboBox = new System.Windows.Forms.ComboBox(); this.deparmentComboBox = new System.Windows.Forms.ComboBox(); this.SuspendLayout(); // - // label1 + // nameLabel // - this.label1.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label1.Location = new System.Drawing.Point(12, 9); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(279, 30); - this.label1.TabIndex = 0; - this.label1.Text = "Имя"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.nameLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.nameLabel.Location = new System.Drawing.Point(12, 9); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(279, 30); + this.nameLabel.TabIndex = 0; + this.nameLabel.Text = "Имя"; + this.nameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // nameTextBox // @@ -65,15 +65,15 @@ private void InitializeComponent() this.nameTextBox.Size = new System.Drawing.Size(279, 23); this.nameTextBox.TabIndex = 1; // - // label2 + // loginLabel // - this.label2.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label2.Location = new System.Drawing.Point(12, 68); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(279, 30); - this.label2.TabIndex = 2; - this.label2.Text = "Логин"; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.loginLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.loginLabel.Location = new System.Drawing.Point(12, 68); + this.loginLabel.Name = "loginLabel"; + this.loginLabel.Size = new System.Drawing.Size(279, 30); + this.loginLabel.TabIndex = 2; + this.loginLabel.Text = "Логин"; + this.loginLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // loginTextBox // @@ -82,15 +82,15 @@ private void InitializeComponent() this.loginTextBox.Size = new System.Drawing.Size(279, 23); this.loginTextBox.TabIndex = 3; // - // label3 + // changePasswordLabel // - this.label3.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label3.Location = new System.Drawing.Point(12, 127); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(279, 30); - this.label3.TabIndex = 4; - this.label3.Text = "Изменение пароля"; - this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.changePasswordLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.changePasswordLabel.Location = new System.Drawing.Point(12, 127); + this.changePasswordLabel.Name = "changePasswordLabel"; + this.changePasswordLabel.Size = new System.Drawing.Size(279, 30); + this.changePasswordLabel.TabIndex = 4; + this.changePasswordLabel.Text = "Изменение пароля"; + this.changePasswordLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // changePasswordTextBox // @@ -100,15 +100,15 @@ private void InitializeComponent() this.changePasswordTextBox.TabIndex = 5; this.changePasswordTextBox.UseSystemPasswordChar = true; // - // label4 + // confurmChangePasswordLabel // - this.label4.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label4.Location = new System.Drawing.Point(12, 186); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(279, 30); - this.label4.TabIndex = 6; - this.label4.Text = "Повтор пароля"; - this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.confurmChangePasswordLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.confurmChangePasswordLabel.Location = new System.Drawing.Point(12, 186); + this.confurmChangePasswordLabel.Name = "confurmChangePasswordLabel"; + this.confurmChangePasswordLabel.Size = new System.Drawing.Size(279, 30); + this.confurmChangePasswordLabel.TabIndex = 6; + this.confurmChangePasswordLabel.Text = "Повтор пароля"; + this.confurmChangePasswordLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // confurmChangePasswordTextBox // @@ -118,15 +118,15 @@ private void InitializeComponent() this.confurmChangePasswordTextBox.TabIndex = 7; this.confurmChangePasswordTextBox.UseSystemPasswordChar = true; // - // label5 + // emailLabel // - this.label5.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label5.Location = new System.Drawing.Point(12, 245); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(279, 30); - this.label5.TabIndex = 8; - this.label5.Text = "E-Mail"; - this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.emailLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.emailLabel.Location = new System.Drawing.Point(12, 245); + this.emailLabel.Name = "emailLabel"; + this.emailLabel.Size = new System.Drawing.Size(279, 30); + this.emailLabel.TabIndex = 8; + this.emailLabel.Text = "E-Mail"; + this.emailLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // emailTextBox // @@ -135,15 +135,15 @@ private void InitializeComponent() this.emailTextBox.Size = new System.Drawing.Size(279, 23); this.emailTextBox.TabIndex = 9; // - // label6 + // userTypeLabel // - this.label6.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label6.Location = new System.Drawing.Point(12, 304); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(279, 30); - this.label6.TabIndex = 10; - this.label6.Text = "Тип пользователя"; - this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.userTypeLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.userTypeLabel.Location = new System.Drawing.Point(12, 304); + this.userTypeLabel.Name = "userTypeLabel"; + this.userTypeLabel.Size = new System.Drawing.Size(279, 30); + this.userTypeLabel.TabIndex = 10; + this.userTypeLabel.Text = "Тип пользователя"; + this.userTypeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // userTypeComboBox // @@ -158,25 +158,25 @@ private void InitializeComponent() this.userTypeComboBox.TabIndex = 11; this.userTypeComboBox.SelectedValueChanged += new System.EventHandler(this.UserTypeComboBox_SelectedValueChanged); // - // label7 + // functionLabel // - this.label7.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label7.Location = new System.Drawing.Point(12, 422); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(279, 30); - this.label7.TabIndex = 14; - this.label7.Text = "Функция"; - this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.functionLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.functionLabel.Location = new System.Drawing.Point(12, 422); + this.functionLabel.Name = "functionLabel"; + this.functionLabel.Size = new System.Drawing.Size(279, 30); + this.functionLabel.TabIndex = 14; + this.functionLabel.Text = "Функция"; + this.functionLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // label8 + // deparmentLabel // - this.label8.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label8.Location = new System.Drawing.Point(12, 363); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(279, 30); - this.label8.TabIndex = 12; - this.label8.Text = "Отдел"; - this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.deparmentLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.deparmentLabel.Location = new System.Drawing.Point(12, 363); + this.deparmentLabel.Name = "deparmentLabel"; + this.deparmentLabel.Size = new System.Drawing.Size(279, 30); + this.deparmentLabel.TabIndex = 12; + this.deparmentLabel.Text = "Отдел"; + this.deparmentLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // saveButton // @@ -235,20 +235,20 @@ private void InitializeComponent() this.Controls.Add(this.functionComboBox); this.Controls.Add(this.cancelButton); this.Controls.Add(this.saveButton); - this.Controls.Add(this.label8); - this.Controls.Add(this.label7); + this.Controls.Add(this.deparmentLabel); + this.Controls.Add(this.functionLabel); this.Controls.Add(this.userTypeComboBox); - this.Controls.Add(this.label6); + this.Controls.Add(this.userTypeLabel); this.Controls.Add(this.emailTextBox); - this.Controls.Add(this.label5); + this.Controls.Add(this.emailLabel); this.Controls.Add(this.confurmChangePasswordTextBox); - this.Controls.Add(this.label4); + this.Controls.Add(this.confurmChangePasswordLabel); this.Controls.Add(this.changePasswordTextBox); - this.Controls.Add(this.label3); + this.Controls.Add(this.changePasswordLabel); this.Controls.Add(this.loginTextBox); - this.Controls.Add(this.label2); + this.Controls.Add(this.loginLabel); this.Controls.Add(this.nameTextBox); - this.Controls.Add(this.label1); + this.Controls.Add(this.nameLabel); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Name = "EditUserForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; @@ -262,20 +262,20 @@ private void InitializeComponent() #endregion - private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label nameLabel; private System.Windows.Forms.TextBox nameTextBox; - private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label loginLabel; private System.Windows.Forms.TextBox loginTextBox; - private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label changePasswordLabel; private System.Windows.Forms.TextBox changePasswordTextBox; - private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label confurmChangePasswordLabel; private System.Windows.Forms.TextBox confurmChangePasswordTextBox; - private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label emailLabel; private System.Windows.Forms.TextBox emailTextBox; - private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label userTypeLabel; private System.Windows.Forms.ComboBox userTypeComboBox; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label functionLabel; + private System.Windows.Forms.Label deparmentLabel; private System.Windows.Forms.Button saveButton; private System.Windows.Forms.Button cancelButton; private System.Windows.Forms.ComboBox functionComboBox; diff --git a/HelpDesk/HelpDeskWinFormsApp/ExportForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/ExportForm.Designer.cs index 99511d7..35334a7 100644 --- a/HelpDesk/HelpDeskWinFormsApp/ExportForm.Designer.cs +++ b/HelpDesk/HelpDeskWinFormsApp/ExportForm.Designer.cs @@ -28,30 +28,30 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.label1 = new System.Windows.Forms.Label(); + this.fileTypeLabel = new System.Windows.Forms.Label(); this.fileTypeComboBox = new System.Windows.Forms.ComboBox(); this.exportFileDialog = new System.Windows.Forms.SaveFileDialog(); this.exportButton = new System.Windows.Forms.Button(); this.cancelButton = new System.Windows.Forms.Button(); - this.label2 = new System.Windows.Forms.Label(); + this.timeIntervalLabel = new System.Windows.Forms.Label(); this.startDateTimePicker = new System.Windows.Forms.DateTimePicker(); this.endDateTimePicker = new System.Windows.Forms.DateTimePicker(); - this.label3 = new System.Windows.Forms.Label(); + this.exportLabel = new System.Windows.Forms.Label(); this.typeComboBox = new System.Windows.Forms.ComboBox(); this.statusFilterCheckBox = new System.Windows.Forms.CheckBox(); this.statusFilterComboBox = new System.Windows.Forms.ComboBox(); this.progressBar = new System.Windows.Forms.ProgressBar(); this.SuspendLayout(); // - // label1 + // fileTypeLabel // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label1.Location = new System.Drawing.Point(12, 39); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(113, 30); - this.label1.TabIndex = 0; - this.label1.Text = "Тип файла"; + this.fileTypeLabel.AutoSize = true; + this.fileTypeLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.fileTypeLabel.Location = new System.Drawing.Point(12, 39); + this.fileTypeLabel.Name = "fileTypeLabel"; + this.fileTypeLabel.Size = new System.Drawing.Size(113, 30); + this.fileTypeLabel.TabIndex = 0; + this.fileTypeLabel.Text = "Тип файла"; // // fileTypeComboBox // @@ -92,15 +92,15 @@ private void InitializeComponent() this.cancelButton.UseVisualStyleBackColor = true; this.cancelButton.Click += new System.EventHandler(this.CancelButton_Click); // - // label2 + // timeIntervalLabel // - this.label2.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label2.Location = new System.Drawing.Point(12, 72); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(299, 30); - this.label2.TabIndex = 4; - this.label2.Text = "Временной интервал"; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.timeIntervalLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.timeIntervalLabel.Location = new System.Drawing.Point(12, 72); + this.timeIntervalLabel.Name = "timeIntervalLabel"; + this.timeIntervalLabel.Size = new System.Drawing.Size(299, 30); + this.timeIntervalLabel.TabIndex = 4; + this.timeIntervalLabel.Text = "Временной интервал"; + this.timeIntervalLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // startDateTimePicker // @@ -120,15 +120,15 @@ private void InitializeComponent() this.endDateTimePicker.Size = new System.Drawing.Size(121, 23); this.endDateTimePicker.TabIndex = 6; // - // label3 + // exportLabel // - this.label3.AutoSize = true; - this.label3.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label3.Location = new System.Drawing.Point(12, 9); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(169, 30); - this.label3.TabIndex = 7; - this.label3.Text = "Экспортировать"; + this.exportLabel.AutoSize = true; + this.exportLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.exportLabel.Location = new System.Drawing.Point(12, 9); + this.exportLabel.Name = "exportLabel"; + this.exportLabel.Size = new System.Drawing.Size(169, 30); + this.exportLabel.TabIndex = 7; + this.exportLabel.Text = "Экспортировать"; // // typeComboBox // @@ -185,14 +185,14 @@ private void InitializeComponent() this.Controls.Add(this.statusFilterComboBox); this.Controls.Add(this.statusFilterCheckBox); this.Controls.Add(this.typeComboBox); - this.Controls.Add(this.label3); + this.Controls.Add(this.exportLabel); this.Controls.Add(this.endDateTimePicker); this.Controls.Add(this.startDateTimePicker); - this.Controls.Add(this.label2); + this.Controls.Add(this.timeIntervalLabel); this.Controls.Add(this.cancelButton); this.Controls.Add(this.exportButton); this.Controls.Add(this.fileTypeComboBox); - this.Controls.Add(this.label1); + this.Controls.Add(this.fileTypeLabel); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Name = "ExportForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; @@ -206,15 +206,15 @@ private void InitializeComponent() #endregion - private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label fileTypeLabel; private System.Windows.Forms.ComboBox fileTypeComboBox; private System.Windows.Forms.SaveFileDialog exportFileDialog; private System.Windows.Forms.Button exportButton; private System.Windows.Forms.Button cancelButton; - private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label timeIntervalLabel; private System.Windows.Forms.DateTimePicker startDateTimePicker; private System.Windows.Forms.DateTimePicker endDateTimePicker; - private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label exportLabel; private System.Windows.Forms.ComboBox typeComboBox; private System.Windows.Forms.CheckBox statusFilterCheckBox; private System.Windows.Forms.ComboBox statusFilterComboBox; diff --git a/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs b/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs index 24b5f48..48d4587 100644 --- a/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs @@ -58,8 +58,8 @@ private void ExportButton_Click(object sender, EventArgs e) return; } - var allTrubleTickets = provider.GetAllTrubleTickets(); - var trubleTickets = new List(); + var allTrubleTickets = provider.GetAllTroubleTickets(); + var trubleTickets = new List(); foreach ( var tt in allTrubleTickets) { @@ -76,7 +76,7 @@ private void ExportButton_Click(object sender, EventArgs e) { if (statusFilterCheckBox.Checked) { - var tempTrubleTickets = new List(); + var tempTrubleTickets = new List(); foreach( var tt in trubleTickets) { @@ -148,7 +148,7 @@ private void ExportButton_Click(object sender, EventArgs e) } } - private void CsvTrubleTicketExport(List result, List users, string exportFile) + private void CsvTrubleTicketExport(List result, List users, string exportFile) { var rowsCount = result.Count; @@ -305,7 +305,7 @@ private void ExcelUsersExport(List users, string exportFile, bool onlyClie workBook.SaveAs(exportFile); } - private void ExcelTrubleTicketExport(List result, List users, string exportFile) + private void ExcelTrubleTicketExport(List result, List users, string exportFile) { var rowsCount = result.Count; diff --git a/HelpDesk/HelpDeskWinFormsApp/MainForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/MainForm.Designer.cs index 3d20eb5..015b702 100644 --- a/HelpDesk/HelpDeskWinFormsApp/MainForm.Designer.cs +++ b/HelpDesk/HelpDeskWinFormsApp/MainForm.Designer.cs @@ -62,7 +62,7 @@ private void InitializeComponent() this.openTrubleTicketButton = new System.Windows.Forms.Button(); this.exitButton = new System.Windows.Forms.Button(); this.treeView = new System.Windows.Forms.TreeView(); - this.listTTDataGridView = new System.Windows.Forms.DataGridView(); + this.troubleTicketsDataGridView = new System.Windows.Forms.DataGridView(); this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip.SuspendLayout(); this.statusStrip.SuspendLayout(); @@ -70,7 +70,7 @@ private void InitializeComponent() this.splitContainer.Panel1.SuspendLayout(); this.splitContainer.Panel2.SuspendLayout(); this.splitContainer.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.listTTDataGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.troubleTicketsDataGridView)).BeginInit(); this.SuspendLayout(); // // menuStrip @@ -179,7 +179,7 @@ private void InitializeComponent() // // splitContainer.Panel2 // - this.splitContainer.Panel2.Controls.Add(this.listTTDataGridView); + this.splitContainer.Panel2.Controls.Add(this.troubleTicketsDataGridView); this.splitContainer.Panel2.Resize += new System.EventHandler(this.SplitContainer_Panel2_Resize); this.splitContainer.Size = new System.Drawing.Size(982, 610); this.splitContainer.SplitterDistance = 168; @@ -203,7 +203,7 @@ private void InitializeComponent() this.addTrubleTicketbutton.TabIndex = 3; this.addTrubleTicketbutton.Text = "&Создать заявку"; this.addTrubleTicketbutton.UseVisualStyleBackColor = true; - this.addTrubleTicketbutton.Click += new System.EventHandler(this.AddTrubleTicketbutton_Click); + this.addTrubleTicketbutton.Click += new System.EventHandler(this.AddTroubleTicketButton_Click); // // openTrubleTicketButton // @@ -255,24 +255,24 @@ private void InitializeComponent() this.treeView.TabIndex = 0; this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.TreeView_AfterSelect); // - // listTTDataGridView - // - this.listTTDataGridView.AllowUserToAddRows = false; - this.listTTDataGridView.AllowUserToDeleteRows = false; - this.listTTDataGridView.AllowUserToResizeRows = false; - this.listTTDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.DisplayedCells; - this.listTTDataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.RaisedHorizontal; - this.listTTDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.listTTDataGridView.Location = new System.Drawing.Point(0, 0); - this.listTTDataGridView.MultiSelect = false; - this.listTTDataGridView.Name = "listTTDataGridView"; - this.listTTDataGridView.ReadOnly = true; - this.listTTDataGridView.RowHeadersVisible = false; - this.listTTDataGridView.RowTemplate.Height = 25; - this.listTTDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.listTTDataGridView.Size = new System.Drawing.Size(811, 588); - this.listTTDataGridView.TabIndex = 0; - this.listTTDataGridView.DoubleClick += new System.EventHandler(this.ListTTDataGridView_DoubleClick); + // troubleTicketsDataGridView + // + this.troubleTicketsDataGridView.AllowUserToAddRows = false; + this.troubleTicketsDataGridView.AllowUserToDeleteRows = false; + this.troubleTicketsDataGridView.AllowUserToResizeRows = false; + this.troubleTicketsDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.DisplayedCells; + this.troubleTicketsDataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.RaisedHorizontal; + this.troubleTicketsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.troubleTicketsDataGridView.Location = new System.Drawing.Point(0, 0); + this.troubleTicketsDataGridView.MultiSelect = false; + this.troubleTicketsDataGridView.Name = "listTTDataGridView"; + this.troubleTicketsDataGridView.ReadOnly = true; + this.troubleTicketsDataGridView.RowHeadersVisible = false; + this.troubleTicketsDataGridView.RowTemplate.Height = 25; + this.troubleTicketsDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.troubleTicketsDataGridView.Size = new System.Drawing.Size(811, 588); + this.troubleTicketsDataGridView.TabIndex = 0; + this.troubleTicketsDataGridView.DoubleClick += new System.EventHandler(this.ListTTDataGridView_DoubleClick); // // exportToolStripMenuItem // @@ -303,7 +303,7 @@ private void InitializeComponent() this.splitContainer.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); this.splitContainer.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.listTTDataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.troubleTicketsDataGridView)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -321,7 +321,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem logoutToolStripMenuItem; private System.Windows.Forms.SplitContainer splitContainer; private System.Windows.Forms.TreeView treeView; - private System.Windows.Forms.DataGridView listTTDataGridView; + private System.Windows.Forms.DataGridView troubleTicketsDataGridView; private System.Windows.Forms.Button openTrubleTicketButton; private System.Windows.Forms.Button exitButton; private System.Windows.Forms.Button addTrubleTicketbutton; diff --git a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs index e2e7fd2..4300e5c 100644 --- a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; -using System.Net.NetworkInformation; using System.Windows.Forms; using HelpDesk.Common; using HelpDesk.Common.Application; @@ -43,7 +42,7 @@ private void MainForm_Load(object sender, EventArgs e) treeView.Width = splitContainer.Panel1.Width; treeView.Height = splitContainer.Panel1.Height - 152; - listTTDataGridView.Size = splitContainer.Panel2.Size; + troubleTicketsDataGridView.Size = splitContainer.Panel2.Size; userNameToolStripStatusLabel.Text = $"Имя: {user.Name}"; loginToolStripStatusLabel.Text = $"Логин: {user.Login}"; @@ -70,8 +69,8 @@ private void ExitToolStripMenuItem_Click(object sender, EventArgs e) private void LogoutToolStripMenuItem_Click(object sender, EventArgs e) { - listTTDataGridView.Rows.Clear(); - listTTDataGridView.Columns.Clear(); + troubleTicketsDataGridView.Rows.Clear(); + troubleTicketsDataGridView.Columns.Clear(); Hide(); @@ -106,39 +105,39 @@ private void SplitContainer_Panel1_Resize(object sender, EventArgs e) private void SplitContainer_Panel2_Resize(object sender, EventArgs e) { - listTTDataGridView.Size = splitContainer.Panel2.Size; + troubleTicketsDataGridView.Size = splitContainer.Panel2.Size; } private void OpenTrubleTicketButton_Click(object sender, EventArgs e) { - if (listTTDataGridView.SelectedRows.Count != 0) + if (troubleTicketsDataGridView.SelectedRows.Count != 0) { - var ticketId = Convert.ToInt32(listTTDataGridView.SelectedCells[0].Value); + var ticketId = Convert.ToInt32(troubleTicketsDataGridView.SelectedCells[0].Value); - var resolvedUser = Convert.ToInt32(provider.GetTrubleTicket(ticketId).ResolveUser != null ? user.Id : -1); + var resolvedUser = Convert.ToInt32(provider.GetTroubleTicket(ticketId).ResolveUser != null ? user.Id : -1); if (user.IsEmployee && resolvedUser == -1) { resolvedUser = user.Id; } - var dialogResult = new TrubleTicketForm(ticketId, user.IsEmployee, resolvedUser, provider).ShowDialog(); + var dialogResult = new TroubleTicketForm(ticketId, user.IsEmployee, resolvedUser, provider).ShowDialog(); if (dialogResult == DialogResult.OK) { - RefreshTrubleTicketsDataGrid(); + RefreshTroubleTicketsDataGrid(); } } } - private void AddTrubleTicketbutton_Click(object sender, EventArgs e) + private void AddTroubleTicketButton_Click(object sender, EventArgs e) { - var dialogResult = new AddTrubleTicketForm(user, provider); + var dialogResult = new AddTroubleTicketForm(user, provider); if (dialogResult.ShowDialog() == DialogResult.OK) { treeView.SelectedNode = treeView.Nodes["trubleTicketlist"].Nodes["openTrubleTicket"]; - RefreshTrubleTicketsDataGrid(); + RefreshTroubleTicketsDataGrid(); } } @@ -177,9 +176,9 @@ private void ExportToolStripMenuItem_Click(object sender, EventArgs e) private void EditUserButton_Click(object sender, EventArgs e) { - if (listTTDataGridView.SelectedRows.Count != 0) + if (troubleTicketsDataGridView.SelectedRows.Count != 0) { - var userId = Convert.ToInt32(listTTDataGridView.SelectedCells[0].Value); + var userId = Convert.ToInt32(troubleTicketsDataGridView.SelectedCells[0].Value); var dialogResult = new EditUserForm(userId, provider).ShowDialog(); @@ -196,7 +195,7 @@ private void RefreshToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView.SelectedNode.Parent.Name == "trubleTicketlist" || treeView.SelectedNode.Parent.Name == "statusTrubleTicketNode") { - RefreshTrubleTicketsDataGrid(); + RefreshTroubleTicketsDataGrid(); editUserButton.Enabled = false; openTrubleTicketButton.Enabled = true; } @@ -272,15 +271,15 @@ private string AuthorizationUser() { var isNeedRegistration = false; var login = string.Empty; - var authorizationFrom = new AuthorizationFrom(provider); + var authorizationForm = new AuthorizationForm(provider); - if (authorizationFrom.ShowDialog() == DialogResult.OK) + if (authorizationForm.ShowDialog() == DialogResult.OK) { - login = authorizationFrom.LoginTextBox.Text; + login = authorizationForm.loginTextBox.Text; } else { - isNeedRegistration = authorizationFrom.RegistrationChoice; + isNeedRegistration = authorizationForm.RegistrationChoice; if (!isNeedRegistration) { @@ -315,25 +314,25 @@ private void RefreshUsersDataGrid() { var selectedNode = treeView.SelectedNode.Name; - listTTDataGridView.Columns.Clear(); + troubleTicketsDataGridView.Columns.Clear(); switch (selectedNode) { case "allUsersNode": - FillUsersDataGreedView(provider.GetAllUsers()); + FillUsersDataGridView(provider.GetAllUsers()); break; case "clientsNode": - FillUsersDataGreedView(provider.GetAllUsers().Where(u => !u.IsEmployee).ToList()); + FillUsersDataGridView(provider.GetAllUsers().Where(u => !u.IsEmployee).ToList()); break; case "EmployeeNode": - FillUsersDataGreedView(provider.GetAllUsers().Where(u => u.IsEmployee).ToList()); + FillUsersDataGridView(provider.GetAllUsers().Where(u => u.IsEmployee).ToList()); break; default: break; } } - private void RefreshTrubleTicketsDataGrid() + private void RefreshTroubleTicketsDataGrid() { var selectedNode = treeView.SelectedNode.Name; @@ -342,163 +341,163 @@ private void RefreshTrubleTicketsDataGrid() return; } - List trubleTickets = new(); + List troubleTickets = new(); - listTTDataGridView.Columns.Clear(); + troubleTicketsDataGridView.Columns.Clear(); if (user.IsEmployee) { - trubleTickets = provider.GetAllTrubleTickets(); + troubleTickets = provider.GetAllTroubleTickets(); } else { - trubleTickets = provider.GetAllTrubleTickets().Where(t => t.CreateUser == user.Id).ToList(); + troubleTickets = provider.GetAllTroubleTickets().Where(t => t.CreateUser == user.Id).ToList(); } switch (selectedNode) { case "allTrubleTicket": - FillTrubleTicketsDataGreedView(trubleTickets); + FillTroubleTicketsDataGridView(troubleTickets); break; case "openTrubleTicket": - FillTrubleTicketsDataGreedView(trubleTickets.Where(s => s.IsSolved == false).ToList()); + FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.IsSolved == false).ToList()); break; case "closedTrubleTicket": - FillTrubleTicketsDataGreedView(trubleTickets.Where(s => s.IsSolved == true).ToList()); + FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.IsSolved == true).ToList()); break; case "overdueTrubleTicketNode": - FillTrubleTicketsDataGreedView(trubleTickets.Where(s => (DateTime.Now - s.Deadline).TotalSeconds > 0).ToList()); + FillTroubleTicketsDataGridView(troubleTickets.Where(s => (DateTime.Now - s.Deadline).TotalSeconds > 0).ToList()); break; case "registeredTrubleTicketNode": - FillTrubleTicketsDataGreedView(trubleTickets.Where(s => s.Status == "Зарегистрирована").ToList()); + FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.Status == "Зарегистрирована").ToList()); break; case "workTrubleTicketNode": - FillTrubleTicketsDataGreedView(trubleTickets.Where(s => s.Status == "В работе").ToList()); + FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.Status == "В работе").ToList()); break; case "completedTrubleTicketNode": - FillTrubleTicketsDataGreedView(trubleTickets.Where(s => s.Status == "Выполнена").ToList()); + FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.Status == "Выполнена").ToList()); break; case "rejectedTrubleTicketNode": - FillTrubleTicketsDataGreedView(trubleTickets.Where(s => s.Status == "Отклонена").ToList()); + FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.Status == "Отклонена").ToList()); break; default: break; } } - private void FillUsersDataGreedView(List users) + private void FillUsersDataGridView(List users) { - listTTDataGridView.Columns.Add("id", "ID"); - listTTDataGridView.Columns.Add("name", "Имя"); - listTTDataGridView.Columns.Add("login", "Логин"); - listTTDataGridView.Columns.Add("email", "E-Mail"); - listTTDataGridView.Columns.Add("discriminator", "Тип"); - listTTDataGridView.Columns.Add("function", "Функция"); - listTTDataGridView.Columns.Add("department", "Отдел"); + troubleTicketsDataGridView.Columns.Add("id", "ID"); + troubleTicketsDataGridView.Columns.Add("name", "Имя"); + troubleTicketsDataGridView.Columns.Add("login", "Логин"); + troubleTicketsDataGridView.Columns.Add("email", "E-Mail"); + troubleTicketsDataGridView.Columns.Add("discriminator", "Тип"); + troubleTicketsDataGridView.Columns.Add("function", "Функция"); + troubleTicketsDataGridView.Columns.Add("department", "Отдел"); - listTTDataGridView.Rows.Clear(); + troubleTicketsDataGridView.Rows.Clear(); var countRows = users.Count; for (int i = 0; i < countRows; i++) { - listTTDataGridView.Rows.Add(); - listTTDataGridView.Rows[i].Cells[0].Value = users[i].Id; - listTTDataGridView.Rows[i].Cells[1].Value = users[i].Name; - listTTDataGridView.Rows[i].Cells[2].Value = users[i].Login; - listTTDataGridView.Rows[i].Cells[3].Value = users[i].Email; + troubleTicketsDataGridView.Rows.Add(); + troubleTicketsDataGridView.Rows[i].Cells[0].Value = users[i].Id; + troubleTicketsDataGridView.Rows[i].Cells[1].Value = users[i].Name; + troubleTicketsDataGridView.Rows[i].Cells[2].Value = users[i].Login; + troubleTicketsDataGridView.Rows[i].Cells[3].Value = users[i].Email; var userType = users[i].IsEmployee; - listTTDataGridView.Rows[i].Cells[4].Value = userType ? "Сотрудник" : "Клиент"; + troubleTicketsDataGridView.Rows[i].Cells[4].Value = userType ? "Сотрудник" : "Клиент"; if (userType) { - listTTDataGridView.Rows[i].Cells[5].Value = user.Function; - listTTDataGridView.Rows[i].Cells[6].Value = user.Department; + troubleTicketsDataGridView.Rows[i].Cells[5].Value = user.Function; + troubleTicketsDataGridView.Rows[i].Cells[6].Value = user.Department; } else { - listTTDataGridView.Rows[i].Cells[5].Style.BackColor = Color.Gray; - listTTDataGridView.Rows[i].Cells[6].Style.BackColor = Color.Gray; + troubleTicketsDataGridView.Rows[i].Cells[5].Style.BackColor = Color.Gray; + troubleTicketsDataGridView.Rows[i].Cells[6].Style.BackColor = Color.Gray; } } - listTTDataGridView.ClearSelection(); + troubleTicketsDataGridView.ClearSelection(); } - private void FillTrubleTicketsDataGreedView(List allTrubleTickets) + private void FillTroubleTicketsDataGridView(List allTroubleTickets) { - AddColumnsTrubleTicketsDataGreedView(); + AddColumnsTroubleTicketsDataGridView(); - listTTDataGridView.Rows.Clear(); + troubleTicketsDataGridView.Rows.Clear(); - var countRow = allTrubleTickets.Count; + var countRow = allTroubleTickets.Count; var allUsers = provider.GetAllUsers(); for (int i = 0; i < countRow; i++) { - var user = allUsers.Where(u => u.Id == allTrubleTickets[i].CreateUser).FirstOrDefault(); - var resolveUser = allUsers.Where(u => u.Id == allTrubleTickets[i].ResolveUser).FirstOrDefault(); + var user = allUsers.Where(u => u.Id == allTroubleTickets[i].CreateUser).FirstOrDefault(); + var resolveUser = allUsers.Where(u => u.Id == allTroubleTickets[i].ResolveUser).FirstOrDefault(); - listTTDataGridView.Rows.Add(); + troubleTicketsDataGridView.Rows.Add(); - listTTDataGridView.Rows[i].Cells[0].Value = allTrubleTickets[i].Id; + troubleTicketsDataGridView.Rows[i].Cells[0].Value = allTroubleTickets[i].Id; - if (allTrubleTickets[i].IsSolved) + if (allTroubleTickets[i].IsSolved) { - listTTDataGridView.Rows[i].Cells[1].Value = "Да"; - listTTDataGridView.Rows[i].DefaultCellStyle.BackColor = allTrubleTickets[i].Status == "Выполнена" ? Color.LightGreen : Color.LightGray; + troubleTicketsDataGridView.Rows[i].Cells[1].Value = "Да"; + troubleTicketsDataGridView.Rows[i].DefaultCellStyle.BackColor = allTroubleTickets[i].Status == "Выполнена" ? Color.LightGreen : Color.LightGray; } else { - listTTDataGridView.Rows[i].Cells[1].Value = "Нет"; + troubleTicketsDataGridView.Rows[i].Cells[1].Value = "Нет"; - if ((DateTime.Now - allTrubleTickets[i].Deadline).TotalSeconds > 0) + if ((DateTime.Now - allTroubleTickets[i].Deadline).TotalSeconds > 0) { - listTTDataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightSalmon; + troubleTicketsDataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightSalmon; } - if (allTrubleTickets[i].Status == "В работе") + if (allTroubleTickets[i].Status == "В работе") { - listTTDataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightYellow; + troubleTicketsDataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightYellow; } } - listTTDataGridView.Rows[i].Cells[2].Value = allTrubleTickets[i].Status; + troubleTicketsDataGridView.Rows[i].Cells[2].Value = allTroubleTickets[i].Status; - if (allTrubleTickets[i].Text.Length > 50) + if (allTroubleTickets[i].Text.Length > 50) { - listTTDataGridView.Rows[i].Cells[3].Value = $"{allTrubleTickets[i].Text.Substring(0, 47)}..."; + troubleTicketsDataGridView.Rows[i].Cells[3].Value = $"{allTroubleTickets[i].Text.Substring(0, 47)}..."; } else { - listTTDataGridView.Rows[i].Cells[3].Value = allTrubleTickets[i].Text; + troubleTicketsDataGridView.Rows[i].Cells[3].Value = allTroubleTickets[i].Text; } - listTTDataGridView.Rows[i].Cells[4].Value = allTrubleTickets[i].Resolve; - listTTDataGridView.Rows[i].Cells[5].Value = resolveUser != null ? resolveUser.Name : string.Empty; - listTTDataGridView.Rows[i].Cells[6].Value = allTrubleTickets[i].Created; - listTTDataGridView.Rows[i].Cells[7].Value = allTrubleTickets[i].ResolveTime; - listTTDataGridView.Rows[i].Cells[8].Value = allTrubleTickets[i].Deadline; - listTTDataGridView.Rows[i].Cells[9].Value = $"{user.Name} \\ {user.Email}"; + troubleTicketsDataGridView.Rows[i].Cells[4].Value = allTroubleTickets[i].Resolve; + troubleTicketsDataGridView.Rows[i].Cells[5].Value = resolveUser != null ? resolveUser.Name : string.Empty; + troubleTicketsDataGridView.Rows[i].Cells[6].Value = allTroubleTickets[i].Created; + troubleTicketsDataGridView.Rows[i].Cells[7].Value = allTroubleTickets[i].ResolveTime; + troubleTicketsDataGridView.Rows[i].Cells[8].Value = allTroubleTickets[i].Deadline; + troubleTicketsDataGridView.Rows[i].Cells[9].Value = $"{user.Name} \\ {user.Email}"; } - listTTDataGridView.ClearSelection(); + troubleTicketsDataGridView.ClearSelection(); } - private void AddColumnsTrubleTicketsDataGreedView() + private void AddColumnsTroubleTicketsDataGridView() { - listTTDataGridView.Columns.Add("id", "ID"); - listTTDataGridView.Columns.Add("isSolved", "Решён"); - listTTDataGridView.Columns.Add("status", "Статус"); - listTTDataGridView.Columns.Add("text", "Текст"); - listTTDataGridView.Columns.Add("resolve", "Решение"); - listTTDataGridView.Columns.Add("resolveUser", "Решил"); - listTTDataGridView.Columns.Add("created", "Создано"); - listTTDataGridView.Columns.Add("resolveDate", "Дата решения"); - listTTDataGridView.Columns.Add("deadline", "Крайний срок"); - listTTDataGridView.Columns.Add("userCreate", "Кем создано"); + troubleTicketsDataGridView.Columns.Add("id", "ID"); + troubleTicketsDataGridView.Columns.Add("isSolved", "Решён"); + troubleTicketsDataGridView.Columns.Add("status", "Статус"); + troubleTicketsDataGridView.Columns.Add("text", "Текст"); + troubleTicketsDataGridView.Columns.Add("resolve", "Решение"); + troubleTicketsDataGridView.Columns.Add("resolveUser", "Решил"); + troubleTicketsDataGridView.Columns.Add("created", "Создано"); + troubleTicketsDataGridView.Columns.Add("resolveDate", "Дата решения"); + troubleTicketsDataGridView.Columns.Add("deadline", "Крайний срок"); + troubleTicketsDataGridView.Columns.Add("userCreate", "Кем создано"); } } } \ No newline at end of file diff --git a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.Designer.cs index 15b8f55..89d1f3e 100644 --- a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.Designer.cs +++ b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.Designer.cs @@ -28,30 +28,30 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.label4 = new System.Windows.Forms.Label(); + this.nameLabel = new System.Windows.Forms.Label(); this.nameTextBox = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); + this.loginLabel = new System.Windows.Forms.Label(); this.loginTextBox = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); + this.passwordLabel = new System.Windows.Forms.Label(); this.passwordTextBox = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); + this.emailLabel = new System.Windows.Forms.Label(); this.emailTextBox = new System.Windows.Forms.TextBox(); this.registrationButton = new System.Windows.Forms.Button(); this.cancelButton = new System.Windows.Forms.Button(); this.exitButton = new System.Windows.Forms.Button(); - this.label5 = new System.Windows.Forms.Label(); + this.replyPasswordLabel = new System.Windows.Forms.Label(); this.replyPasswordTextBox = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // - // label4 + // nameLabel // - this.label4.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label4.Location = new System.Drawing.Point(12, 5); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(279, 30); - this.label4.TabIndex = 0; - this.label4.Text = "&Имя"; - this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.nameLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.nameLabel.Location = new System.Drawing.Point(12, 5); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(279, 30); + this.nameLabel.TabIndex = 0; + this.nameLabel.Text = "&Имя"; + this.nameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // nameTextBox // @@ -60,15 +60,15 @@ private void InitializeComponent() this.nameTextBox.Size = new System.Drawing.Size(279, 23); this.nameTextBox.TabIndex = 1; // - // label1 + // loginLabel // - this.label1.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label1.Location = new System.Drawing.Point(12, 64); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(279, 30); - this.label1.TabIndex = 2; - this.label1.Text = "&Логин"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.loginLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.loginLabel.Location = new System.Drawing.Point(12, 64); + this.loginLabel.Name = "loginLabel"; + this.loginLabel.Size = new System.Drawing.Size(279, 30); + this.loginLabel.TabIndex = 2; + this.loginLabel.Text = "&Логин"; + this.loginLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // loginTextBox // @@ -77,15 +77,15 @@ private void InitializeComponent() this.loginTextBox.Size = new System.Drawing.Size(279, 23); this.loginTextBox.TabIndex = 3; // - // label2 + // passwordLabel // - this.label2.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label2.Location = new System.Drawing.Point(12, 123); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(279, 30); - this.label2.TabIndex = 4; - this.label2.Text = "&Пароль"; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.passwordLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.passwordLabel.Location = new System.Drawing.Point(12, 123); + this.passwordLabel.Name = "passwordLabel"; + this.passwordLabel.Size = new System.Drawing.Size(279, 30); + this.passwordLabel.TabIndex = 4; + this.passwordLabel.Text = "&Пароль"; + this.passwordLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // passwordTextBox // @@ -95,15 +95,15 @@ private void InitializeComponent() this.passwordTextBox.TabIndex = 5; this.passwordTextBox.UseSystemPasswordChar = true; // - // label3 + // emailLabel // - this.label3.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label3.Location = new System.Drawing.Point(12, 241); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(279, 30); - this.label3.TabIndex = 8; - this.label3.Text = "&E-Mail"; - this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.emailLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.emailLabel.Location = new System.Drawing.Point(12, 241); + this.emailLabel.Name = "emailLabel"; + this.emailLabel.Size = new System.Drawing.Size(279, 30); + this.emailLabel.TabIndex = 8; + this.emailLabel.Text = "&E-Mail"; + this.emailLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // emailTextBox // @@ -142,15 +142,15 @@ private void InitializeComponent() this.exitButton.Text = "Выход"; this.exitButton.UseVisualStyleBackColor = true; // - // label5 + // replyPasswordLabel // - this.label5.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label5.Location = new System.Drawing.Point(12, 182); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(279, 30); - this.label5.TabIndex = 6; - this.label5.Text = "Повторите пароль"; - this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.replyPasswordLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.replyPasswordLabel.Location = new System.Drawing.Point(12, 182); + this.replyPasswordLabel.Name = "replyPasswordLabel"; + this.replyPasswordLabel.Size = new System.Drawing.Size(279, 30); + this.replyPasswordLabel.TabIndex = 6; + this.replyPasswordLabel.Text = "Повторите пароль"; + this.replyPasswordLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // replyPasswordTextBox // @@ -169,18 +169,18 @@ private void InitializeComponent() this.ClientSize = new System.Drawing.Size(303, 437); this.ControlBox = false; this.Controls.Add(this.replyPasswordTextBox); - this.Controls.Add(this.label5); + this.Controls.Add(this.replyPasswordLabel); this.Controls.Add(this.exitButton); this.Controls.Add(this.cancelButton); this.Controls.Add(this.registrationButton); this.Controls.Add(this.nameTextBox); - this.Controls.Add(this.label4); + this.Controls.Add(this.nameLabel); this.Controls.Add(this.loginTextBox); - this.Controls.Add(this.label1); + this.Controls.Add(this.loginLabel); this.Controls.Add(this.passwordTextBox); - this.Controls.Add(this.label2); + this.Controls.Add(this.passwordLabel); this.Controls.Add(this.emailTextBox); - this.Controls.Add(this.label3); + this.Controls.Add(this.emailLabel); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "RegistrationForm"; @@ -195,18 +195,18 @@ private void InitializeComponent() #endregion - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label loginLabel; + private System.Windows.Forms.Label passwordLabel; private System.Windows.Forms.TextBox passwordTextBox; - private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label emailLabel; private System.Windows.Forms.TextBox emailTextBox; - private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label nameLabel; private System.Windows.Forms.TextBox nameTextBox; private System.Windows.Forms.Button registrationButton; private System.Windows.Forms.Button cancelButton; private System.Windows.Forms.Button exitButton; public System.Windows.Forms.TextBox loginTextBox; - private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label replyPasswordLabel; private System.Windows.Forms.TextBox replyPasswordTextBox; } } \ No newline at end of file diff --git a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.Designer.cs new file mode 100644 index 0000000..0ba5e63 --- /dev/null +++ b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.Designer.cs @@ -0,0 +1,185 @@ +namespace HelpDeskWinFormsApp +{ + partial class TroubleTicketForm + { + /// + /// 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.userCreateLabel = new System.Windows.Forms.Label(); + this.userCreateTextBox = new System.Windows.Forms.TextBox(); + this.troubleTicketRichLabel = new System.Windows.Forms.Label(); + this.troubleTicketRichTextBox = new System.Windows.Forms.RichTextBox(); + this.resolveRichLabel = new System.Windows.Forms.Label(); + this.resolveRichTextBox = new System.Windows.Forms.RichTextBox(); + this.saveButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.statusLabel = new System.Windows.Forms.Label(); + this.statusTroubleTicketComboBox = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // userCreateLabel + // + this.userCreateLabel.AutoSize = true; + this.userCreateLabel.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.userCreateLabel.Location = new System.Drawing.Point(12, 9); + this.userCreateLabel.Name = "userCreateLabel"; + this.userCreateLabel.Size = new System.Drawing.Size(89, 19); + this.userCreateLabel.TabIndex = 0; + this.userCreateLabel.Text = "Кем создано"; + // + // userCreateTextBox + // + this.userCreateTextBox.Location = new System.Drawing.Point(12, 31); + this.userCreateTextBox.Name = "userCreateTextBox"; + this.userCreateTextBox.ReadOnly = true; + this.userCreateTextBox.Size = new System.Drawing.Size(380, 23); + this.userCreateTextBox.TabIndex = 1; + // + // troubleTicketRichLabel + // + this.troubleTicketRichLabel.AutoSize = true; + this.troubleTicketRichLabel.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.troubleTicketRichLabel.Location = new System.Drawing.Point(12, 57); + this.troubleTicketRichLabel.Name = "troubleTicketRichLabel"; + this.troubleTicketRichLabel.Size = new System.Drawing.Size(119, 19); + this.troubleTicketRichLabel.TabIndex = 2; + this.troubleTicketRichLabel.Text = "Текст обращения"; + // + // troubleTicketRichTextBox + // + this.troubleTicketRichTextBox.Location = new System.Drawing.Point(12, 79); + this.troubleTicketRichTextBox.Name = "trubleTicketRichTextBox"; + this.troubleTicketRichTextBox.ReadOnly = true; + this.troubleTicketRichTextBox.Size = new System.Drawing.Size(380, 244); + this.troubleTicketRichTextBox.TabIndex = 3; + this.troubleTicketRichTextBox.Text = ""; + // + // resolveRichLabel + // + this.resolveRichLabel.AutoSize = true; + this.resolveRichLabel.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.resolveRichLabel.Location = new System.Drawing.Point(12, 326); + this.resolveRichLabel.Name = "resolveRichLabel"; + this.resolveRichLabel.Size = new System.Drawing.Size(65, 19); + this.resolveRichLabel.TabIndex = 4; + this.resolveRichLabel.Text = "Решение"; + // + // resolveRichTextBox + // + this.resolveRichTextBox.Location = new System.Drawing.Point(12, 348); + this.resolveRichTextBox.Name = "resolveRichTextBox"; + this.resolveRichTextBox.Size = new System.Drawing.Size(380, 165); + this.resolveRichTextBox.TabIndex = 5; + this.resolveRichTextBox.Text = ""; + // + // saveButton + // + this.saveButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.saveButton.Location = new System.Drawing.Point(12, 582); + this.saveButton.Name = "saveButton"; + this.saveButton.Size = new System.Drawing.Size(380, 37); + this.saveButton.TabIndex = 6; + this.saveButton.Text = "&Сохранить"; + this.saveButton.UseVisualStyleBackColor = true; + // + // cancelButton + // + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(12, 625); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(380, 37); + this.cancelButton.TabIndex = 7; + this.cancelButton.Text = "&Закрыть"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // statusLabel + // + this.statusLabel.AutoSize = true; + this.statusLabel.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.statusLabel.Location = new System.Drawing.Point(12, 516); + this.statusLabel.Name = "statusLabel"; + this.statusLabel.Size = new System.Drawing.Size(50, 19); + this.statusLabel.TabIndex = 8; + this.statusLabel.Text = "Статус"; + // + // statusTroubleTicketComboBox + // + this.statusTroubleTicketComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.statusTroubleTicketComboBox.FormattingEnabled = true; + this.statusTroubleTicketComboBox.Items.AddRange(new object[] { + "Зарегистрирована", + "В работе", + "Выполнена", + "Отклонена"}); + this.statusTroubleTicketComboBox.Location = new System.Drawing.Point(12, 538); + this.statusTroubleTicketComboBox.Name = "statusTrubleTicketComboBox"; + this.statusTroubleTicketComboBox.Size = new System.Drawing.Size(380, 23); + this.statusTroubleTicketComboBox.TabIndex = 9; + // + // TrubleTicketForm + // + this.AcceptButton = this.saveButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.cancelButton; + this.ClientSize = new System.Drawing.Size(404, 673); + this.ControlBox = false; + this.Controls.Add(this.statusTroubleTicketComboBox); + this.Controls.Add(this.statusLabel); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.saveButton); + this.Controls.Add(this.resolveRichTextBox); + this.Controls.Add(this.resolveRichLabel); + this.Controls.Add(this.troubleTicketRichTextBox); + this.Controls.Add(this.troubleTicketRichLabel); + this.Controls.Add(this.userCreateTextBox); + this.Controls.Add(this.userCreateLabel); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TrubleTicketForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "TrubleTicketForm"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TroubleTicketForm_FormClosing); + this.Shown += new System.EventHandler(this.TroubleTicketForm_Shown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label userCreateLabel; + private System.Windows.Forms.TextBox userCreateTextBox; + private System.Windows.Forms.Label troubleTicketRichLabel; + private System.Windows.Forms.RichTextBox troubleTicketRichTextBox; + private System.Windows.Forms.Label resolveRichLabel; + private System.Windows.Forms.RichTextBox resolveRichTextBox; + private System.Windows.Forms.Button saveButton; + private System.Windows.Forms.Button cancelButton; + private System.Windows.Forms.Label statusLabel; + private System.Windows.Forms.ComboBox statusTroubleTicketComboBox; + } +} \ No newline at end of file diff --git a/HelpDesk/HelpDeskWinFormsApp/TrubleTicketForm.cs b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs similarity index 51% rename from HelpDesk/HelpDeskWinFormsApp/TrubleTicketForm.cs rename to HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs index 29d9932..178a63a 100644 --- a/HelpDesk/HelpDeskWinFormsApp/TrubleTicketForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs @@ -4,17 +4,17 @@ namespace HelpDeskWinFormsApp { - public partial class TrubleTicketForm : Form + public partial class TroubleTicketForm : Form { int ticketId; - TrubleTicket trubleTicket; + TroubleTicket troubleTicket; User userCreate; bool isEmployee; int resolveUserId; string lastStatus; private readonly IProvider provider; - public TrubleTicketForm(int ticketId, bool isEmployee, int resolveUserId, IProvider provider) + public TroubleTicketForm(int ticketId, bool isEmployee, int resolveUserId, IProvider provider) { InitializeComponent(); this.ticketId = ticketId; @@ -23,23 +23,23 @@ public TrubleTicketForm(int ticketId, bool isEmployee, int resolveUserId, IProvi this.provider = provider; } - private void TrubleTicketForm_Shown(object sender, System.EventArgs e) + private void TroubleTicketForm_Shown(object sender, System.EventArgs e) { - trubleTicket = provider.GetTrubleTicket(ticketId); - userCreate = provider.GetUser(trubleTicket.CreateUser); - lastStatus = trubleTicket.Status; + troubleTicket = provider.GetTroubleTicket(ticketId); + userCreate = provider.GetUser(troubleTicket.CreateUser); + lastStatus = troubleTicket.Status; - Text = $"HelpDesk. Заяка №{trubleTicket.Id}"; + Text = $"HelpDesk. Заяка №{troubleTicket.Id}"; userCreateTextBox.Text = $"{userCreate.Name} \\ {userCreate.Email}"; - trubleTicketRichTextBox.Text = trubleTicket.Text; - statusTrubleTicketComboBox.Text = trubleTicket.Status; + troubleTicketRichTextBox.Text = troubleTicket.Text; + statusTroubleTicketComboBox.Text = troubleTicket.Status; - if (trubleTicket.Resolve != null) + if (troubleTicket.Resolve != null) { - resolveRichTextBox.Text = $"Заявка решена {trubleTicket.ResolveTime}\n\r"; - resolveRichTextBox.Text += trubleTicket.Resolve; + resolveRichTextBox.Text = $"Заявка решена {troubleTicket.ResolveTime}\n\r"; + resolveRichTextBox.Text += troubleTicket.Resolve; resolveRichTextBox.ReadOnly = true; - statusTrubleTicketComboBox.Enabled = false; + statusTroubleTicketComboBox.Enabled = false; saveButton.Enabled = false; } @@ -47,28 +47,28 @@ private void TrubleTicketForm_Shown(object sender, System.EventArgs e) { saveButton.Visible = false; resolveRichTextBox.Enabled = false; - statusTrubleTicketComboBox.Enabled = false; + statusTroubleTicketComboBox.Enabled = false; } } - private void TrubleTicketForm_FormClosing(object sender, FormClosingEventArgs e) + private void TroubleTicketForm_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult == DialogResult.OK) { - if (resolveRichTextBox.Text == string.Empty && (statusTrubleTicketComboBox.Text == "Выполнена" || statusTrubleTicketComboBox.Text == "Отклонена")) + if (resolveRichTextBox.Text == string.Empty && (statusTroubleTicketComboBox.Text == "Выполнена" || statusTroubleTicketComboBox.Text == "Отклонена")) { e.Cancel = true; MessageBox.Show("Пожалуйста заполните решение.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (statusTrubleTicketComboBox.Text != lastStatus) + if (statusTroubleTicketComboBox.Text != lastStatus) { - if (statusTrubleTicketComboBox.Text == "Выполнена" || statusTrubleTicketComboBox.Text == "Отклонена") + if (statusTroubleTicketComboBox.Text == "Выполнена" || statusTroubleTicketComboBox.Text == "Отклонена") { - provider.ResolveTrubleTicket(trubleTicket.Id, statusTrubleTicketComboBox.Text, resolveRichTextBox.Text, resolveUserId); + provider.ResolveTroubleTicket(troubleTicket.Id, statusTroubleTicketComboBox.Text, resolveRichTextBox.Text, resolveUserId); } - else if (statusTrubleTicketComboBox.Text == "Зарегистрирована" && lastStatus != "Зарегистрирована") + else if (statusTroubleTicketComboBox.Text == "Зарегистрирована" && lastStatus != "Зарегистрирована") { e.Cancel = true; MessageBox.Show("Возврат в статус \"Зарегистрирована\" запрещён.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -76,7 +76,7 @@ private void TrubleTicketForm_FormClosing(object sender, FormClosingEventArgs e) } else { - provider.ChangeStatusTrubleTicket(trubleTicket.Id, statusTrubleTicketComboBox.Text, resolveUserId); + provider.ChangeStatusTroubleTicket(troubleTicket.Id, statusTroubleTicketComboBox.Text, resolveUserId); } } } diff --git a/HelpDesk/HelpDeskWinFormsApp/TrubleTicketForm.resx b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.resx similarity index 100% rename from HelpDesk/HelpDeskWinFormsApp/TrubleTicketForm.resx rename to HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.resx diff --git a/HelpDesk/HelpDeskWinFormsApp/TrubleTicketForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/TrubleTicketForm.Designer.cs deleted file mode 100644 index fa8d46a..0000000 --- a/HelpDesk/HelpDeskWinFormsApp/TrubleTicketForm.Designer.cs +++ /dev/null @@ -1,185 +0,0 @@ -namespace HelpDeskWinFormsApp -{ - partial class TrubleTicketForm - { - /// - /// 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.label1 = new System.Windows.Forms.Label(); - this.userCreateTextBox = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.trubleTicketRichTextBox = new System.Windows.Forms.RichTextBox(); - this.label3 = new System.Windows.Forms.Label(); - this.resolveRichTextBox = new System.Windows.Forms.RichTextBox(); - this.saveButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.label4 = new System.Windows.Forms.Label(); - this.statusTrubleTicketComboBox = new System.Windows.Forms.ComboBox(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label1.Location = new System.Drawing.Point(12, 9); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(89, 19); - this.label1.TabIndex = 0; - this.label1.Text = "Кем создано"; - // - // userCreateTextBox - // - this.userCreateTextBox.Location = new System.Drawing.Point(12, 31); - this.userCreateTextBox.Name = "userCreateTextBox"; - this.userCreateTextBox.ReadOnly = true; - this.userCreateTextBox.Size = new System.Drawing.Size(380, 23); - this.userCreateTextBox.TabIndex = 1; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label2.Location = new System.Drawing.Point(12, 57); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(119, 19); - this.label2.TabIndex = 2; - this.label2.Text = "Текст обращения"; - // - // trubleTicketRichTextBox - // - this.trubleTicketRichTextBox.Location = new System.Drawing.Point(12, 79); - this.trubleTicketRichTextBox.Name = "trubleTicketRichTextBox"; - this.trubleTicketRichTextBox.ReadOnly = true; - this.trubleTicketRichTextBox.Size = new System.Drawing.Size(380, 244); - this.trubleTicketRichTextBox.TabIndex = 3; - this.trubleTicketRichTextBox.Text = ""; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label3.Location = new System.Drawing.Point(12, 326); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(65, 19); - this.label3.TabIndex = 4; - this.label3.Text = "Решение"; - // - // resolveRichTextBox - // - this.resolveRichTextBox.Location = new System.Drawing.Point(12, 348); - this.resolveRichTextBox.Name = "resolveRichTextBox"; - this.resolveRichTextBox.Size = new System.Drawing.Size(380, 165); - this.resolveRichTextBox.TabIndex = 5; - this.resolveRichTextBox.Text = ""; - // - // saveButton - // - this.saveButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.saveButton.Location = new System.Drawing.Point(12, 582); - this.saveButton.Name = "saveButton"; - this.saveButton.Size = new System.Drawing.Size(380, 37); - this.saveButton.TabIndex = 6; - this.saveButton.Text = "&Сохранить"; - this.saveButton.UseVisualStyleBackColor = true; - // - // cancelButton - // - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(12, 625); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(380, 37); - this.cancelButton.TabIndex = 7; - this.cancelButton.Text = "&Закрыть"; - this.cancelButton.UseVisualStyleBackColor = true; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.label4.Location = new System.Drawing.Point(12, 516); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(50, 19); - this.label4.TabIndex = 8; - this.label4.Text = "Статус"; - // - // statusTrubleTicketComboBox - // - this.statusTrubleTicketComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.statusTrubleTicketComboBox.FormattingEnabled = true; - this.statusTrubleTicketComboBox.Items.AddRange(new object[] { - "Зарегистрирована", - "В работе", - "Выполнена", - "Отклонена"}); - this.statusTrubleTicketComboBox.Location = new System.Drawing.Point(12, 538); - this.statusTrubleTicketComboBox.Name = "statusTrubleTicketComboBox"; - this.statusTrubleTicketComboBox.Size = new System.Drawing.Size(380, 23); - this.statusTrubleTicketComboBox.TabIndex = 9; - // - // TrubleTicketForm - // - this.AcceptButton = this.saveButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(404, 673); - this.ControlBox = false; - this.Controls.Add(this.statusTrubleTicketComboBox); - this.Controls.Add(this.label4); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.saveButton); - this.Controls.Add(this.resolveRichTextBox); - this.Controls.Add(this.label3); - this.Controls.Add(this.trubleTicketRichTextBox); - this.Controls.Add(this.label2); - this.Controls.Add(this.userCreateTextBox); - this.Controls.Add(this.label1); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "TrubleTicketForm"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "TrubleTicketForm"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TrubleTicketForm_FormClosing); - this.Shown += new System.EventHandler(this.TrubleTicketForm_Shown); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox userCreateTextBox; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.RichTextBox trubleTicketRichTextBox; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.RichTextBox resolveRichTextBox; - private System.Windows.Forms.Button saveButton; - private System.Windows.Forms.Button cancelButton; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.ComboBox statusTrubleTicketComboBox; - } -} \ No newline at end of file From 8d7a3605dbac124e9ffa13c5db11afb74748108d Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Thu, 4 Dec 2025 00:44:18 +0300 Subject: [PATCH 02/14] =?UTF-8?q?=D0=BD=D0=B0=D0=B8=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HelpDesk.Common/Models/TroubleTicket.cs | 14 ----- .../AddTroubleTicketForm.Designer.cs | 6 +- .../ExportForm.Designer.cs | 2 +- HelpDesk/HelpDeskWinFormsApp/ExportForm.cs | 22 +++---- .../HelpDeskWinFormsApp/MainForm.Designer.cs | 62 +++++++++---------- HelpDesk/HelpDeskWinFormsApp/MainForm.cs | 57 +++++++++-------- .../TroubleTicketForm.Designer.cs | 8 +-- 7 files changed, 80 insertions(+), 91 deletions(-) diff --git a/HelpDesk/HelpDesk.Common/Models/TroubleTicket.cs b/HelpDesk/HelpDesk.Common/Models/TroubleTicket.cs index b30c36c..fd8fb37 100644 --- a/HelpDesk/HelpDesk.Common/Models/TroubleTicket.cs +++ b/HelpDesk/HelpDesk.Common/Models/TroubleTicket.cs @@ -19,19 +19,5 @@ public class TroubleTicket public TroubleTicket() { } - [JsonConstructor] - private TroubleTicket(int id, string status, int createUser, string text, string? resolve, bool isSolved, DateTime created, DateTime? resolveTime, int? resolveUser, DateTime deadline) - { - Id = id; - Status = status; - CreateUser = createUser; - Text = text; - Resolve = resolve; - IsSolved = isSolved; - Created = created; - ResolveTime = resolveTime; - ResolveUser = resolveUser; - Deadline = deadline; - } } } diff --git a/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.Designer.cs index 400334d..614dc18 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.Designer.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.Designer.cs @@ -78,7 +78,7 @@ private void InitializeComponent() this.createTroubleTicketButton.DialogResult = System.Windows.Forms.DialogResult.OK; this.createTroubleTicketButton.Enabled = false; this.createTroubleTicketButton.Location = new System.Drawing.Point(12, 322); - this.createTroubleTicketButton.Name = "createTrubleTicketButton"; + this.createTroubleTicketButton.Name = "createTroubleTicketButton"; this.createTroubleTicketButton.Size = new System.Drawing.Size(378, 34); this.createTroubleTicketButton.TabIndex = 4; this.createTroubleTicketButton.Text = "&Создать заявку"; @@ -94,7 +94,7 @@ private void InitializeComponent() this.cancelButton.Text = "&Отмена"; this.cancelButton.UseVisualStyleBackColor = true; // - // AddTrubleTicketForm + // AddTroubleTicketForm // this.AcceptButton = this.createTroubleTicketButton; this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -109,7 +109,7 @@ private void InitializeComponent() this.Controls.Add(this.loginLabel); this.MaximizeBox = false; this.MinimizeBox = false; - this.Name = "AddTrubleTicketForm"; + this.Name = "AddTroubleTicketForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "HelpDesk Создание заявки"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.AddTroubleTicketForm_FormClosing); diff --git a/HelpDesk/HelpDeskWinFormsApp/ExportForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/ExportForm.Designer.cs index 35334a7..3ea5e6c 100644 --- a/HelpDesk/HelpDeskWinFormsApp/ExportForm.Designer.cs +++ b/HelpDesk/HelpDeskWinFormsApp/ExportForm.Designer.cs @@ -135,7 +135,7 @@ private void InitializeComponent() this.typeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.typeComboBox.FormattingEnabled = true; this.typeComboBox.Items.AddRange(new object[] { - "Truble Ticket", + "Trouble Ticket", "Пользователи"}); this.typeComboBox.Location = new System.Drawing.Point(176, 16); this.typeComboBox.Name = "typeComboBox"; diff --git a/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs b/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs index 48d4587..e6b5797 100644 --- a/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs @@ -58,10 +58,10 @@ private void ExportButton_Click(object sender, EventArgs e) return; } - var allTrubleTickets = provider.GetAllTroubleTickets(); + var allTroubleTickets = provider.GetAllTroubleTickets(); var trubleTickets = new List(); - foreach ( var tt in allTrubleTickets) + foreach ( var tt in allTroubleTickets) { if (tt.Created >= startDateTimePicker.Value && tt.Created <= endDateTimePicker.Value) { @@ -72,33 +72,33 @@ private void ExportButton_Click(object sender, EventArgs e) var users = provider.GetAllUsers(); var exportFile = exportFileDialog.FileName; - if (typeComboBox.Text == "Truble Ticket") + if (typeComboBox.Text == "Trouble Ticket") { if (statusFilterCheckBox.Checked) { - var tempTrubleTickets = new List(); + var tempTroubleTickets = new List(); foreach( var tt in trubleTickets) { if (tt.Status == statusFilterComboBox.Text) { - tempTrubleTickets.Add(tt); + tempTroubleTickets.Add(tt); } } trubleTickets.Clear(); - trubleTickets.AddRange(tempTrubleTickets); + trubleTickets.AddRange(tempTroubleTickets); } if (trubleTickets.Count != 0) { if (fileTypeComboBox.Text == "Excel (.xlsx)") { - ExcelTrubleTicketExport(trubleTickets, users, exportFile); + ExcelTroubleTicketExport(trubleTickets, users, exportFile); } else if (fileTypeComboBox.Text == "Comma-Separated Values (.csv)") { - CsvTrubleTicketExport(trubleTickets, users, exportFile); + CsvTroubleTicketExport(trubleTickets, users, exportFile); } } else @@ -148,7 +148,7 @@ private void ExportButton_Click(object sender, EventArgs e) } } - private void CsvTrubleTicketExport(List result, List users, string exportFile) + private void CsvTroubleTicketExport(List result, List users, string exportFile) { var rowsCount = result.Count; @@ -305,7 +305,7 @@ private void ExcelUsersExport(List users, string exportFile, bool onlyClie workBook.SaveAs(exportFile); } - private void ExcelTrubleTicketExport(List result, List users, string exportFile) + private void ExcelTroubleTicketExport(List result, List users, string exportFile) { var rowsCount = result.Count; @@ -353,7 +353,7 @@ private void ExcelTrubleTicketExport(List result, List user private void TypeComboBox_SelectedIndexChanged(object sender, EventArgs e) { - if (typeComboBox.Text == "Truble Ticket") + if (typeComboBox.Text == "Trouble Ticket") { startDateTimePicker.Enabled = true; endDateTimePicker.Enabled = true; diff --git a/HelpDesk/HelpDeskWinFormsApp/MainForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/MainForm.Designer.cs index 015b702..6d68fa8 100644 --- a/HelpDesk/HelpDeskWinFormsApp/MainForm.Designer.cs +++ b/HelpDesk/HelpDeskWinFormsApp/MainForm.Designer.cs @@ -58,8 +58,8 @@ private void InitializeComponent() this.loginToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.splitContainer = new System.Windows.Forms.SplitContainer(); this.editUserButton = new System.Windows.Forms.Button(); - this.addTrubleTicketbutton = new System.Windows.Forms.Button(); - this.openTrubleTicketButton = new System.Windows.Forms.Button(); + this.addTroubleTicketbutton = new System.Windows.Forms.Button(); + this.openTroubleTicketButton = new System.Windows.Forms.Button(); this.exitButton = new System.Windows.Forms.Button(); this.treeView = new System.Windows.Forms.TreeView(); this.troubleTicketsDataGridView = new System.Windows.Forms.DataGridView(); @@ -171,8 +171,8 @@ private void InitializeComponent() // splitContainer.Panel1 // this.splitContainer.Panel1.Controls.Add(this.editUserButton); - this.splitContainer.Panel1.Controls.Add(this.addTrubleTicketbutton); - this.splitContainer.Panel1.Controls.Add(this.openTrubleTicketButton); + this.splitContainer.Panel1.Controls.Add(this.addTroubleTicketbutton); + this.splitContainer.Panel1.Controls.Add(this.openTroubleTicketButton); this.splitContainer.Panel1.Controls.Add(this.exitButton); this.splitContainer.Panel1.Controls.Add(this.treeView); this.splitContainer.Panel1.Resize += new System.EventHandler(this.SplitContainer_Panel1_Resize); @@ -195,25 +195,25 @@ private void InitializeComponent() this.editUserButton.UseVisualStyleBackColor = true; this.editUserButton.Click += new System.EventHandler(this.EditUserButton_Click); // - // addTrubleTicketbutton + // addTroubleTicketbutton // - this.addTrubleTicketbutton.Location = new System.Drawing.Point(3, 551); - this.addTrubleTicketbutton.Name = "addTrubleTicketbutton"; - this.addTrubleTicketbutton.Size = new System.Drawing.Size(158, 23); - this.addTrubleTicketbutton.TabIndex = 3; - this.addTrubleTicketbutton.Text = "&Создать заявку"; - this.addTrubleTicketbutton.UseVisualStyleBackColor = true; - this.addTrubleTicketbutton.Click += new System.EventHandler(this.AddTroubleTicketButton_Click); + this.addTroubleTicketbutton.Location = new System.Drawing.Point(3, 551); + this.addTroubleTicketbutton.Name = "addTroubleTicketbutton"; + this.addTroubleTicketbutton.Size = new System.Drawing.Size(158, 23); + this.addTroubleTicketbutton.TabIndex = 3; + this.addTroubleTicketbutton.Text = "&Создать заявку"; + this.addTroubleTicketbutton.UseVisualStyleBackColor = true; + this.addTroubleTicketbutton.Click += new System.EventHandler(this.AddTroubleTicketButton_Click); // - // openTrubleTicketButton + // openTroubleTicketButton // - this.openTrubleTicketButton.Location = new System.Drawing.Point(3, 522); - this.openTrubleTicketButton.Name = "openTrubleTicketButton"; - this.openTrubleTicketButton.Size = new System.Drawing.Size(158, 23); - this.openTrubleTicketButton.TabIndex = 2; - this.openTrubleTicketButton.Text = "&Открыть ТТ"; - this.openTrubleTicketButton.UseVisualStyleBackColor = true; - this.openTrubleTicketButton.Click += new System.EventHandler(this.OpenTrubleTicketButton_Click); + this.openTroubleTicketButton.Location = new System.Drawing.Point(3, 522); + this.openTroubleTicketButton.Name = "openTroubleTicketButton"; + this.openTroubleTicketButton.Size = new System.Drawing.Size(158, 23); + this.openTroubleTicketButton.TabIndex = 2; + this.openTroubleTicketButton.Text = "&Открыть ТТ"; + this.openTroubleTicketButton.UseVisualStyleBackColor = true; + this.openTroubleTicketButton.Click += new System.EventHandler(this.OpenTroubleTicketButton_Click); // // exitButton // @@ -229,23 +229,23 @@ private void InitializeComponent() // this.treeView.Location = new System.Drawing.Point(0, 0); this.treeView.Name = "treeView"; - treeNode1.Name = "allTrubleTicket"; + treeNode1.Name = "allTroubleTicket"; treeNode1.Text = "Все ТТ"; - treeNode2.Name = "openTrubleTicket"; + treeNode2.Name = "openTroubleTicket"; treeNode2.Text = "Открытые ТТ"; - treeNode3.Name = "closedTrubleTicket"; + treeNode3.Name = "closedTroubleTicket"; treeNode3.Text = "Закрытые ТТ"; - treeNode4.Name = "overdueTrubleTicketNode"; + treeNode4.Name = "overdueTroubleTicketNode"; treeNode4.Text = "Просроченные ТТ"; - treeNode5.Name = "registeredTrubleTicketNode"; + treeNode5.Name = "registeredTroubleTicketNode"; treeNode5.Text = "Зарегистрирован"; - treeNode6.Name = "workTrubleTicketNode"; + treeNode6.Name = "workTroubleTicketNode"; treeNode6.Text = "В работе"; - treeNode7.Name = "completedTrubleTicketNode"; + treeNode7.Name = "completedTroubleTicketNode"; treeNode7.Text = "Выполнен"; - treeNode8.Name = "rejectedTrubleTicketNode"; + treeNode8.Name = "rejectedTroubleTicketNode"; treeNode8.Text = "Отклонен"; - treeNode9.Name = "statusTrubleTicketNode"; + treeNode9.Name = "statusTroubleTicketNode"; treeNode9.Text = "Статус ТТ"; treeNode10.Name = "trubleTicketlist"; treeNode10.Text = "Лента ТТ"; @@ -322,9 +322,9 @@ private void InitializeComponent() private System.Windows.Forms.SplitContainer splitContainer; private System.Windows.Forms.TreeView treeView; private System.Windows.Forms.DataGridView troubleTicketsDataGridView; - private System.Windows.Forms.Button openTrubleTicketButton; + private System.Windows.Forms.Button openTroubleTicketButton; private System.Windows.Forms.Button exitButton; - private System.Windows.Forms.Button addTrubleTicketbutton; + private System.Windows.Forms.Button addTroubleTicketbutton; private System.Windows.Forms.Button editUserButton; private System.Windows.Forms.ToolStripMenuItem refreshToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exportToolStripMenuItem; diff --git a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs index 4300e5c..ddd43d0 100644 --- a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs @@ -29,7 +29,7 @@ public void GetProvider() private void MainForm_Load(object sender, EventArgs e) { - string login = AuthorizationUser(); + var login = AuthorizationUser(); if (login != string.Empty) { @@ -44,12 +44,17 @@ private void MainForm_Load(object sender, EventArgs e) troubleTicketsDataGridView.Size = splitContainer.Panel2.Size; - userNameToolStripStatusLabel.Text = $"Имя: {user.Name}"; - loginToolStripStatusLabel.Text = $"Логин: {user.Login}"; - userNameToolStripMenuItem.Text = $"&{user.Name}"; + UpdateUserInfoUI(); } } + private void UpdateUserInfoUI() + { + userNameToolStripStatusLabel.Text = $"Имя: {user.Name}"; + loginToolStripStatusLabel.Text = $"Логин: {user.Login}"; + userNameToolStripMenuItem.Text = $"&{user.Name}"; + } + private void ShowExportSubMenu() { if (!user.IsEmployee) @@ -82,9 +87,7 @@ private void LogoutToolStripMenuItem_Click(object sender, EventArgs e) SetHeaderWindowText(); - userNameToolStripStatusLabel.Text = $"Имя: {user.Name}"; - loginToolStripStatusLabel.Text = $"Логин: {user.Login}"; - userNameToolStripMenuItem.Text = $"&{user.Name}"; + UpdateUserInfoUI(); treeView.SelectedNode = treeView.Nodes[0]; ShowUserTreeNode(); @@ -97,9 +100,9 @@ private void SplitContainer_Panel1_Resize(object sender, EventArgs e) { treeView.Width = splitContainer.Panel1.Width; treeView.Height = splitContainer.Panel1.Height - 152; - editUserButton.Location = new Point(openTrubleTicketButton.Location.X, splitContainer.Panel1.Height - 117); - openTrubleTicketButton.Location = new Point(openTrubleTicketButton.Location.X, splitContainer.Panel1.Height - 88); - addTrubleTicketbutton.Location = new Point(openTrubleTicketButton.Location.X, splitContainer.Panel1.Height - 59); + editUserButton.Location = new Point(openTroubleTicketButton.Location.X, splitContainer.Panel1.Height - 117); + openTroubleTicketButton.Location = new Point(openTroubleTicketButton.Location.X, splitContainer.Panel1.Height - 88); + addTroubleTicketbutton.Location = new Point(openTroubleTicketButton.Location.X, splitContainer.Panel1.Height - 59); exitButton.Location = new Point(exitButton.Location.X, splitContainer.Panel1.Height - 30); } @@ -108,7 +111,7 @@ private void SplitContainer_Panel2_Resize(object sender, EventArgs e) troubleTicketsDataGridView.Size = splitContainer.Panel2.Size; } - private void OpenTrubleTicketButton_Click(object sender, EventArgs e) + private void OpenTroubleTicketButton_Click(object sender, EventArgs e) { if (troubleTicketsDataGridView.SelectedRows.Count != 0) { @@ -136,7 +139,7 @@ private void AddTroubleTicketButton_Click(object sender, EventArgs e) if (dialogResult.ShowDialog() == DialogResult.OK) { - treeView.SelectedNode = treeView.Nodes["trubleTicketlist"].Nodes["openTrubleTicket"]; + treeView.SelectedNode = treeView.Nodes["trubleTicketlist"].Nodes["openTroubleTicket"]; RefreshTroubleTicketsDataGrid(); } } @@ -150,9 +153,9 @@ private void ListTTDataGridView_DoubleClick(object sender, EventArgs e) { if (treeView.SelectedNode.Level != 0) { - if (treeView.SelectedNode.Parent.Name == "trubleTicketlist" || treeView.SelectedNode.Parent.Name == "statusTrubleTicketNode") + if (treeView.SelectedNode.Parent.Name == "trubleTicketlist" || treeView.SelectedNode.Parent.Name == "statusTroubleTicketNode") { - openTrubleTicketButton.PerformClick(); + openTroubleTicketButton.PerformClick(); } if (treeView.SelectedNode.Parent.Name == "usersNode") @@ -193,24 +196,24 @@ private void RefreshToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView.SelectedNode.Level != 0) { - if (treeView.SelectedNode.Parent.Name == "trubleTicketlist" || treeView.SelectedNode.Parent.Name == "statusTrubleTicketNode") + if (treeView.SelectedNode.Parent.Name == "trubleTicketlist" || treeView.SelectedNode.Parent.Name == "statusTroubleTicketNode") { RefreshTroubleTicketsDataGrid(); editUserButton.Enabled = false; - openTrubleTicketButton.Enabled = true; + openTroubleTicketButton.Enabled = true; } if (treeView.SelectedNode.Parent.Name == "usersNode") { RefreshUsersDataGrid(); editUserButton.Enabled = true; - openTrubleTicketButton.Enabled = false; + openTroubleTicketButton.Enabled = false; } } else { editUserButton.Enabled = false; - openTrubleTicketButton.Enabled = false; + openTroubleTicketButton.Enabled = false; } } @@ -336,7 +339,7 @@ private void RefreshTroubleTicketsDataGrid() { var selectedNode = treeView.SelectedNode.Name; - if (selectedNode == "statusTrubleTicketNode") + if (selectedNode == "statusTroubleTicketNode") { return; } @@ -356,28 +359,28 @@ private void RefreshTroubleTicketsDataGrid() switch (selectedNode) { - case "allTrubleTicket": + case "allTroubleTicket": FillTroubleTicketsDataGridView(troubleTickets); break; - case "openTrubleTicket": + case "openTroubleTicket": FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.IsSolved == false).ToList()); break; - case "closedTrubleTicket": + case "closedTroubleTicket": FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.IsSolved == true).ToList()); break; - case "overdueTrubleTicketNode": + case "overdueTroubleTicketNode": FillTroubleTicketsDataGridView(troubleTickets.Where(s => (DateTime.Now - s.Deadline).TotalSeconds > 0).ToList()); break; - case "registeredTrubleTicketNode": + case "registeredTroubleTicketNode": FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.Status == "Зарегистрирована").ToList()); break; - case "workTrubleTicketNode": + case "workTroubleTicketNode": FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.Status == "В работе").ToList()); break; - case "completedTrubleTicketNode": + case "completedTroubleTicketNode": FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.Status == "Выполнена").ToList()); break; - case "rejectedTrubleTicketNode": + case "rejectedTroubleTicketNode": FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.Status == "Отклонена").ToList()); break; default: diff --git a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.Designer.cs index 0ba5e63..3aae98a 100644 --- a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.Designer.cs +++ b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.Designer.cs @@ -135,11 +135,11 @@ private void InitializeComponent() "Выполнена", "Отклонена"}); this.statusTroubleTicketComboBox.Location = new System.Drawing.Point(12, 538); - this.statusTroubleTicketComboBox.Name = "statusTrubleTicketComboBox"; + this.statusTroubleTicketComboBox.Name = "statusTroubleTicketComboBox"; this.statusTroubleTicketComboBox.Size = new System.Drawing.Size(380, 23); this.statusTroubleTicketComboBox.TabIndex = 9; // - // TrubleTicketForm + // TroubleTicketForm // this.AcceptButton = this.saveButton; this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -159,9 +159,9 @@ private void InitializeComponent() this.Controls.Add(this.userCreateLabel); this.MaximizeBox = false; this.MinimizeBox = false; - this.Name = "TrubleTicketForm"; + this.Name = "TroubleTicketForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "TrubleTicketForm"; + this.Text = "TroubleTicketForm"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TroubleTicketForm_FormClosing); this.Shown += new System.EventHandler(this.TroubleTicketForm_Shown); this.ResumeLayout(false); From b337a369c50c5b5bf93f7c7ce4913ac311899109 Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Thu, 4 Dec 2025 19:53:14 +0300 Subject: [PATCH 03/14] =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20=20AppCo?= =?UTF-8?q?nstants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HelpDesk/HelpDeskWinFormsApp/AppConstants.cs | 37 ++++ .../AuthorizationForm.Designer.cs | 50 +++--- .../AuthorizationForm.resx | 8 +- HelpDesk/HelpDeskWinFormsApp/MainForm.cs | 168 ++++++++++-------- 4 files changed, 159 insertions(+), 104 deletions(-) create mode 100644 HelpDesk/HelpDeskWinFormsApp/AppConstants.cs diff --git a/HelpDesk/HelpDeskWinFormsApp/AppConstants.cs b/HelpDesk/HelpDeskWinFormsApp/AppConstants.cs new file mode 100644 index 0000000..62c3b6c --- /dev/null +++ b/HelpDesk/HelpDeskWinFormsApp/AppConstants.cs @@ -0,0 +1,37 @@ +namespace HelpDeskWinFormsApp +{ + public static class AppConstants + { + public const string TreeNodeTrubleTicketList = "trubleTicketlist"; + public const string TreeNodeStatusTroubleTicket = "statusTroubleTicketNode"; + public const string TreeNodeUsers = "usersNode"; + public const string TreeNodeAllUsers = "allUsersNode"; + public const string TreeNodeClients = "clientsNode"; + public const string TreeNodeEmployees = "EmployeeNode"; + public const string TreeNodeAllTroubleTickets = "allTroubleTicket"; + public const string TreeNodeOpenTroubleTickets = "openTroubleTicket"; + public const string TreeNodeClosedTroubleTickets = "closedTroubleTicket"; + public const string TreeNodeOverdueTroubleTickets = "overdueTroubleTicketNode"; + public const string TreeNodeRegisteredTroubleTickets = "registeredTroubleTicketNode"; + public const string TreeNodeWorkTroubleTickets = "workTroubleTicketNode"; + public const string TreeNodeCompletedTroubleTickets = "completedTroubleTicketNode"; + public const string TreeNodeRejectedTroubleTickets = "rejectedTroubleTicketNode"; + + public const string StatusRegistered = "Зарегистрирована"; + public const string StatusInProgress = "В работе"; + public const string StatusCompleted = "Выполнена"; + public const string StatusRejected = "Отклонена"; + + public const string DepartmentTechnicalSupport = "Техническая поддержка"; + + public const int TreeViewBottomMargin = 152; + public const int EditButtonOffset = 117; + public const int OpenButtonOffset = 88; + public const int AddButtonOffset = 59; + public const int ExitButtonOffset = 30; + public const int TextPreviewLength = 50; + public const int TextPreviewEllipsisLength = 47; + + public const int InvalidUserId = -1; + } +} diff --git a/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.Designer.cs index 0a3fcd5..2c9f4e1 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.Designer.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.Designer.cs @@ -46,26 +46,28 @@ private void InitializeComponent() // loginTextBox // loginTextBox.Enabled = false; - loginTextBox.Location = new System.Drawing.Point(12, 75); - loginTextBox.Name = "LoginTextBox"; - loginTextBox.Size = new System.Drawing.Size(279, 23); + loginTextBox.Location = new System.Drawing.Point(14, 100); + loginTextBox.Margin = new Padding(3, 4, 3, 4); + loginTextBox.Name = "loginTextBox"; + loginTextBox.Size = new System.Drawing.Size(318, 27); loginTextBox.TabIndex = 0; // // passwordTextBox // passwordTextBox.Enabled = false; - passwordTextBox.Location = new System.Drawing.Point(12, 139); - passwordTextBox.Name = "PasswordTextBox"; - passwordTextBox.Size = new System.Drawing.Size(279, 23); + passwordTextBox.Location = new System.Drawing.Point(14, 185); + passwordTextBox.Margin = new Padding(3, 4, 3, 4); + passwordTextBox.Name = "passwordTextBox"; + passwordTextBox.Size = new System.Drawing.Size(318, 27); passwordTextBox.TabIndex = 1; passwordTextBox.UseSystemPasswordChar = true; // // loginLabel // loginLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - loginLabel.Location = new System.Drawing.Point(12, 42); + loginLabel.Location = new System.Drawing.Point(14, 56); loginLabel.Name = "loginLabel"; - loginLabel.Size = new System.Drawing.Size(279, 30); + loginLabel.Size = new System.Drawing.Size(319, 40); loginLabel.TabIndex = 2; loginLabel.Text = "&Логин"; loginLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -73,9 +75,9 @@ private void InitializeComponent() // passwordLabel // passwordLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - passwordLabel.Location = new System.Drawing.Point(12, 101); + passwordLabel.Location = new System.Drawing.Point(14, 135); passwordLabel.Name = "passwordLabel"; - passwordLabel.Size = new System.Drawing.Size(279, 35); + passwordLabel.Size = new System.Drawing.Size(319, 47); passwordLabel.TabIndex = 3; passwordLabel.Text = "&Пароль"; passwordLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -84,9 +86,10 @@ private void InitializeComponent() // loginButton.DialogResult = DialogResult.OK; loginButton.Enabled = false; - loginButton.Location = new System.Drawing.Point(12, 202); + loginButton.Location = new System.Drawing.Point(14, 269); + loginButton.Margin = new Padding(3, 4, 3, 4); loginButton.Name = "loginButton"; - loginButton.Size = new System.Drawing.Size(279, 33); + loginButton.Size = new System.Drawing.Size(319, 44); loginButton.TabIndex = 4; loginButton.Text = "&Вход"; loginButton.UseVisualStyleBackColor = true; @@ -94,9 +97,10 @@ private void InitializeComponent() // cancelButton // cancelButton.DialogResult = DialogResult.Cancel; - cancelButton.Location = new System.Drawing.Point(12, 280); + cancelButton.Location = new System.Drawing.Point(14, 373); + cancelButton.Margin = new Padding(3, 4, 3, 4); cancelButton.Name = "cancelButton"; - cancelButton.Size = new System.Drawing.Size(279, 33); + cancelButton.Size = new System.Drawing.Size(319, 44); cancelButton.TabIndex = 5; cancelButton.Text = "В&ыход"; cancelButton.UseVisualStyleBackColor = true; @@ -104,9 +108,10 @@ private void InitializeComponent() // registrationButton // registrationButton.Enabled = false; - registrationButton.Location = new System.Drawing.Point(12, 241); + registrationButton.Location = new System.Drawing.Point(14, 321); + registrationButton.Margin = new Padding(3, 4, 3, 4); registrationButton.Name = "registrationButton"; - registrationButton.Size = new System.Drawing.Size(279, 33); + registrationButton.Size = new System.Drawing.Size(319, 44); registrationButton.TabIndex = 6; registrationButton.Text = "&Регистрация"; registrationButton.UseVisualStyleBackColor = true; @@ -114,10 +119,12 @@ private void InitializeComponent() // // mainMenuStrip // + mainMenuStrip.ImageScalingSize = new System.Drawing.Size(20, 20); mainMenuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem }); mainMenuStrip.Location = new System.Drawing.Point(0, 0); mainMenuStrip.Name = "mainMenuStrip"; - mainMenuStrip.Size = new System.Drawing.Size(303, 24); + mainMenuStrip.Padding = new Padding(7, 3, 0, 3); + mainMenuStrip.Size = new System.Drawing.Size(346, 30); mainMenuStrip.TabIndex = 9; mainMenuStrip.Text = "mainMenuStrip"; // @@ -125,23 +132,23 @@ private void InitializeComponent() // fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { exitToolStripMenuItem }); fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - fileToolStripMenuItem.Size = new System.Drawing.Size(48, 20); + fileToolStripMenuItem.Size = new System.Drawing.Size(59, 24); fileToolStripMenuItem.Text = "&Файл"; // // exitToolStripMenuItem // exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + exitToolStripMenuItem.Size = new System.Drawing.Size(136, 26); exitToolStripMenuItem.Text = "&Выход"; exitToolStripMenuItem.Click += ExitToolStripMenuItem_Click; // // AuthorizationForm // AcceptButton = loginButton; - AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; CancelButton = cancelButton; - ClientSize = new System.Drawing.Size(303, 328); + ClientSize = new System.Drawing.Size(346, 445); ControlBox = false; Controls.Add(registrationButton); Controls.Add(cancelButton); @@ -153,6 +160,7 @@ private void InitializeComponent() Controls.Add(mainMenuStrip); FormBorderStyle = FormBorderStyle.FixedDialog; MainMenuStrip = mainMenuStrip; + Margin = new Padding(3, 4, 3, 4); Name = "AuthorizationForm"; ShowIcon = false; StartPosition = FormStartPosition.CenterScreen; diff --git a/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.resx b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.resx index ef8ebb8..25af1eb 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.resx +++ b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.resx @@ -1,7 +1,7 @@  diff --git a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.Designer.cs b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.Designer.cs index 89d1f3e..612437e 100644 --- a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.Designer.cs +++ b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.Designer.cs @@ -28,168 +28,178 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.nameLabel = new System.Windows.Forms.Label(); - this.nameTextBox = new System.Windows.Forms.TextBox(); - this.loginLabel = new System.Windows.Forms.Label(); - this.loginTextBox = new System.Windows.Forms.TextBox(); - this.passwordLabel = new System.Windows.Forms.Label(); - this.passwordTextBox = new System.Windows.Forms.TextBox(); - this.emailLabel = new System.Windows.Forms.Label(); - this.emailTextBox = new System.Windows.Forms.TextBox(); - this.registrationButton = new System.Windows.Forms.Button(); - this.cancelButton = new System.Windows.Forms.Button(); - this.exitButton = new System.Windows.Forms.Button(); - this.replyPasswordLabel = new System.Windows.Forms.Label(); - this.replyPasswordTextBox = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); + nameLabel = new System.Windows.Forms.Label(); + nameTextBox = new System.Windows.Forms.TextBox(); + loginLabel = new System.Windows.Forms.Label(); + loginTextBox = new System.Windows.Forms.TextBox(); + passwordLabel = new System.Windows.Forms.Label(); + passwordTextBox = new System.Windows.Forms.TextBox(); + emailLabel = new System.Windows.Forms.Label(); + emailTextBox = new System.Windows.Forms.TextBox(); + registrationButton = new System.Windows.Forms.Button(); + cancelButton = new System.Windows.Forms.Button(); + exitButton = new System.Windows.Forms.Button(); + replyPasswordLabel = new System.Windows.Forms.Label(); + replyPasswordTextBox = new System.Windows.Forms.TextBox(); + SuspendLayout(); // // nameLabel // - this.nameLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.nameLabel.Location = new System.Drawing.Point(12, 5); - this.nameLabel.Name = "nameLabel"; - this.nameLabel.Size = new System.Drawing.Size(279, 30); - this.nameLabel.TabIndex = 0; - this.nameLabel.Text = "&Имя"; - this.nameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + nameLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + nameLabel.Location = new System.Drawing.Point(14, 7); + nameLabel.Name = "nameLabel"; + nameLabel.Size = new System.Drawing.Size(319, 40); + nameLabel.TabIndex = 0; + nameLabel.Text = "&Имя"; + nameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // nameTextBox // - this.nameTextBox.Location = new System.Drawing.Point(12, 38); - this.nameTextBox.Name = "nameTextBox"; - this.nameTextBox.Size = new System.Drawing.Size(279, 23); - this.nameTextBox.TabIndex = 1; + nameTextBox.Location = new System.Drawing.Point(14, 51); + nameTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + nameTextBox.Name = "nameTextBox"; + nameTextBox.Size = new System.Drawing.Size(318, 27); + nameTextBox.TabIndex = 1; // // loginLabel // - this.loginLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.loginLabel.Location = new System.Drawing.Point(12, 64); - this.loginLabel.Name = "loginLabel"; - this.loginLabel.Size = new System.Drawing.Size(279, 30); - this.loginLabel.TabIndex = 2; - this.loginLabel.Text = "&Логин"; - this.loginLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + loginLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + loginLabel.Location = new System.Drawing.Point(14, 85); + loginLabel.Name = "loginLabel"; + loginLabel.Size = new System.Drawing.Size(319, 40); + loginLabel.TabIndex = 2; + loginLabel.Text = "&Логин"; + loginLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // loginTextBox // - this.loginTextBox.Location = new System.Drawing.Point(12, 97); - this.loginTextBox.Name = "loginTextBox"; - this.loginTextBox.Size = new System.Drawing.Size(279, 23); - this.loginTextBox.TabIndex = 3; + loginTextBox.Location = new System.Drawing.Point(14, 129); + loginTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + loginTextBox.Name = "loginTextBox"; + loginTextBox.Size = new System.Drawing.Size(318, 27); + loginTextBox.TabIndex = 3; // // passwordLabel // - this.passwordLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.passwordLabel.Location = new System.Drawing.Point(12, 123); - this.passwordLabel.Name = "passwordLabel"; - this.passwordLabel.Size = new System.Drawing.Size(279, 30); - this.passwordLabel.TabIndex = 4; - this.passwordLabel.Text = "&Пароль"; - this.passwordLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + passwordLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + passwordLabel.Location = new System.Drawing.Point(14, 164); + passwordLabel.Name = "passwordLabel"; + passwordLabel.Size = new System.Drawing.Size(319, 40); + passwordLabel.TabIndex = 4; + passwordLabel.Text = "&Пароль"; + passwordLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // passwordTextBox // - this.passwordTextBox.Location = new System.Drawing.Point(12, 156); - this.passwordTextBox.Name = "passwordTextBox"; - this.passwordTextBox.Size = new System.Drawing.Size(279, 23); - this.passwordTextBox.TabIndex = 5; - this.passwordTextBox.UseSystemPasswordChar = true; + passwordTextBox.Location = new System.Drawing.Point(14, 208); + passwordTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + passwordTextBox.Name = "passwordTextBox"; + passwordTextBox.Size = new System.Drawing.Size(318, 27); + passwordTextBox.TabIndex = 5; + passwordTextBox.UseSystemPasswordChar = true; // // emailLabel // - this.emailLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.emailLabel.Location = new System.Drawing.Point(12, 241); - this.emailLabel.Name = "emailLabel"; - this.emailLabel.Size = new System.Drawing.Size(279, 30); - this.emailLabel.TabIndex = 8; - this.emailLabel.Text = "&E-Mail"; - this.emailLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + emailLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + emailLabel.Location = new System.Drawing.Point(14, 321); + emailLabel.Name = "emailLabel"; + emailLabel.Size = new System.Drawing.Size(319, 40); + emailLabel.TabIndex = 8; + emailLabel.Text = "&E-Mail"; + emailLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // emailTextBox // - this.emailTextBox.Location = new System.Drawing.Point(12, 274); - this.emailTextBox.Name = "emailTextBox"; - this.emailTextBox.Size = new System.Drawing.Size(279, 23); - this.emailTextBox.TabIndex = 9; + emailTextBox.Location = new System.Drawing.Point(14, 365); + emailTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + emailTextBox.Name = "emailTextBox"; + emailTextBox.Size = new System.Drawing.Size(318, 27); + emailTextBox.TabIndex = 9; // // registrationButton // - this.registrationButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.registrationButton.Location = new System.Drawing.Point(12, 316); - this.registrationButton.Name = "registrationButton"; - this.registrationButton.Size = new System.Drawing.Size(279, 33); - this.registrationButton.TabIndex = 10; - this.registrationButton.Text = "&Регистрация"; - this.registrationButton.UseVisualStyleBackColor = true; + registrationButton.DialogResult = System.Windows.Forms.DialogResult.OK; + registrationButton.Location = new System.Drawing.Point(14, 421); + registrationButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + registrationButton.Name = "registrationButton"; + registrationButton.Size = new System.Drawing.Size(319, 44); + registrationButton.TabIndex = 10; + registrationButton.Text = "&Регистрация"; + registrationButton.UseVisualStyleBackColor = true; + registrationButton.Click += RegistrationButton_Click; // // cancelButton // - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(12, 355); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(279, 33); - this.cancelButton.TabIndex = 11; - this.cancelButton.Text = "&Отмена"; - this.cancelButton.UseVisualStyleBackColor = true; + cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + cancelButton.Location = new System.Drawing.Point(14, 473); + cancelButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + cancelButton.Name = "cancelButton"; + cancelButton.Size = new System.Drawing.Size(319, 44); + cancelButton.TabIndex = 11; + cancelButton.Text = "&Отмена"; + cancelButton.UseVisualStyleBackColor = true; // // exitButton // - this.exitButton.DialogResult = System.Windows.Forms.DialogResult.Abort; - this.exitButton.Location = new System.Drawing.Point(12, 394); - this.exitButton.Name = "exitButton"; - this.exitButton.Size = new System.Drawing.Size(279, 33); - this.exitButton.TabIndex = 12; - this.exitButton.Text = "Выход"; - this.exitButton.UseVisualStyleBackColor = true; + exitButton.DialogResult = System.Windows.Forms.DialogResult.Abort; + exitButton.Location = new System.Drawing.Point(14, 525); + exitButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + exitButton.Name = "exitButton"; + exitButton.Size = new System.Drawing.Size(319, 44); + exitButton.TabIndex = 12; + exitButton.Text = "Выход"; + exitButton.UseVisualStyleBackColor = true; // // replyPasswordLabel // - this.replyPasswordLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.replyPasswordLabel.Location = new System.Drawing.Point(12, 182); - this.replyPasswordLabel.Name = "replyPasswordLabel"; - this.replyPasswordLabel.Size = new System.Drawing.Size(279, 30); - this.replyPasswordLabel.TabIndex = 6; - this.replyPasswordLabel.Text = "Повторите пароль"; - this.replyPasswordLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + replyPasswordLabel.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + replyPasswordLabel.Location = new System.Drawing.Point(14, 243); + replyPasswordLabel.Name = "replyPasswordLabel"; + replyPasswordLabel.Size = new System.Drawing.Size(319, 40); + replyPasswordLabel.TabIndex = 6; + replyPasswordLabel.Text = "Повторите пароль"; + replyPasswordLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // replyPasswordTextBox // - this.replyPasswordTextBox.Location = new System.Drawing.Point(12, 215); - this.replyPasswordTextBox.Name = "replyPasswordTextBox"; - this.replyPasswordTextBox.Size = new System.Drawing.Size(279, 23); - this.replyPasswordTextBox.TabIndex = 7; - this.replyPasswordTextBox.UseSystemPasswordChar = true; + replyPasswordTextBox.Location = new System.Drawing.Point(14, 287); + replyPasswordTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + replyPasswordTextBox.Name = "replyPasswordTextBox"; + replyPasswordTextBox.Size = new System.Drawing.Size(318, 27); + replyPasswordTextBox.TabIndex = 7; + replyPasswordTextBox.UseSystemPasswordChar = true; // // RegistrationForm // - this.AcceptButton = this.registrationButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(303, 437); - this.ControlBox = false; - this.Controls.Add(this.replyPasswordTextBox); - this.Controls.Add(this.replyPasswordLabel); - this.Controls.Add(this.exitButton); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.registrationButton); - this.Controls.Add(this.nameTextBox); - this.Controls.Add(this.nameLabel); - this.Controls.Add(this.loginTextBox); - this.Controls.Add(this.loginLabel); - this.Controls.Add(this.passwordTextBox); - this.Controls.Add(this.passwordLabel); - this.Controls.Add(this.emailTextBox); - this.Controls.Add(this.emailLabel); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "RegistrationForm"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "HelpDesk Регистрация"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.RegistrationForm_FormClosing); - this.ResumeLayout(false); - this.PerformLayout(); + AcceptButton = registrationButton; + AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + CancelButton = cancelButton; + ClientSize = new System.Drawing.Size(346, 583); + ControlBox = false; + Controls.Add(replyPasswordTextBox); + Controls.Add(replyPasswordLabel); + Controls.Add(exitButton); + Controls.Add(cancelButton); + Controls.Add(registrationButton); + Controls.Add(nameTextBox); + Controls.Add(nameLabel); + Controls.Add(loginTextBox); + Controls.Add(loginLabel); + Controls.Add(passwordTextBox); + Controls.Add(passwordLabel); + Controls.Add(emailTextBox); + Controls.Add(emailLabel); + Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + MaximizeBox = false; + MinimizeBox = false; + Name = "RegistrationForm"; + ShowIcon = false; + StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + Text = "HelpDesk Регистрация"; + FormClosing += RegistrationForm_FormClosing; + ResumeLayout(false); + PerformLayout(); } diff --git a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs index f5738ed..4229c28 100644 --- a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs @@ -1,7 +1,8 @@ -using HelpDesk.Common; -using HelpDesk.Common.Models; -using System.Linq; + using System.Windows.Forms; +using HelpDesk.Common; +using HelpDesk.Common.Models; +using HelpDesk.Common.System; namespace HelpDeskWinFormsApp { @@ -16,6 +17,9 @@ public RegistrationForm(IProvider provider) this.provider = provider; } + + + private void RegistrationForm_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult == DialogResult.Cancel || DialogResult == DialogResult.Abort) @@ -33,5 +37,17 @@ private void RegistrationForm_FormClosing(object sender, FormClosingEventArgs e) provider.AddUser(user); } + + private void RegistrationButton_Click(object sender, System.EventArgs e) + { + + + DialogResult = DialogResult.None; + return; + + + DialogResult = DialogResult.OK; + Close(); + } } } diff --git a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.resx b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.resx index f298a7b..8b2ff64 100644 --- a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.resx +++ b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.resx @@ -1,4 +1,64 @@ - + + + diff --git a/HelpDesk/HelpDeskWinFormsApp/Validators.cs b/HelpDesk/HelpDeskWinFormsApp/Validators.cs new file mode 100644 index 0000000..9d621b8 --- /dev/null +++ b/HelpDesk/HelpDeskWinFormsApp/Validators.cs @@ -0,0 +1,6 @@ +namespace HelpDesk.Common +{ + internal class Validators + { + } +} From 9f41f51998fe7b544ee52dec9f45d0ffcd4ba2a5 Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Sat, 6 Dec 2025 01:14:09 +0300 Subject: [PATCH 05/14] =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20+=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BC=D0=B0=D0=B9=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HelpDesk/HelpDeskWinFormsApp/AppConstants.cs | 2 +- .../HelpDeskWinFormsApp/AuthorizationForm.cs | 44 +- HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs | 59 +- HelpDesk/HelpDeskWinFormsApp/ExportForm.cs | 11 +- .../HelpDeskWinFormsApp/InputValidator.cs | 98 +++ HelpDesk/HelpDeskWinFormsApp/MainForm.cs | 616 ++++++++++-------- .../HelpDeskWinFormsApp/RegistrationForm.cs | 35 +- .../HelpDeskWinFormsApp/TroubleTicketForm.cs | 18 +- HelpDesk/HelpDeskWinFormsApp/Validators.cs | 6 - 9 files changed, 599 insertions(+), 290 deletions(-) create mode 100644 HelpDesk/HelpDeskWinFormsApp/InputValidator.cs delete mode 100644 HelpDesk/HelpDeskWinFormsApp/Validators.cs diff --git a/HelpDesk/HelpDeskWinFormsApp/AppConstants.cs b/HelpDesk/HelpDeskWinFormsApp/AppConstants.cs index 2145c7c..3aa3ea4 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AppConstants.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AppConstants.cs @@ -39,6 +39,6 @@ public static class AppConstants public const int TextPreviewLength = 50; public const int TextPreviewEllipsisLength = 47; - public const int InvalidUserId = -1; + public const int InvalidId = -1; } } diff --git a/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs index 3874966..d6bb30f 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs @@ -1,7 +1,7 @@ -using HelpDesk.Common; -using HelpDesk.Common.Models; -using System; +using System; using System.Windows.Forms; +using HelpDesk.Common; +using HelpDesk.Common.Models; namespace HelpDeskWinFormsApp { @@ -16,7 +16,7 @@ public AuthorizationForm(IProvider provider) this.provider = provider; } - + private void AuthorizationForm_Shown(object sender, EventArgs e) { AddFirstEmployee(); @@ -59,6 +59,28 @@ private void AddFirstEmployee() } } + private bool ValidateAllFields() + { + var validations = new[] + { + InputValidator.ValidateLogin(loginTextBox.Text), + InputValidator.ValidatePassword(passwordTextBox.Text) + }; + + foreach (var validation in validations) + { + if (!validation.IsValid) + { + MessageBox.Show(validation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + } + + return true; + } + + private void AuthorizationForm_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult == DialogResult.Cancel) @@ -66,6 +88,12 @@ private void AuthorizationForm_FormClosing(object sender, FormClosingEventArgs e return; } + if (!ValidateAllFields()) + { + e.Cancel = true; + return; + } + if (!provider.IsCorrectLoginPassword(loginTextBox.Text, passwordTextBox.Text)) { e.Cancel = true; @@ -77,10 +105,14 @@ private void ExitToolStripMenuItem_Click(object sender, EventArgs e) { Environment.Exit(0); } - + private void LoginButton_Click(object sender, EventArgs e) { - + if (!ValidateAllFields()) + { + return; + } + DialogResult = DialogResult.OK; } } } diff --git a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs index bf54c76..c41aab2 100644 --- a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs @@ -61,6 +61,14 @@ private void UserTypeComboBox_SelectedValueChanged(object sender, System.EventAr private void EditUserForm_FormClosing(object sender, FormClosingEventArgs e) { + if (DialogResult != DialogResult.OK) return; + + if (!ValidateAllFields()) + { + e.Cancel = true; + return; + } + user.Name = nameTextBox.Text; user.Login = loginTextBox.Text; @@ -109,11 +117,60 @@ private void DeparmentComboBox_SelectedValueChanged(object sender, EventArgs e) } } + private bool ValidateAllFields() + { + var validations = new[] + { + InputValidator.ValidateName(nameTextBox.Text), + InputValidator.ValidateLogin(loginTextBox.Text), + InputValidator.ValidateEmail(emailTextBox.Text) + }; + + if (!string.IsNullOrEmpty(changePasswordTextBox.Text)) + { + var passwordValidation = InputValidator.ValidatePassword(changePasswordTextBox.Text); + if (!passwordValidation.IsValid) + { + MessageBox.Show(passwordValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + var matchValidation = InputValidator.ValidatePasswordMatch( + changePasswordTextBox.Text, + confurmChangePasswordTextBox.Text); + if (!matchValidation.IsValid) + { + MessageBox.Show(matchValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + } + + foreach (var validation in validations) + { + if (!validation.IsValid) + { + MessageBox.Show(validation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + } + + return true; + } + private void SaveButton_Click(object sender, EventArgs e) { - + if (!ValidateAllFields()) + { + DialogResult = DialogResult.None; + return; + } + DialogResult = DialogResult.OK; Close(); + } } } diff --git a/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs b/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs index e6b5797..e05ce1e 100644 --- a/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs @@ -359,7 +359,14 @@ private void TypeComboBox_SelectedIndexChanged(object sender, EventArgs e) endDateTimePicker.Enabled = true; statusFilter.Clear(); - statusFilter.AddRange(new List() { "Зарегистрирована", "В работе", "Выполнена", "Отклонена" }); + statusFilter.AddRange(new List() + { + AppConstants.StatusRegistered, + AppConstants.StatusInProgress, + AppConstants.StatusCompleted, + AppConstants.StatusRejected + }); + statusFilterComboBox.DataSource = null; statusFilterComboBox.DataSource = statusFilter; } @@ -369,7 +376,7 @@ private void TypeComboBox_SelectedIndexChanged(object sender, EventArgs e) endDateTimePicker.Enabled = false; statusFilter.Clear(); - statusFilter.AddRange(new List() { "Клиент", "Сотрудник" }); + statusFilter.AddRange(new List() { AppConstants.UserTypeClient, AppConstants.UserTypeEmployee }); statusFilterComboBox.DataSource = null; statusFilterComboBox.DataSource = statusFilter; } diff --git a/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs b/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs new file mode 100644 index 0000000..81bd9cf --- /dev/null +++ b/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs @@ -0,0 +1,98 @@ +using System; +using System.Net.Mail; +using System.Text.RegularExpressions; + +namespace HelpDesk.Common +{ + public static class InputValidator + { + private const int MinNameLength = 2; + private const int MaxNameLength = 100; + private const int MinLoginLength = 3; + private const int MaxLoginLength = 50; + private const int MinPasswordLength = 6; + private const int MaxPasswordLength = 50; + + + public static (bool IsValid, string Message) ValidateName(string inputName) + { + var name = inputName?.Trim() ?? ""; + + if (string.IsNullOrWhiteSpace(name)) + { + return (false, "Имя обязательно для заполнения"); + } + + if (name.Length < MinNameLength || name.Length > MaxNameLength) + { + return (false, $"Имя должно быть от {MinNameLength} до {MaxNameLength} символов"); + } + + return (true, string.Empty); + } + + public static (bool IsValid, string Message) ValidateLogin(string inputLogin) + { + var login = inputLogin?.Trim() ?? ""; + + if (string.IsNullOrWhiteSpace(login)) + { + return (false, "Логин обязателен для заполнения"); + } + + if (login.Length < MinLoginLength || login.Length > MaxLoginLength) + { + return (false, $"Логин должен быть от {MinLoginLength} до {MaxLoginLength} символов"); + } + return (true, string.Empty); + } + + public static (bool IsValid, string Message) ValidatePassword(string inputPassword) + { + var password = inputPassword ?? ""; + + if (string.IsNullOrWhiteSpace(password)) + { + return (false, "Пароль обязателен для заполнения"); + } + + if (password.Length < MinPasswordLength || password.Length > MaxPasswordLength) + { + return (false, $"Пароль должен быть от {MinPasswordLength} до {MaxPasswordLength} символов"); + } + + return (true, string.Empty); + } + + public static (bool IsValid, string Message) ValidatePasswordMatch( + string password, string confirmPassword) + { + + if (password != confirmPassword) + { + return (false, "Пароли не совпадают"); + } + + return (true, string.Empty); + } + + public static (bool IsValid, string Message) ValidateEmail(string inputEmail) + { + var email = inputEmail?.Trim() ?? ""; + + if (string.IsNullOrWhiteSpace(email)) + { + return (false, "Email обязателен для заполнения"); + } + try + { + var mailAddress = new MailAddress(email); + return (true, string.Empty); + } + catch (FormatException) + { + return (false, "Неверный формат email"); + } + } + } +} diff --git a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs index d30b1af..7e7cbde 100644 --- a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs @@ -11,8 +11,7 @@ namespace HelpDeskWinFormsApp { public partial class MainForm : Form - { - + { private User user = new(); private IProvider provider; @@ -30,23 +29,41 @@ public void GetProvider() private void MainForm_Load(object sender, EventArgs e) { - var login = AuthorizationUser(); + string login = AuthorizationUser(); - if (login != string.Empty) + if (!string.IsNullOrEmpty(login)) { - user = provider.GetUser(login); + InitializeUserSession(login); + } + } - ShowUserTreeNode(); - SetHeaderWindowText(); - ShowExportSubMenu(); + private void InitializeUserSession(string login) + { + user = provider.GetUser(login); - treeView.Width = splitContainer.Panel1.Width; - treeView.Height = splitContainer.Panel1.Height - AppConstants.TreeViewBottomMargin; + SetupUserInterface(); + SetupTreeViewLayout(); + SetupDataGridViewLayout(); - troubleTicketsDataGridView.Size = splitContainer.Panel2.Size; + UpdateUserInfoUI(); + } - UpdateUserInfoUI(); - } + private void SetupUserInterface() + { + ShowUserTreeNode(); + SetWindowHeaderText(); + ShowExportSubMenu(); + } + + private void SetupTreeViewLayout() + { + treeView.Width = splitContainer.Panel1.Width; + treeView.Height = splitContainer.Panel1.Height - AppConstants.TreeViewBottomMargin; + } + + private void SetupDataGridViewLayout() + { + troubleTicketsDataGridView.Size = splitContainer.Panel2.Size; } private void UpdateUserInfoUI() @@ -58,14 +75,7 @@ private void UpdateUserInfoUI() private void ShowExportSubMenu() { - if (!user.IsEmployee) - { - exportToolStripMenuItem.Visible = false; - } - else - { - exportToolStripMenuItem.Visible = true; - } + exportToolStripMenuItem.Visible = user.IsEmployee; } private void ExitToolStripMenuItem_Click(object sender, EventArgs e) @@ -75,36 +85,65 @@ private void ExitToolStripMenuItem_Click(object sender, EventArgs e) private void LogoutToolStripMenuItem_Click(object sender, EventArgs e) { - troubleTicketsDataGridView.Rows.Clear(); - troubleTicketsDataGridView.Columns.Clear(); - + ClearDataGridView(); Hide(); - var login = AuthorizationUser(); + string login = AuthorizationUser(); - if (login != string.Empty) + if (!string.IsNullOrEmpty(login)) { user = provider.GetUser(login); - - SetHeaderWindowText(); - + SetWindowHeaderText(); UpdateUserInfoUI(); - treeView.SelectedNode = treeView.Nodes[0]; - + ResetTreeViewSelection(); ShowUserTreeNode(); ShowExportSubMenu(); Show(); } } + private void ClearDataGridView() + { + troubleTicketsDataGridView.Rows.Clear(); + troubleTicketsDataGridView.Columns.Clear(); + } + + private void ResetTreeViewSelection() + { + treeView.SelectedNode = treeView.Nodes[0]; + } + private void SplitContainer_Panel1_Resize(object sender, EventArgs e) + { + UpdateTreeViewLayout(); + UpdateButtonPositions(); + } + + private void UpdateTreeViewLayout() { treeView.Width = splitContainer.Panel1.Width; treeView.Height = splitContainer.Panel1.Height - AppConstants.TreeViewBottomMargin; - editUserButton.Location = new Point(openTroubleTicketButton.Location.X, splitContainer.Panel1.Height - AppConstants.EditButtonOffset); - openTroubleTicketButton.Location = new Point(openTroubleTicketButton.Location.X, splitContainer.Panel1.Height - AppConstants.OpenButtonOffset); - addTroubleTicketbutton.Location = new Point(openTroubleTicketButton.Location.X, splitContainer.Panel1.Height - AppConstants.AddButtonOffset); - exitButton.Location = new Point(exitButton.Location.X, splitContainer.Panel1.Height - AppConstants.ExitButtonOffset); + } + + private void UpdateButtonPositions() + { + int panelHeight = splitContainer.Panel1.Height; + + editUserButton.Location = new Point( + openTroubleTicketButton.Location.X, + panelHeight - AppConstants.EditButtonOffset); + + openTroubleTicketButton.Location = new Point( + openTroubleTicketButton.Location.X, + panelHeight - AppConstants.OpenButtonOffset); + + addTroubleTicketbutton.Location = new Point( + openTroubleTicketButton.Location.X, + panelHeight - AppConstants.AddButtonOffset); + + exitButton.Location = new Point( + exitButton.Location.X, + panelHeight - AppConstants.ExitButtonOffset); } private void SplitContainer_Panel2_Resize(object sender, EventArgs e) @@ -114,35 +153,66 @@ private void SplitContainer_Panel2_Resize(object sender, EventArgs e) private void OpenTroubleTicketButton_Click(object sender, EventArgs e) { - if (troubleTicketsDataGridView.SelectedRows.Count != 0) + if (TryGetSelectedTicketId(out int ticketId)) { - var ticketId = Convert.ToInt32(troubleTicketsDataGridView.SelectedCells[0].Value); + OpenTroubleTicketForm(ticketId); + } + } - var resolvedUser = Convert.ToInt32(provider.GetTroubleTicket(ticketId).ResolveUser != null ? user.Id : -1); + private bool TryGetSelectedTicketId(out int ticketId) + { + ticketId = AppConstants.InvalidId; - if (user.IsEmployee && resolvedUser == AppConstants.InvalidUserId) - { - resolvedUser = user.Id; - } + if (troubleTicketsDataGridView.SelectedRows.Count > 0) + { + ticketId = Convert.ToInt32(troubleTicketsDataGridView.SelectedCells[0].Value); + return true; + } + + return false; + } - var dialogResult = new TroubleTicketForm(ticketId, user.IsEmployee, resolvedUser, provider).ShowDialog(); + private void OpenTroubleTicketForm(int ticketId) + { + int resolveUserId = GetResolveUserIdForTicket(ticketId); - if (dialogResult == DialogResult.OK) + using (TroubleTicketForm ticketForm = new TroubleTicketForm(ticketId, user.IsEmployee, resolveUserId, provider)) + { + if (ticketForm.ShowDialog() == DialogResult.OK) { RefreshTroubleTicketsDataGrid(); } } } - private void AddTroubleTicketButton_Click(object sender, EventArgs e) + private int GetResolveUserIdForTicket(int ticketId) { - var dialogResult = new AddTroubleTicketForm(user, provider); + TroubleTicket ticket = provider.GetTroubleTicket(ticketId); - if (dialogResult.ShowDialog() == DialogResult.OK) + if (ticket.ResolveUser != null) { - treeView.SelectedNode = treeView.Nodes[AppConstants.TreeNodeTrubleTicketList].Nodes[AppConstants.TreeNodeOpenTroubleTickets]; - RefreshTroubleTicketsDataGrid(); + return (int)ticket.ResolveUser; } + + return user.IsEmployee ? user.Id : AppConstants.InvalidId; + } + + private void AddTroubleTicketButton_Click(object sender, EventArgs e) + { + using (AddTroubleTicketForm addForm = new AddTroubleTicketForm(user, provider)) + { + if (addForm.ShowDialog() == DialogResult.OK) + { + SelectOpenTroubleTicketsNode(); + RefreshTroubleTicketsDataGrid(); + } + } + } + + private void SelectOpenTroubleTicketsNode() + { + treeView.SelectedNode = treeView.Nodes[AppConstants.TreeNodeTrubleTicketList] + .Nodes[AppConstants.TreeNodeOpenTroubleTickets]; } private void TreeView_AfterSelect(object sender, TreeViewEventArgs e) @@ -150,249 +220,225 @@ private void TreeView_AfterSelect(object sender, TreeViewEventArgs e) refreshToolStripMenuItem.PerformClick(); } - private void ListTTDataGridView_DoubleClick(object sender, EventArgs e) - { + private void RefreshDataGridBasedOnSelectedNode() + { + if (treeView.SelectedNode?.Parent == null) return; - if (treeView.SelectedNode.Level != 0) + string parentName = treeView.SelectedNode.Parent.Name; + + UpdateButtonStates(parentName); + + if (parentName == AppConstants.TreeNodeTrubleTicketList || + parentName == AppConstants.TreeNodeStatusTroubleTicket) + { + RefreshTroubleTicketsDataGrid(); + } + else if (parentName == AppConstants.TreeNodeUsers) { - var parentName = treeView.SelectedNode.Parent.Name; + RefreshUsersDataGrid(); + } + } - if (parentName == AppConstants.TreeNodeTrubleTicketList || parentName == AppConstants.TreeNodeStatusTroubleTicket) - { - openTroubleTicketButton.PerformClick(); - } + private void UpdateButtonStates(string parentName) + { + bool isUsersNode = parentName == AppConstants.TreeNodeUsers; - if (parentName == AppConstants.TreeNodeUsers) - { - editUserButton.PerformClick(); - } + editUserButton.Enabled = isUsersNode; + openTroubleTicketButton.Enabled = !isUsersNode; + } + + private void RefreshToolStripMenuItem_Click(object sender, EventArgs e) + { + RefreshDataGridBasedOnSelectedNode(); + } + + private void ListTTDataGridView_DoubleClick(object sender, EventArgs e) + { + if (treeView.SelectedNode?.Parent == null) return; + + string parentName = treeView.SelectedNode.Parent.Name; + + if (parentName == AppConstants.TreeNodeTrubleTicketList || + parentName == AppConstants.TreeNodeStatusTroubleTicket) + { + openTroubleTicketButton.PerformClick(); + } + else if (parentName == AppConstants.TreeNodeUsers) + { + editUserButton.PerformClick(); } } private void ExportToolStripMenuItem_Click(object sender, EventArgs e) { - var isSupport = false; + bool isSupport = user.IsEmployee && user.Department == AppConstants.DepartmentTechnicalSupport; - if (user.IsEmployee) + using (ExportForm exportForm = new ExportForm(isSupport, provider)) { - isSupport = user.Department == AppConstants.DepartmentTechnicalSupport; + exportForm.ShowDialog(); } - - new ExportForm(isSupport, provider).ShowDialog(); } private void EditUserButton_Click(object sender, EventArgs e) { - if (troubleTicketsDataGridView.SelectedRows.Count != 0) + if (TryGetSelectedUserId(out int userId)) { - var userId = Convert.ToInt32(troubleTicketsDataGridView.SelectedCells[0].Value); - - var dialogResult = new EditUserForm(userId, provider).ShowDialog(); - - if (dialogResult == DialogResult.OK) - { - RefreshUsersDataGrid(); - } + OpenEditUserForm(userId); } } - private void RefreshToolStripMenuItem_Click(object sender, EventArgs e) + private bool TryGetSelectedUserId(out int userId) { - if (treeView.SelectedNode.Level != 0) + userId = AppConstants.InvalidId; + + if (troubleTicketsDataGridView.SelectedRows.Count > 0) { - var parentName = treeView.SelectedNode.Parent.Name; + userId = Convert.ToInt32(troubleTicketsDataGridView.SelectedCells[0].Value); + return true; + } - if (parentName == AppConstants.TreeNodeTrubleTicketList || parentName == AppConstants.TreeNodeStatusTroubleTicket) - { - RefreshTroubleTicketsDataGrid(); - editUserButton.Enabled = false; - openTroubleTicketButton.Enabled = true; - } + return false; + } - if (parentName == AppConstants.TreeNodeUsers) + private void OpenEditUserForm(int userId) + { + using (EditUserForm editForm = new EditUserForm(userId, provider)) + { + if (editForm.ShowDialog() == DialogResult.OK) { RefreshUsersDataGrid(); - editUserButton.Enabled = true; - openTroubleTicketButton.Enabled = false; } } - else + } + + private void SetWindowHeaderText() + { + string userType = user.IsEmployee ? $"{user.Function}: {user.Name}" : $"Клиент: {user.Name}"; + Text = $"HelpDesk. {userType}/{user.Login}"; + } + + private void RemoveUserTreeNode() + { + if (treeView.Nodes.Count > 1) { - editUserButton.Enabled = false; - openTroubleTicketButton.Enabled = false; + treeView.Nodes.RemoveAt(1); } } private void ShowUserTreeNode() { - if (!user.IsEmployee || user.Department == AppConstants.DepartmentTechnicalSupport) + bool shouldShowUsersNode = user.IsEmployee && user.Department != AppConstants.DepartmentTechnicalSupport; + + if (shouldShowUsersNode && treeView.Nodes.Count == 1) { - RemoveUserTreeNode(); - editUserButton.Visible = false; + TreeNode usersNode = CreateUsersTreeStructure(); + treeView.Nodes.Add(usersNode); } - else + else if (!shouldShowUsersNode) { - if (treeView.Nodes.Count == 1) - { - AddUserTreeNode(); - } - - editUserButton.Visible = true; + RemoveUserTreeNode(); } + + editUserButton.Visible = shouldShowUsersNode; } - private void SetHeaderWindowText() + private TreeNode CreateUsersTreeStructure() { - if (user.IsEmployee) + TreeNode allUsersNode = new TreeNode("Все пользователи") { - Text = $"HelpDesk. {user.Function}: {user.Name}/{user.Login}"; - } - else + Name = AppConstants.TreeNodeAllUsers + }; + + TreeNode clientsNode = new TreeNode("Клиенты") { - Text = $"HelpDesk. Клиент: {user.Name}/{user.Login}"; - } - } + Name = AppConstants.TreeNodeClients + }; - private void RemoveUserTreeNode() - { - if (treeView.Nodes.Count > 1) + TreeNode employeesNode = new TreeNode("Сотрудники") { - treeView.Nodes.RemoveAt(1); - } - } + Name = AppConstants.TreeNodeEmployees + }; - private void AddUserTreeNode() - { - var allUsersNode = new TreeNode("Все пользователи") { Name = AppConstants.TreeNodeAllUsers }; - var clientsNode = new TreeNode("Клиенты") { Name = AppConstants.TreeNodeClients }; - var employeesNode = new TreeNode("Сотрудники") { Name = AppConstants.TreeNodeEmployees }; - var usersNode = new TreeNode("Пользователи", new TreeNode[] { allUsersNode, clientsNode, employeesNode }) + return new TreeNode("Пользователи", new TreeNode[] { allUsersNode, clientsNode, employeesNode }) { Name = AppConstants.TreeNodeUsers }; - - treeView.Nodes.AddRange(new TreeNode[] { usersNode }); } private string AuthorizationUser() { - var isNeedRegistration = false; - var login = string.Empty; - var authorizationForm = new AuthorizationForm(provider); + AuthorizationForm authorizationForm = new AuthorizationForm(provider); if (authorizationForm.ShowDialog() == DialogResult.OK) { - login = authorizationForm.loginTextBox.Text; + return authorizationForm.loginTextBox.Text; } - else - { - isNeedRegistration = authorizationForm.RegistrationChoice; - if (!isNeedRegistration) - { - Environment.Exit(0); - return string.Empty; - } + return HandleAuthorizationFailure(authorizationForm.RegistrationChoice); + } + + private string HandleAuthorizationFailure(bool isNeedRegistration) + { + if (!isNeedRegistration) + { + Environment.Exit(0); + return string.Empty; } - if (isNeedRegistration) + return ProcessRegistration(); + } + + private string ProcessRegistration() + { + using (RegistrationForm registrationForm = new RegistrationForm(provider)) { - var registrationForm = new RegistrationForm(provider); - var registrationFormDialogResult = registrationForm.ShowDialog(); + DialogResult result = registrationForm.ShowDialog(); - if (registrationFormDialogResult == DialogResult.OK) - { - login = registrationForm.loginTextBox.Text; - } - else if (registrationFormDialogResult == DialogResult.Cancel) + switch (result) { - Application.Restart(); - } - else - { - Environment.Exit(0); + case DialogResult.OK: + return registrationForm.loginTextBox.Text; + case DialogResult.Cancel: + Application.Restart(); + break; + default: + Environment.Exit(0); + break; } } - return login; + return string.Empty; } private void RefreshUsersDataGrid() { - var selectedNode = treeView.SelectedNode.Name; - - troubleTicketsDataGridView.Columns.Clear(); + string selectedNode = treeView.SelectedNode.Name; + List users = GetFilteredUsers(selectedNode); - switch (selectedNode) - { - case AppConstants.TreeNodeAllUsers: - FillUsersDataGridView(provider.GetAllUsers()); - break; - case AppConstants.TreeNodeClients: - FillUsersDataGridView(provider.GetAllUsers().Where(u => !u.IsEmployee).ToList()); - break; - case AppConstants.TreeNodeEmployees: - FillUsersDataGridView(provider.GetAllUsers().Where(u => u.IsEmployee).ToList()); - break; - default: - break; - } + ClearAndSetupDataGridViewForUsers(); + FillUsersDataGridView(users); } - private void RefreshTroubleTicketsDataGrid() + private List GetFilteredUsers(string nodeName) { - var selectedNode = treeView.SelectedNode.Name; + List allUsers = provider.GetAllUsers(); - if (selectedNode == AppConstants.TreeNodeStatusTroubleTicket) + return nodeName switch { - return; - } - - List troubleTickets = new(); + AppConstants.TreeNodeAllUsers => allUsers, + AppConstants.TreeNodeClients => allUsers.Where(u => !u.IsEmployee).ToList(), + AppConstants.TreeNodeEmployees => allUsers.Where(u => u.IsEmployee).ToList(), + _ => new List() + }; + } + private void ClearAndSetupDataGridViewForUsers() + { troubleTicketsDataGridView.Columns.Clear(); - - if (user.IsEmployee) - { - troubleTickets = provider.GetAllTroubleTickets(); - } - else - { - troubleTickets = provider.GetAllTroubleTickets().Where(t => t.CreateUser == user.Id).ToList(); - } - - switch (selectedNode) - { - case AppConstants.TreeNodeAllTroubleTickets: - FillTroubleTicketsDataGridView(troubleTickets); - break; - case AppConstants.TreeNodeOpenTroubleTickets: - FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.IsSolved == false).ToList()); - break; - case AppConstants.TreeNodeClosedTroubleTickets: - FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.IsSolved == true).ToList()); - break; - case AppConstants.TreeNodeOverdueTroubleTickets: - FillTroubleTicketsDataGridView(troubleTickets.Where(s => (DateTime.Now - s.Deadline).TotalSeconds > 0).ToList()); - break; - case AppConstants.TreeNodeRegisteredTroubleTickets: - FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.Status == AppConstants.StatusRegistered).ToList()); - break; - case AppConstants.TreeNodeWorkTroubleTickets: - FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.Status == AppConstants.StatusInProgress).ToList()); - break; - case AppConstants.TreeNodeCompletedTroubleTickets: - FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.Status == AppConstants.StatusCompleted).ToList()); - break; - case AppConstants.TreeNodeRejectedTroubleTickets: - FillTroubleTicketsDataGridView(troubleTickets.Where(s => s.Status == AppConstants.StatusRejected).ToList()); - break; - default: - break; - } + AddUserColumnsToDataGridView(); } - private void FillUsersDataGridView(List users) + private void AddUserColumnsToDataGridView() { troubleTicketsDataGridView.Columns.Add("id", "ID"); troubleTicketsDataGridView.Columns.Add("name", "Имя"); @@ -401,73 +447,125 @@ private void FillUsersDataGridView(List users) troubleTicketsDataGridView.Columns.Add("discriminator", "Тип"); troubleTicketsDataGridView.Columns.Add("function", "Функция"); troubleTicketsDataGridView.Columns.Add("department", "Отдел"); + } + private void FillUsersDataGridView(List users) + { troubleTicketsDataGridView.Rows.Clear(); - var countRows = users.Count; - - for (int i = 0; i < countRows; i++) + foreach (User userData in users) { - troubleTicketsDataGridView.Rows.Add(); - troubleTicketsDataGridView.Rows[i].Cells[0].Value = users[i].Id; - troubleTicketsDataGridView.Rows[i].Cells[1].Value = users[i].Name; - troubleTicketsDataGridView.Rows[i].Cells[2].Value = users[i].Login; - troubleTicketsDataGridView.Rows[i].Cells[3].Value = users[i].Email; - - var userType = users[i].IsEmployee; + int rowIndex = troubleTicketsDataGridView.Rows.Add(); + DataGridViewRow row = troubleTicketsDataGridView.Rows[rowIndex]; - troubleTicketsDataGridView.Rows[i].Cells[4].Value = userType ? "Сотрудник" : "Клиент"; - - if (userType) - { - troubleTicketsDataGridView.Rows[i].Cells[5].Value = user.Function; - troubleTicketsDataGridView.Rows[i].Cells[6].Value = user.Department; - } - else - { - troubleTicketsDataGridView.Rows[i].Cells[5].Style.BackColor = Color.Gray; - troubleTicketsDataGridView.Rows[i].Cells[6].Style.BackColor = Color.Gray; - } + PopulateUserRow(row, userData); } troubleTicketsDataGridView.ClearSelection(); } - private void FillTroubleTicketsDataGridView(List allTroubleTickets) + private void PopulateUserRow(DataGridViewRow row, User userData) { - AddColumnsTroubleTicketsDataGridView(); + row.Cells[0].Value = userData.Id; + row.Cells[1].Value = userData.Name; + row.Cells[2].Value = userData.Login; + row.Cells[3].Value = userData.Email; + row.Cells[4].Value = userData.IsEmployee ? "Сотрудник" : "Клиент"; - troubleTicketsDataGridView.Rows.Clear(); + if (userData.IsEmployee) + { + row.Cells[5].Value = userData.Function; + row.Cells[6].Value = userData.Department; + } + else + { + row.Cells[5].Style.BackColor = Color.Gray; + row.Cells[6].Style.BackColor = Color.Gray; + } + } - var allUsers = provider.GetAllUsers(); + private void RefreshTroubleTicketsDataGrid() + { + string selectedNode = treeView.SelectedNode.Name; + + if (selectedNode == AppConstants.TreeNodeStatusTroubleTicket) + { + return; + } - foreach (var ticket in allTroubleTickets) + List tickets = GetFilteredTroubleTickets(selectedNode); + + ClearAndSetupDataGridViewForTickets(); + FillTroubleTicketsDataGridView(tickets); + } + + private List GetFilteredTroubleTickets(string nodeName) + { + List allTickets = GetAllRelevantTickets(); + + return nodeName switch { - var user = allUsers.FirstOrDefault(u => u.Id == ticket.CreateUser); - var resolveUser = allUsers.FirstOrDefault(u => u.Id == ticket.ResolveUser); + AppConstants.TreeNodeAllTroubleTickets => allTickets, + AppConstants.TreeNodeOpenTroubleTickets => allTickets.Where(t => !t.IsSolved).ToList(), + AppConstants.TreeNodeClosedTroubleTickets => allTickets.Where(t => t.IsSolved).ToList(), + AppConstants.TreeNodeOverdueTroubleTickets => allTickets.Where(t => DateTime.Now > t.Deadline).ToList(), + AppConstants.TreeNodeRegisteredTroubleTickets => allTickets.Where(t => t.Status == AppConstants.StatusRegistered).ToList(), + AppConstants.TreeNodeWorkTroubleTickets => allTickets.Where(t => t.Status == AppConstants.StatusInProgress).ToList(), + AppConstants.TreeNodeCompletedTroubleTickets => allTickets.Where(t => t.Status == AppConstants.StatusCompleted).ToList(), + AppConstants.TreeNodeRejectedTroubleTickets => allTickets.Where(t => t.Status == AppConstants.StatusRejected).ToList(), + _ => new List() + }; + } - var rowIndex = troubleTicketsDataGridView.Rows.Add(); - var row = troubleTicketsDataGridView.Rows[rowIndex]; + private List GetAllRelevantTickets() + { + return user.IsEmployee + ? provider.GetAllTroubleTickets() + : provider.GetAllTroubleTickets().Where(t => t.CreateUser == user.Id).ToList(); + } - row.Cells[0].Value = ticket.Id; - row.Cells[1].Value = ticket.IsSolved ? "Да" : "Нет"; + private void ClearAndSetupDataGridViewForTickets() + { + troubleTicketsDataGridView.Columns.Clear(); + AddTicketColumnsToDataGridView(); + } + + private void FillTroubleTicketsDataGridView(List tickets) + { + troubleTicketsDataGridView.Rows.Clear(); + List allUsers = provider.GetAllUsers(); - SetRowStyleBasedOnStatus(row, ticket); + foreach (TroubleTicket ticket in tickets) + { + int rowIndex = troubleTicketsDataGridView.Rows.Add(); + DataGridViewRow row = troubleTicketsDataGridView.Rows[rowIndex]; - row.Cells[2].Value = ticket.Status; - row.Cells[3].Value = GetPreviewText(ticket.Text); - row.Cells[4].Value = ticket.Resolve; - row.Cells[5].Value = resolveUser?.Name ?? string.Empty; - row.Cells[6].Value = ticket.Created; - row.Cells[7].Value = ticket.ResolveTime; - row.Cells[8].Value = ticket.Deadline; - row.Cells[9].Value = $"{user?.Name} \\ {user?.Email}"; + PopulateTicketRow(row, ticket, allUsers); } troubleTicketsDataGridView.ClearSelection(); } - private void SetRowStyleBasedOnStatus(DataGridViewRow row, TroubleTicket ticket) + private void PopulateTicketRow(DataGridViewRow row, TroubleTicket ticket, List allUsers) + { + User createUser = allUsers.FirstOrDefault(u => u.Id == ticket.CreateUser); + User resolveUser = allUsers.FirstOrDefault(u => u.Id == ticket.ResolveUser); + + row.Cells[0].Value = ticket.Id; + row.Cells[1].Value = ticket.IsSolved ? "Да" : "Нет"; + row.Cells[2].Value = ticket.Status; + row.Cells[3].Value = GetPreviewText(ticket.Text); + row.Cells[4].Value = ticket.Resolve; + row.Cells[5].Value = resolveUser?.Name ?? string.Empty; + row.Cells[6].Value = ticket.Created; + row.Cells[7].Value = ticket.ResolveTime; + row.Cells[8].Value = ticket.Deadline; + row.Cells[9].Value = $"{createUser?.Name} \\ {createUser?.Email}"; + + ApplyRowStylingBasedOnTicket(row, ticket); + } + + private void ApplyRowStylingBasedOnTicket(DataGridViewRow row, TroubleTicket ticket) { if (ticket.IsSolved) { @@ -477,12 +575,11 @@ private void SetRowStyleBasedOnStatus(DataGridViewRow row, TroubleTicket ticket) } else { - if ((DateTime.Now - ticket.Deadline).TotalSeconds > 0) + if (DateTime.Now > ticket.Deadline) { row.DefaultCellStyle.BackColor = Color.LightSalmon; } - - if (ticket.Status == AppConstants.StatusInProgress) + else if (ticket.Status == AppConstants.StatusInProgress) { row.DefaultCellStyle.BackColor = Color.LightYellow; } @@ -498,8 +595,7 @@ private string GetPreviewText(string text) return text; } - - private void AddColumnsTroubleTicketsDataGridView() + private void AddTicketColumnsToDataGridView() { troubleTicketsDataGridView.Columns.Add("id", "ID"); troubleTicketsDataGridView.Columns.Add("isSolved", "Решён"); diff --git a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs index 4229c28..df18e36 100644 --- a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs @@ -2,7 +2,6 @@ using System.Windows.Forms; using HelpDesk.Common; using HelpDesk.Common.Models; -using HelpDesk.Common.System; namespace HelpDeskWinFormsApp { @@ -17,8 +16,29 @@ public RegistrationForm(IProvider provider) this.provider = provider; } + private bool ValidateAllFields() + { + var validations = new[] + { + InputValidator.ValidateName(nameTextBox.Text), + InputValidator.ValidateLogin(loginTextBox.Text), + InputValidator.ValidatePassword(passwordTextBox.Text), + InputValidator.ValidatePasswordMatch(passwordTextBox.Text, replyPasswordTextBox.Text), + InputValidator.ValidateEmail(emailTextBox.Text) + }; + + foreach (var validation in validations) + { + if (!validation.IsValid) + { + MessageBox.Show(validation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + } - + return true; + } private void RegistrationForm_FormClosing(object sender, FormClosingEventArgs e) { @@ -26,6 +46,11 @@ private void RegistrationForm_FormClosing(object sender, FormClosingEventArgs e) { return; } + if (!ValidateAllFields()) + { + e.Cancel = true; + return; + } var user = new User { @@ -40,11 +65,11 @@ private void RegistrationForm_FormClosing(object sender, FormClosingEventArgs e) private void RegistrationButton_Click(object sender, System.EventArgs e) { - - + if (!ValidateAllFields()) + { DialogResult = DialogResult.None; return; - + } DialogResult = DialogResult.OK; Close(); diff --git a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs index 178a63a..13a87d3 100644 --- a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs @@ -6,12 +6,12 @@ namespace HelpDeskWinFormsApp { public partial class TroubleTicketForm : Form { - int ticketId; - TroubleTicket troubleTicket; - User userCreate; - bool isEmployee; - int resolveUserId; - string lastStatus; + private int ticketId; + private TroubleTicket troubleTicket; + private User userCreate; + private bool isEmployee; + private int resolveUserId; + private string lastStatus; private readonly IProvider provider; public TroubleTicketForm(int ticketId, bool isEmployee, int resolveUserId, IProvider provider) @@ -55,7 +55,7 @@ private void TroubleTicketForm_FormClosing(object sender, FormClosingEventArgs e { if (DialogResult == DialogResult.OK) { - if (resolveRichTextBox.Text == string.Empty && (statusTroubleTicketComboBox.Text == "Выполнена" || statusTroubleTicketComboBox.Text == "Отклонена")) + if (resolveRichTextBox.Text == string.Empty && (statusTroubleTicketComboBox.Text == AppConstants.StatusCompleted || statusTroubleTicketComboBox.Text == AppConstants.StatusCompleted)) { e.Cancel = true; MessageBox.Show("Пожалуйста заполните решение.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -64,11 +64,11 @@ private void TroubleTicketForm_FormClosing(object sender, FormClosingEventArgs e if (statusTroubleTicketComboBox.Text != lastStatus) { - if (statusTroubleTicketComboBox.Text == "Выполнена" || statusTroubleTicketComboBox.Text == "Отклонена") + if (statusTroubleTicketComboBox.Text == AppConstants.StatusCompleted || statusTroubleTicketComboBox.Text == AppConstants.StatusCompleted) { provider.ResolveTroubleTicket(troubleTicket.Id, statusTroubleTicketComboBox.Text, resolveRichTextBox.Text, resolveUserId); } - else if (statusTroubleTicketComboBox.Text == "Зарегистрирована" && lastStatus != "Зарегистрирована") + else if (statusTroubleTicketComboBox.Text == AppConstants.StatusRegistered && lastStatus != AppConstants.StatusRegistered) { e.Cancel = true; MessageBox.Show("Возврат в статус \"Зарегистрирована\" запрещён.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/HelpDesk/HelpDeskWinFormsApp/Validators.cs b/HelpDesk/HelpDeskWinFormsApp/Validators.cs deleted file mode 100644 index 9d621b8..0000000 --- a/HelpDesk/HelpDeskWinFormsApp/Validators.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace HelpDesk.Common -{ - internal class Validators - { - } -} From ea486aefb1dc4794d682e8d5e7b80ad6e80df796 Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Sat, 6 Dec 2025 01:36:39 +0300 Subject: [PATCH 06/14] var --- HelpDesk/HelpDeskWinFormsApp/MainForm.cs | 72 ++++++++++++------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs index 7e7cbde..5e077b2 100644 --- a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs @@ -29,7 +29,7 @@ public void GetProvider() private void MainForm_Load(object sender, EventArgs e) { - string login = AuthorizationUser(); + var login = AuthorizationUser(); if (!string.IsNullOrEmpty(login)) { @@ -88,7 +88,7 @@ private void LogoutToolStripMenuItem_Click(object sender, EventArgs e) ClearDataGridView(); Hide(); - string login = AuthorizationUser(); + var login = AuthorizationUser(); if (!string.IsNullOrEmpty(login)) { @@ -127,7 +127,7 @@ private void UpdateTreeViewLayout() private void UpdateButtonPositions() { - int panelHeight = splitContainer.Panel1.Height; + var panelHeight = splitContainer.Panel1.Height; editUserButton.Location = new Point( openTroubleTicketButton.Location.X, @@ -174,9 +174,9 @@ private bool TryGetSelectedTicketId(out int ticketId) private void OpenTroubleTicketForm(int ticketId) { - int resolveUserId = GetResolveUserIdForTicket(ticketId); + var resolveUserId = GetResolveUserIdForTicket(ticketId); - using (TroubleTicketForm ticketForm = new TroubleTicketForm(ticketId, user.IsEmployee, resolveUserId, provider)) + using (var ticketForm = new TroubleTicketForm(ticketId, user.IsEmployee, resolveUserId, provider)) { if (ticketForm.ShowDialog() == DialogResult.OK) { @@ -187,7 +187,7 @@ private void OpenTroubleTicketForm(int ticketId) private int GetResolveUserIdForTicket(int ticketId) { - TroubleTicket ticket = provider.GetTroubleTicket(ticketId); + var ticket = provider.GetTroubleTicket(ticketId); if (ticket.ResolveUser != null) { @@ -199,7 +199,7 @@ private int GetResolveUserIdForTicket(int ticketId) private void AddTroubleTicketButton_Click(object sender, EventArgs e) { - using (AddTroubleTicketForm addForm = new AddTroubleTicketForm(user, provider)) + using (var addForm = new AddTroubleTicketForm(user, provider)) { if (addForm.ShowDialog() == DialogResult.OK) { @@ -224,7 +224,7 @@ private void RefreshDataGridBasedOnSelectedNode() { if (treeView.SelectedNode?.Parent == null) return; - string parentName = treeView.SelectedNode.Parent.Name; + var parentName = treeView.SelectedNode.Parent.Name; UpdateButtonStates(parentName); @@ -241,7 +241,7 @@ private void RefreshDataGridBasedOnSelectedNode() private void UpdateButtonStates(string parentName) { - bool isUsersNode = parentName == AppConstants.TreeNodeUsers; + var isUsersNode = parentName == AppConstants.TreeNodeUsers; editUserButton.Enabled = isUsersNode; openTroubleTicketButton.Enabled = !isUsersNode; @@ -256,7 +256,7 @@ private void ListTTDataGridView_DoubleClick(object sender, EventArgs e) { if (treeView.SelectedNode?.Parent == null) return; - string parentName = treeView.SelectedNode.Parent.Name; + var parentName = treeView.SelectedNode.Parent.Name; if (parentName == AppConstants.TreeNodeTrubleTicketList || parentName == AppConstants.TreeNodeStatusTroubleTicket) @@ -271,9 +271,9 @@ private void ListTTDataGridView_DoubleClick(object sender, EventArgs e) private void ExportToolStripMenuItem_Click(object sender, EventArgs e) { - bool isSupport = user.IsEmployee && user.Department == AppConstants.DepartmentTechnicalSupport; + var isSupport = user.IsEmployee && user.Department == AppConstants.DepartmentTechnicalSupport; - using (ExportForm exportForm = new ExportForm(isSupport, provider)) + using (var exportForm = new ExportForm(isSupport, provider)) { exportForm.ShowDialog(); } @@ -302,7 +302,7 @@ private bool TryGetSelectedUserId(out int userId) private void OpenEditUserForm(int userId) { - using (EditUserForm editForm = new EditUserForm(userId, provider)) + using (var editForm = new EditUserForm(userId, provider)) { if (editForm.ShowDialog() == DialogResult.OK) { @@ -313,7 +313,7 @@ private void OpenEditUserForm(int userId) private void SetWindowHeaderText() { - string userType = user.IsEmployee ? $"{user.Function}: {user.Name}" : $"Клиент: {user.Name}"; + var userType = user.IsEmployee ? $"{user.Function}: {user.Name}" : $"Клиент: {user.Name}"; Text = $"HelpDesk. {userType}/{user.Login}"; } @@ -327,11 +327,11 @@ private void RemoveUserTreeNode() private void ShowUserTreeNode() { - bool shouldShowUsersNode = user.IsEmployee && user.Department != AppConstants.DepartmentTechnicalSupport; + var shouldShowUsersNode = user.IsEmployee && user.Department != AppConstants.DepartmentTechnicalSupport; if (shouldShowUsersNode && treeView.Nodes.Count == 1) { - TreeNode usersNode = CreateUsersTreeStructure(); + var usersNode = CreateUsersTreeStructure(); treeView.Nodes.Add(usersNode); } else if (!shouldShowUsersNode) @@ -344,17 +344,17 @@ private void ShowUserTreeNode() private TreeNode CreateUsersTreeStructure() { - TreeNode allUsersNode = new TreeNode("Все пользователи") + var allUsersNode = new TreeNode("Все пользователи") { Name = AppConstants.TreeNodeAllUsers }; - TreeNode clientsNode = new TreeNode("Клиенты") + var clientsNode = new TreeNode("Клиенты") { Name = AppConstants.TreeNodeClients }; - TreeNode employeesNode = new TreeNode("Сотрудники") + var employeesNode = new TreeNode("Сотрудники") { Name = AppConstants.TreeNodeEmployees }; @@ -367,7 +367,7 @@ private TreeNode CreateUsersTreeStructure() private string AuthorizationUser() { - AuthorizationForm authorizationForm = new AuthorizationForm(provider); + var authorizationForm = new AuthorizationForm(provider); if (authorizationForm.ShowDialog() == DialogResult.OK) { @@ -390,7 +390,7 @@ private string HandleAuthorizationFailure(bool isNeedRegistration) private string ProcessRegistration() { - using (RegistrationForm registrationForm = new RegistrationForm(provider)) + using (var registrationForm = new RegistrationForm(provider)) { DialogResult result = registrationForm.ShowDialog(); @@ -412,8 +412,8 @@ private string ProcessRegistration() private void RefreshUsersDataGrid() { - string selectedNode = treeView.SelectedNode.Name; - List users = GetFilteredUsers(selectedNode); + var selectedNode = treeView.SelectedNode.Name; + var users = GetFilteredUsers(selectedNode); ClearAndSetupDataGridViewForUsers(); FillUsersDataGridView(users); @@ -421,7 +421,7 @@ private void RefreshUsersDataGrid() private List GetFilteredUsers(string nodeName) { - List allUsers = provider.GetAllUsers(); + var allUsers = provider.GetAllUsers(); return nodeName switch { @@ -453,10 +453,10 @@ private void FillUsersDataGridView(List users) { troubleTicketsDataGridView.Rows.Clear(); - foreach (User userData in users) + foreach (var userData in users) { - int rowIndex = troubleTicketsDataGridView.Rows.Add(); - DataGridViewRow row = troubleTicketsDataGridView.Rows[rowIndex]; + var rowIndex = troubleTicketsDataGridView.Rows.Add(); + var row = troubleTicketsDataGridView.Rows[rowIndex]; PopulateUserRow(row, userData); } @@ -486,14 +486,14 @@ private void PopulateUserRow(DataGridViewRow row, User userData) private void RefreshTroubleTicketsDataGrid() { - string selectedNode = treeView.SelectedNode.Name; + var selectedNode = treeView.SelectedNode.Name; if (selectedNode == AppConstants.TreeNodeStatusTroubleTicket) { return; } - List tickets = GetFilteredTroubleTickets(selectedNode); + var tickets = GetFilteredTroubleTickets(selectedNode); ClearAndSetupDataGridViewForTickets(); FillTroubleTicketsDataGridView(tickets); @@ -501,7 +501,7 @@ private void RefreshTroubleTicketsDataGrid() private List GetFilteredTroubleTickets(string nodeName) { - List allTickets = GetAllRelevantTickets(); + var allTickets = GetAllRelevantTickets(); return nodeName switch { @@ -533,12 +533,12 @@ private void ClearAndSetupDataGridViewForTickets() private void FillTroubleTicketsDataGridView(List tickets) { troubleTicketsDataGridView.Rows.Clear(); - List allUsers = provider.GetAllUsers(); + var allUsers = provider.GetAllUsers(); - foreach (TroubleTicket ticket in tickets) + foreach (var ticket in tickets) { - int rowIndex = troubleTicketsDataGridView.Rows.Add(); - DataGridViewRow row = troubleTicketsDataGridView.Rows[rowIndex]; + var rowIndex = troubleTicketsDataGridView.Rows.Add(); + var row = troubleTicketsDataGridView.Rows[rowIndex]; PopulateTicketRow(row, ticket, allUsers); } @@ -548,8 +548,8 @@ private void FillTroubleTicketsDataGridView(List tickets) private void PopulateTicketRow(DataGridViewRow row, TroubleTicket ticket, List allUsers) { - User createUser = allUsers.FirstOrDefault(u => u.Id == ticket.CreateUser); - User resolveUser = allUsers.FirstOrDefault(u => u.Id == ticket.ResolveUser); + var createUser = allUsers.FirstOrDefault(u => u.Id == ticket.CreateUser); + var resolveUser = allUsers.FirstOrDefault(u => u.Id == ticket.ResolveUser); row.Cells[0].Value = ticket.Id; row.Cells[1].Value = ticket.IsSolved ? "Да" : "Нет"; From b59758ff4b285d893a350ae494b5d6937d4f8664 Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Sun, 7 Dec 2025 22:45:31 +0300 Subject: [PATCH 07/14] =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20+=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BF=D0=BE=20=D1=80=D0=B5=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Constants/TicketStatuses.cs | 17 ++ HelpDesk/HelpDesk.Common/JsonStorage.cs | 154 ++++++------------ .../HelpDesk.Common/Models/TroubleTicket.cs | 2 +- .../AddTroubleTicketForm.cs | 5 +- HelpDesk/HelpDeskWinFormsApp/AppConstants.cs | 44 ----- .../HelpDeskWinFormsApp/AuthorizationForm.cs | 24 +-- .../Costants/Departments.cs | 8 + .../HelpDeskWinFormsApp/Costants/Functions.cs | 12 ++ .../Costants/TreeViewNodes.cs | 21 +++ .../Costants/UIConstants.cs | 16 ++ .../Costants/UserInterfaceTexts.cs | 15 ++ HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs | 80 +++++---- HelpDesk/HelpDeskWinFormsApp/ExportForm.cs | 40 ++--- .../HelpDeskWinFormsApp/InputValidator.cs | 2 +- HelpDesk/HelpDeskWinFormsApp/MainForm.cs | 87 +++++----- .../HelpDeskWinFormsApp/RegistrationForm.cs | 56 +++++-- .../HelpDeskWinFormsApp/TroubleTicketForm.cs | 9 +- 17 files changed, 311 insertions(+), 281 deletions(-) create mode 100644 HelpDesk/HelpDesk.Common/Constants/TicketStatuses.cs delete mode 100644 HelpDesk/HelpDeskWinFormsApp/AppConstants.cs create mode 100644 HelpDesk/HelpDeskWinFormsApp/Costants/Departments.cs create mode 100644 HelpDesk/HelpDeskWinFormsApp/Costants/Functions.cs create mode 100644 HelpDesk/HelpDeskWinFormsApp/Costants/TreeViewNodes.cs create mode 100644 HelpDesk/HelpDeskWinFormsApp/Costants/UIConstants.cs create mode 100644 HelpDesk/HelpDeskWinFormsApp/Costants/UserInterfaceTexts.cs diff --git a/HelpDesk/HelpDesk.Common/Constants/TicketStatuses.cs b/HelpDesk/HelpDesk.Common/Constants/TicketStatuses.cs new file mode 100644 index 0000000..5fb40be --- /dev/null +++ b/HelpDesk/HelpDesk.Common/Constants/TicketStatuses.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HelpDesk.Common.Constants +{ + public static class TicketStatuses + { + public const string Registered = "Зарегистрирована"; + public const string InProgress = "В работе"; + public const string Completed = "Выполнена"; + public const string Rejected = "Отклонена"; + + } +} diff --git a/HelpDesk/HelpDesk.Common/JsonStorage.cs b/HelpDesk/HelpDesk.Common/JsonStorage.cs index b649600..d667158 100644 --- a/HelpDesk/HelpDesk.Common/JsonStorage.cs +++ b/HelpDesk/HelpDesk.Common/JsonStorage.cs @@ -13,107 +13,58 @@ public class JsonStorage : IProvider public bool IsCorrectLoginPassword(string login, string password) { var users = JsonProvider.Deserialize(usersFileName); - User user = null; if (users == null || users.Count == 0) { return false; } - else - { - user = users.FirstOrDefault(x => x.Login == login); - } + + var user = users.FirstOrDefault(x => x.Login == login); if (user == null) { return false; } - return user.Password != Methods.GetHashMD5(password); + return user.Password == Methods.GetHashMD5(password); } public User GetUser(string login) { var users = JsonProvider.Deserialize(usersFileName); - User user = null; - - if (users == null || users.Count == 0) - { - return new User(); - } - else - { - user = users.FirstOrDefault(x => x.Login == login); - } - - if (user == null) - { - return new User(); - } - - return user; + + return users?.FirstOrDefault(x => x.Login == login); + } public User GetUser(int id) { var users = JsonProvider.Deserialize(usersFileName); - User user = null; - - if (users == null || users.Count == 0) - { - return new User(); - } - else - { - user = users.FirstOrDefault(x => x.Id == id); - } - - if (user == null) - { - return new User(); - } - return user; + return users?.FirstOrDefault(x => x.Id == id); } public void AddUser(User user) { - var users = JsonProvider.Deserialize(usersFileName); - - if (users != null) - { - user.Id = users.Max(x => x.Id) + 1; - - users.Add(user); - } - else - { - users = new List { user }; - } + var users = JsonProvider.Deserialize(usersFileName) ?? new List(); + user.Id = users.Count == 0 ? 1 : users.Max(x => x.Id) + 1; + users.Add(user); JsonProvider.Serialize(users, usersFileName); } public List GetAllUsers() { - return JsonProvider.Deserialize(usersFileName); + return JsonProvider.Deserialize(usersFileName) ?? new List(); } public void AddTroubleTicket(TroubleTicket troubleTicket) { - var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName); - - if (troubleTickets == null) - { - troubleTickets = new List { troubleTicket }; - } - else - { - troubleTicket.Id = troubleTickets.Max(x => x.Id) + 1; + var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName) ?? new List(); - troubleTickets.Add(troubleTicket); - } + troubleTicket.Id = troubleTickets.Count == 0 ? 1 : troubleTickets.Max(x => x.Id) + 1; + troubleTickets.Add(troubleTicket); JsonProvider.Serialize(troubleTickets, troubleTicketsFileName); } @@ -122,38 +73,38 @@ public List GetAllTroubleTickets() { var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName); - if (troubleTickets == null) - { - return new List(); - } - else - { - return JsonProvider.Deserialize(troubleTicketsFileName); - } + return troubleTickets ?? new List(); } public TroubleTicket GetTroubleTicket(int id) { var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName); - if (troubleTickets == null) - { - return new TroubleTicket(); - } - else - { - var troubleTicket = troubleTickets.FirstOrDefault(t => t.Id == id); + return troubleTickets?.FirstOrDefault(t => t.Id == id); + } - return troubleTicket; - } + private void SaveTroubleTickets(List tickets) + { + JsonProvider.Serialize(tickets.OrderBy(x => x.Id).ToList(), troubleTicketsFileName); + } + + private void SaveUsers(List users) + { + JsonProvider.Serialize(users.OrderBy(x => x.Id).ToList(), usersFileName); + } + + private List GetAllTroubleTicketsInternal() + { + return JsonProvider.Deserialize(troubleTicketsFileName) + ?? new List(); } public void ResolveTroubleTicket(int id, string status, string resolve, int resolveUserId) { - var troubleTickets = GetAllTroubleTickets(); - var troubleTicket = GetTroubleTicket(id); + var troubleTickets = GetAllTroubleTicketsInternal(); + var troubleTicket = troubleTickets.FirstOrDefault(t => t.Id == id); - troubleTickets.RemoveAll(x => x.Id == id); + if (troubleTicket == null) return; troubleTicket.IsSolved = true; troubleTicket.Status = status; @@ -161,34 +112,26 @@ public void ResolveTroubleTicket(int id, string status, string resolve, int reso troubleTicket.ResolveTime = DateTime.Now; troubleTicket.ResolveUser = resolveUserId; - troubleTickets.Add(troubleTicket); - - var sortedTroubleTickets = troubleTickets.OrderBy(x => x.Id).ToList(); - - JsonProvider.Serialize(sortedTroubleTickets, troubleTicketsFileName); + SaveTroubleTickets(troubleTickets); } public void ChangeStatusTroubleTicket(int id, string status, int resolveUserId) { - var troubleTickets = GetAllTroubleTickets(); - var troubleTicket = GetTroubleTicket(id); + var troubleTickets = GetAllTroubleTicketsInternal(); + var troubleTicket = troubleTickets.FirstOrDefault(t => t.Id == id); - troubleTickets.RemoveAll(x => x.Id == id); + if (troubleTicket == null) return; troubleTicket.Status = status; troubleTicket.ResolveUser = resolveUserId; - troubleTickets.Add(troubleTicket); - - var sortedTroubleTickets = troubleTickets.OrderBy(x => x.Id).ToList(); - - JsonProvider.Serialize(sortedTroubleTickets, troubleTicketsFileName); + SaveTroubleTickets(troubleTickets); } public void ChangeUserToEmployee(User user, string function, string department) { - var users = GetAllUsers(); + var users = GetAllUsers() ?? new List(); users.RemoveAll(x => x.Id == user.Id); var convertedUser = new User @@ -205,14 +148,12 @@ public void ChangeUserToEmployee(User user, string function, string department) users.Add(convertedUser); - var sortedUsers = users.OrderBy(x => x.Id).ToList(); - - JsonProvider.Serialize(sortedUsers, usersFileName); + SaveUsers(users); } public void ChangeEmployeeToUser(User user) { - var users = GetAllUsers(); + var users = GetAllUsers() ?? new List(); users.RemoveAll(x => x.Id == user.Id); user.IsEmployee = false; @@ -221,20 +162,17 @@ public void ChangeEmployeeToUser(User user) users.Add(user); - var sortedUsers = users.OrderBy(x => x.Id).ToList(); - - JsonProvider.Serialize(sortedUsers, usersFileName); + SaveUsers(users); } public void UpdateUser(User user) { - var users = GetAllUsers(); + var users = GetAllUsers() ?? new List(); users.RemoveAll(x => x.Id == user.Id); users.Add(user); - var sortedUsers = users.OrderBy(x => x.Id).ToList(); - - JsonProvider.Serialize(sortedUsers, usersFileName); + SaveUsers(users); } + } } diff --git a/HelpDesk/HelpDesk.Common/Models/TroubleTicket.cs b/HelpDesk/HelpDesk.Common/Models/TroubleTicket.cs index fd8fb37..0ae17a0 100644 --- a/HelpDesk/HelpDesk.Common/Models/TroubleTicket.cs +++ b/HelpDesk/HelpDesk.Common/Models/TroubleTicket.cs @@ -7,7 +7,7 @@ public class TroubleTicket { public int Id { get; set; } public string Status { get; set; } - public int CreateUser { get; set; } + public int CreateUserId { get; set; } public string Text { get; set; } public string? Resolve { get; set; } public bool IsSolved { get; set; } diff --git a/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs index d972946..a982214 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs @@ -2,6 +2,7 @@ using HelpDesk.Common.Models; using System; using System.Windows.Forms; +using HelpDesk.Common.Constants; namespace HelpDeskWinFormsApp { @@ -29,9 +30,9 @@ private void AddTroubleTicketForm_FormClosing(object sender, FormClosingEventArg { var troubelTicket = new TroubleTicket { - CreateUser = user.Id, + CreateUserId = user.Id, Text = troubleRichTextBox.Text, - Status = AppConstants.StatusRegistered, + Status = TicketStatuses.Registered, Created = DateTime.Now, Deadline = DateTime.Now.AddDays(4) }; diff --git a/HelpDesk/HelpDeskWinFormsApp/AppConstants.cs b/HelpDesk/HelpDeskWinFormsApp/AppConstants.cs deleted file mode 100644 index 3aa3ea4..0000000 --- a/HelpDesk/HelpDeskWinFormsApp/AppConstants.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace HelpDeskWinFormsApp -{ - public static class AppConstants - { - public const string TreeNodeTrubleTicketList = "trubleTicketlist"; - public const string TreeNodeStatusTroubleTicket = "statusTroubleTicketNode"; - public const string TreeNodeUsers = "usersNode"; - public const string TreeNodeAllUsers = "allUsersNode"; - public const string TreeNodeClients = "clientsNode"; - public const string TreeNodeEmployees = "EmployeeNode"; - public const string TreeNodeAllTroubleTickets = "allTroubleTicket"; - public const string TreeNodeOpenTroubleTickets = "openTroubleTicket"; - public const string TreeNodeClosedTroubleTickets = "closedTroubleTicket"; - public const string TreeNodeOverdueTroubleTickets = "overdueTroubleTicketNode"; - public const string TreeNodeRegisteredTroubleTickets = "registeredTroubleTicketNode"; - public const string TreeNodeWorkTroubleTickets = "workTroubleTicketNode"; - public const string TreeNodeCompletedTroubleTickets = "completedTroubleTicketNode"; - public const string TreeNodeRejectedTroubleTickets = "rejectedTroubleTicketNode"; - - public const string StatusRegistered = "Зарегистрирована"; - public const string StatusInProgress = "В работе"; - public const string StatusCompleted = "Выполнена"; - public const string StatusRejected = "Отклонена"; - - public const string UserTypeEmployee = "Сотрудник"; - public const string UserTypeClient = "Клиент"; - public const string DepartmentTechnicalSupport = "Техническая поддержка"; - public const string DepartmentDevelopment = "Разработка"; - public const string FunctionOperator = "Оператор"; - public const string FunctionTechnicalSpecialist = "Технический специалист"; - public const string FunctionTester = "Тестировщик"; - public const string FunctionDeveloper = "Разработчик"; - - public const int TreeViewBottomMargin = 152; - public const int EditButtonOffset = 117; - public const int OpenButtonOffset = 88; - public const int AddButtonOffset = 59; - public const int ExitButtonOffset = 30; - public const int TextPreviewLength = 50; - public const int TextPreviewEllipsisLength = 47; - - public const int InvalidId = -1; - } -} diff --git a/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs index d6bb30f..62ad823 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs @@ -61,20 +61,22 @@ private void AddFirstEmployee() private bool ValidateAllFields() { - var validations = new[] + var loginValidation = InputValidator.ValidateLogin(loginTextBox.Text); + if (!loginValidation.IsValid) { - InputValidator.ValidateLogin(loginTextBox.Text), - InputValidator.ValidatePassword(passwordTextBox.Text) - }; + MessageBox.Show(loginValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + loginTextBox.Focus(); + return false; + } - foreach (var validation in validations) + var passwordValidation = InputValidator.ValidatePassword(passwordTextBox.Text); + if (!passwordValidation.IsValid) { - if (!validation.IsValid) - { - MessageBox.Show(validation.Message, "Ошибка валидации", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return false; - } + MessageBox.Show(passwordValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + passwordTextBox.Focus(); + return false; } return true; diff --git a/HelpDesk/HelpDeskWinFormsApp/Costants/Departments.cs b/HelpDesk/HelpDeskWinFormsApp/Costants/Departments.cs new file mode 100644 index 0000000..b2a3d9c --- /dev/null +++ b/HelpDesk/HelpDeskWinFormsApp/Costants/Departments.cs @@ -0,0 +1,8 @@ +namespace HelpDeskWinFormsApp.Costants +{ + public static class Departments + { + public const string TechnicalSupport = "Техническая поддержка"; + public const string Development = "Разработка"; + } +} diff --git a/HelpDesk/HelpDeskWinFormsApp/Costants/Functions.cs b/HelpDesk/HelpDeskWinFormsApp/Costants/Functions.cs new file mode 100644 index 0000000..5364e2b --- /dev/null +++ b/HelpDesk/HelpDeskWinFormsApp/Costants/Functions.cs @@ -0,0 +1,12 @@ + +namespace HelpDeskWinFormsApp.Costants +{ + public static class Functions + { + public const string Operator = "Оператор"; + public const string TechnicalSpecialist = "Технический специалист"; + public const string Tester = "Тестировщик"; + public const string Developer = "Разработчик"; + + } +} diff --git a/HelpDesk/HelpDeskWinFormsApp/Costants/TreeViewNodes.cs b/HelpDesk/HelpDeskWinFormsApp/Costants/TreeViewNodes.cs new file mode 100644 index 0000000..3712cf7 --- /dev/null +++ b/HelpDesk/HelpDeskWinFormsApp/Costants/TreeViewNodes.cs @@ -0,0 +1,21 @@ + +namespace HelpDeskWinFormsApp.Costants +{ + public static class TreeViewNodes + { + public const string TroubleTicketList = "trubleTicketlist"; + public const string StatusTroubleTicket = "statusTroubleTicketNode"; + public const string Users = "usersNode"; + public const string AllUsers = "allUsersNode"; + public const string Clients = "clientsNode"; + public const string Employees = "EmployeeNode"; + public const string AllTroubleTickets = "allTroubleTicket"; + public const string OpenTroubleTickets = "openTroubleTicket"; + public const string ClosedTroubleTickets = "closedTroubleTicket"; + public const string OverdueTroubleTickets = "overdueTroubleTicketNode"; + public const string RegisteredTroubleTickets = "registeredTroubleTicketNode"; + public const string WorkTroubleTickets = "workTroubleTicketNode"; + public const string CompletedTroubleTickets = "completedTroubleTicketNode"; + public const string RejectedTroubleTickets = "rejectedTroubleTicketNode"; + } +} diff --git a/HelpDesk/HelpDeskWinFormsApp/Costants/UIConstants.cs b/HelpDesk/HelpDeskWinFormsApp/Costants/UIConstants.cs new file mode 100644 index 0000000..ee99f4a --- /dev/null +++ b/HelpDesk/HelpDeskWinFormsApp/Costants/UIConstants.cs @@ -0,0 +1,16 @@ + +namespace HelpDeskWinFormsApp.Costants +{ + public static class UIConstants + { + public const int TreeViewBottomMargin = 152; + public const int EditButtonOffset = 117; + public const int OpenButtonOffset = 88; + public const int AddButtonOffset = 59; + public const int ExitButtonOffset = 30; + + public const int TextPreviewLength = 50; + public const int TextPreviewEllipsisLength = 47; + + } +} diff --git a/HelpDesk/HelpDeskWinFormsApp/Costants/UserInterfaceTexts.cs b/HelpDesk/HelpDeskWinFormsApp/Costants/UserInterfaceTexts.cs new file mode 100644 index 0000000..3395bb4 --- /dev/null +++ b/HelpDesk/HelpDeskWinFormsApp/Costants/UserInterfaceTexts.cs @@ -0,0 +1,15 @@ + +namespace HelpDeskWinFormsApp.Costants +{ + public static class UserInterfaceTexts + { + public const string UserTypeEmployee = "Сотрудник"; + public const string UserTypeClient = "Клиент"; + + public const string AddButtonText = "Добавить"; + public const string EditButtonText = "Редактировать"; + public const string DeleteButtonText = "Удалить"; + public const string SaveButtonText = "Сохранить"; + public const string CancelButtonText = "Отмена"; + } +} diff --git a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs index c41aab2..24c1647 100644 --- a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs @@ -1,7 +1,8 @@ -using HelpDesk.Common; -using HelpDesk.Common.Models; -using System; +using System; using System.Windows.Forms; +using HelpDesk.Common; +using HelpDesk.Common.Models; +using HelpDeskWinFormsApp.Costants; namespace HelpDeskWinFormsApp { @@ -27,7 +28,7 @@ private void EditUserForm_Shown(object sender, EventArgs e) deparmentComboBox.Enabled = true; functionComboBox.Enabled = true; - userTypeComboBox.Text = AppConstants.UserTypeEmployee; + userTypeComboBox.Text = UserInterfaceTexts.UserTypeEmployee; deparmentComboBox.Text = user.Department; functionComboBox.Text = user.Function; } @@ -36,7 +37,7 @@ private void EditUserForm_Shown(object sender, EventArgs e) deparmentComboBox.Enabled = false; functionComboBox.Enabled = false; - userTypeComboBox.Text = AppConstants.UserTypeClient; + userTypeComboBox.Text = UserInterfaceTexts.UserTypeClient; } nameTextBox.Text = user.Name; @@ -47,12 +48,12 @@ private void EditUserForm_Shown(object sender, EventArgs e) private void UserTypeComboBox_SelectedValueChanged(object sender, System.EventArgs e) { - if (userTypeComboBox.Text == AppConstants.UserTypeEmployee) + if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeEmployee) { deparmentComboBox.Enabled = true; functionComboBox.Enabled = true; } - else if (userTypeComboBox.Text == AppConstants.UserTypeClient) + else if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeClient) { deparmentComboBox.Enabled = false; functionComboBox.Enabled = false; @@ -85,11 +86,11 @@ private void EditUserForm_FormClosing(object sender, FormClosingEventArgs e) user.Department = deparmentComboBox.Text; } - if (userTypeComboBox.Text == AppConstants.UserTypeEmployee && !user.IsEmployee) + if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeEmployee && !user.IsEmployee) { provider.ChangeUserToEmployee(user, functionComboBox.Text, deparmentComboBox.Text); } - else if (userTypeComboBox.Text == AppConstants.UserTypeClient && user.IsEmployee) + else if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeClient && user.IsEmployee) { provider.ChangeEmployeeToUser(user); } @@ -101,31 +102,49 @@ private void EditUserForm_FormClosing(object sender, FormClosingEventArgs e) private void DeparmentComboBox_SelectedValueChanged(object sender, EventArgs e) { - if (deparmentComboBox.Text == AppConstants.DepartmentTechnicalSupport) + if (deparmentComboBox.Text == Departments.TechnicalSupport) { functionComboBox.Items.Clear(); - functionComboBox.Items.Add(AppConstants.FunctionOperator); - functionComboBox.Items.Add(AppConstants.FunctionTechnicalSpecialist); - functionComboBox.Text = AppConstants.FunctionOperator; + functionComboBox.Items.Add(Functions.Operator); + functionComboBox.Items.Add(Functions.TechnicalSpecialist); + functionComboBox.Text = Functions.Operator; } - else if (deparmentComboBox.Text == AppConstants.DepartmentDevelopment) + else if (deparmentComboBox.Text == Departments.Development) { functionComboBox.Items.Clear(); - functionComboBox.Items.Add(AppConstants.FunctionTester); - functionComboBox.Items.Add(AppConstants.FunctionDeveloper); - functionComboBox.Text = AppConstants.FunctionTester; + functionComboBox.Items.Add(Functions.Tester); + functionComboBox.Items.Add(Functions.Developer); + functionComboBox.Text = Functions.Tester; } } private bool ValidateAllFields() { - var validations = new[] + var nameValidation = InputValidator.ValidateName(nameTextBox.Text); + if (!nameValidation.IsValid) + { + MessageBox.Show(nameValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + var loginValidation = InputValidator.ValidateLogin(loginTextBox.Text); + if (!loginValidation.IsValid) { - InputValidator.ValidateName(nameTextBox.Text), - InputValidator.ValidateLogin(loginTextBox.Text), - InputValidator.ValidateEmail(emailTextBox.Text) - }; - + MessageBox.Show(loginValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + var emailValidation = InputValidator.ValidateEmail(emailTextBox.Text); + if (!emailValidation.IsValid) + { + MessageBox.Show(emailValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + emailTextBox.Focus(); + return false; + } + if (!string.IsNullOrEmpty(changePasswordTextBox.Text)) { var passwordValidation = InputValidator.ValidatePassword(changePasswordTextBox.Text); @@ -133,6 +152,7 @@ private bool ValidateAllFields() { MessageBox.Show(passwordValidation.Message, "Ошибка валидации", MessageBoxButtons.OK, MessageBoxIcon.Error); + changePasswordTextBox.Focus(); return false; } @@ -143,23 +163,13 @@ private bool ValidateAllFields() { MessageBox.Show(matchValidation.Message, "Ошибка валидации", MessageBoxButtons.OK, MessageBoxIcon.Error); + confurmChangePasswordTextBox.Focus(); return false; } - } - - foreach (var validation in validations) - { - if (!validation.IsValid) - { - MessageBox.Show(validation.Message, "Ошибка валидации", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return false; - } - } + } return true; } - private void SaveButton_Click(object sender, EventArgs e) { if (!ValidateAllFields()) diff --git a/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs b/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs index e05ce1e..dfd81d7 100644 --- a/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs @@ -1,12 +1,14 @@ -using ClosedXML.Excel; -using HelpDesk.Common; -using HelpDesk.Common.Models; -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; +using ClosedXML.Excel; +using HelpDesk.Common; +using HelpDesk.Common.Constants; +using HelpDesk.Common.Models; +using HelpDeskWinFormsApp.Costants; namespace HelpDeskWinFormsApp { @@ -59,13 +61,13 @@ private void ExportButton_Click(object sender, EventArgs e) } var allTroubleTickets = provider.GetAllTroubleTickets(); - var trubleTickets = new List(); + var troubleTickets = new List(); foreach ( var tt in allTroubleTickets) { if (tt.Created >= startDateTimePicker.Value && tt.Created <= endDateTimePicker.Value) { - trubleTickets.Add(tt); + troubleTickets.Add(tt); } } @@ -78,7 +80,7 @@ private void ExportButton_Click(object sender, EventArgs e) { var tempTroubleTickets = new List(); - foreach( var tt in trubleTickets) + foreach( var tt in troubleTickets) { if (tt.Status == statusFilterComboBox.Text) { @@ -86,19 +88,19 @@ private void ExportButton_Click(object sender, EventArgs e) } } - trubleTickets.Clear(); - trubleTickets.AddRange(tempTroubleTickets); + troubleTickets.Clear(); + troubleTickets.AddRange(tempTroubleTickets); } - if (trubleTickets.Count != 0) + if (troubleTickets.Count != 0) { if (fileTypeComboBox.Text == "Excel (.xlsx)") { - ExcelTroubleTicketExport(trubleTickets, users, exportFile); + ExcelTroubleTicketExport(troubleTickets, users, exportFile); } else if (fileTypeComboBox.Text == "Comma-Separated Values (.csv)") { - CsvTroubleTicketExport(trubleTickets, users, exportFile); + CsvTroubleTicketExport(troubleTickets, users, exportFile); } } else @@ -173,7 +175,7 @@ private void CsvTroubleTicketExport(List result, List users progressBar.PerformStep(); var resolveUser = users.Where(u => u.Id == result[i].ResolveUser).FirstOrDefault(); - var createUser = users.Where(u => u.Id == result[i].CreateUser).FirstOrDefault(); + var createUser = users.Where(u => u.Id == result[i].CreateUserId).FirstOrDefault(); sw.Write("\"" + result[i].Id + "\";"); sw.Write(result[i].IsSolved == true ? "\"Да\";" : "\"Нет\";"); @@ -332,7 +334,7 @@ private void ExcelTroubleTicketExport(List result, List use progressBar.PerformStep(); var resolveUser = users.Where(u => u.Id == result[i].ResolveUser).FirstOrDefault(); - var createUser = users.Where(u => u.Id == result[i].CreateUser).FirstOrDefault(); + var createUser = users.Where(u => u.Id == result[i].CreateUserId).FirstOrDefault(); sheet.Cell(i + 2, 1).SetValue(result[i].Id); sheet.Cell(i + 2, 2).SetValue(result[i].IsSolved == true ? "Да" : "Нет"); @@ -361,10 +363,10 @@ private void TypeComboBox_SelectedIndexChanged(object sender, EventArgs e) statusFilter.Clear(); statusFilter.AddRange(new List() { - AppConstants.StatusRegistered, - AppConstants.StatusInProgress, - AppConstants.StatusCompleted, - AppConstants.StatusRejected + TicketStatuses.Registered, + TicketStatuses.InProgress, + TicketStatuses.Completed, + TicketStatuses.Rejected }); statusFilterComboBox.DataSource = null; @@ -376,7 +378,7 @@ private void TypeComboBox_SelectedIndexChanged(object sender, EventArgs e) endDateTimePicker.Enabled = false; statusFilter.Clear(); - statusFilter.AddRange(new List() { AppConstants.UserTypeClient, AppConstants.UserTypeEmployee }); + statusFilter.AddRange(new List() { UserInterfaceTexts.UserTypeClient, UserInterfaceTexts.UserTypeEmployee }); statusFilterComboBox.DataSource = null; statusFilterComboBox.DataSource = statusFilter; } diff --git a/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs b/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs index 81bd9cf..cb2e74e 100644 --- a/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs +++ b/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs @@ -10,7 +10,7 @@ public static class InputValidator private const int MaxNameLength = 100; private const int MinLoginLength = 3; private const int MaxLoginLength = 50; - private const int MinPasswordLength = 6; + private const int MinPasswordLength = 5; private const int MaxPasswordLength = 50; diff --git a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs index 5e077b2..b733f93 100644 --- a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs @@ -7,6 +7,8 @@ using HelpDesk.Common.Application; using HelpDesk.Common.Models; using HelpDesk.Common.System; +using HelpDesk.Common.Constants; +using HelpDeskWinFormsApp.Costants; namespace HelpDeskWinFormsApp { @@ -14,6 +16,7 @@ public partial class MainForm : Form { private User user = new(); private IProvider provider; + public const int InvalidId = -1; public MainForm(ApplicationDIController controller) { @@ -58,7 +61,7 @@ private void SetupUserInterface() private void SetupTreeViewLayout() { treeView.Width = splitContainer.Panel1.Width; - treeView.Height = splitContainer.Panel1.Height - AppConstants.TreeViewBottomMargin; + treeView.Height = splitContainer.Panel1.Height - UIConstants.TreeViewBottomMargin; } private void SetupDataGridViewLayout() @@ -122,7 +125,7 @@ private void SplitContainer_Panel1_Resize(object sender, EventArgs e) private void UpdateTreeViewLayout() { treeView.Width = splitContainer.Panel1.Width; - treeView.Height = splitContainer.Panel1.Height - AppConstants.TreeViewBottomMargin; + treeView.Height = splitContainer.Panel1.Height - UIConstants.TreeViewBottomMargin; } private void UpdateButtonPositions() @@ -131,19 +134,19 @@ private void UpdateButtonPositions() editUserButton.Location = new Point( openTroubleTicketButton.Location.X, - panelHeight - AppConstants.EditButtonOffset); + panelHeight - UIConstants.EditButtonOffset); openTroubleTicketButton.Location = new Point( openTroubleTicketButton.Location.X, - panelHeight - AppConstants.OpenButtonOffset); + panelHeight - UIConstants.OpenButtonOffset); addTroubleTicketbutton.Location = new Point( openTroubleTicketButton.Location.X, - panelHeight - AppConstants.AddButtonOffset); + panelHeight - UIConstants.AddButtonOffset); exitButton.Location = new Point( exitButton.Location.X, - panelHeight - AppConstants.ExitButtonOffset); + panelHeight - UIConstants.ExitButtonOffset); } private void SplitContainer_Panel2_Resize(object sender, EventArgs e) @@ -161,7 +164,7 @@ private void OpenTroubleTicketButton_Click(object sender, EventArgs e) private bool TryGetSelectedTicketId(out int ticketId) { - ticketId = AppConstants.InvalidId; + ticketId = InvalidId; if (troubleTicketsDataGridView.SelectedRows.Count > 0) { @@ -194,7 +197,7 @@ private int GetResolveUserIdForTicket(int ticketId) return (int)ticket.ResolveUser; } - return user.IsEmployee ? user.Id : AppConstants.InvalidId; + return user.IsEmployee ? user.Id : InvalidId; } private void AddTroubleTicketButton_Click(object sender, EventArgs e) @@ -211,8 +214,8 @@ private void AddTroubleTicketButton_Click(object sender, EventArgs e) private void SelectOpenTroubleTicketsNode() { - treeView.SelectedNode = treeView.Nodes[AppConstants.TreeNodeTrubleTicketList] - .Nodes[AppConstants.TreeNodeOpenTroubleTickets]; + treeView.SelectedNode = treeView.Nodes[TreeViewNodes.TroubleTicketList] + .Nodes[TreeViewNodes.OpenTroubleTickets]; } private void TreeView_AfterSelect(object sender, TreeViewEventArgs e) @@ -228,12 +231,12 @@ private void RefreshDataGridBasedOnSelectedNode() UpdateButtonStates(parentName); - if (parentName == AppConstants.TreeNodeTrubleTicketList || - parentName == AppConstants.TreeNodeStatusTroubleTicket) + if (parentName == TreeViewNodes.TroubleTicketList || + parentName == TreeViewNodes.StatusTroubleTicket) { RefreshTroubleTicketsDataGrid(); } - else if (parentName == AppConstants.TreeNodeUsers) + else if (parentName == TreeViewNodes.Users) { RefreshUsersDataGrid(); } @@ -241,7 +244,7 @@ private void RefreshDataGridBasedOnSelectedNode() private void UpdateButtonStates(string parentName) { - var isUsersNode = parentName == AppConstants.TreeNodeUsers; + var isUsersNode = parentName == TreeViewNodes.Users; editUserButton.Enabled = isUsersNode; openTroubleTicketButton.Enabled = !isUsersNode; @@ -258,12 +261,12 @@ private void ListTTDataGridView_DoubleClick(object sender, EventArgs e) var parentName = treeView.SelectedNode.Parent.Name; - if (parentName == AppConstants.TreeNodeTrubleTicketList || - parentName == AppConstants.TreeNodeStatusTroubleTicket) + if (parentName == TreeViewNodes.TroubleTicketList || + parentName == TreeViewNodes.StatusTroubleTicket) { openTroubleTicketButton.PerformClick(); } - else if (parentName == AppConstants.TreeNodeUsers) + else if (parentName == TreeViewNodes.Users) { editUserButton.PerformClick(); } @@ -271,7 +274,7 @@ private void ListTTDataGridView_DoubleClick(object sender, EventArgs e) private void ExportToolStripMenuItem_Click(object sender, EventArgs e) { - var isSupport = user.IsEmployee && user.Department == AppConstants.DepartmentTechnicalSupport; + var isSupport = user.IsEmployee && user.Department == Departments.TechnicalSupport; using (var exportForm = new ExportForm(isSupport, provider)) { @@ -289,7 +292,7 @@ private void EditUserButton_Click(object sender, EventArgs e) private bool TryGetSelectedUserId(out int userId) { - userId = AppConstants.InvalidId; + userId = InvalidId; if (troubleTicketsDataGridView.SelectedRows.Count > 0) { @@ -327,7 +330,7 @@ private void RemoveUserTreeNode() private void ShowUserTreeNode() { - var shouldShowUsersNode = user.IsEmployee && user.Department != AppConstants.DepartmentTechnicalSupport; + var shouldShowUsersNode = user.IsEmployee && user.Department != Departments.TechnicalSupport; if (shouldShowUsersNode && treeView.Nodes.Count == 1) { @@ -346,22 +349,22 @@ private TreeNode CreateUsersTreeStructure() { var allUsersNode = new TreeNode("Все пользователи") { - Name = AppConstants.TreeNodeAllUsers + Name = TreeViewNodes.AllUsers }; var clientsNode = new TreeNode("Клиенты") { - Name = AppConstants.TreeNodeClients + Name = TreeViewNodes.Clients }; var employeesNode = new TreeNode("Сотрудники") { - Name = AppConstants.TreeNodeEmployees + Name = TreeViewNodes.Employees }; return new TreeNode("Пользователи", new TreeNode[] { allUsersNode, clientsNode, employeesNode }) { - Name = AppConstants.TreeNodeUsers + Name = TreeViewNodes.Users }; } @@ -425,9 +428,9 @@ private List GetFilteredUsers(string nodeName) return nodeName switch { - AppConstants.TreeNodeAllUsers => allUsers, - AppConstants.TreeNodeClients => allUsers.Where(u => !u.IsEmployee).ToList(), - AppConstants.TreeNodeEmployees => allUsers.Where(u => u.IsEmployee).ToList(), + TreeViewNodes.AllUsers => allUsers, + TreeViewNodes.Clients => allUsers.Where(u => !u.IsEmployee).ToList(), + TreeViewNodes.Employees => allUsers.Where(u => u.IsEmployee).ToList(), _ => new List() }; } @@ -488,7 +491,7 @@ private void RefreshTroubleTicketsDataGrid() { var selectedNode = treeView.SelectedNode.Name; - if (selectedNode == AppConstants.TreeNodeStatusTroubleTicket) + if (selectedNode == TreeViewNodes.StatusTroubleTicket) { return; } @@ -505,14 +508,14 @@ private List GetFilteredTroubleTickets(string nodeName) return nodeName switch { - AppConstants.TreeNodeAllTroubleTickets => allTickets, - AppConstants.TreeNodeOpenTroubleTickets => allTickets.Where(t => !t.IsSolved).ToList(), - AppConstants.TreeNodeClosedTroubleTickets => allTickets.Where(t => t.IsSolved).ToList(), - AppConstants.TreeNodeOverdueTroubleTickets => allTickets.Where(t => DateTime.Now > t.Deadline).ToList(), - AppConstants.TreeNodeRegisteredTroubleTickets => allTickets.Where(t => t.Status == AppConstants.StatusRegistered).ToList(), - AppConstants.TreeNodeWorkTroubleTickets => allTickets.Where(t => t.Status == AppConstants.StatusInProgress).ToList(), - AppConstants.TreeNodeCompletedTroubleTickets => allTickets.Where(t => t.Status == AppConstants.StatusCompleted).ToList(), - AppConstants.TreeNodeRejectedTroubleTickets => allTickets.Where(t => t.Status == AppConstants.StatusRejected).ToList(), + TreeViewNodes.AllTroubleTickets => allTickets, + TreeViewNodes.OpenTroubleTickets => allTickets.Where(t => !t.IsSolved).ToList(), + TreeViewNodes.ClosedTroubleTickets => allTickets.Where(t => t.IsSolved).ToList(), + TreeViewNodes.OverdueTroubleTickets => allTickets.Where(t => DateTime.Now > t.Deadline).ToList(), + TreeViewNodes.RegisteredTroubleTickets => allTickets.Where(t => t.Status == TicketStatuses.Registered).ToList(), + TreeViewNodes.WorkTroubleTickets => allTickets.Where(t => t.Status == TicketStatuses.InProgress).ToList(), + TreeViewNodes.CompletedTroubleTickets => allTickets.Where(t => t.Status == TicketStatuses.Completed).ToList(), + TreeViewNodes.RejectedTroubleTickets => allTickets.Where(t => t.Status == TicketStatuses.Rejected).ToList(), _ => new List() }; } @@ -521,7 +524,7 @@ private List GetAllRelevantTickets() { return user.IsEmployee ? provider.GetAllTroubleTickets() - : provider.GetAllTroubleTickets().Where(t => t.CreateUser == user.Id).ToList(); + : provider.GetAllTroubleTickets().Where(t => t.CreateUserId == user.Id).ToList(); } private void ClearAndSetupDataGridViewForTickets() @@ -548,7 +551,7 @@ private void FillTroubleTicketsDataGridView(List tickets) private void PopulateTicketRow(DataGridViewRow row, TroubleTicket ticket, List allUsers) { - var createUser = allUsers.FirstOrDefault(u => u.Id == ticket.CreateUser); + var createUser = allUsers.FirstOrDefault(u => u.Id == ticket.CreateUserId); var resolveUser = allUsers.FirstOrDefault(u => u.Id == ticket.ResolveUser); row.Cells[0].Value = ticket.Id; @@ -569,7 +572,7 @@ private void ApplyRowStylingBasedOnTicket(DataGridViewRow row, TroubleTicket tic { if (ticket.IsSolved) { - row.DefaultCellStyle.BackColor = ticket.Status == AppConstants.StatusCompleted + row.DefaultCellStyle.BackColor = ticket.Status == TicketStatuses.Completed ? Color.LightGreen : Color.LightGray; } @@ -579,7 +582,7 @@ private void ApplyRowStylingBasedOnTicket(DataGridViewRow row, TroubleTicket tic { row.DefaultCellStyle.BackColor = Color.LightSalmon; } - else if (ticket.Status == AppConstants.StatusInProgress) + else if (ticket.Status == TicketStatuses.InProgress) { row.DefaultCellStyle.BackColor = Color.LightYellow; } @@ -588,9 +591,9 @@ private void ApplyRowStylingBasedOnTicket(DataGridViewRow row, TroubleTicket tic private string GetPreviewText(string text) { - if (text.Length > AppConstants.TextPreviewLength) + if (text.Length > UIConstants.TextPreviewLength) { - return $"{text.Substring(0, AppConstants.TextPreviewEllipsisLength)}..."; + return $"{text.Substring(0, UIConstants.TextPreviewEllipsisLength)}..."; } return text; } diff --git a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs index df18e36..8a859df 100644 --- a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs @@ -18,23 +18,51 @@ public RegistrationForm(IProvider provider) private bool ValidateAllFields() { - var validations = new[] + var nameValidation = InputValidator.ValidateName(nameTextBox.Text); + if (!nameValidation.IsValid) { - InputValidator.ValidateName(nameTextBox.Text), - InputValidator.ValidateLogin(loginTextBox.Text), - InputValidator.ValidatePassword(passwordTextBox.Text), - InputValidator.ValidatePasswordMatch(passwordTextBox.Text, replyPasswordTextBox.Text), - InputValidator.ValidateEmail(emailTextBox.Text) - }; + MessageBox.Show(nameValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + nameTextBox.Focus(); + return false; + } + + var loginValidation = InputValidator.ValidateLogin(loginTextBox.Text); + if (!loginValidation.IsValid) + { + MessageBox.Show(loginValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + loginTextBox.Focus(); + return false; + } + + var passwordValidation = InputValidator.ValidatePassword(passwordTextBox.Text); + if (!passwordValidation.IsValid) + { + MessageBox.Show(passwordValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + passwordTextBox.Focus(); + return false; + } + + var matchValidation = InputValidator.ValidatePasswordMatch( + passwordTextBox.Text, replyPasswordTextBox.Text); + + if (!matchValidation.IsValid) + { + MessageBox.Show(matchValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + replyPasswordTextBox.Focus(); + return false; + } - foreach (var validation in validations) + var emailValidation = InputValidator.ValidateEmail(emailTextBox.Text); + if (!emailValidation.IsValid) { - if (!validation.IsValid) - { - MessageBox.Show(validation.Message, "Ошибка валидации", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return false; - } + MessageBox.Show(emailValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + emailTextBox.Focus(); + return false; } return true; diff --git a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs index 13a87d3..ea789ab 100644 --- a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs @@ -1,6 +1,7 @@ using HelpDesk.Common; using HelpDesk.Common.Models; using System.Windows.Forms; +using HelpDesk.Common.Constants; namespace HelpDeskWinFormsApp { @@ -26,7 +27,7 @@ public TroubleTicketForm(int ticketId, bool isEmployee, int resolveUserId, IProv private void TroubleTicketForm_Shown(object sender, System.EventArgs e) { troubleTicket = provider.GetTroubleTicket(ticketId); - userCreate = provider.GetUser(troubleTicket.CreateUser); + userCreate = provider.GetUser(troubleTicket.CreateUserId); lastStatus = troubleTicket.Status; Text = $"HelpDesk. Заяка №{troubleTicket.Id}"; @@ -55,7 +56,7 @@ private void TroubleTicketForm_FormClosing(object sender, FormClosingEventArgs e { if (DialogResult == DialogResult.OK) { - if (resolveRichTextBox.Text == string.Empty && (statusTroubleTicketComboBox.Text == AppConstants.StatusCompleted || statusTroubleTicketComboBox.Text == AppConstants.StatusCompleted)) + if (resolveRichTextBox.Text == string.Empty && (statusTroubleTicketComboBox.Text == TicketStatuses.Completed || statusTroubleTicketComboBox.Text == TicketStatuses.Completed)) { e.Cancel = true; MessageBox.Show("Пожалуйста заполните решение.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -64,11 +65,11 @@ private void TroubleTicketForm_FormClosing(object sender, FormClosingEventArgs e if (statusTroubleTicketComboBox.Text != lastStatus) { - if (statusTroubleTicketComboBox.Text == AppConstants.StatusCompleted || statusTroubleTicketComboBox.Text == AppConstants.StatusCompleted) + if (statusTroubleTicketComboBox.Text == TicketStatuses.Completed || statusTroubleTicketComboBox.Text == TicketStatuses.Completed) { provider.ResolveTroubleTicket(troubleTicket.Id, statusTroubleTicketComboBox.Text, resolveRichTextBox.Text, resolveUserId); } - else if (statusTroubleTicketComboBox.Text == AppConstants.StatusRegistered && lastStatus != AppConstants.StatusRegistered) + else if (statusTroubleTicketComboBox.Text == TicketStatuses.Registered && lastStatus != TicketStatuses.Registered) { e.Cancel = true; MessageBox.Show("Возврат в статус \"Зарегистрирована\" запрещён.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); From 579ae7f9306f206274296697d2dc80b5b7e2841a Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Mon, 8 Dec 2025 00:13:44 +0300 Subject: [PATCH 08/14] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=80=D0=B5=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs | 15 ++--- HelpDesk/HelpDeskWinFormsApp/MainForm.cs | 58 ++++++++++++-------- 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs index 24c1647..ee58db2 100644 --- a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs @@ -53,7 +53,7 @@ private void UserTypeComboBox_SelectedValueChanged(object sender, System.EventAr deparmentComboBox.Enabled = true; functionComboBox.Enabled = true; } - else if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeClient) + if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeClient) { deparmentComboBox.Enabled = false; functionComboBox.Enabled = false; @@ -89,15 +89,16 @@ private void EditUserForm_FormClosing(object sender, FormClosingEventArgs e) if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeEmployee && !user.IsEmployee) { provider.ChangeUserToEmployee(user, functionComboBox.Text, deparmentComboBox.Text); + return; } - else if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeClient && user.IsEmployee) + + if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeClient && user.IsEmployee) { provider.ChangeEmployeeToUser(user); + return; } - else - { - provider.UpdateUser(user); - } + + provider.UpdateUser(user); } private void DeparmentComboBox_SelectedValueChanged(object sender, EventArgs e) @@ -109,7 +110,7 @@ private void DeparmentComboBox_SelectedValueChanged(object sender, EventArgs e) functionComboBox.Items.Add(Functions.TechnicalSpecialist); functionComboBox.Text = Functions.Operator; } - else if (deparmentComboBox.Text == Departments.Development) + if (deparmentComboBox.Text == Departments.Development) { functionComboBox.Items.Clear(); functionComboBox.Items.Add(Functions.Tester); diff --git a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs index b733f93..21cdefb 100644 --- a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs @@ -231,14 +231,16 @@ private void RefreshDataGridBasedOnSelectedNode() UpdateButtonStates(parentName); - if (parentName == TreeViewNodes.TroubleTicketList || + if (parentName == TreeViewNodes.TroubleTicketList || parentName == TreeViewNodes.StatusTroubleTicket) { RefreshTroubleTicketsDataGrid(); + return; } - else if (parentName == TreeViewNodes.Users) + if (parentName == TreeViewNodes.Users) { RefreshUsersDataGrid(); + return; } } @@ -265,10 +267,12 @@ private void ListTTDataGridView_DoubleClick(object sender, EventArgs e) parentName == TreeViewNodes.StatusTroubleTicket) { openTroubleTicketButton.PerformClick(); + return; } - else if (parentName == TreeViewNodes.Users) + if (parentName == TreeViewNodes.Users) { editUserButton.PerformClick(); + return; } } @@ -332,17 +336,21 @@ private void ShowUserTreeNode() { var shouldShowUsersNode = user.IsEmployee && user.Department != Departments.TechnicalSupport; - if (shouldShowUsersNode && treeView.Nodes.Count == 1) - { - var usersNode = CreateUsersTreeStructure(); - treeView.Nodes.Add(usersNode); - } - else if (!shouldShowUsersNode) + editUserButton.Visible = shouldShowUsersNode; + + if (!shouldShowUsersNode) { RemoveUserTreeNode(); + return; } - editUserButton.Visible = shouldShowUsersNode; + if (treeView.Nodes.Count == 1) + { + var usersNode = CreateUsersTreeStructure(); + treeView.Nodes.Add(usersNode); + } + + } private TreeNode CreateUsersTreeStructure() @@ -479,12 +487,12 @@ private void PopulateUserRow(DataGridViewRow row, User userData) { row.Cells[5].Value = userData.Function; row.Cells[6].Value = userData.Department; + return; } - else - { - row.Cells[5].Style.BackColor = Color.Gray; - row.Cells[6].Style.BackColor = Color.Gray; - } + + row.Cells[5].Style.BackColor = Color.Gray; + row.Cells[6].Style.BackColor = Color.Gray; + } private void RefreshTroubleTicketsDataGrid() @@ -575,18 +583,20 @@ private void ApplyRowStylingBasedOnTicket(DataGridViewRow row, TroubleTicket tic row.DefaultCellStyle.BackColor = ticket.Status == TicketStatuses.Completed ? Color.LightGreen : Color.LightGray; + return; } - else + if (DateTime.Now > ticket.Deadline) { - if (DateTime.Now > ticket.Deadline) - { - row.DefaultCellStyle.BackColor = Color.LightSalmon; - } - else if (ticket.Status == TicketStatuses.InProgress) - { - row.DefaultCellStyle.BackColor = Color.LightYellow; - } + row.DefaultCellStyle.BackColor = Color.LightSalmon; + return; + } + + if (ticket.Status == TicketStatuses.InProgress) + { + row.DefaultCellStyle.BackColor = Color.LightYellow; + return; } + row.DefaultCellStyle.BackColor = Color.Empty; } private string GetPreviewText(string text) From 852f79b2429de0fedd4d32cca3f17501e8cb189e Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Mon, 8 Dec 2025 00:52:18 +0300 Subject: [PATCH 09/14] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=80=D0=B5=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AddTroubleTicketForm.cs | 12 ++--- .../HelpDeskWinFormsApp/TroubleTicketForm.cs | 53 ++++++++++--------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs index a982214..d3c1367 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs @@ -8,8 +8,9 @@ namespace HelpDeskWinFormsApp { public partial class AddTroubleTicketForm : Form { - User user; + private User user; private readonly IProvider provider; + private const int MinTroubleTextLength = 5; public AddTroubleTicketForm(User user, IProvider provider) { @@ -43,14 +44,7 @@ private void AddTroubleTicketForm_FormClosing(object sender, FormClosingEventArg private void TroubleRichTextBox_TextChanged(object sender, EventArgs e) { - if (troubleRichTextBox.Text.Length < 5) - { - createTroubleTicketButton.Enabled = false; - } - else - { - createTroubleTicketButton.Enabled = true; - } + createTroubleTicketButton.Enabled = troubleRichTextBox.Text.Length >= MinTroubleTextLength; } } } diff --git a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs index ea789ab..bea896f 100644 --- a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs @@ -54,33 +54,38 @@ private void TroubleTicketForm_Shown(object sender, System.EventArgs e) private void TroubleTicketForm_FormClosing(object sender, FormClosingEventArgs e) { - if (DialogResult == DialogResult.OK) + if (DialogResult != DialogResult.OK) return; + var newStatus = statusTroubleTicketComboBox.Text; + + var isResolutionRequired = newStatus == TicketStatuses.Completed || + newStatus == TicketStatuses.Rejected; + if (isResolutionRequired && resolveRichTextBox.Text == string.Empty) { - if (resolveRichTextBox.Text == string.Empty && (statusTroubleTicketComboBox.Text == TicketStatuses.Completed || statusTroubleTicketComboBox.Text == TicketStatuses.Completed)) - { - e.Cancel = true; - MessageBox.Show("Пожалуйста заполните решение.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } + e.Cancel = true; + MessageBox.Show("Пожалуйста заполните решение.", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + if (newStatus == lastStatus) return; - if (statusTroubleTicketComboBox.Text != lastStatus) - { - if (statusTroubleTicketComboBox.Text == TicketStatuses.Completed || statusTroubleTicketComboBox.Text == TicketStatuses.Completed) - { - provider.ResolveTroubleTicket(troubleTicket.Id, statusTroubleTicketComboBox.Text, resolveRichTextBox.Text, resolveUserId); - } - else if (statusTroubleTicketComboBox.Text == TicketStatuses.Registered && lastStatus != TicketStatuses.Registered) - { - e.Cancel = true; - MessageBox.Show("Возврат в статус \"Зарегистрирована\" запрещён.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - else - { - provider.ChangeStatusTroubleTicket(troubleTicket.Id, statusTroubleTicketComboBox.Text, resolveUserId); - } - } + if (newStatus == TicketStatuses.Registered && lastStatus != TicketStatuses.Registered) + { + e.Cancel = true; + MessageBox.Show("Возврат в статус \"Зарегистрирована\" запрещён.", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; } + + if (isResolutionRequired) + { + provider.ResolveTroubleTicket(troubleTicket.Id, newStatus, + resolveRichTextBox.Text, resolveUserId); + return; + } + + provider.ChangeStatusTroubleTicket(troubleTicket.Id, newStatus, resolveUserId); + } } } From 1e8ea78e0c4bce8b2a3a3928cce0925cbce86c64 Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Mon, 8 Dec 2025 22:29:14 +0300 Subject: [PATCH 10/14] =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5?= =?UTF-8?q?=D0=B9=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Application/ApplicationDIController.cs | 7 ++- HelpDesk/HelpDesk.Common/IProvider.cs | 22 --------- .../HelpDesk.Common/ITroubleTicketProvider.cs | 15 +++++++ HelpDesk/HelpDesk.Common/IUserProvider.cs | 17 +++++++ HelpDesk/HelpDesk.Common/JsonStorage.cs | 2 +- .../AddTroubleTicketForm.cs | 8 ++-- .../HelpDeskWinFormsApp/AuthorizationForm.cs | 12 ++--- HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs | 14 +++--- HelpDesk/HelpDeskWinFormsApp/ExportForm.cs | 13 +++--- HelpDesk/HelpDeskWinFormsApp/MainForm.cs | 45 +++++++++---------- HelpDesk/HelpDeskWinFormsApp/Program.cs | 17 +++++-- .../HelpDeskWinFormsApp/RegistrationForm.cs | 8 ++-- .../HelpDeskWinFormsApp/TroubleTicketForm.cs | 16 ++++--- 13 files changed, 110 insertions(+), 86 deletions(-) delete mode 100644 HelpDesk/HelpDesk.Common/IProvider.cs create mode 100644 HelpDesk/HelpDesk.Common/ITroubleTicketProvider.cs create mode 100644 HelpDesk/HelpDesk.Common/IUserProvider.cs diff --git a/HelpDesk/HelpDesk.Common/Application/ApplicationDIController.cs b/HelpDesk/HelpDesk.Common/Application/ApplicationDIController.cs index e1c66d3..95d451d 100644 --- a/HelpDesk/HelpDesk.Common/Application/ApplicationDIController.cs +++ b/HelpDesk/HelpDesk.Common/Application/ApplicationDIController.cs @@ -11,8 +11,11 @@ public void Start() private void RegisterSystems() { - SystemManager.Register(this); - SystemManager.Register(() => new JsonStorage()); + SystemManager.Register(this); + var jsonStorage = new JsonStorage(); + + SystemManager.Register(jsonStorage); + SystemManager.Register(jsonStorage); } } } diff --git a/HelpDesk/HelpDesk.Common/IProvider.cs b/HelpDesk/HelpDesk.Common/IProvider.cs deleted file mode 100644 index e5e5b6b..0000000 --- a/HelpDesk/HelpDesk.Common/IProvider.cs +++ /dev/null @@ -1,22 +0,0 @@ -using HelpDesk.Common.Models; -using System.Collections.Generic; - -namespace HelpDesk.Common -{ - public interface IProvider - { - bool IsCorrectLoginPassword(string login, string password); - User GetUser(string login); - User GetUser(int id); - void AddUser(User user); - List GetAllUsers(); - void AddTroubleTicket(TroubleTicket troubleTicket); - List GetAllTroubleTickets(); - TroubleTicket GetTroubleTicket(int id); - void ResolveTroubleTicket(int id, string status, string resolve, int resolveUserId); - void ChangeStatusTroubleTicket(int id, string status, int resolveUserId); - void ChangeUserToEmployee(User user, string function, string department); - void ChangeEmployeeToUser(User user); - void UpdateUser(User user); - } -} \ No newline at end of file diff --git a/HelpDesk/HelpDesk.Common/ITroubleTicketProvider.cs b/HelpDesk/HelpDesk.Common/ITroubleTicketProvider.cs new file mode 100644 index 0000000..f1989c7 --- /dev/null +++ b/HelpDesk/HelpDesk.Common/ITroubleTicketProvider.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; +using HelpDesk.Common.Models; + +namespace HelpDesk.Common +{ + public interface ITroubleTicketProvider + { + void AddTroubleTicket(TroubleTicket troubleTicket); + List GetAllTroubleTickets(); + TroubleTicket GetTroubleTicket(int id); + void ResolveTroubleTicket(int id, string status, string resolve, int resolveUserId); + void ChangeStatusTroubleTicket(int id, string status, int resolveUserId); + } +} + diff --git a/HelpDesk/HelpDesk.Common/IUserProvider.cs b/HelpDesk/HelpDesk.Common/IUserProvider.cs new file mode 100644 index 0000000..8eac556 --- /dev/null +++ b/HelpDesk/HelpDesk.Common/IUserProvider.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using HelpDesk.Common.Models; + +namespace HelpDesk.Common +{ + public interface IUserProvider + { + bool IsCorrectLoginPassword(string login, string password); + User GetUser(string login); + User GetUser(int id); + void AddUser(User user); + List GetAllUsers(); + void ChangeUserToEmployee(User user, string function, string department); + void ChangeEmployeeToUser(User user); + void UpdateUser(User user); + } +} diff --git a/HelpDesk/HelpDesk.Common/JsonStorage.cs b/HelpDesk/HelpDesk.Common/JsonStorage.cs index d667158..51217b7 100644 --- a/HelpDesk/HelpDesk.Common/JsonStorage.cs +++ b/HelpDesk/HelpDesk.Common/JsonStorage.cs @@ -5,7 +5,7 @@ namespace HelpDesk.Common { - public class JsonStorage : IProvider + public class JsonStorage : IUserProvider, ITroubleTicketProvider { private string usersFileName = "users.json"; private string troubleTicketsFileName = "troubleTicket.json"; diff --git a/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs index d3c1367..58fcf5c 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs @@ -9,14 +9,14 @@ namespace HelpDeskWinFormsApp public partial class AddTroubleTicketForm : Form { private User user; - private readonly IProvider provider; + private readonly ITroubleTicketProvider ticketProvider; private const int MinTroubleTextLength = 5; - public AddTroubleTicketForm(User user, IProvider provider) + public AddTroubleTicketForm(User user, ITroubleTicketProvider ticketProvider) { InitializeComponent(); - this.provider = provider; + this.ticketProvider = ticketProvider; this.user = user; } @@ -38,7 +38,7 @@ private void AddTroubleTicketForm_FormClosing(object sender, FormClosingEventArg Deadline = DateTime.Now.AddDays(4) }; - provider.AddTroubleTicket(troubelTicket); + ticketProvider.AddTroubleTicket(troubelTicket); } } diff --git a/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs index 62ad823..89d664d 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs @@ -8,12 +8,12 @@ namespace HelpDeskWinFormsApp public partial class AuthorizationForm : Form { public bool RegistrationChoice = false; - private readonly IProvider provider; + private readonly IUserProvider userProvider; - public AuthorizationForm(IProvider provider) + public AuthorizationForm(IUserProvider userProvider) { InitializeComponent(); - this.provider = provider; + this.userProvider = userProvider; } @@ -40,7 +40,7 @@ private void UnlockTextBox() private void AddFirstEmployee() { - var isEmptyUsers = provider.GetAllUsers(); + var isEmptyUsers = userProvider.GetAllUsers(); if (isEmptyUsers == null || isEmptyUsers.Count == 0) { @@ -55,7 +55,7 @@ private void AddFirstEmployee() Function = "Разработчик" }; - provider.AddUser(employee); + userProvider.AddUser(employee); } } @@ -96,7 +96,7 @@ private void AuthorizationForm_FormClosing(object sender, FormClosingEventArgs e return; } - if (!provider.IsCorrectLoginPassword(loginTextBox.Text, passwordTextBox.Text)) + if (!userProvider.IsCorrectLoginPassword(loginTextBox.Text, passwordTextBox.Text)) { e.Cancel = true; MessageBox.Show("Неверный логин или пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs index ee58db2..610cc3a 100644 --- a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs @@ -10,18 +10,18 @@ public partial class EditUserForm : Form { private int userId; private User user; - private readonly IProvider provider; + private readonly IUserProvider userProvider; - public EditUserForm(int userId, IProvider provider) + public EditUserForm(int userId, IUserProvider userProvider) { InitializeComponent(); this.userId = userId; - this.provider = provider; + this.userProvider = userProvider; } private void EditUserForm_Shown(object sender, EventArgs e) { - user = provider.GetUser(userId); + user = userProvider.GetUser(userId); if (user.IsEmployee) { @@ -88,17 +88,17 @@ private void EditUserForm_FormClosing(object sender, FormClosingEventArgs e) if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeEmployee && !user.IsEmployee) { - provider.ChangeUserToEmployee(user, functionComboBox.Text, deparmentComboBox.Text); + userProvider.ChangeUserToEmployee(user, functionComboBox.Text, deparmentComboBox.Text); return; } if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeClient && user.IsEmployee) { - provider.ChangeEmployeeToUser(user); + userProvider.ChangeEmployeeToUser(user); return; } - provider.UpdateUser(user); + userProvider.UpdateUser(user); } private void DeparmentComboBox_SelectedValueChanged(object sender, EventArgs e) diff --git a/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs b/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs index dfd81d7..37037e8 100644 --- a/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs @@ -18,15 +18,16 @@ public partial class ExportForm : Form private bool successfullyExport = false; private DialogResult exportFileDialogResult = DialogResult.Cancel; private bool isSupport = false; - private readonly IProvider provider; + private readonly IUserProvider userProvider; + private readonly ITroubleTicketProvider ticketProvider; - public ExportForm(bool isSupport, IProvider provider) + public ExportForm(bool isSupport, IUserProvider userProvider, ITroubleTicketProvider ticketProvider) { InitializeComponent(); - this.provider = provider; + this.userProvider = userProvider; this.isSupport = isSupport; - this.provider = provider; + this.ticketProvider = ticketProvider; } private void ExportForm_Shown(object sender, EventArgs e) @@ -60,7 +61,7 @@ private void ExportButton_Click(object sender, EventArgs e) return; } - var allTroubleTickets = provider.GetAllTroubleTickets(); + var allTroubleTickets = ticketProvider.GetAllTroubleTickets(); var troubleTickets = new List(); foreach ( var tt in allTroubleTickets) @@ -71,7 +72,7 @@ private void ExportButton_Click(object sender, EventArgs e) } } - var users = provider.GetAllUsers(); + var users = userProvider.GetAllUsers(); var exportFile = exportFileDialog.FileName; if (typeComboBox.Text == "Trouble Ticket") diff --git a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs index 21cdefb..12dd14e 100644 --- a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs @@ -15,21 +15,20 @@ namespace HelpDeskWinFormsApp public partial class MainForm : Form { private User user = new(); - private IProvider provider; + private readonly IUserProvider userProvider; + private readonly ITroubleTicketProvider troubleTicketProvider; public const int InvalidId = -1; - public MainForm(ApplicationDIController controller) + public MainForm(ApplicationDIController controller, + IUserProvider userProvider, + ITroubleTicketProvider troubleTicketProvider) { - controller.Start(); - InitializeComponent(); - GetProvider(); - } + this.userProvider = userProvider; + this.troubleTicketProvider = troubleTicketProvider; - public void GetProvider() - { - SystemManager.Get(out provider); + InitializeComponent(); } - + private void MainForm_Load(object sender, EventArgs e) { var login = AuthorizationUser(); @@ -42,7 +41,7 @@ private void MainForm_Load(object sender, EventArgs e) private void InitializeUserSession(string login) { - user = provider.GetUser(login); + user = userProvider.GetUser(login); SetupUserInterface(); SetupTreeViewLayout(); @@ -95,7 +94,7 @@ private void LogoutToolStripMenuItem_Click(object sender, EventArgs e) if (!string.IsNullOrEmpty(login)) { - user = provider.GetUser(login); + user = userProvider.GetUser(login); SetWindowHeaderText(); UpdateUserInfoUI(); ResetTreeViewSelection(); @@ -179,7 +178,7 @@ private void OpenTroubleTicketForm(int ticketId) { var resolveUserId = GetResolveUserIdForTicket(ticketId); - using (var ticketForm = new TroubleTicketForm(ticketId, user.IsEmployee, resolveUserId, provider)) + using (var ticketForm = new TroubleTicketForm(ticketId, user.IsEmployee, resolveUserId, troubleTicketProvider, userProvider)) { if (ticketForm.ShowDialog() == DialogResult.OK) { @@ -190,7 +189,7 @@ private void OpenTroubleTicketForm(int ticketId) private int GetResolveUserIdForTicket(int ticketId) { - var ticket = provider.GetTroubleTicket(ticketId); + var ticket = troubleTicketProvider.GetTroubleTicket(ticketId); if (ticket.ResolveUser != null) { @@ -202,7 +201,7 @@ private int GetResolveUserIdForTicket(int ticketId) private void AddTroubleTicketButton_Click(object sender, EventArgs e) { - using (var addForm = new AddTroubleTicketForm(user, provider)) + using (var addForm = new AddTroubleTicketForm(user, troubleTicketProvider)) { if (addForm.ShowDialog() == DialogResult.OK) { @@ -280,7 +279,7 @@ private void ExportToolStripMenuItem_Click(object sender, EventArgs e) { var isSupport = user.IsEmployee && user.Department == Departments.TechnicalSupport; - using (var exportForm = new ExportForm(isSupport, provider)) + using (var exportForm = new ExportForm(isSupport, userProvider, troubleTicketProvider)) { exportForm.ShowDialog(); } @@ -309,7 +308,7 @@ private bool TryGetSelectedUserId(out int userId) private void OpenEditUserForm(int userId) { - using (var editForm = new EditUserForm(userId, provider)) + using (var editForm = new EditUserForm(userId, userProvider)) { if (editForm.ShowDialog() == DialogResult.OK) { @@ -378,7 +377,7 @@ private TreeNode CreateUsersTreeStructure() private string AuthorizationUser() { - var authorizationForm = new AuthorizationForm(provider); + var authorizationForm = new AuthorizationForm(userProvider); if (authorizationForm.ShowDialog() == DialogResult.OK) { @@ -401,7 +400,7 @@ private string HandleAuthorizationFailure(bool isNeedRegistration) private string ProcessRegistration() { - using (var registrationForm = new RegistrationForm(provider)) + using (var registrationForm = new RegistrationForm(userProvider)) { DialogResult result = registrationForm.ShowDialog(); @@ -432,7 +431,7 @@ private void RefreshUsersDataGrid() private List GetFilteredUsers(string nodeName) { - var allUsers = provider.GetAllUsers(); + var allUsers = userProvider.GetAllUsers(); return nodeName switch { @@ -531,8 +530,8 @@ private List GetFilteredTroubleTickets(string nodeName) private List GetAllRelevantTickets() { return user.IsEmployee - ? provider.GetAllTroubleTickets() - : provider.GetAllTroubleTickets().Where(t => t.CreateUserId == user.Id).ToList(); + ? troubleTicketProvider.GetAllTroubleTickets() + : troubleTicketProvider.GetAllTroubleTickets().Where(t => t.CreateUserId == user.Id).ToList(); } private void ClearAndSetupDataGridViewForTickets() @@ -544,7 +543,7 @@ private void ClearAndSetupDataGridViewForTickets() private void FillTroubleTicketsDataGridView(List tickets) { troubleTicketsDataGridView.Rows.Clear(); - var allUsers = provider.GetAllUsers(); + var allUsers = userProvider.GetAllUsers(); foreach (var ticket in tickets) { diff --git a/HelpDesk/HelpDeskWinFormsApp/Program.cs b/HelpDesk/HelpDeskWinFormsApp/Program.cs index 9dddfda..ca7017e 100644 --- a/HelpDesk/HelpDeskWinFormsApp/Program.cs +++ b/HelpDesk/HelpDeskWinFormsApp/Program.cs @@ -1,6 +1,8 @@ -using HelpDesk.Common.Application; -using System; +using System; using System.Windows.Forms; +using HelpDesk.Common; +using HelpDesk.Common.Application; +using HelpDesk.Common.System; namespace HelpDeskWinFormsApp { @@ -15,7 +17,14 @@ static void Main() // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new MainForm(new ApplicationDIController())); - } + + var controller = new ApplicationDIController(); + controller.Start(); + + var userProvider = SystemManager.Get(); + var ticketProvider = SystemManager.Get(); + + Application.Run(new MainForm(controller, userProvider, ticketProvider)); + } } } \ No newline at end of file diff --git a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs index 8a859df..6db12ff 100644 --- a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs @@ -7,13 +7,13 @@ namespace HelpDeskWinFormsApp { public partial class RegistrationForm : Form { - private readonly IProvider provider; + private readonly IUserProvider userProvider; - public RegistrationForm(IProvider provider) + public RegistrationForm(IUserProvider userProvider) { InitializeComponent(); - this.provider = provider; + this.userProvider = userProvider; } private bool ValidateAllFields() @@ -88,7 +88,7 @@ private void RegistrationForm_FormClosing(object sender, FormClosingEventArgs e) Email = emailTextBox.Text }; - provider.AddUser(user); + userProvider.AddUser(user); } private void RegistrationButton_Click(object sender, System.EventArgs e) diff --git a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs index bea896f..3509436 100644 --- a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs @@ -13,21 +13,23 @@ public partial class TroubleTicketForm : Form private bool isEmployee; private int resolveUserId; private string lastStatus; - private readonly IProvider provider; + private readonly ITroubleTicketProvider troubleTicketProvider; + private readonly IUserProvider userProvider; - public TroubleTicketForm(int ticketId, bool isEmployee, int resolveUserId, IProvider provider) + public TroubleTicketForm(int ticketId, bool isEmployee, int resolveUserId, ITroubleTicketProvider troubleTicketProvider, IUserProvider userProvider) { InitializeComponent(); this.ticketId = ticketId; this.isEmployee = isEmployee; this.resolveUserId = resolveUserId; - this.provider = provider; + this.troubleTicketProvider = troubleTicketProvider; + this.userProvider = userProvider; } private void TroubleTicketForm_Shown(object sender, System.EventArgs e) { - troubleTicket = provider.GetTroubleTicket(ticketId); - userCreate = provider.GetUser(troubleTicket.CreateUserId); + troubleTicket = troubleTicketProvider.GetTroubleTicket(ticketId); + userCreate = userProvider.GetUser(troubleTicket.CreateUserId); lastStatus = troubleTicket.Status; Text = $"HelpDesk. Заяка №{troubleTicket.Id}"; @@ -79,12 +81,12 @@ private void TroubleTicketForm_FormClosing(object sender, FormClosingEventArgs e if (isResolutionRequired) { - provider.ResolveTroubleTicket(troubleTicket.Id, newStatus, + troubleTicketProvider.ResolveTroubleTicket(troubleTicket.Id, newStatus, resolveRichTextBox.Text, resolveUserId); return; } - provider.ChangeStatusTroubleTicket(troubleTicket.Id, newStatus, resolveUserId); + troubleTicketProvider.ChangeStatusTroubleTicket(troubleTicket.Id, newStatus, resolveUserId); } } From dd12bcab372365e56cc243fa8663a478e5dfacc4 Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Tue, 9 Dec 2025 00:58:12 +0300 Subject: [PATCH 11/14] =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D0=BB=D0=B0=20=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8E,=20=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=D0=B0=20=D1=88=D0=B8=D1=84=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HelpDesk/HelpDesk.Common/FileProvider.cs | 4 +- HelpDesk/HelpDesk.Common/SimpleEncryption.cs | 68 +++++++++++++++++++ HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs | 18 ++++- .../HelpDeskWinFormsApp/InputValidator.cs | 27 +++++--- HelpDesk/HelpDeskWinFormsApp/Program.cs | 29 ++++++++ 5 files changed, 134 insertions(+), 12 deletions(-) create mode 100644 HelpDesk/HelpDesk.Common/SimpleEncryption.cs diff --git a/HelpDesk/HelpDesk.Common/FileProvider.cs b/HelpDesk/HelpDesk.Common/FileProvider.cs index 94eba02..317c996 100644 --- a/HelpDesk/HelpDesk.Common/FileProvider.cs +++ b/HelpDesk/HelpDesk.Common/FileProvider.cs @@ -12,6 +12,8 @@ public static bool Exist(string fileName) public static void Put(string fileName, string text) { + text = SimpleEncryption.Encrypt(text); + using (var writer = new StreamWriter(fileName, false, Encoding.UTF8)) { writer.WriteLine(text); @@ -32,7 +34,7 @@ public static string Get(string fileName) text = reader.ReadToEnd(); } - return text; + return SimpleEncryption.Decrypt(text); } } } diff --git a/HelpDesk/HelpDesk.Common/SimpleEncryption.cs b/HelpDesk/HelpDesk.Common/SimpleEncryption.cs new file mode 100644 index 0000000..dcdac31 --- /dev/null +++ b/HelpDesk/HelpDesk.Common/SimpleEncryption.cs @@ -0,0 +1,68 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace HelpDesk.Common +{ + public static class SimpleEncryption + { + private static string password = "MyHelpDeskApp2025!"; + + public static string Encrypt(string text) + { + if (string.IsNullOrEmpty(text)) return text; + + byte[] key = Encoding.UTF8.GetBytes(password.PadRight(32).Substring(0, 32)); + byte[] iv = Encoding.UTF8.GetBytes(password.PadRight(16).Substring(0, 16)); + + using (Aes aes = Aes.Create()) + { + aes.Key = key; + aes.IV = iv; + + using (MemoryStream ms = new MemoryStream()) + { + using (CryptoStream cs = new CryptoStream(ms, aes.CreateEncryptor(), CryptoStreamMode.Write)) + { + byte[] data = Encoding.UTF8.GetBytes(text); + cs.Write(data, 0, data.Length); + cs.FlushFinalBlock(); + + return Convert.ToBase64String(ms.ToArray()); + } + } + } + } + + public static string Decrypt(string encryptedText) + { + if (string.IsNullOrEmpty(encryptedText)) return encryptedText; + + try + { + byte[] key = Encoding.UTF8.GetBytes(password.PadRight(32).Substring(0, 32)); + byte[] iv = Encoding.UTF8.GetBytes(password.PadRight(16).Substring(0, 16)); + + using (Aes aes = Aes.Create()) + { + aes.Key = key; + aes.IV = iv; + + byte[] encryptedData = Convert.FromBase64String(encryptedText); + + using (MemoryStream ms = new MemoryStream(encryptedData)) + using (CryptoStream cs = new CryptoStream(ms, aes.CreateDecryptor(), CryptoStreamMode.Read)) + using (StreamReader reader = new StreamReader(cs)) + { + return reader.ReadToEnd(); + } + } + } + catch + { + return encryptedText; + } + } + } +} \ No newline at end of file diff --git a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs index 610cc3a..b06458f 100644 --- a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs @@ -45,7 +45,7 @@ private void EditUserForm_Shown(object sender, EventArgs e) emailTextBox.Text = user.Email; } - + private void UserTypeComboBox_SelectedValueChanged(object sender, System.EventArgs e) { if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeEmployee) @@ -167,10 +167,22 @@ private bool ValidateAllFields() confurmChangePasswordTextBox.Focus(); return false; } - } - + } + if (userTypeComboBox.Text == UserInterfaceTexts.UserTypeEmployee) + { + var departmentValidation = InputValidator.ValidateDepartment(deparmentComboBox.Text); + if (!departmentValidation.IsValid) + { + MessageBox.Show(departmentValidation.Message, "Ошибка валидации", + MessageBoxButtons.OK, MessageBoxIcon.Error); + deparmentComboBox.Focus(); + return false; + } + } return true; } + + private void SaveButton_Click(object sender, EventArgs e) { if (!ValidateAllFields()) diff --git a/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs b/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs index cb2e74e..9e186b4 100644 --- a/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs +++ b/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs @@ -13,10 +13,10 @@ public static class InputValidator private const int MinPasswordLength = 5; private const int MaxPasswordLength = 50; - + public static (bool IsValid, string Message) ValidateName(string inputName) { - var name = inputName?.Trim() ?? ""; + var name = inputName?.Trim() ?? string.Empty; if (string.IsNullOrWhiteSpace(name)) { @@ -33,7 +33,7 @@ public static (bool IsValid, string Message) ValidateName(string inputName) public static (bool IsValid, string Message) ValidateLogin(string inputLogin) { - var login = inputLogin?.Trim() ?? ""; + var login = inputLogin?.Trim() ?? string.Empty; if (string.IsNullOrWhiteSpace(login)) { @@ -49,7 +49,7 @@ public static (bool IsValid, string Message) ValidateLogin(string inputLogin) public static (bool IsValid, string Message) ValidatePassword(string inputPassword) { - var password = inputPassword ?? ""; + var password = inputPassword ?? string.Empty; if (string.IsNullOrWhiteSpace(password)) { @@ -67,7 +67,7 @@ public static (bool IsValid, string Message) ValidatePassword(string inputPasswo public static (bool IsValid, string Message) ValidatePasswordMatch( string password, string confirmPassword) { - + if (password != confirmPassword) { return (false, "Пароли не совпадают"); @@ -78,7 +78,7 @@ public static (bool IsValid, string Message) ValidatePasswordMatch( public static (bool IsValid, string Message) ValidateEmail(string inputEmail) { - var email = inputEmail?.Trim() ?? ""; + var email = inputEmail?.Trim() ?? string.Empty; if (string.IsNullOrWhiteSpace(email)) { @@ -92,7 +92,18 @@ public static (bool IsValid, string Message) ValidateEmail(string inputEmail) catch (FormatException) { return (false, "Неверный формат email"); - } - } + } + } + + public static (bool IsValid, string Message) ValidateDepartment(string inputDepartment) + { + var department = inputDepartment?.Trim() ?? string.Empty; + + if (string.IsNullOrWhiteSpace(department)) + { + return (false, "Отдел обязателен для заполнения"); + } + return (true, string.Empty); + } } } diff --git a/HelpDesk/HelpDeskWinFormsApp/Program.cs b/HelpDesk/HelpDeskWinFormsApp/Program.cs index ca7017e..61d5b09 100644 --- a/HelpDesk/HelpDeskWinFormsApp/Program.cs +++ b/HelpDesk/HelpDeskWinFormsApp/Program.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Windows.Forms; using HelpDesk.Common; using HelpDesk.Common.Application; @@ -18,6 +19,8 @@ static void Main() // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); + CheckAndEncryptOldFiles(); + var controller = new ApplicationDIController(); controller.Start(); @@ -26,5 +29,31 @@ static void Main() Application.Run(new MainForm(controller, userProvider, ticketProvider)); } + static void CheckAndEncryptOldFiles() + { + string[] files = { "users.json", "troubleTicket.json" }; + + foreach (var file in files) + { + if (File.Exists(file)) + { + try + { + string content = File.ReadAllText(file); + + if (content.Trim().StartsWith("[") || content.Trim().StartsWith("{")) + { + File.Copy(file, file + ".backup", true); + + FileProvider.Put(file, content); + } + } + catch + { + + } + } + } + } } } \ No newline at end of file From ef054e9508f3d2bdf429a2a71afa4be4d899196b Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Tue, 9 Dec 2025 20:57:55 +0300 Subject: [PATCH 12/14] =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0=20JsonStorage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Application/ApplicationDIController.cs | 5 +- HelpDesk/HelpDesk.Common/FileProvider.cs | 7 +- .../JsonTroubleTicketStorage.cs | 79 ++++++++++++++++++ .../{JsonStorage.cs => JsonUserStorage.cs} | 81 ++----------------- HelpDesk/HelpDeskWinFormsApp/MainForm.cs | 1 - HelpDesk/HelpDeskWinFormsApp/Program.cs | 4 +- 6 files changed, 91 insertions(+), 86 deletions(-) create mode 100644 HelpDesk/HelpDesk.Common/JsonTroubleTicketStorage.cs rename HelpDesk/HelpDesk.Common/{JsonStorage.cs => JsonUserStorage.cs} (51%) diff --git a/HelpDesk/HelpDesk.Common/Application/ApplicationDIController.cs b/HelpDesk/HelpDesk.Common/Application/ApplicationDIController.cs index 95d451d..ee4e705 100644 --- a/HelpDesk/HelpDesk.Common/Application/ApplicationDIController.cs +++ b/HelpDesk/HelpDesk.Common/Application/ApplicationDIController.cs @@ -12,10 +12,9 @@ public void Start() private void RegisterSystems() { SystemManager.Register(this); - var jsonStorage = new JsonStorage(); - SystemManager.Register(jsonStorage); - SystemManager.Register(jsonStorage); + SystemManager.Register(new JsonUserStorage()); + SystemManager.Register(new JsonTroubleTicketStorage()); } } } diff --git a/HelpDesk/HelpDesk.Common/FileProvider.cs b/HelpDesk/HelpDesk.Common/FileProvider.cs index 317c996..88837c8 100644 --- a/HelpDesk/HelpDesk.Common/FileProvider.cs +++ b/HelpDesk/HelpDesk.Common/FileProvider.cs @@ -18,12 +18,7 @@ public static void Put(string fileName, string text) { writer.WriteLine(text); } - } - - public static void Delete(string fileName) - { - File.Delete(fileName); - } + } public static string Get(string fileName) { diff --git a/HelpDesk/HelpDesk.Common/JsonTroubleTicketStorage.cs b/HelpDesk/HelpDesk.Common/JsonTroubleTicketStorage.cs new file mode 100644 index 0000000..3c54e20 --- /dev/null +++ b/HelpDesk/HelpDesk.Common/JsonTroubleTicketStorage.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using HelpDesk.Common.Models; + +namespace HelpDesk.Common +{ + public class JsonTroubleTicketStorage : ITroubleTicketProvider + { + private readonly string troubleTicketsFileName = "troubleTicket.json"; + + public void AddTroubleTicket(TroubleTicket troubleTicket) + { + var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName) ?? new List(); + + troubleTicket.Id = troubleTickets.Count == 0 ? 1 : troubleTickets.Max(x => x.Id) + 1; + troubleTickets.Add(troubleTicket); + + JsonProvider.Serialize(troubleTickets, troubleTicketsFileName); + } + + public List GetAllTroubleTickets() + { + var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName); + + return troubleTickets ?? new List(); + } + + public TroubleTicket GetTroubleTicket(int id) + { + var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName); + + return troubleTickets?.FirstOrDefault(t => t.Id == id); + } + + private void SaveTroubleTickets(List tickets) + { + JsonProvider.Serialize(tickets.OrderBy(x => x.Id).ToList(), troubleTicketsFileName); + } + + private List GetAllTroubleTicketsInternal() + { + return JsonProvider.Deserialize(troubleTicketsFileName) + ?? new List(); + } + + public void ResolveTroubleTicket(int id, string status, string resolve, int resolveUserId) + { + var troubleTickets = GetAllTroubleTicketsInternal(); + var troubleTicket = troubleTickets.FirstOrDefault(t => t.Id == id); + + if (troubleTicket == null) return; + + troubleTicket.IsSolved = true; + troubleTicket.Status = status; + troubleTicket.Resolve = resolve; + troubleTicket.ResolveTime = DateTime.Now; + troubleTicket.ResolveUser = resolveUserId; + + SaveTroubleTickets(troubleTickets); + } + + public void ChangeStatusTroubleTicket(int id, string status, int resolveUserId) + { + var troubleTickets = GetAllTroubleTicketsInternal(); + var troubleTicket = troubleTickets.FirstOrDefault(t => t.Id == id); + + if (troubleTicket == null) return; + + troubleTicket.Status = status; + troubleTicket.ResolveUser = resolveUserId; + + SaveTroubleTickets(troubleTickets); + + } + } +} diff --git a/HelpDesk/HelpDesk.Common/JsonStorage.cs b/HelpDesk/HelpDesk.Common/JsonUserStorage.cs similarity index 51% rename from HelpDesk/HelpDesk.Common/JsonStorage.cs rename to HelpDesk/HelpDesk.Common/JsonUserStorage.cs index 51217b7..05b52b7 100644 --- a/HelpDesk/HelpDesk.Common/JsonStorage.cs +++ b/HelpDesk/HelpDesk.Common/JsonUserStorage.cs @@ -1,14 +1,12 @@ -using HelpDesk.Common.Models; -using System.Collections.Generic; -using System; +using System.Collections.Generic; using System.Linq; +using HelpDesk.Common.Models; namespace HelpDesk.Common { - public class JsonStorage : IUserProvider, ITroubleTicketProvider + public class JsonUserStorage : IUserProvider { - private string usersFileName = "users.json"; - private string troubleTicketsFileName = "troubleTicket.json"; + private readonly string usersFileName = "users.json"; public bool IsCorrectLoginPassword(string login, string password) { @@ -32,9 +30,9 @@ public bool IsCorrectLoginPassword(string login, string password) public User GetUser(string login) { var users = JsonProvider.Deserialize(usersFileName); - + return users?.FirstOrDefault(x => x.Login == login); - + } public User GetUser(int id) @@ -59,76 +57,11 @@ public List GetAllUsers() return JsonProvider.Deserialize(usersFileName) ?? new List(); } - public void AddTroubleTicket(TroubleTicket troubleTicket) - { - var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName) ?? new List(); - - troubleTicket.Id = troubleTickets.Count == 0 ? 1 : troubleTickets.Max(x => x.Id) + 1; - troubleTickets.Add(troubleTicket); - - JsonProvider.Serialize(troubleTickets, troubleTicketsFileName); - } - - public List GetAllTroubleTickets() - { - var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName); - - return troubleTickets ?? new List(); - } - - public TroubleTicket GetTroubleTicket(int id) - { - var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName); - - return troubleTickets?.FirstOrDefault(t => t.Id == id); - } - - private void SaveTroubleTickets(List tickets) - { - JsonProvider.Serialize(tickets.OrderBy(x => x.Id).ToList(), troubleTicketsFileName); - } - private void SaveUsers(List users) { JsonProvider.Serialize(users.OrderBy(x => x.Id).ToList(), usersFileName); } - private List GetAllTroubleTicketsInternal() - { - return JsonProvider.Deserialize(troubleTicketsFileName) - ?? new List(); - } - - public void ResolveTroubleTicket(int id, string status, string resolve, int resolveUserId) - { - var troubleTickets = GetAllTroubleTicketsInternal(); - var troubleTicket = troubleTickets.FirstOrDefault(t => t.Id == id); - - if (troubleTicket == null) return; - - troubleTicket.IsSolved = true; - troubleTicket.Status = status; - troubleTicket.Resolve = resolve; - troubleTicket.ResolveTime = DateTime.Now; - troubleTicket.ResolveUser = resolveUserId; - - SaveTroubleTickets(troubleTickets); - } - - public void ChangeStatusTroubleTicket(int id, string status, int resolveUserId) - { - var troubleTickets = GetAllTroubleTicketsInternal(); - var troubleTicket = troubleTickets.FirstOrDefault(t => t.Id == id); - - if (troubleTicket == null) return; - - troubleTicket.Status = status; - troubleTicket.ResolveUser = resolveUserId; - - SaveTroubleTickets(troubleTickets); - - } - public void ChangeUserToEmployee(User user, string function, string department) { var users = GetAllUsers() ?? new List(); @@ -173,6 +106,6 @@ public void UpdateUser(User user) SaveUsers(users); } - + } } diff --git a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs index 12dd14e..aa2bcae 100644 --- a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs @@ -6,7 +6,6 @@ using HelpDesk.Common; using HelpDesk.Common.Application; using HelpDesk.Common.Models; -using HelpDesk.Common.System; using HelpDesk.Common.Constants; using HelpDeskWinFormsApp.Costants; diff --git a/HelpDesk/HelpDeskWinFormsApp/Program.cs b/HelpDesk/HelpDeskWinFormsApp/Program.cs index 61d5b09..d6fbfa7 100644 --- a/HelpDesk/HelpDeskWinFormsApp/Program.cs +++ b/HelpDesk/HelpDeskWinFormsApp/Program.cs @@ -19,10 +19,10 @@ static void Main() // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - CheckAndEncryptOldFiles(); + CheckAndEncryptOldFiles(); var controller = new ApplicationDIController(); - controller.Start(); + controller.Start(); var userProvider = SystemManager.Get(); var ticketProvider = SystemManager.Get(); From f03fb1e20a00d64ab8167f12de4ebad7c56bfda8 Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Wed, 10 Dec 2025 20:48:42 +0300 Subject: [PATCH 13/14] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=80=D0=B5=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HelpDesk.Common/ITroubleTicketProvider.cs | 10 +++---- HelpDesk/HelpDesk.Common/IUserProvider.cs | 10 +++---- .../JsonTroubleTicketStorage.cs | 25 +++++++++--------- HelpDesk/HelpDesk.Common/JsonUserStorage.cs | 24 ++++++++--------- .../AddTroubleTicketForm.cs | 2 +- .../HelpDeskWinFormsApp/AuthorizationForm.cs | 4 +-- HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs | 4 +-- HelpDesk/HelpDeskWinFormsApp/ExportForm.cs | 4 +-- .../HelpDeskWinFormsApp/InputValidator.cs | 26 +++++++++---------- HelpDesk/HelpDeskWinFormsApp/MainForm.cs | 14 +++++----- .../HelpDeskWinFormsApp/RegistrationForm.cs | 2 +- .../HelpDeskWinFormsApp/TroubleTicketForm.cs | 8 +++--- 12 files changed, 66 insertions(+), 67 deletions(-) diff --git a/HelpDesk/HelpDesk.Common/ITroubleTicketProvider.cs b/HelpDesk/HelpDesk.Common/ITroubleTicketProvider.cs index f1989c7..2fb0905 100644 --- a/HelpDesk/HelpDesk.Common/ITroubleTicketProvider.cs +++ b/HelpDesk/HelpDesk.Common/ITroubleTicketProvider.cs @@ -5,11 +5,11 @@ namespace HelpDesk.Common { public interface ITroubleTicketProvider { - void AddTroubleTicket(TroubleTicket troubleTicket); - List GetAllTroubleTickets(); - TroubleTicket GetTroubleTicket(int id); - void ResolveTroubleTicket(int id, string status, string resolve, int resolveUserId); - void ChangeStatusTroubleTicket(int id, string status, int resolveUserId); + void Add(TroubleTicket troubleTicket); + List GetAll(); + TroubleTicket Get(int id); + void Resolve(int id, string status, string resolve, int resolveUserId); + void ChangeStatus(int id, string status, int resolveUserId); } } diff --git a/HelpDesk/HelpDesk.Common/IUserProvider.cs b/HelpDesk/HelpDesk.Common/IUserProvider.cs index 8eac556..918d526 100644 --- a/HelpDesk/HelpDesk.Common/IUserProvider.cs +++ b/HelpDesk/HelpDesk.Common/IUserProvider.cs @@ -6,12 +6,12 @@ namespace HelpDesk.Common public interface IUserProvider { bool IsCorrectLoginPassword(string login, string password); - User GetUser(string login); - User GetUser(int id); - void AddUser(User user); - List GetAllUsers(); + User Get(string login); + User Get(int id); + void Add(User user); + List GetAll(); void ChangeUserToEmployee(User user, string function, string department); void ChangeEmployeeToUser(User user); - void UpdateUser(User user); + void Update(User user); } } diff --git a/HelpDesk/HelpDesk.Common/JsonTroubleTicketStorage.cs b/HelpDesk/HelpDesk.Common/JsonTroubleTicketStorage.cs index 3c54e20..459e9cd 100644 --- a/HelpDesk/HelpDesk.Common/JsonTroubleTicketStorage.cs +++ b/HelpDesk/HelpDesk.Common/JsonTroubleTicketStorage.cs @@ -1,8 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; + using HelpDesk.Common.Models; namespace HelpDesk.Common @@ -11,7 +10,7 @@ public class JsonTroubleTicketStorage : ITroubleTicketProvider { private readonly string troubleTicketsFileName = "troubleTicket.json"; - public void AddTroubleTicket(TroubleTicket troubleTicket) + public void Add(TroubleTicket troubleTicket) { var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName) ?? new List(); @@ -21,34 +20,34 @@ public void AddTroubleTicket(TroubleTicket troubleTicket) JsonProvider.Serialize(troubleTickets, troubleTicketsFileName); } - public List GetAllTroubleTickets() + public List GetAll() { var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName); return troubleTickets ?? new List(); } - public TroubleTicket GetTroubleTicket(int id) + public TroubleTicket Get(int id) { var troubleTickets = JsonProvider.Deserialize(troubleTicketsFileName); return troubleTickets?.FirstOrDefault(t => t.Id == id); } - private void SaveTroubleTickets(List tickets) + private void Save(List tickets) { JsonProvider.Serialize(tickets.OrderBy(x => x.Id).ToList(), troubleTicketsFileName); } - private List GetAllTroubleTicketsInternal() + private List GetAllInternal() { return JsonProvider.Deserialize(troubleTicketsFileName) ?? new List(); } - public void ResolveTroubleTicket(int id, string status, string resolve, int resolveUserId) + public void Resolve(int id, string status, string resolve, int resolveUserId) { - var troubleTickets = GetAllTroubleTicketsInternal(); + var troubleTickets = GetAllInternal(); var troubleTicket = troubleTickets.FirstOrDefault(t => t.Id == id); if (troubleTicket == null) return; @@ -59,12 +58,12 @@ public void ResolveTroubleTicket(int id, string status, string resolve, int reso troubleTicket.ResolveTime = DateTime.Now; troubleTicket.ResolveUser = resolveUserId; - SaveTroubleTickets(troubleTickets); + Save(troubleTickets); } - public void ChangeStatusTroubleTicket(int id, string status, int resolveUserId) + public void ChangeStatus(int id, string status, int resolveUserId) { - var troubleTickets = GetAllTroubleTicketsInternal(); + var troubleTickets = GetAllInternal(); var troubleTicket = troubleTickets.FirstOrDefault(t => t.Id == id); if (troubleTicket == null) return; @@ -72,7 +71,7 @@ public void ChangeStatusTroubleTicket(int id, string status, int resolveUserId) troubleTicket.Status = status; troubleTicket.ResolveUser = resolveUserId; - SaveTroubleTickets(troubleTickets); + Save(troubleTickets); } } diff --git a/HelpDesk/HelpDesk.Common/JsonUserStorage.cs b/HelpDesk/HelpDesk.Common/JsonUserStorage.cs index 05b52b7..ada0603 100644 --- a/HelpDesk/HelpDesk.Common/JsonUserStorage.cs +++ b/HelpDesk/HelpDesk.Common/JsonUserStorage.cs @@ -27,7 +27,7 @@ public bool IsCorrectLoginPassword(string login, string password) return user.Password == Methods.GetHashMD5(password); } - public User GetUser(string login) + public User Get(string login) { var users = JsonProvider.Deserialize(usersFileName); @@ -35,14 +35,14 @@ public User GetUser(string login) } - public User GetUser(int id) + public User Get(int id) { var users = JsonProvider.Deserialize(usersFileName); return users?.FirstOrDefault(x => x.Id == id); } - public void AddUser(User user) + public void Add(User user) { var users = JsonProvider.Deserialize(usersFileName) ?? new List(); @@ -52,19 +52,19 @@ public void AddUser(User user) JsonProvider.Serialize(users, usersFileName); } - public List GetAllUsers() + public List GetAll() { return JsonProvider.Deserialize(usersFileName) ?? new List(); } - private void SaveUsers(List users) + private void Save(List users) { JsonProvider.Serialize(users.OrderBy(x => x.Id).ToList(), usersFileName); } public void ChangeUserToEmployee(User user, string function, string department) { - var users = GetAllUsers() ?? new List(); + var users = GetAll() ?? new List(); users.RemoveAll(x => x.Id == user.Id); var convertedUser = new User @@ -81,12 +81,12 @@ public void ChangeUserToEmployee(User user, string function, string department) users.Add(convertedUser); - SaveUsers(users); + Save(users); } public void ChangeEmployeeToUser(User user) { - var users = GetAllUsers() ?? new List(); + var users = GetAll() ?? new List(); users.RemoveAll(x => x.Id == user.Id); user.IsEmployee = false; @@ -95,16 +95,16 @@ public void ChangeEmployeeToUser(User user) users.Add(user); - SaveUsers(users); + Save(users); } - public void UpdateUser(User user) + public void Update(User user) { - var users = GetAllUsers() ?? new List(); + var users = GetAll() ?? new List(); users.RemoveAll(x => x.Id == user.Id); users.Add(user); - SaveUsers(users); + Save(users); } } diff --git a/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs index 58fcf5c..4d4f56b 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AddTroubleTicketForm.cs @@ -38,7 +38,7 @@ private void AddTroubleTicketForm_FormClosing(object sender, FormClosingEventArg Deadline = DateTime.Now.AddDays(4) }; - ticketProvider.AddTroubleTicket(troubelTicket); + ticketProvider.Add(troubelTicket); } } diff --git a/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs index 89d664d..17200cc 100644 --- a/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/AuthorizationForm.cs @@ -40,7 +40,7 @@ private void UnlockTextBox() private void AddFirstEmployee() { - var isEmptyUsers = userProvider.GetAllUsers(); + var isEmptyUsers = userProvider.GetAll(); if (isEmptyUsers == null || isEmptyUsers.Count == 0) { @@ -55,7 +55,7 @@ private void AddFirstEmployee() Function = "Разработчик" }; - userProvider.AddUser(employee); + userProvider.Add(employee); } } diff --git a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs index b06458f..75923e7 100644 --- a/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/EditUserForm.cs @@ -21,7 +21,7 @@ public EditUserForm(int userId, IUserProvider userProvider) private void EditUserForm_Shown(object sender, EventArgs e) { - user = userProvider.GetUser(userId); + user = userProvider.Get(userId); if (user.IsEmployee) { @@ -98,7 +98,7 @@ private void EditUserForm_FormClosing(object sender, FormClosingEventArgs e) return; } - userProvider.UpdateUser(user); + userProvider.Update(user); } private void DeparmentComboBox_SelectedValueChanged(object sender, EventArgs e) diff --git a/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs b/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs index 37037e8..0fbb090 100644 --- a/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/ExportForm.cs @@ -61,7 +61,7 @@ private void ExportButton_Click(object sender, EventArgs e) return; } - var allTroubleTickets = ticketProvider.GetAllTroubleTickets(); + var allTroubleTickets = ticketProvider.GetAll(); var troubleTickets = new List(); foreach ( var tt in allTroubleTickets) @@ -72,7 +72,7 @@ private void ExportButton_Click(object sender, EventArgs e) } } - var users = userProvider.GetAllUsers(); + var users = userProvider.GetAll(); var exportFile = exportFileDialog.FileName; if (typeComboBox.Text == "Trouble Ticket") diff --git a/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs b/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs index 9e186b4..25fbc2a 100644 --- a/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs +++ b/HelpDesk/HelpDeskWinFormsApp/InputValidator.cs @@ -1,17 +1,17 @@ using System; using System.Net.Mail; -using System.Text.RegularExpressions; + namespace HelpDesk.Common { public static class InputValidator { - private const int MinNameLength = 2; - private const int MaxNameLength = 100; - private const int MinLoginLength = 3; - private const int MaxLoginLength = 50; - private const int MinPasswordLength = 5; - private const int MaxPasswordLength = 50; + private const int minNameLength = 2; + private const int maxNameLength = 100; + private const int minLoginLength = 3; + private const int maxLoginLength = 50; + private const int minPasswordLength = 5; + private const int maxPasswordLength = 50; public static (bool IsValid, string Message) ValidateName(string inputName) @@ -23,9 +23,9 @@ public static (bool IsValid, string Message) ValidateName(string inputName) return (false, "Имя обязательно для заполнения"); } - if (name.Length < MinNameLength || name.Length > MaxNameLength) + if (name.Length < minNameLength || name.Length > maxNameLength) { - return (false, $"Имя должно быть от {MinNameLength} до {MaxNameLength} символов"); + return (false, $"Имя должно быть от {minNameLength} до {maxNameLength} символов"); } return (true, string.Empty); @@ -40,9 +40,9 @@ public static (bool IsValid, string Message) ValidateLogin(string inputLogin) return (false, "Логин обязателен для заполнения"); } - if (login.Length < MinLoginLength || login.Length > MaxLoginLength) + if (login.Length < minLoginLength || login.Length > maxLoginLength) { - return (false, $"Логин должен быть от {MinLoginLength} до {MaxLoginLength} символов"); + return (false, $"Логин должен быть от {minLoginLength} до {maxLoginLength} символов"); } return (true, string.Empty); } @@ -56,9 +56,9 @@ public static (bool IsValid, string Message) ValidatePassword(string inputPasswo return (false, "Пароль обязателен для заполнения"); } - if (password.Length < MinPasswordLength || password.Length > MaxPasswordLength) + if (password.Length < minPasswordLength || password.Length > maxPasswordLength) { - return (false, $"Пароль должен быть от {MinPasswordLength} до {MaxPasswordLength} символов"); + return (false, $"Пароль должен быть от {minPasswordLength} до {maxPasswordLength} символов"); } return (true, string.Empty); diff --git a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs index aa2bcae..4ece032 100644 --- a/HelpDesk/HelpDeskWinFormsApp/MainForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/MainForm.cs @@ -40,7 +40,7 @@ private void MainForm_Load(object sender, EventArgs e) private void InitializeUserSession(string login) { - user = userProvider.GetUser(login); + user = userProvider.Get(login); SetupUserInterface(); SetupTreeViewLayout(); @@ -93,7 +93,7 @@ private void LogoutToolStripMenuItem_Click(object sender, EventArgs e) if (!string.IsNullOrEmpty(login)) { - user = userProvider.GetUser(login); + user = userProvider.Get(login); SetWindowHeaderText(); UpdateUserInfoUI(); ResetTreeViewSelection(); @@ -188,7 +188,7 @@ private void OpenTroubleTicketForm(int ticketId) private int GetResolveUserIdForTicket(int ticketId) { - var ticket = troubleTicketProvider.GetTroubleTicket(ticketId); + var ticket = troubleTicketProvider.Get(ticketId); if (ticket.ResolveUser != null) { @@ -430,7 +430,7 @@ private void RefreshUsersDataGrid() private List GetFilteredUsers(string nodeName) { - var allUsers = userProvider.GetAllUsers(); + var allUsers = userProvider.GetAll(); return nodeName switch { @@ -529,8 +529,8 @@ private List GetFilteredTroubleTickets(string nodeName) private List GetAllRelevantTickets() { return user.IsEmployee - ? troubleTicketProvider.GetAllTroubleTickets() - : troubleTicketProvider.GetAllTroubleTickets().Where(t => t.CreateUserId == user.Id).ToList(); + ? troubleTicketProvider.GetAll() + : troubleTicketProvider.GetAll().Where(t => t.CreateUserId == user.Id).ToList(); } private void ClearAndSetupDataGridViewForTickets() @@ -542,7 +542,7 @@ private void ClearAndSetupDataGridViewForTickets() private void FillTroubleTicketsDataGridView(List tickets) { troubleTicketsDataGridView.Rows.Clear(); - var allUsers = userProvider.GetAllUsers(); + var allUsers = userProvider.GetAll(); foreach (var ticket in tickets) { diff --git a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs index 6db12ff..c9905d9 100644 --- a/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/RegistrationForm.cs @@ -88,7 +88,7 @@ private void RegistrationForm_FormClosing(object sender, FormClosingEventArgs e) Email = emailTextBox.Text }; - userProvider.AddUser(user); + userProvider.Add(user); } private void RegistrationButton_Click(object sender, System.EventArgs e) diff --git a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs index 3509436..7492911 100644 --- a/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs +++ b/HelpDesk/HelpDeskWinFormsApp/TroubleTicketForm.cs @@ -28,8 +28,8 @@ public TroubleTicketForm(int ticketId, bool isEmployee, int resolveUserId, ITrou private void TroubleTicketForm_Shown(object sender, System.EventArgs e) { - troubleTicket = troubleTicketProvider.GetTroubleTicket(ticketId); - userCreate = userProvider.GetUser(troubleTicket.CreateUserId); + troubleTicket = troubleTicketProvider.Get(ticketId); + userCreate = userProvider.Get(troubleTicket.CreateUserId); lastStatus = troubleTicket.Status; Text = $"HelpDesk. Заяка №{troubleTicket.Id}"; @@ -81,12 +81,12 @@ private void TroubleTicketForm_FormClosing(object sender, FormClosingEventArgs e if (isResolutionRequired) { - troubleTicketProvider.ResolveTroubleTicket(troubleTicket.Id, newStatus, + troubleTicketProvider.Resolve(troubleTicket.Id, newStatus, resolveRichTextBox.Text, resolveUserId); return; } - troubleTicketProvider.ChangeStatusTroubleTicket(troubleTicket.Id, newStatus, resolveUserId); + troubleTicketProvider.ChangeStatus(troubleTicket.Id, newStatus, resolveUserId); } } From b2f158f93c0d60f1de2dd1f4af9e6bfb9ec1ace0 Mon Sep 17 00:00:00 2001 From: "Valentina T." Date: Wed, 10 Dec 2025 21:17:37 +0300 Subject: [PATCH 14/14] =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB?= =?UTF-8?q?=D0=B0=20=D0=B8=D0=B7=D0=B1=D1=8B=D1=82=D0=BE=D1=87=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HelpDesk/HelpDesk.Common/Models/User.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/HelpDesk/HelpDesk.Common/Models/User.cs b/HelpDesk/HelpDesk.Common/Models/User.cs index dc89eda..97bcfd3 100644 --- a/HelpDesk/HelpDesk.Common/Models/User.cs +++ b/HelpDesk/HelpDesk.Common/Models/User.cs @@ -14,18 +14,6 @@ public class User public string? Department { get; set; } public User() { } - - [JsonConstructor] - private User(int id, string name, string login, string password, string email, bool isEmployee, string? function, string? department) - { - Id = id; - Name = name; - Login = login; - Password = password; - Email = email; - IsEmployee = isEmployee; - Function = function; - Department = department; - } + } } \ No newline at end of file