Добавил названия колонок для моделей

This commit is contained in:
Никита Потапов 2024-05-08 02:06:28 +04:00
parent 69d271b9a2
commit 4173a05542
9 changed files with 71 additions and 9 deletions

View File

@ -1,7 +1,10 @@
namespace MedicalDatabaseContracts.Models using System.ComponentModel;
namespace MedicalDatabaseContracts.Models
{ {
public class AbstractModel public class AbstractModel
{ {
[DisplayName("ID")]
public int Id { get; set; } public int Id { get; set; }
} }
} }

View File

@ -1,10 +1,16 @@
namespace MedicalDatabaseContracts.Models using System.ComponentModel;
namespace MedicalDatabaseContracts.Models
{ {
public class AbstractPersonModel : AbstractModel public class AbstractPersonModel : AbstractModel
{ {
[DisplayName("Имя")]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[DisplayName("Фамилия")]
public string Surname { get; set; } = string.Empty; public string Surname { get; set; } = string.Empty;
[DisplayName("Отчество")]
public string? Patronymic { get; set; } public string? Patronymic { get; set; }
[DisplayName("Телефон")]
public string PhoneNumber { get; set; } = string.Empty; public string PhoneNumber { get; set; } = string.Empty;
} }
} }

View File

@ -1,7 +1,10 @@
namespace MedicalDatabaseContracts.Models using System.ComponentModel;
namespace MedicalDatabaseContracts.Models
{ {
public class Diagnose : AbstractModel public class Diagnose : AbstractModel
{ {
[DisplayName("Название")]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
} }
} }

View File

@ -1,10 +1,16 @@
namespace MedicalDatabaseContracts.Models using System.ComponentModel;
namespace MedicalDatabaseContracts.Models
{ {
public class Patient : AbstractPersonModel public class Patient : AbstractPersonModel
{ {
[DisplayName("Пол")]
public char Gender { get; set; } public char Gender { get; set; }
[DisplayName("Дата рождения")]
public DateOnly Birthday { get; set; } public DateOnly Birthday { get; set; }
[DisplayName("Вес, кг")]
public int Weight { get; set; } public int Weight { get; set; }
[DisplayName("Рост, см")]
public int Height { get; set; } public int Height { get; set; }
} }
} }

View File

@ -1,9 +1,14 @@
namespace MedicalDatabaseContracts.Models using System.ComponentModel;
namespace MedicalDatabaseContracts.Models
{ {
public class Specialization : AbstractModel public class Specialization : AbstractModel
{ {
[DisplayName("Название")]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[DisplayName("Педиатрия")]
public bool IsPediatric { get; set; } public bool IsPediatric { get; set; }
[DisplayName("Терапия")]
public bool IsTherapeutic { get; set; } public bool IsTherapeutic { get; set; }
} }
} }

View File

@ -1,10 +1,13 @@
namespace MedicalDatabaseContracts.Models using System.ComponentModel;
namespace MedicalDatabaseContracts.Models
{ {
public class Visit : AbstractModel public class Visit : AbstractModel
{ {
public int PatientId { get; set; } public int PatientId { get; set; }
public int DoctorId { get; set; } public int DoctorId { get; set; }
public int DiagnoseId { get; set; } public int DiagnoseId { get; set; }
[DisplayName("Комментарий")]
public string? Comment { get; set; } public string? Comment { get; set; }
} }
} }

View File

