diff --git a/ProjectRacing/Entities/Competitions.cs b/ProjectRacing/Entities/Competitions.cs index 83698a5..585ff8c 100644 --- a/ProjectRacing/Entities/Competitions.cs +++ b/ProjectRacing/Entities/Competitions.cs @@ -5,14 +5,16 @@ public class Competitions public int Id { get; set; } public DateOnly DateOfCompetitions { get; set; } public string Adress { get; set; } = string.Empty; + public string Name { get; set; } = string.Empty; - public static Competitions CreateEntity(int id, DateOnly dateOfCompetitions, string adress) + public static Competitions CreateEntity(int id, DateOnly dateOfCompetitions, string adress, string name) { return new Competitions { Id = id, Adress = adress, - DateOfCompetitions = dateOfCompetitions + DateOfCompetitions = dateOfCompetitions, + Name = name }; } } \ No newline at end of file diff --git a/ProjectRacing/Entities/Enums/Gender.cs b/ProjectRacing/Entities/Enums/Gender.cs new file mode 100644 index 0000000..0eb7754 --- /dev/null +++ b/ProjectRacing/Entities/Enums/Gender.cs @@ -0,0 +1,8 @@ +namespace ProjectRacing.Entities.Enums; +[Flags] +public enum Gender +{ + Unknown = 0, + Man = 1, + Woman = 2 +} \ No newline at end of file diff --git a/ProjectRacing/Entities/Enums/HealthStatus.cs b/ProjectRacing/Entities/Enums/HealthStatus.cs new file mode 100644 index 0000000..a60fe41 --- /dev/null +++ b/ProjectRacing/Entities/Enums/HealthStatus.cs @@ -0,0 +1,7 @@ +namespace ProjectRacing.Entities.Enums; +public enum HealthStatus +{ + Completely = 0, + Partially = 1, + Unwell = 2 +} \ No newline at end of file diff --git a/ProjectRacing/Entities/Horse.cs b/ProjectRacing/Entities/Horse.cs index 947e2ea..0964acf 100644 --- a/ProjectRacing/Entities/Horse.cs +++ b/ProjectRacing/Entities/Horse.cs @@ -1,17 +1,15 @@ -namespace ProjectRacing.Entities; +using ProjectRacing.Entities.Enums; +namespace ProjectRacing.Entities; public class Horse { public int Id { get; private set; } - public string NameOfHorse { get; private set; } = string.Empty; - - public bool Sex { get; private set; } - + public Gender Sex { get; private set; } public DateOnly Birthday { get; private set; } public int OwnerId { get; private set; } - public static Horse CreateEntity(int id, string nameOfHorse, bool sex, DateOnly birthday, int ownerId) + public static Horse CreateEntity(int id, string nameOfHorse, Gender sex, DateOnly birthday, int ownerId) { return new Horse { diff --git a/ProjectRacing/Entities/Jockey.cs b/ProjectRacing/Entities/Jockey.cs index 6d8549d..bf59d6f 100644 --- a/ProjectRacing/Entities/Jockey.cs +++ b/ProjectRacing/Entities/Jockey.cs @@ -1,5 +1,4 @@ namespace ProjectRacing.Entities; - public class Jockey { public int Id { get; private set; } diff --git a/ProjectRacing/Entities/MedicalExamination.cs b/ProjectRacing/Entities/MedicalExamination.cs new file mode 100644 index 0000000..21702b1 --- /dev/null +++ b/ProjectRacing/Entities/MedicalExamination.cs @@ -0,0 +1,20 @@ +using ProjectRacing.Entities.Enums; + +namespace ProjectRacing.Entities; +public class MedicalExamination +{ + public int Id { get; private set; } + public DateOnly Date { get; private set; } + public HealthStatus HealthStatus { get; private set; } + public int HorseId { get; private set; } + public static MedicalExamination CreateEntity(int id, DateOnly date, HealthStatus healthStatus, int horseId) + { + return new MedicalExamination + { + Id = id, + Date = date, + HealthStatus = healthStatus, + HorseId = horseId + }; + } +} \ No newline at end of file diff --git a/ProjectRacing/Entities/Owner.cs b/ProjectRacing/Entities/Owner.cs index d71d36a..d489337 100644 --- a/ProjectRacing/Entities/Owner.cs +++ b/ProjectRacing/Entities/Owner.cs @@ -4,13 +4,15 @@ public class Owner public int Id { get; private set; } public string NameOfOwner { get; private set; } = string.Empty; public string Number { get; private set; } = string.Empty; - public static Owner CreateEntity(int id, string nameOfOwner, string number) + public string Adress { get; private set; } = string.Empty; + public static Owner CreateEntity(int id, string nameOfOwner, string number, string adress) { return new Owner { Id = id, NameOfOwner = nameOfOwner, - Number = number + Number = number, + Adress = adress }; } } \ No newline at end of file diff --git a/ProjectRacing/Entities/Participants.cs b/ProjectRacing/Entities/Participants.cs index 87a20a3..6b197db 100644 --- a/ProjectRacing/Entities/Participants.cs +++ b/ProjectRacing/Entities/Participants.cs @@ -1,24 +1,22 @@ namespace ProjectRacing.Entities; - public class Participants { public int ParticipantId { get; private set; } - public int JockeyId { get; private set; } - public int HorseId { get; private set; } - public int CompetitionsId { get; private set; } - public TimeSpan HorseTime { get; private set; } - public int HorsePlase { get; private set; } - - public static Participants CreateEntity(int id, int jockeyId, int horseId, int competitionsId, TimeSpan horseTime, int horsePlace) + public int JockeyId { get; private set; } + public int CompetitionsId { get; private set; } + public int HorsesId { get; private set; } + public int Place { get; private set; } + public static Participants CreateEntity(int id, int jockeyId, int horsesId, int competitionsId, int place) { + + return new Participants { - ParticipantId = id, - JockeyId = jockeyId, - HorseId = horseId, - CompetitionsId = competitionsId, - HorseTime = horseTime, - HorsePlase = horsePlace + ParticipantId = id, + JockeyId = jockeyId, + HorsesId = horsesId, + CompetitionsId = competitionsId, + Place = place }; } -} +} \ No newline at end of file diff --git a/ProjectRacing/FormRacing.Designer.cs b/ProjectRacing/FormRacing.Designer.cs index 007ba7f..5dfb395 100644 --- a/ProjectRacing/FormRacing.Designer.cs +++ b/ProjectRacing/FormRacing.Designer.cs @@ -28,12 +28,110 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; + menuStrip = new MenuStrip(); + infoToolStripMenuItem = new ToolStripMenuItem(); + horsesToolStripMenuItem = new ToolStripMenuItem(); + ownersToolStripMenuItem = new ToolStripMenuItem(); + jockeysToolStripMenuItem = new ToolStripMenuItem(); + operationToolStripMenuItem = new ToolStripMenuItem(); + registrationCompetitionToolStripMenuItem = new ToolStripMenuItem(); + completeMedicalExaminationToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip.SuspendLayout(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.Items.AddRange(new ToolStripItem[] { infoToolStripMenuItem, operationToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(800, 24); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // infoToolStripMenuItem + // + infoToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { horsesToolStripMenuItem, ownersToolStripMenuItem, jockeysToolStripMenuItem }); + infoToolStripMenuItem.Name = "infoToolStripMenuItem"; + infoToolStripMenuItem.Size = new Size(94, 20); + infoToolStripMenuItem.Text = "Справочники"; + // + // horsesToolStripMenuItem + // + horsesToolStripMenuItem.Name = "horsesToolStripMenuItem"; + horsesToolStripMenuItem.Size = new Size(180, 22); + horsesToolStripMenuItem.Text = "Лошади"; + horsesToolStripMenuItem.Click += HorsesToolStripMenuItem_Click; + // + // ownersToolStripMenuItem + // + ownersToolStripMenuItem.Name = "ownersToolStripMenuItem"; + ownersToolStripMenuItem.Size = new Size(180, 22); + ownersToolStripMenuItem.Text = "Владельцы"; + ownersToolStripMenuItem.Click += OwnersToolStripMenuItem_Click; + // + // jockeysToolStripMenuItem + // + jockeysToolStripMenuItem.Name = "jockeysToolStripMenuItem"; + jockeysToolStripMenuItem.Size = new Size(180, 22); + jockeysToolStripMenuItem.Text = "Жокеи"; + jockeysToolStripMenuItem.Click += JockeysToolStripMenuItem_Click; + // + // operationToolStripMenuItem + // + operationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { registrationCompetitionToolStripMenuItem, completeMedicalExaminationToolStripMenuItem }); + operationToolStripMenuItem.Name = "operationToolStripMenuItem"; + operationToolStripMenuItem.Size = new Size(75, 20); + operationToolStripMenuItem.Text = "Операции"; + // + // registrationCompetitionToolStripMenuItem + // + registrationCompetitionToolStripMenuItem.Name = "registrationCompetitionToolStripMenuItem"; + registrationCompetitionToolStripMenuItem.Size = new Size(225, 22); + registrationCompetitionToolStripMenuItem.Text = "Регистрация соревнований"; + registrationCompetitionToolStripMenuItem.Click += RegistrationCompetitionToolStripMenuItem_Click; + // + // completeMedicalExaminationToolStripMenuItem + // + completeMedicalExaminationToolStripMenuItem.Name = "completeMedicalExaminationToolStripMenuItem"; + completeMedicalExaminationToolStripMenuItem.Size = new Size(225, 22); + completeMedicalExaminationToolStripMenuItem.Text = "Провести медосмотр"; + completeMedicalExaminationToolStripMenuItem.Click += CompleteMedicalExaminationToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormRacing + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.orig; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(800, 450); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormRacing"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Скачки"; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + PerformLayout(); } #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem infoToolStripMenuItem; + private ToolStripMenuItem horsesToolStripMenuItem; + private ToolStripMenuItem ownersToolStripMenuItem; + private ToolStripMenuItem jockeysToolStripMenuItem; + private ToolStripMenuItem operationToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem registrationCompetitionToolStripMenuItem; + private ToolStripMenuItem completeMedicalExaminationToolStripMenuItem; } } diff --git a/ProjectRacing/FormRacing.cs b/ProjectRacing/FormRacing.cs index ecdc79d..60ab2ee 100644 --- a/ProjectRacing/FormRacing.cs +++ b/ProjectRacing/FormRacing.cs @@ -1,10 +1,96 @@ +using ProjectRacing.Forms; +using ProjectRacing.Forms.Competitions; +using ProjectRacing.Forms.Jockeys; +using ProjectRacing.Forms.MedicalExamination; +using Unity; + namespace ProjectRacing { public partial class FormRacing : Form { - public FormRacing() + private readonly IUnityContainer _container; + public FormRacing(IUnityContainer container) { InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + private void CompetitionToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private void HorsesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private void OwnersToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private void JockeysToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private void RegistrationCompetitionToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void CompleteMedicalExaminationToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } } } } diff --git a/ProjectRacing/FormRacing.resx b/ProjectRacing/FormRacing.resx index 1af7de1..31084d5 100644 --- a/ProjectRacing/FormRacing.resx +++ b/ProjectRacing/FormRacing.resx @@ -1,17 +1,17 @@  - @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/ProjectRacing/Forms/Competitions/FormCompetition.Designer.cs b/ProjectRacing/Forms/Competitions/FormCompetition.Designer.cs new file mode 100644 index 0000000..77ee634 --- /dev/null +++ b/ProjectRacing/Forms/Competitions/FormCompetition.Designer.cs @@ -0,0 +1,210 @@ +namespace ProjectRacing.Forms +{ + partial class FormCompetition + { + /// + /// 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() + { + dateTimePickerDateOfCompetition = new DateTimePicker(); + textBoxNameOfCompetition = new TextBox(); + labelDateOfCompetition = new Label(); + labelNameOfCompetitions = new Label(); + buttonSave = new Button(); + buttonExit = new Button(); + textBoxAdressOfCompetition = new TextBox(); + labelAdressOfCompetition = new Label(); + label1 = new Label(); + numericUpDownPlace = new NumericUpDown(); + comboBoxHorses = new ComboBox(); + comboBoxJockeys = new ComboBox(); + labelHorses = new Label(); + labelJockeys = new Label(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPlace).BeginInit(); + SuspendLayout(); + // + // dateTimePickerDateOfCompetition + // + dateTimePickerDateOfCompetition.Location = new Point(159, 108); + dateTimePickerDateOfCompetition.Name = "dateTimePickerDateOfCompetition"; + dateTimePickerDateOfCompetition.Size = new Size(173, 23); + dateTimePickerDateOfCompetition.TabIndex = 0; + // + // textBoxNameOfCompetition + // + textBoxNameOfCompetition.Location = new Point(159, 143); + textBoxNameOfCompetition.Name = "textBoxNameOfCompetition"; + textBoxNameOfCompetition.Size = new Size(173, 23); + textBoxNameOfCompetition.TabIndex = 1; + // + // labelDateOfCompetition + // + labelDateOfCompetition.AutoSize = true; + labelDateOfCompetition.Location = new Point(12, 108); + labelDateOfCompetition.Name = "labelDateOfCompetition"; + labelDateOfCompetition.Size = new Size(114, 15); + labelDateOfCompetition.TabIndex = 2; + labelDateOfCompetition.Text = "Дата соревнований"; + // + // labelNameOfCompetitions + // + labelNameOfCompetitions.AutoSize = true; + labelNameOfCompetitions.Location = new Point(12, 143); + labelNameOfCompetitions.Name = "labelNameOfCompetitions"; + labelNameOfCompetitions.Size = new Size(141, 15); + labelNameOfCompetitions.TabIndex = 3; + labelNameOfCompetitions.Text = "Название соревнований"; + // + // buttonSave + // + buttonSave.Location = new Point(51, 212); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonExit + // + buttonExit.Location = new Point(179, 212); + buttonExit.Name = "buttonExit"; + buttonExit.Size = new Size(75, 23); + buttonExit.TabIndex = 5; + buttonExit.Text = "Отмена"; + buttonExit.UseVisualStyleBackColor = true; + buttonExit.Click += ButtonExit_Click; + // + // textBoxAdressOfCompetition + // + textBoxAdressOfCompetition.Location = new Point(159, 180); + textBoxAdressOfCompetition.Name = "textBoxAdressOfCompetition"; + textBoxAdressOfCompetition.Size = new Size(173, 23); + textBoxAdressOfCompetition.TabIndex = 6; + // + // labelAdressOfCompetition + // + labelAdressOfCompetition.AutoSize = true; + labelAdressOfCompetition.Location = new Point(12, 183); + labelAdressOfCompetition.Name = "labelAdressOfCompetition"; + labelAdressOfCompetition.Size = new Size(124, 15); + labelAdressOfCompetition.TabIndex = 7; + labelAdressOfCompetition.Text = "Место соревнований"; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(14, 72); + label1.Name = "label1"; + label1.Size = new Size(42, 15); + label1.TabIndex = 24; + label1.Text = "Место"; + // + // numericUpDownPlace + // + numericUpDownPlace.Location = new Point(159, 70); + numericUpDownPlace.Name = "numericUpDownPlace"; + numericUpDownPlace.Size = new Size(173, 23); + numericUpDownPlace.TabIndex = 23; + numericUpDownPlace.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // comboBoxHorses + // + comboBoxHorses.FormattingEnabled = true; + comboBoxHorses.Location = new Point(159, 41); + comboBoxHorses.Name = "comboBoxHorses"; + comboBoxHorses.Size = new Size(173, 23); + comboBoxHorses.TabIndex = 22; + // + // comboBoxJockeys + // + comboBoxJockeys.FormattingEnabled = true; + comboBoxJockeys.Location = new Point(159, 12); + comboBoxJockeys.Name = "comboBoxJockeys"; + comboBoxJockeys.Size = new Size(173, 23); + comboBoxJockeys.TabIndex = 21; + // + // labelHorses + // + labelHorses.AutoSize = true; + labelHorses.Location = new Point(12, 44); + labelHorses.Name = "labelHorses"; + labelHorses.Size = new Size(51, 15); + labelHorses.TabIndex = 18; + labelHorses.Text = "Лошадь"; + // + // labelJockeys + // + labelJockeys.AutoSize = true; + labelJockeys.Location = new Point(12, 9); + labelJockeys.Name = "labelJockeys"; + labelJockeys.Size = new Size(44, 15); + labelJockeys.TabIndex = 17; + labelJockeys.Text = "Жокей"; + // + // FormCompetition + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(350, 269); + Controls.Add(label1); + Controls.Add(numericUpDownPlace); + Controls.Add(comboBoxHorses); + Controls.Add(comboBoxJockeys); + Controls.Add(labelHorses); + Controls.Add(labelJockeys); + Controls.Add(labelAdressOfCompetition); + Controls.Add(textBoxAdressOfCompetition); + Controls.Add(buttonExit); + Controls.Add(buttonSave); + Controls.Add(labelNameOfCompetitions); + Controls.Add(labelDateOfCompetition); + Controls.Add(textBoxNameOfCompetition); + Controls.Add(dateTimePickerDateOfCompetition); + Name = "FormCompetition"; + Text = "Соревнование"; + ((System.ComponentModel.ISupportInitialize)numericUpDownPlace).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private DateTimePicker dateTimePickerDateOfCompetition; + private TextBox textBoxNameOfCompetition; + private Label labelDateOfCompetition; + private Label labelNameOfCompetitions; + private Button buttonSave; + private Button buttonExit; + private TextBox textBoxAdressOfCompetition; + private Label labelAdressOfCompetition; + private Label label1; + private NumericUpDown numericUpDownPlace; + private ComboBox comboBoxHorses; + private ComboBox comboBoxJockeys; + private Label labelHorses; + private Label labelJockeys; + } +} \ No newline at end of file diff --git a/ProjectRacing/Forms/Competitions/FormCompetition.cs b/ProjectRacing/Forms/Competitions/FormCompetition.cs new file mode 100644 index 0000000..083dfa8 --- /dev/null +++ b/ProjectRacing/Forms/Competitions/FormCompetition.cs @@ -0,0 +1,93 @@ +using ProjectRacing.Repositories; +namespace ProjectRacing.Forms +{ + public partial class FormCompetition : Form + { + private readonly ICompetitionsRepository _competitionRepository; + private readonly IParticipantsRepository _participantsRepository; + private readonly IHorseRepository _horseRepository; + private readonly IJockeyRepository _jockeyRepository; + private int? _participantsId; + private int? _competitionId; + public int CompetitionID + { + set + { + try + { + var competition = _competitionRepository.GetCompetitionById(value); + if (competition == null) + { + throw new InvalidDataException(nameof(competition)); + } + textBoxNameOfCompetition.Text = competition.Name; + dateTimePickerDateOfCompetition.Text = competition.DateOfCompetitions.ToString(); + _competitionId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + public int ParticipantsID + { + set + { + try + { + var participants = _participantsRepository.GetParticipantsById(value); + if (participants == null) + { + throw new InvalidDataException(nameof(participants)); + } + comboBoxJockeys.DataSource = _jockeyRepository.GetJockeys(); + comboBoxHorses.DataSource = _horseRepository.GetHorses(); + _participantsId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + public FormCompetition(ICompetitionsRepository competitionRepository, IParticipantsRepository participantsRepository, IJockeyRepository jockeyRepository, IHorseRepository horseRepository) + { + InitializeComponent(); + _competitionRepository = competitionRepository ?? throw new ArgumentNullException(nameof(competitionRepository)); + _participantsRepository = participantsRepository ?? throw new ArgumentNullException( nameof(participantsRepository)); + _horseRepository = horseRepository ?? throw new ArgumentNullException( nameof(horseRepository)); + _jockeyRepository = jockeyRepository ?? throw new ArgumentNullException(nameof(jockeyRepository)); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxNameOfCompetition.Text)) throw new Exception("Название соревнований не заполнено"); + if (string.IsNullOrWhiteSpace(textBoxAdressOfCompetition.Text)) throw new Exception("Место соревнований не заполнено"); + + if (_competitionId.HasValue) + { + _competitionRepository.UpdateCompetitions(_competitionId.Value); + } + else + { + _competitionRepository.CreateCompetitions(CreateCompetition(0)); + } + if (_participantsId.HasValue) + _participantsRepository.UpdateParticipants(_participantsId.Value); + else + _participantsRepository.CreateParticipants(CreateParticipants(0)); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonExit_Click(object sender, EventArgs e) => Close(); + private Entities.Competitions CreateCompetition(int id) => Entities.Competitions.CreateEntity(id, DateOnly.FromDateTime(dateTimePickerDateOfCompetition.Value), textBoxAdressOfCompetition.Text, textBoxNameOfCompetition.Text); + private Entities.Participants CreateParticipants(int id) => Entities.Participants.CreateEntity(id, comboBoxJockeys.SelectedIndex, comboBoxHorses.SelectedIndex, _competitionId == null? 0 : (int)_competitionId, (int)numericUpDownPlace.Value); + } +} diff --git a/ProjectRacing/Forms/Competitions/FormCompetition.resx b/ProjectRacing/Forms/Competitions/FormCompetition.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectRacing/Forms/Competitions/FormCompetition.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectRacing/Forms/Competitions/FormCompetitions.Designer.cs b/ProjectRacing/Forms/Competitions/FormCompetitions.Designer.cs new file mode 100644 index 0000000..6bd3558 --- /dev/null +++ b/ProjectRacing/Forms/Competitions/FormCompetitions.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectRacing.Forms.Competitions +{ + partial class FormCompetitions + { + /// + /// 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(); + buttonUpdate = new Button(); + buttonDelete = new Button(); + buttonAdd = new Button(); + dataGridViewCompetitionsAndParticipants = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewCompetitionsAndParticipants).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonUpdate); + panel1.Controls.Add(buttonDelete); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(684, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(116, 450); + panel1.TabIndex = 4; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.icons8_update_64; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(16, 146); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(75, 61); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.icons8_delete_480; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(16, 79); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(75, 61); + buttonDelete.TabIndex = 1; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icons8_add_100; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 61); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewCompetitionsAndParticipants + // + dataGridViewCompetitionsAndParticipants.AllowUserToAddRows = false; + dataGridViewCompetitionsAndParticipants.AllowUserToDeleteRows = false; + dataGridViewCompetitionsAndParticipants.AllowUserToResizeColumns = false; + dataGridViewCompetitionsAndParticipants.AllowUserToResizeRows = false; + dataGridViewCompetitionsAndParticipants.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewCompetitionsAndParticipants.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCompetitionsAndParticipants.Dock = DockStyle.Fill; + dataGridViewCompetitionsAndParticipants.Location = new Point(0, 0); + dataGridViewCompetitionsAndParticipants.MultiSelect = false; + dataGridViewCompetitionsAndParticipants.Name = "dataGridViewCompetitionsAndParticipants"; + dataGridViewCompetitionsAndParticipants.ReadOnly = true; + dataGridViewCompetitionsAndParticipants.RowHeadersVisible = false; + dataGridViewCompetitionsAndParticipants.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewCompetitionsAndParticipants.Size = new Size(800, 450); + dataGridViewCompetitionsAndParticipants.TabIndex = 5; + // + // FormCompetitions + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel1); + Controls.Add(dataGridViewCompetitionsAndParticipants); + Name = "FormCompetitions"; + Text = "Соревнования"; + Load += FormCompetitions_Load_1; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewCompetitionsAndParticipants).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonUpdate; + private Button buttonDelete; + private Button buttonAdd; + private DataGridView dataGridViewCompetitionsAndParticipants; + } +} \ No newline at end of file diff --git a/ProjectRacing/Forms/Competitions/FormCompetitions.cs b/ProjectRacing/Forms/Competitions/FormCompetitions.cs new file mode 100644 index 0000000..9540534 --- /dev/null +++ b/ProjectRacing/Forms/Competitions/FormCompetitions.cs @@ -0,0 +1,159 @@ +using ProjectRacing.Repositories; +using System.Data; +using Unity; +namespace ProjectRacing.Forms.Competitions +{ + public partial class FormCompetitions : Form + { + private readonly IUnityContainer _container; + private readonly ICompetitionsRepository _competitionRepository; + private readonly IParticipantsRepository _participantsRepository; + private readonly IHorseRepository _horseRepository; + private readonly IJockeyRepository _jockeyRepository; + public FormCompetitions(IUnityContainer container, ICompetitionsRepository competitionRepository, IParticipantsRepository participantsRepository, IHorseRepository horseRepository, IJockeyRepository jockeyRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _competitionRepository = competitionRepository ?? throw new ArgumentNullException(nameof(competitionRepository)); + _participantsRepository = participantsRepository ?? throw new ArgumentNullException(nameof(participantsRepository)); + _horseRepository = horseRepository ?? throw new ArgumentNullException(nameof(horseRepository)); + _jockeyRepository = jockeyRepository ?? throw new ArgumentNullException(nameof(jockeyRepository)); + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromsSelectRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _competitionRepository.DeleteCompetitions(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonUpdate_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromsSelectRow(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 LoadList() + { + try + { + // Получение данных из репозиториев + var competitions = _competitionRepository.GetCompetitionses(); + var participants = _participantsRepository.GetParticipants(); + + // Создание DataTable для объединения данных + var dataTable = new DataTable(); + + // Добавление столбцов для данных из Competitions + dataTable.Columns.Add("CompetitionId", typeof(int)); + dataTable.Columns.Add("CompetitionName", typeof(string)); + dataTable.Columns.Add("CompetitionDate", typeof(DateOnly)); + dataTable.Columns.Add("CompetitionAdress",typeof(string)); + + + // Добавление столбцов для данных из Participants + dataTable.Columns.Add("ParticipantId", typeof(int)); + dataTable.Columns.Add("JockeyName", typeof(string)); + dataTable.Columns.Add("HorseName", typeof(string)); + dataTable.Columns.Add("Place", typeof(int)); + // Объединение данных в DataTable + foreach (var competition in competitions) + { + var row = dataTable.NewRow(); + row["CompetitionId"] = competition.Id; + row["CompetitionName"] = competition.Name; + row["CompetitionDate"] = competition.DateOfCompetitions; + row["CompetitionAdress"] = competition.Adress; + dataTable.Rows.Add(row); + } + + foreach (var participant in participants) + { + var row = dataTable.NewRow(); + row["ParticipantId"] = participant.ParticipantId; + row["HorseName"] = _horseRepository.GetHorseById(participant.HorsesId).NameOfHorse; + row["JockeyName"] = _jockeyRepository.GetJockeyById(participant.JockeyId).NameOfJockey; + row["Place"] = participant.Place; + dataTable.Rows.Add(row); + } + + // Установка источника данных для DataGridView + dataGridViewCompetitionsAndParticipants.DataSource = dataTable; + + // Убедитесь, что заголовки отображаются корректно + dataGridViewCompetitionsAndParticipants.Columns["CompetitionId"].HeaderText = "ID Соревнования"; + dataGridViewCompetitionsAndParticipants.Columns["CompetitionName"].HeaderText = "Название Соревнования"; + dataGridViewCompetitionsAndParticipants.Columns["CompetitionDate"].HeaderText = "Дата соревнований"; + dataGridViewCompetitionsAndParticipants.Columns["CompetitionAdress"].HeaderText = "Адресс соревановний"; + dataGridViewCompetitionsAndParticipants.Columns["ParticipantId"].HeaderText = "ID участников"; + dataGridViewCompetitionsAndParticipants.Columns["JockeyName"].HeaderText = "Имя лошади"; + dataGridViewCompetitionsAndParticipants.Columns["HorseName"].HeaderText = "Имя жокея"; + dataGridViewCompetitionsAndParticipants.Columns["Place"].HeaderText = "Занятое место"; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private bool TryGetIdentifierFromsSelectRow(out int id) + { + id = 0; + if (dataGridViewCompetitionsAndParticipants.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewCompetitionsAndParticipants.SelectedRows[0].Cells["Id"].Value); + return true; + } + private void FormCompetitions_Load_1(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ProjectRacing/Forms/Competitions/FormCompetitions.resx b/ProjectRacing/Forms/Competitions/FormCompetitions.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectRacing/Forms/Competitions/FormCompetitions.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectRacing/Forms/Horses/FormHorse.Designer.cs b/ProjectRacing/Forms/Horses/FormHorse.Designer.cs new file mode 100644 index 0000000..59d0025 --- /dev/null +++ b/ProjectRacing/Forms/Horses/FormHorse.Designer.cs @@ -0,0 +1,163 @@ +namespace ProjectRacing.Forms +{ + partial class FormHorse + { + /// + /// 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() + { + labelNameOfHorse = new Label(); + labelSex = new Label(); + labelDateOfBirthday = new Label(); + textBoxNameOfHorse = new TextBox(); + dateTimePickerDateOfBirthday = new DateTimePicker(); + buttonSave = new Button(); + buttonExit = new Button(); + labelOwner = new Label(); + comboBoxOwner = new ComboBox(); + comboBoxSex = new ComboBox(); + SuspendLayout(); + // + // labelNameOfHorse + // + labelNameOfHorse.AutoSize = true; + labelNameOfHorse.Location = new Point(12, 38); + labelNameOfHorse.Name = "labelNameOfHorse"; + labelNameOfHorse.Size = new Size(94, 15); + labelNameOfHorse.TabIndex = 0; + labelNameOfHorse.Text = "Кличка лошади"; + // + // labelSex + // + labelSex.AutoSize = true; + labelSex.Location = new Point(18, 81); + labelSex.Name = "labelSex"; + labelSex.Size = new Size(30, 15); + labelSex.TabIndex = 1; + labelSex.Text = "Пол"; + // + // labelDateOfBirthday + // + labelDateOfBirthday.AutoSize = true; + labelDateOfBirthday.Location = new Point(12, 120); + labelDateOfBirthday.Name = "labelDateOfBirthday"; + labelDateOfBirthday.Size = new Size(90, 15); + labelDateOfBirthday.TabIndex = 2; + labelDateOfBirthday.Text = "Дата рождения"; + // + // textBoxNameOfHorse + // + textBoxNameOfHorse.Location = new Point(112, 38); + textBoxNameOfHorse.Name = "textBoxNameOfHorse"; + textBoxNameOfHorse.Size = new Size(100, 23); + textBoxNameOfHorse.TabIndex = 3; + // + // dateTimePickerDateOfBirthday + // + dateTimePickerDateOfBirthday.Location = new Point(112, 120); + dateTimePickerDateOfBirthday.Name = "dateTimePickerDateOfBirthday"; + dateTimePickerDateOfBirthday.Size = new Size(200, 23); + dateTimePickerDateOfBirthday.TabIndex = 9; + // + // buttonSave + // + buttonSave.Location = new Point(72, 149); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 10; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonExit + // + buttonExit.Location = new Point(203, 149); + buttonExit.Name = "buttonExit"; + buttonExit.Size = new Size(75, 23); + buttonExit.TabIndex = 11; + buttonExit.Text = "Отмена"; + buttonExit.UseVisualStyleBackColor = true; + buttonExit.Click += ButtonExit_Click; + // + // labelOwner + // + labelOwner.AutoSize = true; + labelOwner.Location = new Point(12, 9); + labelOwner.Name = "labelOwner"; + labelOwner.Size = new Size(59, 15); + labelOwner.TabIndex = 12; + labelOwner.Text = "Владелец"; + // + // comboBoxOwner + // + comboBoxOwner.FormattingEnabled = true; + comboBoxOwner.Location = new Point(112, 9); + comboBoxOwner.Name = "comboBoxOwner"; + comboBoxOwner.Size = new Size(121, 23); + comboBoxOwner.TabIndex = 13; + // + // comboBoxSex + // + comboBoxSex.FormattingEnabled = true; + comboBoxSex.Location = new Point(62, 77); + comboBoxSex.Name = "comboBoxSex"; + comboBoxSex.Size = new Size(121, 23); + comboBoxSex.TabIndex = 16; + // + // FormHorse + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(328, 184); + Controls.Add(comboBoxSex); + Controls.Add(comboBoxOwner); + Controls.Add(labelOwner); + Controls.Add(buttonExit); + Controls.Add(buttonSave); + Controls.Add(dateTimePickerDateOfBirthday); + Controls.Add(textBoxNameOfHorse); + Controls.Add(labelDateOfBirthday); + Controls.Add(labelSex); + Controls.Add(labelNameOfHorse); + Name = "FormHorse"; + Text = "Лошадь"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelNameOfHorse; + private Label labelSex; + private Label labelDateOfBirthday; + private TextBox textBoxNameOfHorse; + private DateTimePicker dateTimePickerDateOfBirthday; + private Button buttonSave; + private Button buttonExit; + private Label labelOwner; + private ComboBox comboBoxOwner; + private ComboBox comboBoxSex; + } +} \ No newline at end of file diff --git a/ProjectRacing/Forms/Horses/FormHorse.cs b/ProjectRacing/Forms/Horses/FormHorse.cs new file mode 100644 index 0000000..1832228 --- /dev/null +++ b/ProjectRacing/Forms/Horses/FormHorse.cs @@ -0,0 +1,73 @@ +using ProjectRacing.Entities; +using ProjectRacing.Entities.Enums; +using ProjectRacing.Repositories; +namespace ProjectRacing.Forms +{ + public partial class FormHorse : Form + { + private readonly IHorseRepository _horseRepository; + private int? _horseId; + public int ID + { + set + { + try + { + var horse = _horseRepository.GetHorseById(value); + if (horse == null) + { + throw new InvalidDataException(nameof(horse)); + } + textBoxNameOfHorse.Text = horse.NameOfHorse; + dateTimePickerDateOfBirthday.Text = horse.Birthday.ToString(); + comboBoxOwner.SelectedValue = horse.OwnerId; + comboBoxSex.SelectedValue = horse.Sex; + _horseId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + public FormHorse(IHorseRepository horseRepository, IOwnerRepository ownerRepository) + { + InitializeComponent(); + _horseRepository = horseRepository ?? throw new ArgumentNullException(nameof(horseRepository)); + comboBoxOwner.DataSource = ownerRepository.GetOwners(); + comboBoxOwner.DisplayMember = "NameOfOwner"; + comboBoxOwner.ValueMember = "Id"; + var healthStatusValues = Enum.GetValues(typeof(HealthStatus)); + var genders = Enum.GetValues(typeof(Gender)); + foreach (var gender in genders) + { + comboBoxSex.Items.Add(gender); + } + comboBoxSex.SelectedIndex = 0; + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if(comboBoxOwner.SelectedIndex < 0) throw new Exception("Не выбран владелец"); + if (string.IsNullOrWhiteSpace(textBoxNameOfHorse.Text)) throw new Exception("Кличка не заполнена"); + if (comboBoxSex.SelectedIndex<0) throw new Exception("Не выбран пол"); + if (_horseId.HasValue) + { + _horseRepository.UpdateHorse(_horseId.Value); + } + else + { + _horseRepository.CreateHorse(CreateHorse(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonExit_Click(object sender, EventArgs e) => Close(); + private Horse CreateHorse(int id)=> Horse.CreateEntity(id, textBoxNameOfHorse.Text, (Gender)comboBoxSex.SelectedValue!, DateOnly.FromDateTime(dateTimePickerDateOfBirthday.Value), (int)comboBoxOwner.SelectedValue!); + } +} \ No newline at end of file diff --git a/ProjectRacing/Forms/Horses/FormHorse.resx b/ProjectRacing/Forms/Horses/FormHorse.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectRacing/Forms/Horses/FormHorse.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectRacing/Forms/Horses/FormHorses.Designer.cs b/ProjectRacing/Forms/Horses/FormHorses.Designer.cs new file mode 100644 index 0000000..09a0f47 --- /dev/null +++ b/ProjectRacing/Forms/Horses/FormHorses.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectRacing.Forms +{ + partial class FormHorses + { + /// + /// 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(); + buttonUpdate = new Button(); + buttonDelete = new Button(); + buttonAdd = new Button(); + dataGridViewHorses = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewHorses).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonUpdate); + panel1.Controls.Add(buttonDelete); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(660, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(116, 428); + panel1.TabIndex = 0; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.icons8_update_64; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(16, 146); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(75, 61); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.icons8_delete_480; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(16, 79); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(75, 61); + buttonDelete.TabIndex = 1; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icons8_add_100; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 61); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewHorses + // + dataGridViewHorses.AllowUserToAddRows = false; + dataGridViewHorses.AllowUserToDeleteRows = false; + dataGridViewHorses.AllowUserToResizeColumns = false; + dataGridViewHorses.AllowUserToResizeRows = false; + dataGridViewHorses.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewHorses.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewHorses.Dock = DockStyle.Fill; + dataGridViewHorses.Location = new Point(0, 0); + dataGridViewHorses.MultiSelect = false; + dataGridViewHorses.Name = "dataGridViewHorses"; + dataGridViewHorses.ReadOnly = true; + dataGridViewHorses.RowHeadersVisible = false; + dataGridViewHorses.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewHorses.Size = new Size(660, 428); + dataGridViewHorses.TabIndex = 3; + // + // FormHorses + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(776, 428); + Controls.Add(dataGridViewHorses); + Controls.Add(panel1); + Name = "FormHorses"; + StartPosition = FormStartPosition.CenterParent; + Text = "Лошади"; + Load += FormHorses_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewHorses).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonUpdate; + private Button buttonDelete; + private Button buttonAdd; + private DataGridView dataGridViewHorses; + } +} \ No newline at end of file diff --git a/ProjectRacing/Forms/Horses/FormHorses.cs b/ProjectRacing/Forms/Horses/FormHorses.cs new file mode 100644 index 0000000..59ef4e7 --- /dev/null +++ b/ProjectRacing/Forms/Horses/FormHorses.cs @@ -0,0 +1,90 @@ +using ProjectRacing.Repositories; +using Unity; +namespace ProjectRacing.Forms +{ + public partial class FormHorses : Form + { + private readonly IUnityContainer _container; + private readonly IHorseRepository _horseRepository; + public FormHorses(IUnityContainer container, IHorseRepository horseRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _horseRepository = horseRepository ?? throw new ArgumentNullException(nameof(horseRepository)); + } + private void FormHorses_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromsSelectRow(out var findId)) + { + return; + } + if(MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _horseRepository.DeleteHorse(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonUpdate_Click(object sender, EventArgs e) + { + if(!TryGetIdentifierFromsSelectRow(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 LoadList() => dataGridViewHorses.DataSource = _horseRepository.GetHorses(); + private bool TryGetIdentifierFromsSelectRow(out int id) + { + id = 0; + if (dataGridViewHorses.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewHorses.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} \ No newline at end of file diff --git a/ProjectRacing/Forms/Horses/FormHorses.resx b/ProjectRacing/Forms/Horses/FormHorses.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectRacing/Forms/Horses/FormHorses.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectRacing/Forms/Jockeys/FormJockey.Designer.cs b/ProjectRacing/Forms/Jockeys/FormJockey.Designer.cs new file mode 100644 index 0000000..ba4ee3d --- /dev/null +++ b/ProjectRacing/Forms/Jockeys/FormJockey.Designer.cs @@ -0,0 +1,190 @@ +namespace ProjectRacing.Forms +{ + partial class FormJockey + { + /// + /// 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() + { + textBoxNameOfJockey = new TextBox(); + numericUpDownAgeOfJockey = new NumericUpDown(); + numericUpDownRateOfJockey = new NumericUpDown(); + textBoxAdressOfJockey = new TextBox(); + textBoxNumberOfJockey = new TextBox(); + labelNameOfJockey = new Label(); + labelAdressOfJockey = new Label(); + labelNumberOfJockey = new Label(); + labelAgeOfJockey = new Label(); + labelRateOfJockey = new Label(); + buttonExit = new Button(); + buttonSave = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownAgeOfJockey).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownRateOfJockey).BeginInit(); + SuspendLayout(); + // + // textBoxNameOfJockey + // + textBoxNameOfJockey.Location = new Point(67, 9); + textBoxNameOfJockey.Name = "textBoxNameOfJockey"; + textBoxNameOfJockey.Size = new Size(100, 23); + textBoxNameOfJockey.TabIndex = 0; + // + // numericUpDownAgeOfJockey + // + numericUpDownAgeOfJockey.Location = new Point(67, 94); + numericUpDownAgeOfJockey.Minimum = new decimal(new int[] { 18, 0, 0, 0 }); + numericUpDownAgeOfJockey.Name = "numericUpDownAgeOfJockey"; + numericUpDownAgeOfJockey.Size = new Size(120, 23); + numericUpDownAgeOfJockey.TabIndex = 1; + numericUpDownAgeOfJockey.Value = new decimal(new int[] { 18, 0, 0, 0 }); + // + // numericUpDownRateOfJockey + // + numericUpDownRateOfJockey.DecimalPlaces = 1; + numericUpDownRateOfJockey.Location = new Point(67, 123); + numericUpDownRateOfJockey.Name = "numericUpDownRateOfJockey"; + numericUpDownRateOfJockey.Size = new Size(120, 23); + numericUpDownRateOfJockey.TabIndex = 2; + // + // textBoxAdressOfJockey + // + textBoxAdressOfJockey.Location = new Point(67, 36); + textBoxAdressOfJockey.Name = "textBoxAdressOfJockey"; + textBoxAdressOfJockey.Size = new Size(100, 23); + textBoxAdressOfJockey.TabIndex = 3; + // + // textBoxNumberOfJockey + // + textBoxNumberOfJockey.Location = new Point(67, 65); + textBoxNumberOfJockey.Name = "textBoxNumberOfJockey"; + textBoxNumberOfJockey.Size = new Size(100, 23); + textBoxNumberOfJockey.TabIndex = 4; + // + // labelNameOfJockey + // + labelNameOfJockey.AutoSize = true; + labelNameOfJockey.Location = new Point(12, 9); + labelNameOfJockey.Name = "labelNameOfJockey"; + labelNameOfJockey.Size = new Size(31, 15); + labelNameOfJockey.TabIndex = 5; + labelNameOfJockey.Text = "Имя"; + // + // labelAdressOfJockey + // + labelAdressOfJockey.AutoSize = true; + labelAdressOfJockey.Location = new Point(12, 39); + labelAdressOfJockey.Name = "labelAdressOfJockey"; + labelAdressOfJockey.Size = new Size(40, 15); + labelAdressOfJockey.TabIndex = 6; + labelAdressOfJockey.Text = "Адрес"; + // + // labelNumberOfJockey + // + labelNumberOfJockey.AutoSize = true; + labelNumberOfJockey.Location = new Point(12, 68); + labelNumberOfJockey.Name = "labelNumberOfJockey"; + labelNumberOfJockey.Size = new Size(56, 15); + labelNumberOfJockey.TabIndex = 7; + labelNumberOfJockey.Text = "Телефон"; + // + // labelAgeOfJockey + // + labelAgeOfJockey.AutoSize = true; + labelAgeOfJockey.Location = new Point(12, 96); + labelAgeOfJockey.Name = "labelAgeOfJockey"; + labelAgeOfJockey.Size = new Size(50, 15); + labelAgeOfJockey.TabIndex = 8; + labelAgeOfJockey.Text = "Возраст"; + // + // labelRateOfJockey + // + labelRateOfJockey.AutoSize = true; + labelRateOfJockey.Location = new Point(12, 125); + labelRateOfJockey.Name = "labelRateOfJockey"; + labelRateOfJockey.Size = new Size(51, 15); + labelRateOfJockey.TabIndex = 9; + labelRateOfJockey.Text = "Рейтинг"; + // + // buttonExit + // + buttonExit.Location = new Point(144, 167); + buttonExit.Name = "buttonExit"; + buttonExit.Size = new Size(75, 23); + buttonExit.TabIndex = 11; + buttonExit.Text = "Отмена"; + buttonExit.UseVisualStyleBackColor = true; + buttonExit.Click += ButtonExit_Click; + // + // buttonSave + // + buttonSave.Location = new Point(12, 167); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 10; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormJockey + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(239, 217); + Controls.Add(buttonExit); + Controls.Add(buttonSave); + Controls.Add(labelRateOfJockey); + Controls.Add(labelAgeOfJockey); + Controls.Add(labelNumberOfJockey); + Controls.Add(labelAdressOfJockey); + Controls.Add(labelNameOfJockey); + Controls.Add(textBoxNumberOfJockey); + Controls.Add(textBoxAdressOfJockey); + Controls.Add(numericUpDownRateOfJockey); + Controls.Add(numericUpDownAgeOfJockey); + Controls.Add(textBoxNameOfJockey); + Name = "FormJockey"; + Text = "Жокей"; + ((System.ComponentModel.ISupportInitialize)numericUpDownAgeOfJockey).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownRateOfJockey).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private TextBox textBoxNameOfJockey; + private NumericUpDown numericUpDownAgeOfJockey; + private NumericUpDown numericUpDownRateOfJockey; + private TextBox textBoxAdressOfJockey; + private TextBox textBoxNumberOfJockey; + private Label labelNameOfJockey; + private Label labelAdressOfJockey; + private Label labelNumberOfJockey; + private Label labelAgeOfJockey; + private Label labelRateOfJockey; + private Button buttonExit; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/ProjectRacing/Forms/Jockeys/FormJockey.cs b/ProjectRacing/Forms/Jockeys/FormJockey.cs new file mode 100644 index 0000000..ad7bb46 --- /dev/null +++ b/ProjectRacing/Forms/Jockeys/FormJockey.cs @@ -0,0 +1,60 @@ +using ProjectRacing.Repositories; +namespace ProjectRacing.Forms +{ + public partial class FormJockey : Form + { + private readonly IJockeyRepository _jockeyRepository; + private int? _jockeyId; + public int ID + { + set + { + try + { + var jockey = _jockeyRepository.GetJockeyById(value); + if (jockey == null) + { + throw new InvalidDataException(nameof(jockey)); + } + textBoxNumberOfJockey.Text = jockey.Number; + numericUpDownAgeOfJockey.Value = jockey.Age; + textBoxNameOfJockey.Text = jockey.NameOfJockey; + _jockeyId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + public FormJockey(IJockeyRepository jockeyRepository) + { + InitializeComponent(); + _jockeyRepository = jockeyRepository ?? throw new ArgumentNullException(nameof(jockeyRepository)); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxAdressOfJockey.Text)) throw new Exception("Адрес жокея не заполнен"); + if (string.IsNullOrWhiteSpace(textBoxNameOfJockey.Text)) throw new Exception("Имя не заполнено"); + if (string.IsNullOrWhiteSpace(textBoxNumberOfJockey.Text)) throw new Exception("Номер не заполнен"); + if (_jockeyId.HasValue) + { + _jockeyRepository.UpdateJockey(_jockeyId.Value); + } + else + { + _jockeyRepository.CreateJockey(CreateJockey(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonExit_Click(object sender, EventArgs e) => Close(); + private Entities.Jockey CreateJockey(int id) => Entities.Jockey.CreateEntity(id, textBoxNameOfJockey.Text, (int)numericUpDownAgeOfJockey.Value, (int)numericUpDownRateOfJockey.Value, textBoxNumberOfJockey.Text); + } +} diff --git a/ProjectRacing/Forms/Jockeys/FormJockey.resx b/ProjectRacing/Forms/Jockeys/FormJockey.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectRacing/Forms/Jockeys/FormJockey.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectRacing/Forms/Jockeys/FormJockeys.Designer.cs b/ProjectRacing/Forms/Jockeys/FormJockeys.Designer.cs new file mode 100644 index 0000000..678d787 --- /dev/null +++ b/ProjectRacing/Forms/Jockeys/FormJockeys.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectRacing.Forms.Jockeys +{ + partial class FormJockeys + { + /// + /// 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(); + buttonUpdate = new Button(); + buttonDelete = new Button(); + buttonAdd = new Button(); + dataGridViewHorses = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewHorses).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonUpdate); + panel1.Controls.Add(buttonDelete); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(684, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(116, 450); + panel1.TabIndex = 6; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.icons8_update_64; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(16, 146); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(75, 61); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.icons8_delete_480; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(16, 79); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(75, 61); + buttonDelete.TabIndex = 1; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icons8_add_100; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 61); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewHorses + // + dataGridViewHorses.AllowUserToAddRows = false; + dataGridViewHorses.AllowUserToDeleteRows = false; + dataGridViewHorses.AllowUserToResizeColumns = false; + dataGridViewHorses.AllowUserToResizeRows = false; + dataGridViewHorses.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewHorses.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewHorses.Dock = DockStyle.Fill; + dataGridViewHorses.Location = new Point(0, 0); + dataGridViewHorses.MultiSelect = false; + dataGridViewHorses.Name = "dataGridViewHorses"; + dataGridViewHorses.ReadOnly = true; + dataGridViewHorses.RowHeadersVisible = false; + dataGridViewHorses.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewHorses.Size = new Size(800, 450); + dataGridViewHorses.TabIndex = 7; + // + // FormJockeys + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel1); + Controls.Add(dataGridViewHorses); + Name = "FormJockeys"; + Text = "Жокеи"; + Load += FormJockeys_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewHorses).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonUpdate; + private Button buttonDelete; + private Button buttonAdd; + private DataGridView dataGridViewHorses; + } +} \ No newline at end of file diff --git a/ProjectRacing/Forms/Jockeys/FormJockeys.cs b/ProjectRacing/Forms/Jockeys/FormJockeys.cs new file mode 100644 index 0000000..0ddcc9a --- /dev/null +++ b/ProjectRacing/Forms/Jockeys/FormJockeys.cs @@ -0,0 +1,91 @@ +using ProjectRacing.Repositories; +using Unity; +namespace ProjectRacing.Forms.Jockeys +{ + public partial class FormJockeys : Form + { + private readonly IUnityContainer _container; + private readonly IJockeyRepository _jockeyRepository; + public FormJockeys(IUnityContainer container, IJockeyRepository jockeyRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _jockeyRepository = jockeyRepository ?? throw new ArgumentNullException(nameof(_jockeyRepository)); + } + private void FormJockeys_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromsSelectRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _jockeyRepository.DeleteJockey(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonUpdate_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromsSelectRow(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 LoadList() => dataGridViewHorses.DataSource = _jockeyRepository.GetJockeys(); + private bool TryGetIdentifierFromsSelectRow(out int id) + { + id = 0; + if (dataGridViewHorses.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewHorses.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ProjectRacing/Forms/Jockeys/FormJockeys.resx b/ProjectRacing/Forms/Jockeys/FormJockeys.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectRacing/Forms/Jockeys/FormJockeys.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectRacing/Forms/MedicalExamination/FormMedicalExamination.Designer.cs b/ProjectRacing/Forms/MedicalExamination/FormMedicalExamination.Designer.cs new file mode 100644 index 0000000..5af8c22 --- /dev/null +++ b/ProjectRacing/Forms/MedicalExamination/FormMedicalExamination.Designer.cs @@ -0,0 +1,139 @@ +namespace ProjectRacing.Forms.MedicalExamination +{ + partial class FormMedicalExamination + { + /// + /// 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() + { + labelHorse = new Label(); + labelResult = new Label(); + labelDate = new Label(); + comboBoxHorses = new ComboBox(); + button1 = new Button(); + button2 = new Button(); + dateTimePickerMedicalExamination = new DateTimePicker(); + comboBoxResult = new ComboBox(); + SuspendLayout(); + // + // labelHorse + // + labelHorse.AutoSize = true; + labelHorse.Location = new Point(12, 12); + labelHorse.Name = "labelHorse"; + labelHorse.Size = new Size(51, 15); + labelHorse.TabIndex = 0; + labelHorse.Text = "Лошадь"; + // + // labelResult + // + labelResult.AutoSize = true; + labelResult.Location = new Point(12, 88); + labelResult.Name = "labelResult"; + labelResult.Size = new Size(60, 15); + labelResult.TabIndex = 1; + labelResult.Text = "Результат"; + // + // labelDate + // + labelDate.AutoSize = true; + labelDate.Location = new Point(12, 53); + labelDate.Name = "labelDate"; + labelDate.Size = new Size(32, 15); + labelDate.TabIndex = 2; + labelDate.Text = "Дата"; + // + // comboBoxHorses + // + comboBoxHorses.FormattingEnabled = true; + comboBoxHorses.Location = new Point(78, 12); + comboBoxHorses.Name = "comboBoxHorses"; + comboBoxHorses.Size = new Size(121, 23); + comboBoxHorses.TabIndex = 3; + // + // button1 + // + button1.Location = new Point(12, 120); + button1.Name = "button1"; + button1.Size = new Size(75, 23); + button1.TabIndex = 4; + button1.Text = "Сохранить"; + button1.UseVisualStyleBackColor = true; + // + // button2 + // + button2.Location = new Point(124, 120); + button2.Name = "button2"; + button2.Size = new Size(75, 23); + button2.TabIndex = 5; + button2.Text = "Отмена"; + button2.UseVisualStyleBackColor = true; + // + // dateTimePickerMedicalExamination + // + dateTimePickerMedicalExamination.Location = new Point(78, 53); + dateTimePickerMedicalExamination.Name = "dateTimePickerMedicalExamination"; + dateTimePickerMedicalExamination.Size = new Size(200, 23); + dateTimePickerMedicalExamination.TabIndex = 6; + // + // comboBoxResult + // + comboBoxResult.FormattingEnabled = true; + comboBoxResult.Location = new Point(78, 85); + comboBoxResult.Name = "comboBoxResult"; + comboBoxResult.Size = new Size(121, 23); + comboBoxResult.TabIndex = 7; + // + // FormMedicalExamination + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(339, 220); + Controls.Add(comboBoxResult); + Controls.Add(dateTimePickerMedicalExamination); + Controls.Add(button2); + Controls.Add(button1); + Controls.Add(comboBoxHorses); + Controls.Add(labelDate); + Controls.Add(labelResult); + Controls.Add(labelHorse); + Name = "FormMedicalExamination"; + Text = "Медицинское обследование"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelHorse; + private Label labelResult; + private Label labelDate; + private ComboBox comboBoxHorses; + private Button button1; + private Button button2; + private DateTimePicker dateTimePickerMedicalExamination; + private ComboBox comboBoxResult; + } +} \ No newline at end of file diff --git a/ProjectRacing/Forms/MedicalExamination/FormMedicalExamination.cs b/ProjectRacing/Forms/MedicalExamination/FormMedicalExamination.cs new file mode 100644 index 0000000..9b1df5b --- /dev/null +++ b/ProjectRacing/Forms/MedicalExamination/FormMedicalExamination.cs @@ -0,0 +1,72 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectRacing.Entities; +using ProjectRacing.Entities.Enums; +using ProjectRacing.Repositories; + +namespace ProjectRacing.Forms.MedicalExamination +{ + public partial class FormMedicalExamination : Form + { + private readonly IMedicalExaminationRepository _medicalExaminationRepository; + private int? _medicalExaminationId; + public int ID + { + set + { + try + { + var medicalExamination = _medicalExaminationRepository.GetMedicalExaminationById(value); + if (medicalExamination == null) + { + throw new InvalidDataException(nameof(medicalExamination)); + } + comboBoxHorses.SelectedValue = medicalExamination.HorseId; + comboBoxResult.SelectedValue = medicalExamination.HealthStatus; + _medicalExaminationId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + public FormMedicalExamination(IHorseRepository horseRepository, IMedicalExaminationRepository medicalExamination) + { + InitializeComponent(); + _medicalExaminationRepository = medicalExamination ?? throw new ArgumentNullException(nameof(horseRepository)); + comboBoxHorses.DataSource = horseRepository.GetHorses(); + comboBoxHorses.DisplayMember = "NameOfHorse"; + comboBoxHorses.ValueMember = "Id"; + var healthStatusValues = Enum.GetValues(typeof(HealthStatus)); + foreach (var value in healthStatusValues) + { + comboBoxResult.Items.Add(value); + } + comboBoxResult.SelectedIndex = 0; + + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + + if (_medicalExaminationId.HasValue) + { + _medicalExaminationRepository.UpdateMedicalExamination(_medicalExaminationId.Value); + } + else + { + _medicalExaminationRepository.CreateMedicalExamination(CreateMedicalExamination(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonExit_Click(object sender, EventArgs e) => Close(); + private Entities.MedicalExamination CreateMedicalExamination(int id) => Entities.MedicalExamination.CreateEntity(id, DateOnly.FromDateTime(dateTimePickerMedicalExamination.Value),(HealthStatus)comboBoxResult.SelectedValue!, (int)comboBoxHorses.SelectedValue!); + } + +} diff --git a/ProjectRacing/Forms/MedicalExamination/FormMedicalExamination.resx b/ProjectRacing/Forms/MedicalExamination/FormMedicalExamination.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectRacing/Forms/MedicalExamination/FormMedicalExamination.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectRacing/Forms/MedicalExamination/FormMedicalExaminations.Designer.cs b/ProjectRacing/Forms/MedicalExamination/FormMedicalExaminations.Designer.cs new file mode 100644 index 0000000..4cd5a12 --- /dev/null +++ b/ProjectRacing/Forms/MedicalExamination/FormMedicalExaminations.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectRacing.Forms.MedicalExamination +{ + partial class FormMedicalExaminations + { + /// + /// 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(); + buttonUpdate = new Button(); + buttonDelete = new Button(); + buttonAdd = new Button(); + dataGridViewHorses = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewHorses).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonUpdate); + panel1.Controls.Add(buttonDelete); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(684, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(116, 450); + panel1.TabIndex = 8; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.icons8_update_64; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(16, 146); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(75, 61); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.icons8_delete_480; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(16, 79); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(75, 61); + buttonDelete.TabIndex = 1; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icons8_add_100; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 61); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewHorses + // + dataGridViewHorses.AllowUserToAddRows = false; + dataGridViewHorses.AllowUserToDeleteRows = false; + dataGridViewHorses.AllowUserToResizeColumns = false; + dataGridViewHorses.AllowUserToResizeRows = false; + dataGridViewHorses.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewHorses.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewHorses.Dock = DockStyle.Fill; + dataGridViewHorses.Location = new Point(0, 0); + dataGridViewHorses.MultiSelect = false; + dataGridViewHorses.Name = "dataGridViewHorses"; + dataGridViewHorses.ReadOnly = true; + dataGridViewHorses.RowHeadersVisible = false; + dataGridViewHorses.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewHorses.Size = new Size(800, 450); + dataGridViewHorses.TabIndex = 9; + // + // FormMedicalExaminations + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel1); + Controls.Add(dataGridViewHorses); + Name = "FormMedicalExaminations"; + Text = "Медицинские обследования"; + Load += FormMedicalExaminations_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewHorses).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonUpdate; + private Button buttonDelete; + private Button buttonAdd; + private DataGridView dataGridViewHorses; + } +} \ No newline at end of file diff --git a/ProjectRacing/Forms/MedicalExamination/FormMedicalExaminations.cs b/ProjectRacing/Forms/MedicalExamination/FormMedicalExaminations.cs new file mode 100644 index 0000000..91a4f74 --- /dev/null +++ b/ProjectRacing/Forms/MedicalExamination/FormMedicalExaminations.cs @@ -0,0 +1,92 @@ +using ProjectRacing.Repositories; +using Unity; + +namespace ProjectRacing.Forms.MedicalExamination +{ + public partial class FormMedicalExaminations : Form + { + private readonly IUnityContainer _container; + private readonly IMedicalExaminationRepository _medicalExaminationRepository; + public FormMedicalExaminations(IUnityContainer container, IMedicalExaminationRepository medicalExaminationRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _medicalExaminationRepository = medicalExaminationRepository ?? throw new ArgumentNullException(nameof(medicalExaminationRepository)); + } + private void FormMedicalExaminations_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromsSelectRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _medicalExaminationRepository.DeleteMedicalExamination(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonUpdate_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromsSelectRow(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 LoadList() => dataGridViewHorses.DataSource = _medicalExaminationRepository.GetMedicalExaminations(); + private bool TryGetIdentifierFromsSelectRow(out int id) + { + id = 0; + if (dataGridViewHorses.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewHorses.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ProjectRacing/Forms/MedicalExamination/FormMedicalExaminations.resx b/ProjectRacing/Forms/MedicalExamination/FormMedicalExaminations.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectRacing/Forms/MedicalExamination/FormMedicalExaminations.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectRacing/Forms/Owners/FormOwner.Designer.cs b/ProjectRacing/Forms/Owners/FormOwner.Designer.cs new file mode 100644 index 0000000..744478d --- /dev/null +++ b/ProjectRacing/Forms/Owners/FormOwner.Designer.cs @@ -0,0 +1,139 @@ +namespace ProjectRacing.Forms.Owners +{ + partial class FormOwner + { + /// + /// 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() + { + labelNameOfOwner = new Label(); + labelNumberOfOwner = new Label(); + textBoxNumberOfOwner = new TextBox(); + textBoxNameOfOwner = new TextBox(); + labelAdressOfOwner = new Label(); + textBoxAdressOfOwner = new TextBox(); + buttonExit = new Button(); + buttonSave = new Button(); + SuspendLayout(); + // + // labelNameOfOwner + // + labelNameOfOwner.AutoSize = true; + labelNameOfOwner.Location = new Point(12, 15); + labelNameOfOwner.Name = "labelNameOfOwner"; + labelNameOfOwner.Size = new Size(31, 15); + labelNameOfOwner.TabIndex = 0; + labelNameOfOwner.Text = "Имя"; + // + // labelNumberOfOwner + // + labelNumberOfOwner.AutoSize = true; + labelNumberOfOwner.Location = new Point(12, 58); + labelNumberOfOwner.Name = "labelNumberOfOwner"; + labelNumberOfOwner.Size = new Size(56, 15); + labelNumberOfOwner.TabIndex = 1; + labelNumberOfOwner.Text = "Телефон"; + // + // textBoxNumberOfOwner + // + textBoxNumberOfOwner.Location = new Point(74, 55); + textBoxNumberOfOwner.Name = "textBoxNumberOfOwner"; + textBoxNumberOfOwner.Size = new Size(100, 23); + textBoxNumberOfOwner.TabIndex = 2; + // + // textBoxNameOfOwner + // + textBoxNameOfOwner.Location = new Point(74, 15); + textBoxNameOfOwner.Name = "textBoxNameOfOwner"; + textBoxNameOfOwner.Size = new Size(100, 23); + textBoxNameOfOwner.TabIndex = 3; + // + // labelAdressOfOwner + // + labelAdressOfOwner.AutoSize = true; + labelAdressOfOwner.Location = new Point(12, 90); + labelAdressOfOwner.Name = "labelAdressOfOwner"; + labelAdressOfOwner.Size = new Size(40, 15); + labelAdressOfOwner.TabIndex = 4; + labelAdressOfOwner.Text = "Адрес"; + // + // textBoxAdressOfOwner + // + textBoxAdressOfOwner.Location = new Point(74, 90); + textBoxAdressOfOwner.Name = "textBoxAdressOfOwner"; + textBoxAdressOfOwner.Size = new Size(100, 23); + textBoxAdressOfOwner.TabIndex = 5; + // + // buttonExit + // + buttonExit.Location = new Point(137, 134); + buttonExit.Name = "buttonExit"; + buttonExit.Size = new Size(75, 23); + buttonExit.TabIndex = 7; + buttonExit.Text = "Отмена"; + buttonExit.UseVisualStyleBackColor = true; + buttonExit.Click += ButtonExit_Click; + // + // buttonSave + // + buttonSave.Location = new Point(5, 134); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormOwner + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(215, 167); + Controls.Add(buttonExit); + Controls.Add(buttonSave); + Controls.Add(textBoxAdressOfOwner); + Controls.Add(labelAdressOfOwner); + Controls.Add(textBoxNameOfOwner); + Controls.Add(textBoxNumberOfOwner); + Controls.Add(labelNumberOfOwner); + Controls.Add(labelNameOfOwner); + Name = "FormOwner"; + Text = "Владелец"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelNameOfOwner; + private Label labelNumberOfOwner; + private TextBox textBoxNumberOfOwner; + private TextBox textBoxNameOfOwner; + private Label labelAdressOfOwner; + private TextBox textBoxAdressOfOwner; + private Button buttonExit; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/ProjectRacing/Forms/Owners/FormOwner.cs b/ProjectRacing/Forms/Owners/FormOwner.cs new file mode 100644 index 0000000..cc42af0 --- /dev/null +++ b/ProjectRacing/Forms/Owners/FormOwner.cs @@ -0,0 +1,61 @@ +using ProjectRacing.Repositories; +namespace ProjectRacing.Forms.Owners +{ + public partial class FormOwner : Form + { + private readonly IOwnerRepository _ownerRepository; + private int? _ownerId; + public int ID + { + set + { + try + { + var owner = _ownerRepository.GetOwnerById(value); + if (owner == null) + { + throw new InvalidDataException(nameof(owner)); + } + textBoxAdressOfOwner.Text = owner.Adress; + textBoxNameOfOwner.Text = owner.NameOfOwner; + textBoxNumberOfOwner.Text = owner.Number; + _ownerId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + public FormOwner(IOwnerRepository ownerRepository) + { + InitializeComponent(); + _ownerRepository = ownerRepository ?? throw new ArgumentNullException(nameof(ownerRepository)); + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxAdressOfOwner.Text)) throw new Exception("Адрес владельца не заполнен"); + if (string.IsNullOrWhiteSpace(textBoxNameOfOwner.Text)) throw new Exception("Имя не заполнено"); + if (string.IsNullOrWhiteSpace(textBoxNumberOfOwner.Text)) throw new Exception("Номер владельца не заполнен"); + + if (_ownerId.HasValue) + { + _ownerRepository.UpdateOwner(_ownerId.Value); + } + else + { + _ownerRepository.CreateOwner(CreateOwner(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonExit_Click(object sender, EventArgs e) => Close(); + private Entities.Owner CreateOwner(int id) => Entities.Owner.CreateEntity(id, textBoxNameOfOwner.Text, textBoxNumberOfOwner.Text, textBoxAdressOfOwner.Text); + } +} diff --git a/ProjectRacing/Forms/Owners/FormOwner.resx b/ProjectRacing/Forms/Owners/FormOwner.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectRacing/Forms/Owners/FormOwner.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectRacing/Forms/Owners/FormOwners.Designer.cs b/ProjectRacing/Forms/Owners/FormOwners.Designer.cs new file mode 100644 index 0000000..1e8bd95 --- /dev/null +++ b/ProjectRacing/Forms/Owners/FormOwners.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectRacing.Forms +{ + partial class FormOwners + { + /// + /// 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(); + buttonUpdate = new Button(); + buttonDelete = new Button(); + buttonAdd = new Button(); + dataGridViewHorses = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewHorses).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonUpdate); + panel1.Controls.Add(buttonDelete); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(684, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(116, 450); + panel1.TabIndex = 6; + // + // buttonUpdate + // + buttonUpdate.BackgroundImage = Properties.Resources.icons8_update_64; + buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpdate.Location = new Point(16, 146); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(75, 61); + buttonUpdate.TabIndex = 2; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // buttonDelete + // + buttonDelete.BackgroundImage = Properties.Resources.icons8_delete_480; + buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; + buttonDelete.Location = new Point(16, 79); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(75, 61); + buttonDelete.TabIndex = 1; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icons8_add_100; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 61); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridViewHorses + // + dataGridViewHorses.AllowUserToAddRows = false; + dataGridViewHorses.AllowUserToDeleteRows = false; + dataGridViewHorses.AllowUserToResizeColumns = false; + dataGridViewHorses.AllowUserToResizeRows = false; + dataGridViewHorses.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewHorses.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewHorses.Dock = DockStyle.Fill; + dataGridViewHorses.Location = new Point(0, 0); + dataGridViewHorses.MultiSelect = false; + dataGridViewHorses.Name = "dataGridViewHorses"; + dataGridViewHorses.ReadOnly = true; + dataGridViewHorses.RowHeadersVisible = false; + dataGridViewHorses.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewHorses.Size = new Size(800, 450); + dataGridViewHorses.TabIndex = 7; + // + // FormOwners + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel1); + Controls.Add(dataGridViewHorses); + Name = "FormOwners"; + Text = "Владельцы"; + Load += FormOwners_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewHorses).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonUpdate; + private Button buttonDelete; + private Button buttonAdd; + private DataGridView dataGridViewHorses; + } +} \ No newline at end of file diff --git a/ProjectRacing/Forms/Owners/FormOwners.cs b/ProjectRacing/Forms/Owners/FormOwners.cs new file mode 100644 index 0000000..820391c --- /dev/null +++ b/ProjectRacing/Forms/Owners/FormOwners.cs @@ -0,0 +1,92 @@ +using ProjectRacing.Forms.Owners; +using ProjectRacing.Repositories; +using Unity; +namespace ProjectRacing.Forms +{ + public partial class FormOwners : Form + { + private readonly IUnityContainer _container; + private readonly IOwnerRepository _ownerRepository; + public FormOwners(IUnityContainer container, IOwnerRepository ownerRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _ownerRepository = ownerRepository ?? throw new ArgumentNullException(nameof(ownerRepository)); + } + private void FormOwners_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void ButtonDelete_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromsSelectRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _ownerRepository.DeleteOwner(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonUpdate_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromsSelectRow(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 LoadList() => dataGridViewHorses.DataSource = _ownerRepository.GetOwners(); + private bool TryGetIdentifierFromsSelectRow(out int id) + { + id = 0; + if (dataGridViewHorses.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewHorses.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ProjectRacing/Forms/Owners/FormOwners.resx b/ProjectRacing/Forms/Owners/FormOwners.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ProjectRacing/Forms/Owners/FormOwners.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ProjectRacing/Program.cs b/ProjectRacing/Program.cs index 37944a8..2a9b57c 100644 --- a/ProjectRacing/Program.cs +++ b/ProjectRacing/Program.cs @@ -1,3 +1,4 @@ + using ProjectRacing.Repositories; using ProjectRacing.Repositories.Implementations; using Unity; @@ -26,6 +27,7 @@ namespace ProjectRacing container.RegisterType(); container.RegisterType(); container.RegisterType(); + container.RegisterType < IMedicalExaminationRepository, MedicalExaminationRepository> (); return container; } } diff --git a/ProjectRacing/ProjectRacing.csproj b/ProjectRacing/ProjectRacing.csproj index 894afcd..6b260fe 100644 --- a/ProjectRacing/ProjectRacing.csproj +++ b/ProjectRacing/ProjectRacing.csproj @@ -10,6 +10,22 @@ + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + \ No newline at end of file diff --git a/ProjectRacing/Properties/Resources.Designer.cs b/ProjectRacing/Properties/Resources.Designer.cs new file mode 100644 index 0000000..e9e6577 --- /dev/null +++ b/ProjectRacing/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectRacing.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectRacing.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_add_100 { + get { + object obj = ResourceManager.GetObject("icons8-add-100", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_delete_480 { + get { + object obj = ResourceManager.GetObject("icons8-delete-480", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_update_64 { + get { + object obj = ResourceManager.GetObject("icons8-update-64", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap orig { + get { + object obj = ResourceManager.GetObject("orig", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectRacing/Properties/Resources.resx b/ProjectRacing/Properties/Resources.resx new file mode 100644 index 0000000..7fdb7a6 --- /dev/null +++ b/ProjectRacing/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\Resources\icons8-delete-480.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\orig.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icons8-add-100.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icons8-update-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectRacing/Repositories/ICompetitionsRepository.cs b/ProjectRacing/Repositories/ICompetitionsRepository.cs index 63c55f9..3ca6f20 100644 --- a/ProjectRacing/Repositories/ICompetitionsRepository.cs +++ b/ProjectRacing/Repositories/ICompetitionsRepository.cs @@ -1,11 +1,10 @@ using ProjectRacing.Entities; - namespace ProjectRacing.Repositories; public interface ICompetitionsRepository { IEnumerable GetCompetitionses(); - Competitions GetCompetitionsById(int id); + Competitions GetCompetitionById(int id); void CreateCompetitions(Competitions competitions); - void UpdateCompetitions(Competitions competitions); + void UpdateCompetitions(int id); void DeleteCompetitions(int id); } \ No newline at end of file diff --git a/ProjectRacing/Repositories/IHorseRepository.cs b/ProjectRacing/Repositories/IHorseRepository.cs index d1c73e9..2db7364 100644 --- a/ProjectRacing/Repositories/IHorseRepository.cs +++ b/ProjectRacing/Repositories/IHorseRepository.cs @@ -5,6 +5,6 @@ public interface IHorseRepository IEnumerable GetHorses(); Horse GetHorseById(int id); void CreateHorse(Horse horse); - void UpdateHorse(Horse horse); + void UpdateHorse(int id); void DeleteHorse(int id); } \ No newline at end of file diff --git a/ProjectRacing/Repositories/IJockeyRepository.cs b/ProjectRacing/Repositories/IJockeyRepository.cs index 45736ba..30f6e52 100644 --- a/ProjectRacing/Repositories/IJockeyRepository.cs +++ b/ProjectRacing/Repositories/IJockeyRepository.cs @@ -1,11 +1,10 @@ using ProjectRacing.Entities; - namespace ProjectRacing.Repositories; public interface IJockeyRepository { IEnumerable GetJockeys(); Jockey GetJockeyById(int id); void CreateJockey(Jockey jockey); - void UpdateJockey(Jockey jockey); + void UpdateJockey(int id); void DeleteJockey(int id); } \ No newline at end of file diff --git a/ProjectRacing/Repositories/IMedicalExaminationRepository.cs b/ProjectRacing/Repositories/IMedicalExaminationRepository.cs new file mode 100644 index 0000000..2a66236 --- /dev/null +++ b/ProjectRacing/Repositories/IMedicalExaminationRepository.cs @@ -0,0 +1,10 @@ +using ProjectRacing.Entities; +namespace ProjectRacing.Repositories; +public interface IMedicalExaminationRepository +{ + IEnumerable GetMedicalExaminations(); + MedicalExamination GetMedicalExaminationById(int id); + void CreateMedicalExamination(MedicalExamination medicalExamination); + void UpdateMedicalExamination(int id); + void DeleteMedicalExamination(int id); +} \ No newline at end of file diff --git a/ProjectRacing/Repositories/IOwnerRepository.cs b/ProjectRacing/Repositories/IOwnerRepository.cs index a725a38..cc93a85 100644 --- a/ProjectRacing/Repositories/IOwnerRepository.cs +++ b/ProjectRacing/Repositories/IOwnerRepository.cs @@ -1,11 +1,10 @@ using ProjectRacing.Entities; - namespace ProjectRacing.Repositories; public interface IOwnerRepository { - IEnumerable GetOwner(); + IEnumerable GetOwners(); Owner GetOwnerById(int id); void CreateOwner(Owner owner); - void UpdateOwner(Owner owner); + void UpdateOwner(int id); void DeleteOwner(int id); } \ No newline at end of file diff --git a/ProjectRacing/Repositories/IParticipantsRepository.cs b/ProjectRacing/Repositories/IParticipantsRepository.cs index 878db50..ffdae2e 100644 --- a/ProjectRacing/Repositories/IParticipantsRepository.cs +++ b/ProjectRacing/Repositories/IParticipantsRepository.cs @@ -1,11 +1,10 @@ using ProjectRacing.Entities; - namespace ProjectRacing.Repositories; public interface IParticipantsRepository { IEnumerable GetParticipants(); Participants GetParticipantsById(int id); void CreateParticipants(Participants participants); - void UpdateParticipants(Participants participants); + void UpdateParticipants(int id); void DeleteParticipants(int id); } \ No newline at end of file diff --git a/ProjectRacing/Repositories/Implementations/CompetitionsRepository.cs b/ProjectRacing/Repositories/Implementations/CompetitionsRepository.cs index 8c0536f..b380a61 100644 --- a/ProjectRacing/Repositories/Implementations/CompetitionsRepository.cs +++ b/ProjectRacing/Repositories/Implementations/CompetitionsRepository.cs @@ -1,28 +1,25 @@ using ProjectRacing.Entities; namespace ProjectRacing.Repositories.Implementations; -internal class CompetitionsRepository : ICompetitionsRepository +public class CompetitionsRepository : ICompetitionsRepository { public void CreateCompetitions(Competitions competitions) { } - public void DeleteCompetitions(int id) { } - - public Competitions GetCompetitionsById(int id) + public Competitions GetCompetitionById(int id) { - return Competitions.CreateEntity(0, new DateOnly(0001,1,1), string.Empty); + return Competitions.CreateEntity(0, new DateOnly(0001,1,1), string.Empty, string.Empty); } public IEnumerable GetCompetitionses() { return []; } - - public void UpdateCompetitions(Competitions competitions) + public void UpdateCompetitions(int id) { } diff --git a/ProjectRacing/Repositories/Implementations/HorseRepository.cs b/ProjectRacing/Repositories/Implementations/HorseRepository.cs index 66dbbb8..2107335 100644 --- a/ProjectRacing/Repositories/Implementations/HorseRepository.cs +++ b/ProjectRacing/Repositories/Implementations/HorseRepository.cs @@ -14,7 +14,7 @@ public class HorseRepository : IHorseRepository public Horse GetHorseById(int id) { - return Horse.CreateEntity(0, string.Empty, true, new DateOnly(0001, 1, 1), 0); + return Horse.CreateEntity(0, string.Empty, 0, new DateOnly(0001, 1, 1), 0); } public IEnumerable GetHorses() @@ -22,7 +22,7 @@ public class HorseRepository : IHorseRepository return []; } - public void UpdateHorse(Horse horse) + public void UpdateHorse(int id) { } diff --git a/ProjectRacing/Repositories/Implementations/JockeyRepository.cs b/ProjectRacing/Repositories/Implementations/JockeyRepository.cs index 6aec417..8216684 100644 --- a/ProjectRacing/Repositories/Implementations/JockeyRepository.cs +++ b/ProjectRacing/Repositories/Implementations/JockeyRepository.cs @@ -1,28 +1,24 @@ using ProjectRacing.Entities; namespace ProjectRacing.Repositories.Implementations; -internal class JockeyRepository : IJockeyRepository +public class JockeyRepository : IJockeyRepository { public void CreateJockey(Jockey jockey) { } - public void DeleteJockey(int id) { } - public Jockey GetJockeyById(int id) { return Jockey.CreateEntity(0, string.Empty, 0, 0, string.Empty); } - public IEnumerable GetJockeys() { return []; } - - public void UpdateJockey(Jockey jockey) + public void UpdateJockey(int id) { } diff --git a/ProjectRacing/Repositories/Implementations/MedicalExaminationRepository.cs b/ProjectRacing/Repositories/Implementations/MedicalExaminationRepository.cs new file mode 100644 index 0000000..1ce800e --- /dev/null +++ b/ProjectRacing/Repositories/Implementations/MedicalExaminationRepository.cs @@ -0,0 +1,28 @@ +namespace ProjectRacing.Repositories.Implementations; +public class MedicalExaminationRepository : IMedicalExaminationRepository +{ + public void CreateMedicalExamination(Entities.MedicalExamination medicalExamination) + { + + } + + public void DeleteMedicalExamination(int id) + { + + } + + public Entities.MedicalExamination GetMedicalExaminationById(int id) + { + return Entities.MedicalExamination.CreateEntity(0, new DateOnly(0001,1,1), 0, 0); + } + + public IEnumerable GetMedicalExaminations() + { + return []; + } + + public void UpdateMedicalExamination(int id) + { + + } +} diff --git a/ProjectRacing/Repositories/Implementations/OwnerRepository.cs b/ProjectRacing/Repositories/Implementations/OwnerRepository.cs index 51c394e..8be5507 100644 --- a/ProjectRacing/Repositories/Implementations/OwnerRepository.cs +++ b/ProjectRacing/Repositories/Implementations/OwnerRepository.cs @@ -1,28 +1,24 @@ using ProjectRacing.Entities; namespace ProjectRacing.Repositories.Implementations; -internal class OwnerRepository : IOwnerRepository +public class OwnerRepository : IOwnerRepository { public void CreateOwner(Owner owner) { } - public void DeleteOwner(int id) { } - - public IEnumerable GetOwner() + public IEnumerable GetOwners() { return []; } - public Owner GetOwnerById(int id) { - return Owner.CreateEntity(0, string.Empty, string.Empty); + return Owner.CreateEntity(0, string.Empty, string.Empty, string.Empty); } - - public void UpdateOwner(Owner owner) + public void UpdateOwner(int id) { } diff --git a/ProjectRacing/Repositories/Implementations/ParticipantsRepository.cs b/ProjectRacing/Repositories/Implementations/ParticipantsRepository.cs index a637e57..79ee30d 100644 --- a/ProjectRacing/Repositories/Implementations/ParticipantsRepository.cs +++ b/ProjectRacing/Repositories/Implementations/ParticipantsRepository.cs @@ -1,12 +1,11 @@ using ProjectRacing.Entities; namespace ProjectRacing.Repositories.Implementations; -internal class ParticipantsRepository : IParticipantsRepository +public class ParticipantsRepository : IParticipantsRepository { public void CreateParticipants(Participants participants) { } - public void DeleteParticipants(int id) { @@ -19,10 +18,10 @@ internal class ParticipantsRepository : IParticipantsRepository public Participants GetParticipantsById(int id) { - return Participants.CreateEntity(0, 0, 0, 0, TimeSpan.Zero, 0); + return Participants.CreateEntity(0, 0, 0, 0, 0); } - public void UpdateParticipants(Participants participants) + public void UpdateParticipants(int id) { } diff --git a/ProjectRacing/Resources/icons8-add-100.png b/ProjectRacing/Resources/icons8-add-100.png new file mode 100644 index 0000000..14a75be Binary files /dev/null and b/ProjectRacing/Resources/icons8-add-100.png differ diff --git a/ProjectRacing/Resources/icons8-delete-480.png b/ProjectRacing/Resources/icons8-delete-480.png new file mode 100644 index 0000000..27ee658 Binary files /dev/null and b/ProjectRacing/Resources/icons8-delete-480.png differ diff --git a/ProjectRacing/Resources/icons8-update-64.png b/ProjectRacing/Resources/icons8-update-64.png new file mode 100644 index 0000000..38ca330 Binary files /dev/null and b/ProjectRacing/Resources/icons8-update-64.png differ diff --git a/ProjectRacing/Resources/orig.png b/ProjectRacing/Resources/orig.png new file mode 100644 index 0000000..648f9b1 Binary files /dev/null and b/ProjectRacing/Resources/orig.png differ