From c4e6741777cd57317bd7a270ca59d3b86840ddbc Mon Sep 17 00:00:00 2001 From: Maxim Date: Sat, 9 Nov 2024 03:06:08 +0400 Subject: [PATCH] lab1 ready --- ProjectGSM/Entities/Advocate.cs | 9 +- ProjectGSM/Entities/Case.cs | 13 +- ProjectGSM/Entities/CaseAdvocate.cs | 4 +- ProjectGSM/Entities/Status.cs | 21 --- ProjectGSM/Entities/StatusHistory.cs | 12 +- ProjectGSM/Entities/TypeAppeal.cs | 19 --- ProjectGSM/FormAdvocateApp.Designer.cs | 22 +-- ProjectGSM/FormAdvocateApp.cs | 26 ---- ProjectGSM/Forms/FormAdvocate.Designer.cs | 70 +++++---- ProjectGSM/Forms/FormAdvocate.cs | 33 ++++- ProjectGSM/Forms/FormCase.Designer.cs | 105 +++++++++----- ProjectGSM/Forms/FormCase.cs | 52 +++++-- ProjectGSM/Forms/FormCase.resx | 6 + .../Forms/FormCaseAdvocates.Designer.cs | 116 --------------- ProjectGSM/Forms/FormCaseAdvocates.cs | 64 --------- ProjectGSM/Forms/FormCaseAdvocates.resx | 120 ---------------- ProjectGSM/Forms/FormCases.Designer.cs | 39 ++--- ProjectGSM/Forms/FormCases.cs | 21 --- .../Forms/FormCasesAdvocates.Designer.cs | 101 ------------- ProjectGSM/Forms/FormCasesAdvocates.cs | 68 --------- ProjectGSM/Forms/FormCasesAdvocates.resx | 120 ---------------- ProjectGSM/Forms/FormStatus.Designer.cs | 136 ------------------ ProjectGSM/Forms/FormStatus.cs | 78 ---------- ProjectGSM/Forms/FormStatus.resx | 120 ---------------- .../Forms/FormStatusHistory.Designer.cs | 44 ++++-- ProjectGSM/Forms/FormStatusHistory.cs | 16 +-- ProjectGSM/Forms/FormStatuses.Designer.cs | 130 ----------------- ProjectGSM/Forms/FormStatuses.cs | 114 --------------- ProjectGSM/Forms/FormStatuses.resx | 120 ---------------- ProjectGSM/Forms/FormTypeApeal.Designer.cs | 92 ------------ ProjectGSM/Forms/FormTypeApeal.cs | 77 ---------- ProjectGSM/Forms/FormTypeApeal.resx | 120 ---------------- ProjectGSM/Forms/FormTypeAppeals.Designer.cs | 130 ----------------- ProjectGSM/Forms/FormTypeAppeals.cs | 123 ---------------- ProjectGSM/Forms/FormTypeAppeals.resx | 120 ---------------- ProjectGSM/Program.cs | 2 - ProjectGSM/ProjectGSM.csproj | 22 --- ProjectGSM/Repositories/IStatusRepository.cs | 12 -- .../Repositories/ITypeAppealRepository.cs | 12 -- .../Implementations/AdvocateRepository.cs | 2 +- .../Implementations/CaseRepository.cs | 2 +- .../Implementations/StatusRepository.cs | 28 ---- .../Implementations/TypeAppealRepository.cs | 28 ---- 43 files changed, 268 insertions(+), 2301 deletions(-) delete mode 100644 ProjectGSM/Entities/Status.cs delete mode 100644 ProjectGSM/Entities/TypeAppeal.cs delete mode 100644 ProjectGSM/Forms/FormCaseAdvocates.Designer.cs delete mode 100644 ProjectGSM/Forms/FormCaseAdvocates.cs delete mode 100644 ProjectGSM/Forms/FormCaseAdvocates.resx delete mode 100644 ProjectGSM/Forms/FormCasesAdvocates.Designer.cs delete mode 100644 ProjectGSM/Forms/FormCasesAdvocates.cs delete mode 100644 ProjectGSM/Forms/FormCasesAdvocates.resx delete mode 100644 ProjectGSM/Forms/FormStatus.Designer.cs delete mode 100644 ProjectGSM/Forms/FormStatus.cs delete mode 100644 ProjectGSM/Forms/FormStatus.resx delete mode 100644 ProjectGSM/Forms/FormStatuses.Designer.cs delete mode 100644 ProjectGSM/Forms/FormStatuses.cs delete mode 100644 ProjectGSM/Forms/FormStatuses.resx delete mode 100644 ProjectGSM/Forms/FormTypeApeal.Designer.cs delete mode 100644 ProjectGSM/Forms/FormTypeApeal.cs delete mode 100644 ProjectGSM/Forms/FormTypeApeal.resx delete mode 100644 ProjectGSM/Forms/FormTypeAppeals.Designer.cs delete mode 100644 ProjectGSM/Forms/FormTypeAppeals.cs delete mode 100644 ProjectGSM/Forms/FormTypeAppeals.resx delete mode 100644 ProjectGSM/Repositories/IStatusRepository.cs delete mode 100644 ProjectGSM/Repositories/ITypeAppealRepository.cs delete mode 100644 ProjectGSM/Repositories/Implementations/StatusRepository.cs delete mode 100644 ProjectGSM/Repositories/Implementations/TypeAppealRepository.cs diff --git a/ProjectGSM/Entities/Advocate.cs b/ProjectGSM/Entities/Advocate.cs index ce2144b..5cdaf8b 100644 --- a/ProjectGSM/Entities/Advocate.cs +++ b/ProjectGSM/Entities/Advocate.cs @@ -1,4 +1,7 @@ -namespace ProjectGSM.Entities; +using ProjectGSM.Entities.Enums; +using System.ComponentModel; + +namespace ProjectGSM.Entities; public class Advocate { @@ -12,6 +15,7 @@ public class Advocate public string Email { get; private set; } = string.Empty; public string PhoneNumber { get; private set; } = string.Empty; public string Address { get; private set; } = string.Empty; + public LicenseType LicenseType { get; private set; } public DateTime CreatedAt { get; private set; } = DateTime.UtcNow; // Конструктор для создания сущности @@ -25,7 +29,7 @@ public class Advocate int rating, string email, string phoneNumber, - string address) + string address, LicenseType license) { return new Advocate { @@ -39,6 +43,7 @@ public class Advocate Email = email ?? string.Empty, PhoneNumber = phoneNumber ?? string.Empty, Address = address ?? string.Empty, + LicenseType = license, CreatedAt = DateTime.UtcNow }; } diff --git a/ProjectGSM/Entities/Case.cs b/ProjectGSM/Entities/Case.cs index b28b706..1d74e39 100644 --- a/ProjectGSM/Entities/Case.cs +++ b/ProjectGSM/Entities/Case.cs @@ -1,13 +1,14 @@ -namespace ProjectGSM.Entities; +using ProjectGSM.Entities.Enums; + +namespace ProjectGSM.Entities; public class Case { public int Id { get; private set; } - public int TypeAppealId { get; private set; } + public TypeAppeal TypeAppeal { get; private set; } public bool Payment { get; private set; } = false; public decimal Price { get; private set; } public decimal VictoryPrice { get; private set; } - public int StatusId { get; private set; } public bool Verdict { get; private set; } = false; public int CourtId { get; private set; } public int ClientId { get; private set; } @@ -17,11 +18,10 @@ public class Case // Конструктор для создания сущности public static Case CreateEntity( int id, - int typeAppealId, + TypeAppeal typeAppeal, bool payment, decimal price, decimal victoryPrice, - int statusId, bool verdict, int courtId, int clientId, @@ -31,11 +31,10 @@ public class Case return new Case { Id = id, - TypeAppealId = typeAppealId, + TypeAppeal = typeAppeal, Payment = payment, Price = price, VictoryPrice = victoryPrice, - StatusId = statusId, Verdict = verdict, CourtId = courtId, ClientId = clientId, diff --git a/ProjectGSM/Entities/CaseAdvocate.cs b/ProjectGSM/Entities/CaseAdvocate.cs index 7d9a309..59b80a0 100644 --- a/ProjectGSM/Entities/CaseAdvocate.cs +++ b/ProjectGSM/Entities/CaseAdvocate.cs @@ -4,15 +4,17 @@ public class CaseAdvocate { public int CaseId { get; private set; } public int AdvocateId { get; private set; } + public string Post { get; private set; } = string.Empty; public DateTime CreatedAt { get; private set; } = DateTime.UtcNow; // Конструктор для создания сущности - public static CaseAdvocate CreateEntity(int caseId, int advocateId) + public static CaseAdvocate CreateEntity(int caseId, int advocateId, string post) { return new CaseAdvocate { CaseId = caseId, AdvocateId = advocateId, + Post = post, CreatedAt = DateTime.UtcNow }; } diff --git a/ProjectGSM/Entities/Status.cs b/ProjectGSM/Entities/Status.cs deleted file mode 100644 index 049f119..0000000 --- a/ProjectGSM/Entities/Status.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace ProjectGSM.Entities; - -public class Status -{ - public int Id { get; private set; } - public string Name { get; private set; } = string.Empty; - public DateTime CreatedAt { get; private set; } = DateTime.UtcNow; - public decimal? Price { get; private set; } - - // Конструктор для создания сущности - public static Status CreateEntity(int id, string name, decimal? price = null, DateTime? dateTime = null) - { - return new Status - { - Id = id, - Name = name ?? string.Empty, - Price = price, - CreatedAt = dateTime ?? DateTime.UtcNow - }; - } -} diff --git a/ProjectGSM/Entities/StatusHistory.cs b/ProjectGSM/Entities/StatusHistory.cs index ee4aa33..55f386b 100644 --- a/ProjectGSM/Entities/StatusHistory.cs +++ b/ProjectGSM/Entities/StatusHistory.cs @@ -1,18 +1,22 @@ -namespace ProjectGSM.Entities; +using ProjectGSM.Entities.Enums; + +namespace ProjectGSM.Entities; public class StatusHistory { public int CaseId { get; private set; } - public int StatusId { get; private set; } + public Status Status { get; private set; } + public decimal Price { get; private set; } public DateTime CreatedAt { get; private set; } = DateTime.UtcNow; // Конструктор для создания сущности - public static StatusHistory CreateEntity(int caseId, int statusId, DateTime? dateTime = null) + public static StatusHistory CreateEntity(int caseId, Status status, decimal price, DateTime? dateTime = null) { return new StatusHistory { CaseId = caseId, - StatusId = statusId, + Status = status, + Price = price, CreatedAt = dateTime ?? DateTime.UtcNow }; } diff --git a/ProjectGSM/Entities/TypeAppeal.cs b/ProjectGSM/Entities/TypeAppeal.cs deleted file mode 100644 index 4b0dd6d..0000000 --- a/ProjectGSM/Entities/TypeAppeal.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace ProjectGSM.Entities; - -public class TypeAppeal -{ - public int Id { get; private set; } - public string Name { get; private set; } = string.Empty; - public DateTime CreatedAt { get; private set; } = DateTime.UtcNow; - - // Конструктор для создания сущности - public static TypeAppeal CreateEntity(int id, string name) - { - return new TypeAppeal - { - Id = id, - Name = name ?? string.Empty, - CreatedAt = DateTime.UtcNow - }; - } -} diff --git a/ProjectGSM/FormAdvocateApp.Designer.cs b/ProjectGSM/FormAdvocateApp.Designer.cs index 1439ed5..05fca93 100644 --- a/ProjectGSM/FormAdvocateApp.Designer.cs +++ b/ProjectGSM/FormAdvocateApp.Designer.cs @@ -13,7 +13,6 @@ private System.Windows.Forms.ToolStripMenuItem clientsMenuItem; private System.Windows.Forms.ToolStripMenuItem advocatesMenuItem; private System.Windows.Forms.ToolStripMenuItem casesMenuItem; - private System.Windows.Forms.ToolStripMenuItem caseAdvocateRepositoryMenuItem; private System.Windows.Forms.ToolStripMenuItem statusHistoryRepositoryMenuItem; /// @@ -42,10 +41,8 @@ clientsMenuItem = new ToolStripMenuItem(); advocatesMenuItem = new ToolStripMenuItem(); casesMenuItem = new ToolStripMenuItem(); - typeAppealsToolStripMenuItem = new ToolStripMenuItem(); courtsToolStripMenuItem = new ToolStripMenuItem(); operationsMenuItem = new ToolStripMenuItem(); - caseAdvocateRepositoryMenuItem = new ToolStripMenuItem(); statusHistoryRepositoryMenuItem = new ToolStripMenuItem(); reportsMenuItem = new ToolStripMenuItem(); menuStrip.SuspendLayout(); @@ -63,7 +60,7 @@ // // directoriesMenuItem // - directoriesMenuItem.DropDownItems.AddRange(new ToolStripItem[] { clientsMenuItem, advocatesMenuItem, casesMenuItem, typeAppealsToolStripMenuItem, courtsToolStripMenuItem }); + directoriesMenuItem.DropDownItems.AddRange(new ToolStripItem[] { clientsMenuItem, advocatesMenuItem, courtsToolStripMenuItem }); directoriesMenuItem.Name = "directoriesMenuItem"; directoriesMenuItem.Size = new Size(94, 20); directoriesMenuItem.Text = "Справочники"; @@ -89,13 +86,6 @@ casesMenuItem.Text = "Дела"; casesMenuItem.Click += casesMenuItem_Click; // - // typeAppealsToolStripMenuItem - // - typeAppealsToolStripMenuItem.Name = "typeAppealsToolStripMenuItem"; - typeAppealsToolStripMenuItem.Size = new Size(161, 22); - typeAppealsToolStripMenuItem.Text = "Тип обращения"; - typeAppealsToolStripMenuItem.Click += typeAppealsToolStripMenuItem_Click; - // // courtsToolStripMenuItem // courtsToolStripMenuItem.Name = "courtsToolStripMenuItem"; @@ -105,18 +95,11 @@ // // operationsMenuItem // - operationsMenuItem.DropDownItems.AddRange(new ToolStripItem[] { caseAdvocateRepositoryMenuItem, statusHistoryRepositoryMenuItem }); + operationsMenuItem.DropDownItems.AddRange(new ToolStripItem[] { casesMenuItem, statusHistoryRepositoryMenuItem }); operationsMenuItem.Name = "operationsMenuItem"; operationsMenuItem.Size = new Size(75, 20); operationsMenuItem.Text = "Операции"; // - // caseAdvocateRepositoryMenuItem - // - caseAdvocateRepositoryMenuItem.Name = "caseAdvocateRepositoryMenuItem"; - caseAdvocateRepositoryMenuItem.Size = new Size(221, 22); - caseAdvocateRepositoryMenuItem.Text = "Привязка адвокатов к делу"; - caseAdvocateRepositoryMenuItem.Click += caseAdvocateRepositoryMenuItem_Click; - // // statusHistoryRepositoryMenuItem // statusHistoryRepositoryMenuItem.Name = "statusHistoryRepositoryMenuItem"; @@ -150,7 +133,6 @@ #endregion - private ToolStripMenuItem typeAppealsToolStripMenuItem; private ToolStripMenuItem courtsToolStripMenuItem; } } diff --git a/ProjectGSM/FormAdvocateApp.cs b/ProjectGSM/FormAdvocateApp.cs index a70a98b..6225014 100644 --- a/ProjectGSM/FormAdvocateApp.cs +++ b/ProjectGSM/FormAdvocateApp.cs @@ -52,19 +52,6 @@ throw new ArgumentNullException(nameof(container)); MessageBoxButtons.OK, MessageBoxIcon.Error); } } - - private void typeAppealsToolStripMenuItem_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, " ", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } private void courtsToolStripMenuItem_Click(object sender, EventArgs e) { try @@ -78,19 +65,6 @@ throw new ArgumentNullException(nameof(container)); } } - private void caseAdvocateRepositoryMenuItem_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, " ", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - private void statusHistoryRepositoryMenuItem_Click(object sender, EventArgs e) { try diff --git a/ProjectGSM/Forms/FormAdvocate.Designer.cs b/ProjectGSM/Forms/FormAdvocate.Designer.cs index cd57418..494f626 100644 --- a/ProjectGSM/Forms/FormAdvocate.Designer.cs +++ b/ProjectGSM/Forms/FormAdvocate.Designer.cs @@ -48,6 +48,8 @@ ratingNumeric = new NumericUpDown(); emailLabel = new Label(); emailTextBox = new TextBox(); + licenseLabel = new Label(); + checkedListBox = new CheckedListBox(); ((System.ComponentModel.ISupportInitialize)expNumeric).BeginInit(); ((System.ComponentModel.ISupportInitialize)tasksNumeric).BeginInit(); ((System.ComponentModel.ISupportInitialize)ratingNumeric).BeginInit(); @@ -55,17 +57,17 @@ // // nameLabel // - nameLabel.Location = new Point(10, 10); + nameLabel.Location = new Point(14, 9); nameLabel.Name = "nameLabel"; - nameLabel.Size = new Size(100, 23); + nameLabel.Size = new Size(134, 23); nameLabel.TabIndex = 0; nameLabel.Text = "Имя адвоката:"; // // nameTextBox // - nameTextBox.Location = new Point(120, 10); + nameTextBox.Location = new Point(148, 5); nameTextBox.Name = "nameTextBox"; - nameTextBox.Size = new Size(116, 23); + nameTextBox.Size = new Size(116, 31); nameTextBox.TabIndex = 1; // // expLabel @@ -80,16 +82,16 @@ // saveButton.Location = new Point(122, 303); saveButton.Name = "saveButton"; - saveButton.Size = new Size(75, 23); + saveButton.Size = new Size(114, 35); saveButton.TabIndex = 4; saveButton.Text = "Сохранить"; saveButton.Click += saveButton_Click; // // cancelButton // - cancelButton.Location = new Point(203, 303); + cancelButton.Location = new Point(255, 309); cancelButton.Name = "cancelButton"; - cancelButton.Size = new Size(75, 23); + cancelButton.Size = new Size(133, 29); cancelButton.TabIndex = 5; cancelButton.Text = "Отмена"; cancelButton.Click += cancelButton_Click; @@ -105,9 +107,9 @@ // sexCheckBox // sexCheckBox.AutoSize = true; - sexCheckBox.Location = new Point(120, 37); + sexCheckBox.Location = new Point(148, 32); sexCheckBox.Name = "sexCheckBox"; - sexCheckBox.Size = new Size(77, 19); + sexCheckBox.Size = new Size(112, 29); sexCheckBox.TabIndex = 6; sexCheckBox.Text = "мужчина"; sexCheckBox.UseVisualStyleBackColor = true; @@ -122,9 +124,9 @@ // // dateTimePicker // - dateTimePicker.Location = new Point(116, 61); + dateTimePicker.Location = new Point(144, 56); dateTimePicker.Name = "dateTimePicker"; - dateTimePicker.Size = new Size(120, 23); + dateTimePicker.Size = new Size(120, 31); dateTimePicker.TabIndex = 8; // // PhoneLabel @@ -137,9 +139,9 @@ // // phoneText // - phoneText.Location = new Point(116, 217); + phoneText.Location = new Point(144, 212); phoneText.Name = "phoneText"; - phoneText.Size = new Size(120, 23); + phoneText.Size = new Size(120, 31); phoneText.TabIndex = 10; // // adressLabel @@ -152,16 +154,16 @@ // // adressBox // - adressBox.Location = new Point(116, 246); + adressBox.Location = new Point(144, 241); adressBox.Name = "adressBox"; - adressBox.Size = new Size(120, 23); + adressBox.Size = new Size(120, 31); adressBox.TabIndex = 12; // // expNumeric // - expNumeric.Location = new Point(116, 90); + expNumeric.Location = new Point(144, 85); expNumeric.Name = "expNumeric"; - expNumeric.Size = new Size(120, 23); + expNumeric.Size = new Size(120, 31); expNumeric.TabIndex = 13; // // tasksLabel @@ -174,9 +176,9 @@ // // tasksNumeric // - tasksNumeric.Location = new Point(116, 119); + tasksNumeric.Location = new Point(144, 114); tasksNumeric.Name = "tasksNumeric"; - tasksNumeric.Size = new Size(120, 23); + tasksNumeric.Size = new Size(120, 31); tasksNumeric.TabIndex = 16; // // ratingLabel @@ -189,9 +191,9 @@ // // ratingNumeric // - ratingNumeric.Location = new Point(116, 152); + ratingNumeric.Location = new Point(144, 147); ratingNumeric.Name = "ratingNumeric"; - ratingNumeric.Size = new Size(120, 23); + ratingNumeric.Size = new Size(120, 31); ratingNumeric.TabIndex = 18; // // emailLabel @@ -204,14 +206,32 @@ // // emailTextBox // - emailTextBox.Location = new Point(116, 184); + emailTextBox.Location = new Point(144, 179); emailTextBox.Name = "emailTextBox"; - emailTextBox.Size = new Size(120, 23); + emailTextBox.Size = new Size(120, 31); emailTextBox.TabIndex = 20; // + // licenseLabel + // + licenseLabel.Location = new Point(298, 9); + licenseLabel.Name = "licenseLabel"; + licenseLabel.Size = new Size(100, 23); + licenseLabel.TabIndex = 21; + licenseLabel.Text = "Лицензии:"; + // + // checkedListBox + // + checkedListBox.FormattingEnabled = true; + checkedListBox.Location = new Point(298, 56); + checkedListBox.Name = "checkedListBox"; + checkedListBox.Size = new Size(304, 228); + checkedListBox.TabIndex = 22; + // // FormAdvocate // - ClientSize = new Size(284, 338); + ClientSize = new Size(637, 593); + Controls.Add(checkedListBox); + Controls.Add(licenseLabel); Controls.Add(emailTextBox); Controls.Add(emailLabel); Controls.Add(ratingNumeric); @@ -266,5 +286,7 @@ private NumericUpDown ratingNumeric; private Label emailLabel; private TextBox emailTextBox; + private Label licenseLabel; + private CheckedListBox checkedListBox; } } \ No newline at end of file diff --git a/ProjectGSM/Forms/FormAdvocate.cs b/ProjectGSM/Forms/FormAdvocate.cs index 3fccacd..ec9a06e 100644 --- a/ProjectGSM/Forms/FormAdvocate.cs +++ b/ProjectGSM/Forms/FormAdvocate.cs @@ -1,4 +1,6 @@ -using ProjectGSM.Entities; +using Microsoft.VisualBasic.FileIO; +using ProjectGSM.Entities; +using ProjectGSM.Entities.Enums; using ProjectGSM.Repositories; namespace ProjectGSM.Forms @@ -23,6 +25,15 @@ namespace ProjectGSM.Forms throw new InvalidDataException(nameof(advocate)); } + foreach (LicenseType elem in Enum.GetValues(typeof(LicenseType))) + { + if ((elem & advocate.LicenseType) != 0) + { + checkedListBox.SetItemChecked(checkedListBox.Items.IndexOf( + elem), true); + } + } + nameTextBox.Text = advocate.Name; sexCheckBox.Checked= advocate.Sex; dateTimePicker.Value = new DateTime(advocate.DateOfBirth.Year, advocate.DateOfBirth.Month, advocate.DateOfBirth.Day); @@ -48,6 +59,12 @@ namespace ProjectGSM.Forms _advocateRepository = advocateRepository ?? throw new ArgumentNullException(nameof(advocateRepository)); + + foreach (var elem in Enum.GetValues(typeof(LicenseType))) + { + checkedListBox.Items.Add(elem); + } + } private void saveButton_Click(object sender, EventArgs e) @@ -57,7 +74,7 @@ namespace ProjectGSM.Forms if (string.IsNullOrWhiteSpace(nameTextBox.Text) || string.IsNullOrWhiteSpace(emailTextBox.Text) || string.IsNullOrWhiteSpace(phoneText.Text) || - string.IsNullOrWhiteSpace(adressBox.Text)) + string.IsNullOrWhiteSpace(adressBox.Text) || checkedListBox.CheckedItems.Count == 0) { throw new Exception("Имеются незаполненные поля"); } @@ -81,7 +98,14 @@ namespace ProjectGSM.Forms private void cancelButton_Click(object sender, EventArgs e) => Close(); - private Advocate CreateAdvocate(int id) => Advocate.CreateEntity(id, + private Advocate CreateAdvocate(int id) + { + LicenseType licenseType = LicenseType.None; + foreach (var elem in checkedListBox.CheckedItems) + { + licenseType |= (LicenseType)elem; + } + return Advocate.CreateEntity(id, nameTextBox.Text, sexCheckBox.Checked, dateTimePicker.Value, @@ -90,7 +114,8 @@ namespace ProjectGSM.Forms Convert.ToInt32(ratingNumeric.Value), emailTextBox.Text, phoneText.Text, - adressBox.Text); + adressBox.Text, licenseType); + } } } diff --git a/ProjectGSM/Forms/FormCase.Designer.cs b/ProjectGSM/Forms/FormCase.Designer.cs index 7b43630..2e67437 100644 --- a/ProjectGSM/Forms/FormCase.Designer.cs +++ b/ProjectGSM/Forms/FormCase.Designer.cs @@ -33,14 +33,12 @@ saveButton = new Button(); cancelButton = new Button(); priceLabel = new Label(); - StatusLabel = new Label(); verdictLabel = new Label(); typeApellBox = new ComboBox(); paymentCheckBox = new CheckBox(); priceNumeric = new NumericUpDown(); winPriceLabel = new Label(); winPriceNumeric = new NumericUpDown(); - statusBox = new ComboBox(); verdictCheckBox = new CheckBox(); courtBox = new ComboBox(); courtLabel = new Label(); @@ -48,8 +46,14 @@ clientLabel = new Label(); descriptionLabel = new Label(); textBox1 = new TextBox(); + groupBox1 = new GroupBox(); + dataGridView1 = new DataGridView(); + ColumnAdvocate = new DataGridViewComboBoxColumn(); + ColumnPost = new DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)priceNumeric).BeginInit(); ((System.ComponentModel.ISupportInitialize)winPriceNumeric).BeginInit(); + groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); SuspendLayout(); // // typeApealLabel @@ -70,18 +74,18 @@ // // saveButton // - saveButton.Location = new Point(118, 375); + saveButton.Location = new Point(116, 531); saveButton.Name = "saveButton"; - saveButton.Size = new Size(75, 23); + saveButton.Size = new Size(128, 39); saveButton.TabIndex = 4; saveButton.Text = "Сохранить"; saveButton.Click += saveButton_Click; // // cancelButton // - cancelButton.Location = new Point(197, 375); + cancelButton.Location = new Point(283, 531); cancelButton.Name = "cancelButton"; - cancelButton.Size = new Size(75, 23); + cancelButton.Size = new Size(126, 39); cancelButton.TabIndex = 5; cancelButton.Text = "Отмена"; cancelButton.Click += cancelButton_Click; @@ -94,17 +98,9 @@ priceLabel.TabIndex = 0; priceLabel.Text = "Цена:"; // - // StatusLabel - // - StatusLabel.Location = new Point(10, 157); - StatusLabel.Name = "StatusLabel"; - StatusLabel.Size = new Size(111, 23); - StatusLabel.TabIndex = 9; - StatusLabel.Text = "Текущий статус:"; - // // verdictLabel // - verdictLabel.Location = new Point(10, 191); + verdictLabel.Location = new Point(10, 176); verdictLabel.Name = "verdictLabel"; verdictLabel.Size = new Size(111, 23); verdictLabel.TabIndex = 11; @@ -116,7 +112,7 @@ typeApellBox.FormattingEnabled = true; typeApellBox.Location = new Point(116, 10); typeApellBox.Name = "typeApellBox"; - typeApellBox.Size = new Size(121, 23); + typeApellBox.Size = new Size(121, 33); typeApellBox.TabIndex = 13; // // paymentCheckBox @@ -124,7 +120,7 @@ paymentCheckBox.AutoSize = true; paymentCheckBox.Location = new Point(120, 49); paymentCheckBox.Name = "paymentCheckBox"; - paymentCheckBox.Size = new Size(76, 19); + paymentCheckBox.Size = new Size(109, 29); paymentCheckBox.TabIndex = 14; paymentCheckBox.Text = "успешно"; paymentCheckBox.UseVisualStyleBackColor = true; @@ -134,7 +130,7 @@ priceNumeric.DecimalPlaces = 2; priceNumeric.Location = new Point(117, 87); priceNumeric.Name = "priceNumeric"; - priceNumeric.Size = new Size(120, 23); + priceNumeric.Size = new Size(120, 31); priceNumeric.TabIndex = 15; // // winPriceLabel @@ -150,24 +146,15 @@ winPriceNumeric.DecimalPlaces = 2; winPriceNumeric.Location = new Point(117, 122); winPriceNumeric.Name = "winPriceNumeric"; - winPriceNumeric.Size = new Size(120, 23); + winPriceNumeric.Size = new Size(120, 31); winPriceNumeric.TabIndex = 17; // - // statusBox - // - statusBox.DropDownStyle = ComboBoxStyle.DropDownList; - statusBox.FormattingEnabled = true; - statusBox.Location = new Point(116, 157); - statusBox.Name = "statusBox"; - statusBox.Size = new Size(121, 23); - statusBox.TabIndex = 18; - // // verdictCheckBox // verdictCheckBox.AutoSize = true; - verdictCheckBox.Location = new Point(117, 191); + verdictCheckBox.Location = new Point(116, 176); verdictCheckBox.Name = "verdictCheckBox"; - verdictCheckBox.Size = new Size(76, 19); + verdictCheckBox.Size = new Size(109, 29); verdictCheckBox.TabIndex = 19; verdictCheckBox.Text = "успешно"; verdictCheckBox.UseVisualStyleBackColor = true; @@ -176,14 +163,14 @@ // courtBox.DropDownStyle = ComboBoxStyle.DropDownList; courtBox.FormattingEnabled = true; - courtBox.Location = new Point(116, 224); + courtBox.Location = new Point(116, 212); courtBox.Name = "courtBox"; - courtBox.Size = new Size(121, 23); + courtBox.Size = new Size(121, 33); courtBox.TabIndex = 21; // // courtLabel // - courtLabel.Location = new Point(10, 224); + courtLabel.Location = new Point(12, 215); courtLabel.Name = "courtLabel"; courtLabel.Size = new Size(100, 23); courtLabel.TabIndex = 20; @@ -195,7 +182,7 @@ clientBox.FormattingEnabled = true; clientBox.Location = new Point(116, 262); clientBox.Name = "clientBox"; - clientBox.Size = new Size(121, 23); + clientBox.Size = new Size(121, 33); clientBox.TabIndex = 23; // // clientLabel @@ -222,9 +209,47 @@ textBox1.Size = new Size(154, 73); textBox1.TabIndex = 25; // + // groupBox1 + // + groupBox1.Controls.Add(dataGridView1); + groupBox1.Location = new Point(327, 30); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new Size(477, 339); + groupBox1.TabIndex = 26; + groupBox1.TabStop = false; + groupBox1.Text = "Прикрепленные адвокаты"; + // + // dataGridView1 + // + dataGridView1.AllowUserToResizeColumns = false; + dataGridView1.AllowUserToResizeRows = false; + dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView1.BackgroundColor = SystemColors.ActiveCaption; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Columns.AddRange(new DataGridViewColumn[] { ColumnAdvocate, ColumnPost }); + dataGridView1.Dock = DockStyle.Fill; + dataGridView1.Location = new Point(3, 27); + dataGridView1.Name = "dataGridView1"; + dataGridView1.RowHeadersWidth = 62; + dataGridView1.Size = new Size(471, 309); + dataGridView1.TabIndex = 0; + // + // ColumnAdvocate + // + ColumnAdvocate.HeaderText = "Адвокаты"; + ColumnAdvocate.MinimumWidth = 8; + ColumnAdvocate.Name = "ColumnAdvocate"; + // + // ColumnPost + // + ColumnPost.HeaderText = "Должности"; + ColumnPost.MinimumWidth = 8; + ColumnPost.Name = "ColumnPost"; + // // FormCase // - ClientSize = new Size(284, 407); + ClientSize = new Size(845, 582); + Controls.Add(groupBox1); Controls.Add(textBox1); Controls.Add(descriptionLabel); Controls.Add(clientBox); @@ -232,14 +257,12 @@ Controls.Add(courtBox); Controls.Add(courtLabel); Controls.Add(verdictCheckBox); - Controls.Add(statusBox); Controls.Add(winPriceNumeric); Controls.Add(winPriceLabel); Controls.Add(priceNumeric); Controls.Add(paymentCheckBox); Controls.Add(typeApellBox); Controls.Add(verdictLabel); - Controls.Add(StatusLabel); Controls.Add(priceLabel); Controls.Add(typeApealLabel); Controls.Add(paymentLabel); @@ -250,6 +273,8 @@ Text = "Дело"; ((System.ComponentModel.ISupportInitialize)priceNumeric).EndInit(); ((System.ComponentModel.ISupportInitialize)winPriceNumeric).EndInit(); + groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -268,7 +293,6 @@ private CheckBox sexCheckBox; private Label DateLabel; private DateTimePicker dateTimePicker; - private Label StatusLabel; private TextBox phoneText; private Label verdictLabel; private ComboBox typeApellBox; @@ -276,7 +300,6 @@ private NumericUpDown priceNumeric; private Label winPriceLabel; private NumericUpDown winPriceNumeric; - private ComboBox statusBox; private CheckBox verdictCheckBox; private ComboBox courtBox; private Label courtLabel; @@ -284,5 +307,9 @@ private Label clientLabel; private Label descriptionLabel; private TextBox textBox1; + private GroupBox groupBox1; + private DataGridView dataGridView1; + private DataGridViewComboBoxColumn ColumnAdvocate; + private DataGridViewTextBoxColumn ColumnPost; } } \ No newline at end of file diff --git a/ProjectGSM/Forms/FormCase.cs b/ProjectGSM/Forms/FormCase.cs index 98ed0ef..29c8afa 100644 --- a/ProjectGSM/Forms/FormCase.cs +++ b/ProjectGSM/Forms/FormCase.cs @@ -1,5 +1,7 @@ using ProjectGSM.Entities; +using ProjectGSM.Entities.Enums; using ProjectGSM.Repositories; +using ProjectGSM.Repositories.Implementations; using System; using System.Collections.Generic; using System.ComponentModel; @@ -17,6 +19,8 @@ namespace ProjectGSM.Forms { private readonly ICaseRepository _caseRepository; + private readonly ICaseAdvocateRepository _caseAdvocateRepository; + private int? _caseId; public int Id @@ -32,10 +36,11 @@ namespace ProjectGSM.Forms throw new InvalidDataException(nameof(caseE)); } - typeApellBox.SelectedIndex = caseE.TypeAppealId; + + + typeApellBox.SelectedItem = caseE.TypeAppeal; clientBox.SelectedIndex = caseE.ClientId; courtBox.SelectedIndex = caseE.CourtId; - statusBox.SelectedIndex = caseE.StatusId; paymentCheckBox.Checked = caseE.Payment; priceNumeric.Value = caseE.Price; winPriceNumeric.Value = caseE.VictoryPrice; @@ -51,25 +56,24 @@ namespace ProjectGSM.Forms } - public FormCase(ICaseRepository caseRepository, IClientRepository clientRepository, ICourtRepository courtRepository, IStatusRepository statusRepository) + public FormCase(ICaseRepository caseRepository, ICaseAdvocateRepository caseAdvocateRepository,IClientRepository clientRepository, ICourtRepository courtRepository, IAdvocateRepository advocateRepository) { InitializeComponent(); _caseRepository = caseRepository ?? throw new ArgumentNullException(nameof(caseRepository)); + _caseAdvocateRepository = caseAdvocateRepository ?? throw new ArgumentNullException(nameof(caseAdvocateRepository)); + + typeApellBox.DataSource = Enum.GetValues(typeof(TypeAppeal)); - typeApellBox.DataSource = caseRepository.ReadCases(); - typeApellBox.DisplayMember = "Name"; - typeApellBox.ValueMember = "Id"; + ColumnAdvocate.DataSource = advocateRepository.ReadAdvocates(); + ColumnAdvocate.DisplayMember = "Name"; + ColumnAdvocate.ValueMember = "Id"; clientBox.DataSource = clientRepository.ReadClients(); clientBox.DisplayMember = "Name"; clientBox.ValueMember = "Id"; - statusBox.DataSource = statusRepository.ReadStatuses(); - statusBox.DisplayMember = "Name"; - statusBox.ValueMember = "Id"; - courtBox.DataSource = courtRepository.ReadCourts(); courtBox.DisplayMember = "Name"; courtBox.ValueMember = "Id"; @@ -78,7 +82,7 @@ namespace ProjectGSM.Forms private void saveButton_Click(object sender, EventArgs e) { try - {if(typeApellBox.SelectedIndex < 0 || clientBox.SelectedIndex < 0 || statusBox.SelectedIndex < 0 || courtBox.SelectedIndex < 0 + {if(dataGridView1.RowCount < 1 || typeApellBox.SelectedIndex < 0 || clientBox.SelectedIndex < 0 || courtBox.SelectedIndex < 0 ) { @@ -92,6 +96,10 @@ namespace ProjectGSM.Forms { _caseRepository.UpdateCase(CreateCase(0)); } + foreach (CaseAdvocate row in CreateListCaseAdvocateFromDataGrid()) + { + _caseAdvocateRepository.CreateCaseAdvocate(CaseAdvocate.CreateEntity(row.CaseId, row.AdvocateId, row.Post)); + } Close(); } catch (Exception ex) @@ -104,12 +112,30 @@ namespace ProjectGSM.Forms private void cancelButton_Click(object sender, EventArgs e) => Close(); + + private List CreateListCaseAdvocateFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridView1.Rows) + { + if (row.Cells["ColumnAdvocates"].Value == null || + row.Cells["ColumnPost"].Value == null) + { + continue; + } + list.Add(CaseAdvocate.CreateEntity(0, + Convert.ToInt32(row.Cells["ColumnAdvocates"].Value), + row.Cells["ColumnPost"].Value.ToString()??string.Empty)); + } + return list; + } + + private Case CreateCase(int id) => Case.CreateEntity(id, - typeApellBox.SelectedIndex, + (TypeAppeal)typeApellBox.SelectedItem!, paymentCheckBox.Checked, priceNumeric.Value, winPriceNumeric.Value, - statusBox.SelectedIndex, verdictCheckBox.Checked, courtBox.SelectedIndex, clientBox.SelectedIndex, diff --git a/ProjectGSM/Forms/FormCase.resx b/ProjectGSM/Forms/FormCase.resx index 8b2ff64..01ea3b5 100644 --- a/ProjectGSM/Forms/FormCase.resx +++ b/ProjectGSM/Forms/FormCase.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + \ No newline at end of file diff --git a/ProjectGSM/Forms/FormCaseAdvocates.Designer.cs b/ProjectGSM/Forms/FormCaseAdvocates.Designer.cs deleted file mode 100644 index 198b534..0000000 --- a/ProjectGSM/Forms/FormCaseAdvocates.Designer.cs +++ /dev/null @@ -1,116 +0,0 @@ -namespace ProjectGSM.Forms -{ - partial class FormCaseAdvocates - { - /// - /// 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() - { - advocateLabel = new Label(); - saveButton = new Button(); - cancelButton = new Button(); - caseLabel = new Label(); - advocateBox = new ComboBox(); - caseBox = new ComboBox(); - SuspendLayout(); - // - // advocateLabel - // - advocateLabel.Location = new Point(10, 47); - advocateLabel.Name = "advocateLabel"; - advocateLabel.Size = new Size(100, 23); - advocateLabel.TabIndex = 0; - advocateLabel.Text = "Адвокат:"; - // - // saveButton - // - saveButton.Location = new Point(138, 92); - saveButton.Name = "saveButton"; - saveButton.Size = new Size(75, 23); - saveButton.TabIndex = 4; - saveButton.Text = "Сохранить"; - saveButton.Click += saveButton_Click; - // - // cancelButton - // - cancelButton.Location = new Point(219, 92); - cancelButton.Name = "cancelButton"; - cancelButton.Size = new Size(75, 23); - cancelButton.TabIndex = 5; - cancelButton.Text = "Отмена"; - cancelButton.Click += cancelButton_Click; - // - // caseLabel - // - caseLabel.Location = new Point(10, 7); - caseLabel.Name = "caseLabel"; - caseLabel.Size = new Size(100, 23); - caseLabel.TabIndex = 15; - caseLabel.Text = "Дело:"; - // - // advocateBox - // - advocateBox.DropDownStyle = ComboBoxStyle.DropDownList; - advocateBox.FormattingEnabled = true; - advocateBox.Location = new Point(125, 47); - advocateBox.Name = "advocateBox"; - advocateBox.Size = new Size(169, 23); - advocateBox.TabIndex = 16; - // - // caseBox - // - caseBox.DropDownStyle = ComboBoxStyle.DropDownList; - caseBox.FormattingEnabled = true; - caseBox.Location = new Point(125, 7); - caseBox.Name = "caseBox"; - caseBox.Size = new Size(169, 23); - caseBox.TabIndex = 17; - // - // FormCaseAdvocates - // - ClientSize = new Size(306, 117); - Controls.Add(caseBox); - Controls.Add(advocateBox); - Controls.Add(caseLabel); - Controls.Add(advocateLabel); - Controls.Add(saveButton); - Controls.Add(cancelButton); - Name = "FormCaseAdvocates"; - StartPosition = FormStartPosition.CenterScreen; - Text = "Закрепление адвоката за делом"; - ResumeLayout(false); - } - - #endregion - - private Label advocateLabel; - - private Button saveButton; - private Button cancelButton; - private Label caseLabel; - private ComboBox advocateBox; - private ComboBox caseBox; - } -} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormCaseAdvocates.cs b/ProjectGSM/Forms/FormCaseAdvocates.cs deleted file mode 100644 index b5606c3..0000000 --- a/ProjectGSM/Forms/FormCaseAdvocates.cs +++ /dev/null @@ -1,64 +0,0 @@ -using ProjectGSM.Entities; -using ProjectGSM.Repositories; -using ProjectGSM.Repositories.Implementations; - -namespace ProjectGSM.Forms -{ - - public partial class FormCaseAdvocates : Form - { - private readonly ICaseAdvocateRepository _caseAdvocateRepository; - - - public FormCaseAdvocates(ICaseAdvocateRepository caseAdvocateRepository, - ICaseRepository caseRepository, IAdvocateRepository advocateRepository) - { - InitializeComponent(); - _caseAdvocateRepository = caseAdvocateRepository ?? - throw new - ArgumentNullException(nameof(caseAdvocateRepository)); - - - try - { - caseBox.DataSource = caseRepository.ReadCases(); - caseBox.DisplayMember = "Name"; - caseBox.SelectedIndex = 0; - } - catch (Exception ex) - { - } - try - { - advocateBox.DataSource = advocateRepository.ReadAdvocates(); - advocateBox.DisplayMember = "Name"; - advocateBox.SelectedIndex = 0; - } - catch (Exception ex) { } - - - - - } - - private void saveButton_Click(object sender, EventArgs e) - { - try - { - if (caseBox.SelectedIndex < 0 || advocateBox.SelectedIndex < 0) - { - throw new Exception("Имеются незаполненные поля"); - } - _caseAdvocateRepository.CreateCaseAdvocate(CaseAdvocate.CreateEntity(caseBox.SelectedIndex, advocateBox.SelectedIndex)); - Close(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при сохранении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - private void cancelButton_Click(object sender, EventArgs e) => Close(); - } -} diff --git a/ProjectGSM/Forms/FormCaseAdvocates.resx b/ProjectGSM/Forms/FormCaseAdvocates.resx deleted file mode 100644 index 8b2ff64..0000000 --- a/ProjectGSM/Forms/FormCaseAdvocates.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectGSM/Forms/FormCases.Designer.cs b/ProjectGSM/Forms/FormCases.Designer.cs index c6401a7..fdbea7f 100644 --- a/ProjectGSM/Forms/FormCases.Designer.cs +++ b/ProjectGSM/Forms/FormCases.Designer.cs @@ -30,7 +30,6 @@ { panel1 = new Panel(); deleteButton = new Button(); - editButton = new Button(); addButton = new Button(); dataGridView1 = new DataGridView(); panel1.SuspendLayout(); @@ -40,45 +39,35 @@ // panel1 // panel1.Controls.Add(deleteButton); - panel1.Controls.Add(editButton); panel1.Controls.Add(addButton); panel1.Dock = DockStyle.Right; - panel1.Location = new Point(604, 0); + panel1.Location = new Point(863, 0); + panel1.Margin = new Padding(4, 5, 4, 5); panel1.Name = "panel1"; - panel1.Size = new Size(142, 450); + panel1.Size = new Size(203, 750); panel1.TabIndex = 0; // // deleteButton // deleteButton.BackgroundImage = Properties.Resources.circle_x_svgrepo_com; deleteButton.BackgroundImageLayout = ImageLayout.Zoom; - deleteButton.Location = new Point(33, 240); + deleteButton.Location = new Point(47, 400); + deleteButton.Margin = new Padding(4, 5, 4, 5); deleteButton.Name = "deleteButton"; - deleteButton.Size = new Size(75, 75); + deleteButton.Size = new Size(107, 125); deleteButton.TabIndex = 2; deleteButton.Text = " "; deleteButton.UseVisualStyleBackColor = true; deleteButton.Click += deleteButton_Click; // - // editButton - // - editButton.BackgroundImage = Properties.Resources.pencil_svgrepo_com; - editButton.BackgroundImageLayout = ImageLayout.Zoom; - editButton.Location = new Point(33, 139); - editButton.Name = "editButton"; - editButton.Size = new Size(75, 75); - editButton.TabIndex = 1; - editButton.Text = " "; - editButton.UseVisualStyleBackColor = true; - editButton.Click += editButton_Click; - // // addButton // addButton.BackgroundImage = Properties.Resources.circle_plus_svgrepo_com; addButton.BackgroundImageLayout = ImageLayout.Zoom; - addButton.Location = new Point(33, 38); + addButton.Location = new Point(47, 63); + addButton.Margin = new Padding(4, 5, 4, 5); addButton.Name = "addButton"; - addButton.Size = new Size(75, 75); + addButton.Size = new Size(107, 125); addButton.TabIndex = 0; addButton.Text = " "; addButton.UseVisualStyleBackColor = true; @@ -95,21 +84,24 @@ dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView1.Dock = DockStyle.Fill; dataGridView1.Location = new Point(0, 0); + dataGridView1.Margin = new Padding(4, 5, 4, 5); dataGridView1.MultiSelect = false; dataGridView1.Name = "dataGridView1"; dataGridView1.ReadOnly = true; dataGridView1.RowHeadersVisible = false; + dataGridView1.RowHeadersWidth = 62; dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView1.Size = new Size(604, 450); + dataGridView1.Size = new Size(863, 750); dataGridView1.TabIndex = 1; // // FormCases // - AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(746, 450); + ClientSize = new Size(1066, 750); Controls.Add(dataGridView1); Controls.Add(panel1); + Margin = new Padding(4, 5, 4, 5); Name = "FormCases"; StartPosition = FormStartPosition.CenterScreen; Text = "Дела"; @@ -123,7 +115,6 @@ private Panel panel1; private Button deleteButton; - private Button editButton; private Button addButton; private DataGridView dataGridView1; } diff --git a/ProjectGSM/Forms/FormCases.cs b/ProjectGSM/Forms/FormCases.cs index 3adba5c..bf998cb 100644 --- a/ProjectGSM/Forms/FormCases.cs +++ b/ProjectGSM/Forms/FormCases.cs @@ -52,27 +52,6 @@ namespace ProjectGSM.Forms } - private void editButton_Click(object sender, EventArgs e) - { - if (!TryGetIdentifierFromSelectedRow(out var findId)) - { - return; - } - try - { - var form = _container.Resolve(); - form.Id = findId; - form.ShowDialog(); - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при изменении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - private void addButton_Click(object sender, EventArgs e) { try diff --git a/ProjectGSM/Forms/FormCasesAdvocates.Designer.cs b/ProjectGSM/Forms/FormCasesAdvocates.Designer.cs deleted file mode 100644 index ad879a6..0000000 --- a/ProjectGSM/Forms/FormCasesAdvocates.Designer.cs +++ /dev/null @@ -1,101 +0,0 @@ -namespace ProjectGSM.Forms -{ - partial class FormCasesAdvocates - { - /// - /// 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() - { - panel1 = new Panel(); - addButton = new Button(); - dataGridView1 = new DataGridView(); - panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); - SuspendLayout(); - // - // panel1 - // - panel1.Controls.Add(addButton); - panel1.Dock = DockStyle.Right; - panel1.Location = new Point(604, 0); - panel1.Name = "panel1"; - panel1.Size = new Size(142, 450); - panel1.TabIndex = 0; - // - // addButton - // - addButton.BackgroundImage = Properties.Resources.circle_plus_svgrepo_com; - addButton.BackgroundImageLayout = ImageLayout.Zoom; - addButton.Location = new Point(33, 38); - addButton.Name = "addButton"; - addButton.Size = new Size(75, 75); - addButton.TabIndex = 0; - addButton.Text = " "; - addButton.UseVisualStyleBackColor = true; - addButton.Click += addButton_Click; - // - // dataGridView1 - // - dataGridView1.AllowUserToAddRows = false; - dataGridView1.AllowUserToDeleteRows = false; - dataGridView1.AllowUserToResizeColumns = false; - dataGridView1.AllowUserToResizeRows = false; - dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView1.BackgroundColor = SystemColors.Info; - dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView1.Dock = DockStyle.Fill; - dataGridView1.Location = new Point(0, 0); - dataGridView1.MultiSelect = false; - dataGridView1.Name = "dataGridView1"; - dataGridView1.ReadOnly = true; - dataGridView1.RowHeadersVisible = false; - dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView1.Size = new Size(604, 450); - dataGridView1.TabIndex = 1; - // - // FormCasesAdvocates - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(746, 450); - Controls.Add(dataGridView1); - Controls.Add(panel1); - Name = "FormCasesAdvocates"; - StartPosition = FormStartPosition.CenterScreen; - Text = "Суды"; - Load += FormClients_Load; - panel1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); - ResumeLayout(false); - } - - #endregion - - private Panel panel1; - private Button addButton; - private DataGridView dataGridView1; - - } -} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormCasesAdvocates.cs b/ProjectGSM/Forms/FormCasesAdvocates.cs deleted file mode 100644 index 079c6ed..0000000 --- a/ProjectGSM/Forms/FormCasesAdvocates.cs +++ /dev/null @@ -1,68 +0,0 @@ -using ProjectGSM.Repositories; -using ProjectGSM.Repositories.Implementations; -using Unity; - -namespace ProjectGSM.Forms -{ - public partial class FormCasesAdvocates : Form - { - private readonly IUnityContainer _container; - - private readonly ICaseAdvocateRepository _caseAdvocateRepository; - public FormCasesAdvocates(IUnityContainer container, ICaseAdvocateRepository caseAdvocateRepository) - { - InitializeComponent(); - _container = container ?? - throw new ArgumentNullException(nameof(container)); - _caseAdvocateRepository = caseAdvocateRepository ?? - throw new - ArgumentNullException(nameof(caseAdvocateRepository)); - - } - private void addButton_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при добавлении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - - private void FormClients_Load(object sender, EventArgs e) - { - try - { - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при загрузке", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - - private void LoadList() => dataGridView1.DataSource = -_caseAdvocateRepository.ReadCaseAdvocates(); - - private bool TryGetIdentifierFromSelectedRow(out int id) - { - id = 0; - if (dataGridView1.SelectedRows.Count < 1) - { - MessageBox.Show("Нет выбранной записи", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return false; - } - id = - Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value); - return true; - } - } -} diff --git a/ProjectGSM/Forms/FormCasesAdvocates.resx b/ProjectGSM/Forms/FormCasesAdvocates.resx deleted file mode 100644 index 8b2ff64..0000000 --- a/ProjectGSM/Forms/FormCasesAdvocates.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectGSM/Forms/FormStatus.Designer.cs b/ProjectGSM/Forms/FormStatus.Designer.cs deleted file mode 100644 index 680cd69..0000000 --- a/ProjectGSM/Forms/FormStatus.Designer.cs +++ /dev/null @@ -1,136 +0,0 @@ -namespace ProjectGSM.Forms -{ - partial class FormStatus - { - /// - /// 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() - { - nameLabel = new Label(); - nameTextBox = new TextBox(); - saveButton = new Button(); - cancelButton = new Button(); - priceLabel = new Label(); - priceNumeric = new NumericUpDown(); - dateLabel = new Label(); - dateTimePicker1 = new DateTimePicker(); - ((System.ComponentModel.ISupportInitialize)priceNumeric).BeginInit(); - SuspendLayout(); - // - // nameLabel - // - nameLabel.Location = new Point(10, 10); - nameLabel.Name = "nameLabel"; - nameLabel.Size = new Size(100, 23); - nameLabel.TabIndex = 0; - nameLabel.Text = "Название:"; - // - // nameTextBox - // - nameTextBox.Location = new Point(116, 10); - nameTextBox.Name = "nameTextBox"; - nameTextBox.Size = new Size(120, 23); - nameTextBox.TabIndex = 1; - // - // saveButton - // - saveButton.Location = new Point(116, 134); - saveButton.Name = "saveButton"; - saveButton.Size = new Size(75, 23); - saveButton.TabIndex = 4; - saveButton.Text = "Сохранить"; - saveButton.Click += saveButton_Click; - // - // cancelButton - // - cancelButton.Location = new Point(197, 134); - cancelButton.Name = "cancelButton"; - cancelButton.Size = new Size(75, 23); - cancelButton.TabIndex = 5; - cancelButton.Text = "Отмена"; - cancelButton.Click += cancelButton_Click; - // - // priceLabel - // - priceLabel.Location = new Point(10, 50); - priceLabel.Name = "priceLabel"; - priceLabel.Size = new Size(111, 23); - priceLabel.TabIndex = 11; - priceLabel.Text = "Цена:"; - // - // priceNumeric - // - priceNumeric.Location = new Point(116, 50); - priceNumeric.Name = "priceNumeric"; - priceNumeric.Size = new Size(120, 23); - priceNumeric.TabIndex = 12; - // - // dateLabel - // - dateLabel.Location = new Point(10, 96); - dateLabel.Name = "dateLabel"; - dateLabel.Size = new Size(111, 23); - dateLabel.TabIndex = 13; - dateLabel.Text = "Дата:"; - // - // dateTimePicker1 - // - dateTimePicker1.Location = new Point(116, 96); - dateTimePicker1.Name = "dateTimePicker1"; - dateTimePicker1.Size = new Size(120, 23); - dateTimePicker1.TabIndex = 14; - // - // FornStatus - // - ClientSize = new Size(284, 169); - Controls.Add(dateTimePicker1); - Controls.Add(dateLabel); - Controls.Add(priceNumeric); - Controls.Add(priceLabel); - Controls.Add(nameLabel); - Controls.Add(nameTextBox); - Controls.Add(saveButton); - Controls.Add(cancelButton); - Name = "FornStatus"; - StartPosition = FormStartPosition.CenterScreen; - Text = "Суд"; - ((System.ComponentModel.ISupportInitialize)priceNumeric).EndInit(); - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private Label nameLabel; - private TextBox nameTextBox; - - private Button saveButton; - private Button cancelButton; - private Label priceLabel; - private NumericUpDown priceNumeric; - private Label dateLabel; - private DateTimePicker dateTimePicker1; - } -} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormStatus.cs b/ProjectGSM/Forms/FormStatus.cs deleted file mode 100644 index 042c5b4..0000000 --- a/ProjectGSM/Forms/FormStatus.cs +++ /dev/null @@ -1,78 +0,0 @@ -using ProjectGSM.Entities; -using ProjectGSM.Repositories; - -namespace ProjectGSM.Forms -{ - - public partial class FormStatus : Form - { - private readonly IStatusRepository _statusRepository; - - private int? _statusId; - - public int Id - { - set - { - try - { - var status = - _statusRepository.ReadStatusById(value); - if (status == null) - { - throw new - InvalidDataException(nameof(status)); - } - nameTextBox.Text = status.Name; - priceNumeric.Value = status.Price ?? 0; - dateTimePicker1.Value = new DateTime(status.CreatedAt.Year, status.CreatedAt.Month, status.CreatedAt.Day); ; - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - } - } - - - public FormStatus(IStatusRepository statusRepository) - { - InitializeComponent(); - _statusRepository = statusRepository ?? - throw new - ArgumentNullException(nameof(statusRepository)); - } - - private void saveButton_Click(object sender, EventArgs e) - { - try - { - if (string.IsNullOrWhiteSpace(nameTextBox.Text)) - { - throw new Exception("Имеются незаполненные поля"); - } - if (_statusId.HasValue) - { - _statusRepository.UpdateStatus(CreateStatus(_statusId.Value)); - } - else - { - _statusRepository.UpdateStatus(CreateStatus(0)); - } - Close(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при сохранении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - - private void cancelButton_Click(object sender, EventArgs e) => Close(); - - private Status CreateStatus(int id) => Status.CreateEntity(id, - nameTextBox.Text, Convert.ToDecimal(priceNumeric.Value), dateTimePicker1.Value); - } -} diff --git a/ProjectGSM/Forms/FormStatus.resx b/ProjectGSM/Forms/FormStatus.resx deleted file mode 100644 index 8b2ff64..0000000 --- a/ProjectGSM/Forms/FormStatus.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectGSM/Forms/FormStatusHistory.Designer.cs b/ProjectGSM/Forms/FormStatusHistory.Designer.cs index d997c92..befdb5b 100644 --- a/ProjectGSM/Forms/FormStatusHistory.Designer.cs +++ b/ProjectGSM/Forms/FormStatusHistory.Designer.cs @@ -36,6 +36,9 @@ caseLabel = new Label(); statusBox = new ComboBox(); caseBox = new ComboBox(); + priceLabel = new Label(); + priceNumeric = new NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)priceNumeric).BeginInit(); SuspendLayout(); // // statusLabel @@ -48,25 +51,25 @@ // // saveButton // - saveButton.Location = new Point(116, 128); + saveButton.Location = new Point(116, 173); saveButton.Name = "saveButton"; - saveButton.Size = new Size(75, 23); + saveButton.Size = new Size(75, 38); saveButton.TabIndex = 4; saveButton.Text = "Сохранить"; saveButton.Click += saveButton_Click; // // cancelButton // - cancelButton.Location = new Point(197, 128); + cancelButton.Location = new Point(197, 173); cancelButton.Name = "cancelButton"; - cancelButton.Size = new Size(75, 23); + cancelButton.Size = new Size(75, 38); cancelButton.TabIndex = 5; cancelButton.Text = "Отмена"; cancelButton.Click += cancelButton_Click; // // dateLabel // - dateLabel.Location = new Point(10, 92); + dateLabel.Location = new Point(10, 137); dateLabel.Name = "dateLabel"; dateLabel.Size = new Size(111, 23); dateLabel.TabIndex = 13; @@ -74,9 +77,9 @@ // // dateTimePicker1 // - dateTimePicker1.Location = new Point(125, 92); + dateTimePicker1.Location = new Point(125, 137); dateTimePicker1.Name = "dateTimePicker1"; - dateTimePicker1.Size = new Size(120, 23); + dateTimePicker1.Size = new Size(120, 31); dateTimePicker1.TabIndex = 14; // // caseLabel @@ -93,7 +96,7 @@ statusBox.FormattingEnabled = true; statusBox.Location = new Point(125, 47); statusBox.Name = "statusBox"; - statusBox.Size = new Size(121, 23); + statusBox.Size = new Size(178, 33); statusBox.TabIndex = 16; // // caseBox @@ -102,12 +105,30 @@ caseBox.FormattingEnabled = true; caseBox.Location = new Point(125, 7); caseBox.Name = "caseBox"; - caseBox.Size = new Size(121, 23); + caseBox.Size = new Size(121, 33); caseBox.TabIndex = 17; // + // priceLabel + // + priceLabel.Location = new Point(10, 98); + priceLabel.Name = "priceLabel"; + priceLabel.Size = new Size(100, 23); + priceLabel.TabIndex = 18; + priceLabel.Text = "Цена:"; + // + // priceNumeric + // + priceNumeric.DecimalPlaces = 2; + priceNumeric.Location = new Point(123, 99); + priceNumeric.Name = "priceNumeric"; + priceNumeric.Size = new Size(180, 31); + priceNumeric.TabIndex = 19; + // // FormStatusHistory // - ClientSize = new Size(284, 163); + ClientSize = new Size(374, 324); + Controls.Add(priceNumeric); + Controls.Add(priceLabel); Controls.Add(caseBox); Controls.Add(statusBox); Controls.Add(caseLabel); @@ -119,6 +140,7 @@ Name = "FormStatusHistory"; StartPosition = FormStartPosition.CenterScreen; Text = "Хронология статусов"; + ((System.ComponentModel.ISupportInitialize)priceNumeric).EndInit(); ResumeLayout(false); } @@ -133,5 +155,7 @@ private Label caseLabel; private ComboBox statusBox; private ComboBox caseBox; + private Label priceLabel; + private NumericUpDown priceNumeric; } } \ No newline at end of file diff --git a/ProjectGSM/Forms/FormStatusHistory.cs b/ProjectGSM/Forms/FormStatusHistory.cs index 3f225a0..e97e9af 100644 --- a/ProjectGSM/Forms/FormStatusHistory.cs +++ b/ProjectGSM/Forms/FormStatusHistory.cs @@ -1,4 +1,5 @@ using ProjectGSM.Entities; +using ProjectGSM.Entities.Enums; using ProjectGSM.Repositories; namespace ProjectGSM.Forms @@ -9,8 +10,7 @@ namespace ProjectGSM.Forms private readonly IStatusHistoryRepository _statusHistoryRepository; - public FormStatusHistory(IStatusHistoryRepository statusHistoryRepository, - IStatusRepository statusRepository, ICaseRepository caseRepository) + public FormStatusHistory(IStatusHistoryRepository statusHistoryRepository, ICaseRepository caseRepository) { InitializeComponent(); _statusHistoryRepository = statusHistoryRepository ?? @@ -25,24 +25,18 @@ namespace ProjectGSM.Forms } catch (Exception ex) { } - try - { - statusBox.DataSource = statusRepository.ReadStatuses(); - statusBox.DisplayMember = "Name"; - statusBox.SelectedIndex = 0; - } - catch (Exception ex) { } + statusBox.DataSource = Enum.GetValues(typeof(Status)); } private void saveButton_Click(object sender, EventArgs e) { try { - if (caseBox.SelectedIndex < 0 || statusBox.SelectedIndex < 0) + if (caseBox.SelectedIndex < 0) { throw new Exception("Имеются незаполненные поля"); } - _statusHistoryRepository.CreateStatusHistory(StatusHistory.CreateEntity(caseBox.SelectedIndex, statusBox.SelectedIndex, dateTimePicker1.Value)); + _statusHistoryRepository.CreateStatusHistory(StatusHistory.CreateEntity(caseBox.SelectedIndex, (Status)statusBox.SelectedIndex!, priceNumeric.Value, dateTimePicker1.Value)); Close(); } catch (Exception ex) diff --git a/ProjectGSM/Forms/FormStatuses.Designer.cs b/ProjectGSM/Forms/FormStatuses.Designer.cs deleted file mode 100644 index 4536b20..0000000 --- a/ProjectGSM/Forms/FormStatuses.Designer.cs +++ /dev/null @@ -1,130 +0,0 @@ -namespace ProjectGSM.Forms -{ - partial class FormStatuses - { - /// - /// 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() - { - panel1 = new Panel(); - deleteButton = new Button(); - editButton = new Button(); - addButton = new Button(); - dataGridView1 = new DataGridView(); - panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); - SuspendLayout(); - // - // panel1 - // - panel1.Controls.Add(deleteButton); - panel1.Controls.Add(editButton); - panel1.Controls.Add(addButton); - panel1.Dock = DockStyle.Right; - panel1.Location = new Point(604, 0); - panel1.Name = "panel1"; - panel1.Size = new Size(142, 450); - panel1.TabIndex = 0; - // - // deleteButton - // - deleteButton.BackgroundImage = Properties.Resources.circle_x_svgrepo_com; - deleteButton.BackgroundImageLayout = ImageLayout.Zoom; - deleteButton.Location = new Point(33, 240); - deleteButton.Name = "deleteButton"; - deleteButton.Size = new Size(75, 75); - deleteButton.TabIndex = 2; - deleteButton.Text = " "; - deleteButton.UseVisualStyleBackColor = true; - deleteButton.Click += deleteButton_Click; - // - // editButton - // - editButton.BackgroundImage = Properties.Resources.pencil_svgrepo_com; - editButton.BackgroundImageLayout = ImageLayout.Zoom; - editButton.Location = new Point(33, 139); - editButton.Name = "editButton"; - editButton.Size = new Size(75, 75); - editButton.TabIndex = 1; - editButton.Text = " "; - editButton.UseVisualStyleBackColor = true; - editButton.Click += editButton_Click; - // - // addButton - // - addButton.BackgroundImage = Properties.Resources.circle_plus_svgrepo_com; - addButton.BackgroundImageLayout = ImageLayout.Zoom; - addButton.Location = new Point(33, 38); - addButton.Name = "addButton"; - addButton.Size = new Size(75, 75); - addButton.TabIndex = 0; - addButton.Text = " "; - addButton.UseVisualStyleBackColor = true; - addButton.Click += addButton_Click; - // - // dataGridView1 - // - dataGridView1.AllowUserToAddRows = false; - dataGridView1.AllowUserToDeleteRows = false; - dataGridView1.AllowUserToResizeColumns = false; - dataGridView1.AllowUserToResizeRows = false; - dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView1.BackgroundColor = SystemColors.Info; - dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView1.Dock = DockStyle.Fill; - dataGridView1.Location = new Point(0, 0); - dataGridView1.MultiSelect = false; - dataGridView1.Name = "dataGridView1"; - dataGridView1.ReadOnly = true; - dataGridView1.RowHeadersVisible = false; - dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView1.Size = new Size(604, 450); - dataGridView1.TabIndex = 1; - // - // FormCourts - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(746, 450); - Controls.Add(dataGridView1); - Controls.Add(panel1); - Name = "FormCourts"; - StartPosition = FormStartPosition.CenterScreen; - Text = "Суды"; - Load += FormClients_Load; - panel1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); - ResumeLayout(false); - } - - #endregion - - private Panel panel1; - private Button deleteButton; - private Button editButton; - private Button addButton; - private DataGridView dataGridView1; - } -} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormStatuses.cs b/ProjectGSM/Forms/FormStatuses.cs deleted file mode 100644 index 3f5afed..0000000 --- a/ProjectGSM/Forms/FormStatuses.cs +++ /dev/null @@ -1,114 +0,0 @@ -using ProjectGSM.Repositories; -using Unity; - -namespace ProjectGSM.Forms -{ - public partial class FormStatuses : Form - { - private readonly IUnityContainer _container; - - private readonly IStatusRepository _statusRepository; - public FormStatuses(IUnityContainer container, IStatusRepository statusRepository) - { - InitializeComponent(); - _container = container ?? - throw new ArgumentNullException(nameof(container)); - _statusRepository = statusRepository ?? - throw new - ArgumentNullException(nameof(statusRepository)); - - } - - private void deleteButton_Click(object sender, EventArgs e) - { - if (!TryGetIdentifierFromSelectedRow(out var findId)) - { - return; - } - if (MessageBox.Show("Удалить запись?", "Удаление", - MessageBoxButtons.YesNo) != DialogResult.Yes) - { - return; - } - try - { - _statusRepository.DeleteStatus(findId); - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при удалении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - - private void editButton_Click(object sender, EventArgs e) - { - if (!TryGetIdentifierFromSelectedRow(out var findId)) - { - return; - } - try - { - var form = _container.Resolve(); - form.Id = findId; - form.ShowDialog(); - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при изменении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - - private void addButton_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при добавлении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - - private void FormClients_Load(object sender, EventArgs e) - { - try - { - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при загрузке", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - - private void LoadList() => dataGridView1.DataSource = -_statusRepository.ReadStatuses(); - - private bool TryGetIdentifierFromSelectedRow(out int id) - { - id = 0; - if (dataGridView1.SelectedRows.Count < 1) - { - MessageBox.Show("Нет выбранной записи", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return false; - } - id = - Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value); - return true; - } - - } -} diff --git a/ProjectGSM/Forms/FormStatuses.resx b/ProjectGSM/Forms/FormStatuses.resx deleted file mode 100644 index 8b2ff64..0000000 --- a/ProjectGSM/Forms/FormStatuses.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectGSM/Forms/FormTypeApeal.Designer.cs b/ProjectGSM/Forms/FormTypeApeal.Designer.cs deleted file mode 100644 index 2cc7c3a..0000000 --- a/ProjectGSM/Forms/FormTypeApeal.Designer.cs +++ /dev/null @@ -1,92 +0,0 @@ -namespace ProjectGSM.Forms -{ - partial class FormTypeApeal - { - /// - /// 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() - { - nameLabel = new Label(); - nameTextBox = new TextBox(); - saveButton = new Button(); - cancelButton = new Button(); - SuspendLayout(); - // - // nameLabel - // - nameLabel.Location = new Point(10, 10); - nameLabel.Name = "nameLabel"; - nameLabel.Size = new Size(100, 23); - nameLabel.TabIndex = 0; - nameLabel.Text = "Название:"; - // - // nameTextBox - // - nameTextBox.Location = new Point(116, 10); - nameTextBox.Name = "nameTextBox"; - nameTextBox.Size = new Size(120, 23); - nameTextBox.TabIndex = 1; - // - // saveButton - // - saveButton.Location = new Point(116, 53); - saveButton.Name = "saveButton"; - saveButton.Size = new Size(75, 23); - saveButton.TabIndex = 4; - saveButton.Text = "Сохранить"; - saveButton.Click += saveButton_Click; - // - // cancelButton - // - cancelButton.Location = new Point(197, 53); - cancelButton.Name = "cancelButton"; - cancelButton.Size = new Size(75, 23); - cancelButton.TabIndex = 5; - cancelButton.Text = "Отмена"; - cancelButton.Click += cancelButton_Click; - // - // FormTypeApeal - // - ClientSize = new Size(284, 84); - Controls.Add(nameLabel); - Controls.Add(nameTextBox); - Controls.Add(saveButton); - Controls.Add(cancelButton); - Name = "FormTypeApeal"; - StartPosition = FormStartPosition.CenterScreen; - Text = "Тип обращения"; - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private Label nameLabel; - private TextBox nameTextBox; - - private Button saveButton; - private Button cancelButton; - } -} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormTypeApeal.cs b/ProjectGSM/Forms/FormTypeApeal.cs deleted file mode 100644 index 61a23d5..0000000 --- a/ProjectGSM/Forms/FormTypeApeal.cs +++ /dev/null @@ -1,77 +0,0 @@ -using ProjectGSM.Entities; -using ProjectGSM.Repositories; - -namespace ProjectGSM.Forms -{ - - public partial class FormTypeApeal : Form - { - private readonly ITypeAppealRepository _typeAppealRepository; - - private int? _appealId; - - public int Id - { - set - { - try - { - var appeal = - _typeAppealRepository.ReadTypeAppealById(value); - if (appeal == null) - { - throw new - InvalidDataException(nameof(appeal)); - } - nameTextBox.Text = appeal.Name; - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - } - } - - - public FormTypeApeal(ITypeAppealRepository typeAppealRepository) - { - InitializeComponent(); - _typeAppealRepository = typeAppealRepository ?? - throw new - ArgumentNullException(nameof(typeAppealRepository)); - } - - private void saveButton_Click(object sender, EventArgs e) - { - try - { - if (string.IsNullOrWhiteSpace(nameTextBox.Text)) - { - throw new Exception("Имеются незаполненные поля"); - } - if (_appealId.HasValue) - { - _typeAppealRepository.UpdateTypeAppeal(CreateTypeAppeal(_appealId.Value)); - } - else - { - _typeAppealRepository.UpdateTypeAppeal(CreateTypeAppeal(0)); - } - Close(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при сохранении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - - private void cancelButton_Click(object sender, EventArgs e) => Close(); - - private TypeAppeal CreateTypeAppeal(int id) => TypeAppeal.CreateEntity(id, - nameTextBox.Text); - - } -} diff --git a/ProjectGSM/Forms/FormTypeApeal.resx b/ProjectGSM/Forms/FormTypeApeal.resx deleted file mode 100644 index 8b2ff64..0000000 --- a/ProjectGSM/Forms/FormTypeApeal.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectGSM/Forms/FormTypeAppeals.Designer.cs b/ProjectGSM/Forms/FormTypeAppeals.Designer.cs deleted file mode 100644 index 1f08700..0000000 --- a/ProjectGSM/Forms/FormTypeAppeals.Designer.cs +++ /dev/null @@ -1,130 +0,0 @@ -namespace ProjectGSM.Forms -{ - partial class FormTypeAppeals - { - /// - /// 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() - { - panel1 = new Panel(); - deleteButton = new Button(); - editButton = new Button(); - addButton = new Button(); - dataGridView1 = new DataGridView(); - panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); - SuspendLayout(); - // - // panel1 - // - panel1.Controls.Add(deleteButton); - panel1.Controls.Add(editButton); - panel1.Controls.Add(addButton); - panel1.Dock = DockStyle.Right; - panel1.Location = new Point(604, 0); - panel1.Name = "panel1"; - panel1.Size = new Size(142, 450); - panel1.TabIndex = 0; - // - // deleteButton - // - deleteButton.BackgroundImage = Properties.Resources.circle_x_svgrepo_com; - deleteButton.BackgroundImageLayout = ImageLayout.Zoom; - deleteButton.Location = new Point(33, 240); - deleteButton.Name = "deleteButton"; - deleteButton.Size = new Size(75, 75); - deleteButton.TabIndex = 2; - deleteButton.Text = " "; - deleteButton.UseVisualStyleBackColor = true; - deleteButton.Click += deleteButton_Click; - // - // editButton - // - editButton.BackgroundImage = Properties.Resources.pencil_svgrepo_com; - editButton.BackgroundImageLayout = ImageLayout.Zoom; - editButton.Location = new Point(33, 139); - editButton.Name = "editButton"; - editButton.Size = new Size(75, 75); - editButton.TabIndex = 1; - editButton.Text = " "; - editButton.UseVisualStyleBackColor = true; - editButton.Click += editButton_Click; - // - // addButton - // - addButton.BackgroundImage = Properties.Resources.circle_plus_svgrepo_com; - addButton.BackgroundImageLayout = ImageLayout.Zoom; - addButton.Location = new Point(33, 38); - addButton.Name = "addButton"; - addButton.Size = new Size(75, 75); - addButton.TabIndex = 0; - addButton.Text = " "; - addButton.UseVisualStyleBackColor = true; - addButton.Click += addButton_Click; - // - // dataGridView1 - // - dataGridView1.AllowUserToAddRows = false; - dataGridView1.AllowUserToDeleteRows = false; - dataGridView1.AllowUserToResizeColumns = false; - dataGridView1.AllowUserToResizeRows = false; - dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView1.BackgroundColor = SystemColors.Info; - dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView1.Dock = DockStyle.Fill; - dataGridView1.Location = new Point(0, 0); - dataGridView1.MultiSelect = false; - dataGridView1.Name = "dataGridView1"; - dataGridView1.ReadOnly = true; - dataGridView1.RowHeadersVisible = false; - dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView1.Size = new Size(604, 450); - dataGridView1.TabIndex = 1; - // - // FormCourts - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(746, 450); - Controls.Add(dataGridView1); - Controls.Add(panel1); - Name = "FormCourts"; - StartPosition = FormStartPosition.CenterScreen; - Text = "Суды"; - Load += FormClients_Load; - panel1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); - ResumeLayout(false); - } - - #endregion - - private Panel panel1; - private Button deleteButton; - private Button editButton; - private Button addButton; - private DataGridView dataGridView1; - } -} \ No newline at end of file diff --git a/ProjectGSM/Forms/FormTypeAppeals.cs b/ProjectGSM/Forms/FormTypeAppeals.cs deleted file mode 100644 index c592c8b..0000000 --- a/ProjectGSM/Forms/FormTypeAppeals.cs +++ /dev/null @@ -1,123 +0,0 @@ -using ProjectGSM.Repositories; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using Unity; - -namespace ProjectGSM.Forms -{ - public partial class FormTypeAppeals : Form - { - private readonly IUnityContainer _container; - - private readonly ITypeAppealRepository _typeAppealRepository; - public FormTypeAppeals(IUnityContainer container, ITypeAppealRepository typeAppealRepository) - { - InitializeComponent(); - _container = container ?? - throw new ArgumentNullException(nameof(container)); - _typeAppealRepository = typeAppealRepository ?? - throw new - ArgumentNullException(nameof(typeAppealRepository)); - - } - - private void deleteButton_Click(object sender, EventArgs e) - { - if (!TryGetIdentifierFromSelectedRow(out var findId)) - { - return; - } - if (MessageBox.Show("Удалить запись?", "Удаление", - MessageBoxButtons.YesNo) != DialogResult.Yes) - { - return; - } - try - { - _typeAppealRepository.DeleteTypeAppeal(findId); - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при удалении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - - private void editButton_Click(object sender, EventArgs e) - { - if (!TryGetIdentifierFromSelectedRow(out var findId)) - { - return; - } - try - { - var form = _container.Resolve(); - form.Id = findId; - form.ShowDialog(); - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при изменении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - - private void addButton_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при добавлении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - - private void FormClients_Load(object sender, EventArgs e) - { - try - { - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при загрузке", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - } - - private void LoadList() => dataGridView1.DataSource = -_typeAppealRepository.ReadTypeAppeals(); - - private bool TryGetIdentifierFromSelectedRow(out int id) - { - id = 0; - if (dataGridView1.SelectedRows.Count < 1) - { - MessageBox.Show("Нет выбранной записи", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return false; - } - id = - Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value); - return true; - } - - } -} diff --git a/ProjectGSM/Forms/FormTypeAppeals.resx b/ProjectGSM/Forms/FormTypeAppeals.resx deleted file mode 100644 index 8b2ff64..0000000 --- a/ProjectGSM/Forms/FormTypeAppeals.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectGSM/Program.cs b/ProjectGSM/Program.cs index 7e70864..d5e65dd 100644 --- a/ProjectGSM/Program.cs +++ b/ProjectGSM/Program.cs @@ -28,9 +28,7 @@ namespace ProjectGSM container.RegisterType(new TransientLifetimeManager()); container.RegisterType(new TransientLifetimeManager()); container.RegisterType(new TransientLifetimeManager()); - container.RegisterType(new TransientLifetimeManager()); container.RegisterType(new TransientLifetimeManager()); - container.RegisterType(new TransientLifetimeManager()); return container; } } diff --git a/ProjectGSM/ProjectGSM.csproj b/ProjectGSM/ProjectGSM.csproj index a31e0ba..282209d 100644 --- a/ProjectGSM/ProjectGSM.csproj +++ b/ProjectGSM/ProjectGSM.csproj @@ -15,30 +15,12 @@ Form - - Form - Form - - Form - Form - - Form - - - Form - - - Form - - - Form - Form @@ -66,10 +48,6 @@ - - - - diff --git a/ProjectGSM/Repositories/IStatusRepository.cs b/ProjectGSM/Repositories/IStatusRepository.cs deleted file mode 100644 index 478b5dd..0000000 --- a/ProjectGSM/Repositories/IStatusRepository.cs +++ /dev/null @@ -1,12 +0,0 @@ -using ProjectGSM.Entities; - -namespace ProjectGSM.Repositories; - -public interface IStatusRepository -{ - IEnumerable ReadStatuses(); - Status ReadStatusById(int id); - void CreateStatus(Status status); - void UpdateStatus(Status status); - void DeleteStatus(int id); -} \ No newline at end of file diff --git a/ProjectGSM/Repositories/ITypeAppealRepository.cs b/ProjectGSM/Repositories/ITypeAppealRepository.cs deleted file mode 100644 index 3f70d06..0000000 --- a/ProjectGSM/Repositories/ITypeAppealRepository.cs +++ /dev/null @@ -1,12 +0,0 @@ -using ProjectGSM.Entities; - -namespace ProjectGSM.Repositories; - -public interface ITypeAppealRepository -{ - IEnumerable ReadTypeAppeals(); - TypeAppeal ReadTypeAppealById(int id); - void CreateTypeAppeal(TypeAppeal typeAppeal); - void UpdateTypeAppeal(TypeAppeal typeAppeal); - void DeleteTypeAppeal(int id); -} \ No newline at end of file diff --git a/ProjectGSM/Repositories/Implementations/AdvocateRepository.cs b/ProjectGSM/Repositories/Implementations/AdvocateRepository.cs index 7fe34ae..820f12f 100644 --- a/ProjectGSM/Repositories/Implementations/AdvocateRepository.cs +++ b/ProjectGSM/Repositories/Implementations/AdvocateRepository.cs @@ -12,7 +12,7 @@ public class AdvocateRepository : IAdvocateRepository public Advocate ReadAdvocateById(int id) { return Advocate.CreateEntity(0, String.Empty, false, DateTime.UtcNow, 0, 0, 0, String.Empty, String.Empty, - String.Empty); + String.Empty, Entities.Enums.LicenseType.None); } public void CreateAdvocate(Advocate advocate) diff --git a/ProjectGSM/Repositories/Implementations/CaseRepository.cs b/ProjectGSM/Repositories/Implementations/CaseRepository.cs index f68e1a8..af99bfd 100644 --- a/ProjectGSM/Repositories/Implementations/CaseRepository.cs +++ b/ProjectGSM/Repositories/Implementations/CaseRepository.cs @@ -11,7 +11,7 @@ public class CaseRepository : ICaseRepository public Case ReadCaseById(int id) { - return Case.CreateEntity(0, 0, false, 0, 0, 0, false, 0, 0, String.Empty); + return Case.CreateEntity(0, 0, false, 0, 0, false, 0, 0, String.Empty); } public void CreateCase(Case caseEntity) diff --git a/ProjectGSM/Repositories/Implementations/StatusRepository.cs b/ProjectGSM/Repositories/Implementations/StatusRepository.cs deleted file mode 100644 index a3b23fa..0000000 --- a/ProjectGSM/Repositories/Implementations/StatusRepository.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ProjectGSM.Entities; - -namespace ProjectGSM.Repositories.Implementations; - -public class StatusRepository : IStatusRepository -{ - public IEnumerable ReadStatuses() - { - return []; - } - - public Status ReadStatusById(int id) - { - return Status.CreateEntity(0, String.Empty); - } - - public void CreateStatus(Status status) - { - } - - public void UpdateStatus(Status status) - { - } - - public void DeleteStatus(int id) - { - } -} \ No newline at end of file diff --git a/ProjectGSM/Repositories/Implementations/TypeAppealRepository.cs b/ProjectGSM/Repositories/Implementations/TypeAppealRepository.cs deleted file mode 100644 index dc64b32..0000000 --- a/ProjectGSM/Repositories/Implementations/TypeAppealRepository.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ProjectGSM.Entities; - -namespace ProjectGSM.Repositories.Implementations; - -public class TypeAppealRepository : ITypeAppealRepository -{ - public IEnumerable ReadTypeAppeals() - { - return []; - } - - public TypeAppeal ReadTypeAppealById(int id) - { - return TypeAppeal.CreateEntity(0, String.Empty); - } - - public void CreateTypeAppeal(TypeAppeal typeAppeal) - { - } - - public void UpdateTypeAppeal(TypeAppeal typeAppeal) - { - } - - public void DeleteTypeAppeal(int id) - { - } -} \ No newline at end of file