@ -34,8 +34,11 @@
добавитьToolStripMenuItem = new ToolStripMenuItem(); добавитьToolStripMenuItem = new ToolStripMenuItem();
изменитьToolStripMenuItem = new ToolStripMenuItem(); изменитьToolStripMenuItem = new ToolStripMenuItem();
удалитьToolStripMenuItem = new ToolStripMenuItem(); удалитьToolStripMenuItem = new ToolStripMenuItem();
statusStrip = new StatusStrip();
toolStripStatusLabel = new ToolStripStatusLabel();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
menuStrip.SuspendLayout(); menuStrip.SuspendLayout();
statusStrip.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// dataGridView // dataGridView
@ -68,7 +71,7 @@
обновитьToolStripMenuItem.Name = "обновитьToolStripMenuItem"; обновитьToolStripMenuItem.Name = "обновитьToolStripMenuItem";
обновитьToolStripMenuItem.Size = new Size(92, 24); обновитьToolStripMenuItem.Size = new Size(92, 24);
обновитьToolStripMenuItem.Text = "Обновить"; обновитьToolStripMenuItem.Text = "Обновить";
обновитьToolStripMenuItem.Click += this.RefreshToolStripMenuItem_Click; обновитьToolStripMenuItem.Click += RefreshToolStripMenuItem_Click;
// //
// добавитьToolStripMenuItem // добавитьToolStripMenuItem
// //
@ -88,11 +91,27 @@
удалитьToolStripMenuItem.Size = new Size(79, 24); удалитьToolStripMenuItem.Size = new Size(79, 24);
удалитьToolStripMenuItem.Text = "Удалить"; удалитьToolStripMenuItem.Text = "Удалить";
// //
// statusStrip
//
statusStrip.ImageScalingSize = new Size(20, 20);
statusStrip.Items.AddRange(new ToolStripItem[] { toolStripStatusLabel });
statusStrip.Location = new Point(0, 428);
statusStrip.Name = "statusStrip";
statusStrip.Size = new Size(800, 22);
statusStrip.TabIndex = 5;
statusStrip.Text = "statusStrip1";
//
// toolStripStatusLabel
//
toolStripStatusLabel.Name = "toolStripStatusLabel";
toolStripStatusLabel.Size = new Size(0, 16);
//
// FormDiagnoses // FormDiagnoses
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(800, 450);
Controls.Add(statusStrip);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Controls.Add(menuStrip); Controls.Add(menuStrip);
MainMenuStrip = menuStrip; MainMenuStrip = menuStrip;
@ -102,6 +121,8 @@
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
menuStrip.ResumeLayout(false); menuStrip.ResumeLayout(false);
menuStrip.PerformLayout(); menuStrip.PerformLayout();
statusStrip.ResumeLayout(false);
statusStrip.PerformLayout();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
@ -113,5 +134,7 @@
private ToolStripMenuItem добавитьToolStripMenuItem; private ToolStripMenuItem добавитьToolStripMenuItem;
private ToolStripMenuItem изменитьToolStripMenuItem; private ToolStripMenuItem изменитьToolStripMenuItem;
private ToolStripMenuItem удалитьToolStripMenuItem; private ToolStripMenuItem удалитьToolStripMenuItem;
private StatusStrip statusStrip;
private ToolStripStatusLabel toolStripStatusLabel;
} }
} }

View File

@ -27,18 +27,28 @@ namespace MedicalView
private void LoadData() private void LoadData()
{ {
SetStatusStripText("Загрузка диагнозов...");
try try
{ {
var diagnoses = _diagnosesStorage.GetAll(); var items = _diagnosesStorage.GetAll();
dataGridView.DataSource = diagnoses;
dataGridView.DataSource = items;
dataGridView.Columns["Id"].Visible = false;
_logger.LogInformation("Список диагнозов загружен успешно"); _logger.LogInformation("Список диагнозов загружен успешно");
SetStatusStripText($"Готово. Загружено записей: {items.Count}");
} }
catch (Exception ex) catch (Exception ex)
{ {
string errorMessage = "Ошибка загрузки списка диагнозов"; string errorMessage = "Ошибка загрузки списка диагнозов";
_logger.LogError(string.Join(", ", errorMessage, $"\"{ex.Message}\"")); _logger.LogError(string.Join(", ", errorMessage, $"\"{ex.Message}\""));
MessageBox.Show(string.Join("\n\n", errorMessage, $"{ex.Message}"), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(string.Join("\n\n", errorMessage, $"{ex.Message}"), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
SetStatusStripText($"Ошибка загрузки");
} }
} }
private void SetStatusStripText(string text)
{
toolStripStatusLabel.Text = text;
}
} }
} }

View File

@ -120,4 +120,7 @@
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>145, 17</value>
</metadata>
</root> </root>