1 лабораторная работа

This commit is contained in:
Алёна Фролова 2024-11-25 16:23:53 +04:00
parent 6e6f74bae3
commit d590a26fb9
71 changed files with 5353 additions and 75 deletions

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Entities;
public class BuyHorse
{
public int Id { get; private set; }
public int OwnersId { get; private set; }
public DateTime DatePurchase { get; private set; }
public IEnumerable<BuyHorseHorse> BuyHorseHorses { get; private set; } = [];
public static BuyHorse CreateEntity(int id, int ownerId,DateTime date, IEnumerable<BuyHorseHorse> buyHorseHorses)
{
return new BuyHorse
{
Id = id,
OwnersId = ownerId,
DatePurchase = date,
BuyHorseHorses = buyHorseHorses
};
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ProjectHorseRacing.Entities;
public class BuyHorseHorse
{
public int Id { get; private set; }
public int HorseId { get; private set; }
public static BuyHorseHorse CreateElement(int id, int horseId)
{
return new BuyHorseHorse
{
Id = id,
HorseId = horseId
};
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Entities.Enums;
[Flags]
public enum HorseCharacters
{
None = 0,
Быстрая = 1,
Выносливая = 2,
Спокойная = 4,
Сильная = 8,
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Entities.Enums;
public enum HorseGender
{
None = 0,
Женский = 1,
Мужской = 2
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Entities.Enums;
public enum RacePlaceEvent
{
None = 0,
Ипподром_1 = 1,
Ипподром_2 = 2,
Ипподром_3 = 3,
Ипподром_4 = 4
}

View File

@ -0,0 +1,34 @@
using ProjectHorseRacing.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Entities;
public class Horse
{
public int Id { get; private set; }
public string Nickname { get; private set; } = string.Empty;
public HorseGender HorseGender { get; private set; }
public int AgeHorse { get; private set; }
public HorseCharacters HorseCharacters { get; private set; }
public static Horse CreateHorse(int id, string nickname, HorseGender horseGender, int ageHorse, HorseCharacters horseCharacters)
{
return new Horse
{
Id = id,
Nickname = nickname,
HorseGender = horseGender,
AgeHorse = ageHorse,
HorseCharacters = horseCharacters
};
}
}

View File

@ -0,0 +1,34 @@
using ProjectHorseRacing.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Entities;
public class Jockey
{
public int Id { get; private set; }
public string FistName { get; private set; } = string.Empty;
public string LastName { get; private set; } = string.Empty;
public int Age { get; private set; }
public double Rating { get; private set; }
public static Jockey CreateEntity(int id, string fistName, string lastName, int age, double rating)
{
return new Jockey
{
Id = id,
FistName = fistName,
LastName = lastName,
Age = age,
Rating = rating
};
}
}

View File

@ -0,0 +1,29 @@
namespace ProjectHorseRacing.Entities;
public class Owners
{
public int Id { get;private set; }
public string FistName { get; private set; } = string.Empty;
public string LastName { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public string PhoneNumber { get; private set; } = string.Empty;
public static Owners CreateEntity(int id, string fistName, string lastName, string address, string phoneNumber)
{
return new Owners
{
Id = id,
FistName = fistName,
LastName = lastName,
Address = address,
PhoneNumber = phoneNumber,
};
}
}

View File

@ -0,0 +1,29 @@
using ProjectHorseRacing.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Entities;
public class Race
{
public int Id { get; private set; }
public DateTime DateTime { get; private set; }
public RacePlaceEvent RacePlaceEvent { get; private set; }
public static Race CreateOperation(int id, DateTime dateTime, RacePlaceEvent racePlaceEvent)
{
return new Race
{
Id = id,
DateTime = dateTime,
RacePlaceEvent = racePlaceEvent
};
}
}

View File

@ -0,0 +1,34 @@
using ProjectHorseRacing.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Entities;
public class Result
{
public int Id { get; private set; }
public int Position { get; private set; }
public int RacesId { get; private set; }
public int JockeyId { get; private set; }
public int HorsesId { get; private set; }
public static Result CreateEntity(int id, int position, int racesId, int jockeyId, int horsesId)
{
return new Result
{
Id = id,
Position = position,
RacesId = racesId,
JockeyId = jockeyId,
HorsesId = horsesId
};
}
}

View File

@ -1,39 +0,0 @@
namespace ProjectHorseRacing
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace ProjectHorseRacing
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,147 @@
namespace ProjectHorseRacing
{
partial class FormHorseRacing
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
menuStrip1 = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem();
JockeyToolStripMenuItem = new ToolStripMenuItem();
HorseToolStripMenuItem = new ToolStripMenuItem();
RaceToolStripMenuItem = new ToolStripMenuItem();
владелецToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
ResultToolStripMenuItem = new ToolStripMenuItem();
ListHorseToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
SuspendLayout();
//
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(20, 20);
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(782, 28);
menuStrip1.TabIndex = 0;
menuStrip1.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { JockeyToolStripMenuItem, HorseToolStripMenuItem, RaceToolStripMenuItem, владелецToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники";
//
// JockeyToolStripMenuItem
//
JockeyToolStripMenuItem.Name = "JockeyToolStripMenuItem";
JockeyToolStripMenuItem.Size = new Size(224, 26);
JockeyToolStripMenuItem.Text = "Жокей";
JockeyToolStripMenuItem.Click += JockeyToolStripMenuItem_Click;
//
// HorseToolStripMenuItem
//
HorseToolStripMenuItem.Name = "HorseToolStripMenuItem";
HorseToolStripMenuItem.Size = new Size(224, 26);
HorseToolStripMenuItem.Text = "Лошадь";
HorseToolStripMenuItem.Click += HorseToolStripMenuItem_Click;
//
// RaceToolStripMenuItem
//
RaceToolStripMenuItem.Name = "RaceToolStripMenuItem";
RaceToolStripMenuItem.Size = new Size(224, 26);
RaceToolStripMenuItem.Text = "Скачки";
RaceToolStripMenuItem.Click += RaceToolStripMenuItem_Click;
//
// владелецToolStripMenuItem
//
владелецToolStripMenuItem.Name = "владелецToolStripMenuItem";
владелецToolStripMenuItem.Size = new Size(224, 26);
владелецToolStripMenuItem.Text = "Владелец";
владелецToolStripMenuItem.Click += владелецToolStripMenuItem_Click;
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ResultToolStripMenuItem, ListHorseToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(95, 24);
операцииToolStripMenuItem.Text = "Операции";
//
// ResultToolStripMenuItem
//
ResultToolStripMenuItem.Name = "ResultToolStripMenuItem";
ResultToolStripMenuItem.Size = new Size(216, 26);
ResultToolStripMenuItem.Text = "Результат";
ResultToolStripMenuItem.Click += ResultToolStripMenuItem_Click;
//
// ListHorseToolStripMenuItem
//
ListHorseToolStripMenuItem.Name = "ListHorseToolStripMenuItem";
ListHorseToolStripMenuItem.Size = new Size(216, 26);
ListHorseToolStripMenuItem.Text = "Покупка лошадей";
ListHorseToolStripMenuItem.Click += ListHorseToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(73, 24);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// FormHorseRacing
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.скачки;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(782, 403);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
Name = "FormHorseRacing";
StartPosition = FormStartPosition.CenterScreen;
Text = "Скачки";
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip1;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem JockeyToolStripMenuItem;
private ToolStripMenuItem HorseToolStripMenuItem;
private ToolStripMenuItem RaceToolStripMenuItem;
private ToolStripMenuItem ResultToolStripMenuItem;
private ToolStripMenuItem ListHorseToolStripMenuItem;
private ToolStripMenuItem владелецToolStripMenuItem;
}
}

View File

@ -0,0 +1,102 @@
using ProjectHorseRacing.Forms;
using System.ComponentModel;
using Unity;
namespace ProjectHorseRacing
{
public partial class FormHorseRacing : Form
{
private readonly IUnityContainer _container;
public FormHorseRacing(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void JockeyToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormJockeys>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void HorseToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormHorses>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void RaceToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormRaces>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ResultToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormResult>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ListHorseToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormBuyHorses>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void âëàäåëåöToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormOwners>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,170 @@
namespace ProjectHorseRacing.Forms
{
partial class FormBuyHorse
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
SaveButtonOwner = new Button();
CancelButtonOwner = new Button();
groupBox = new GroupBox();
dataGridView = new DataGridView();
label2 = new Label();
comboBoxOwner = new ComboBox();
dateTimePicker = new DateTimePicker();
label3 = new Label();
ColumnHorse = new DataGridViewComboBoxColumn();
groupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// SaveButtonOwner
//
SaveButtonOwner.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
SaveButtonOwner.Location = new Point(109, 512);
SaveButtonOwner.Name = "SaveButtonOwner";
SaveButtonOwner.Size = new Size(94, 29);
SaveButtonOwner.TabIndex = 26;
SaveButtonOwner.Text = "Сохранить";
SaveButtonOwner.UseVisualStyleBackColor = true;
SaveButtonOwner.Click += SaveButtonOwner_Click;
//
// CancelButtonOwner
//
CancelButtonOwner.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
CancelButtonOwner.Location = new Point(287, 512);
CancelButtonOwner.Name = "CancelButtonOwner";
CancelButtonOwner.Size = new Size(94, 29);
CancelButtonOwner.TabIndex = 38;
CancelButtonOwner.Text = "Отмена";
CancelButtonOwner.UseVisualStyleBackColor = true;
CancelButtonOwner.Click += CancelButtonOwner_Click;
//
// groupBox
//
groupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBox.Controls.Add(dataGridView);
groupBox.Location = new Point(25, 165);
groupBox.Name = "groupBox";
groupBox.Size = new Size(438, 329);
groupBox.TabIndex = 40;
groupBox.TabStop = false;
groupBox.Text = "Лошади";
//
// dataGridView
//
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnHorse });
dataGridView.Location = new Point(0, 32);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(432, 291);
dataGridView.TabIndex = 0;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(88, 43);
label2.Name = "label2";
label2.Size = new Size(78, 20);
label2.TabIndex = 42;
label2.Text = "Владелец:";
//
// comboBoxOwner
//
comboBoxOwner.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxOwner.FormattingEnabled = true;
comboBoxOwner.Location = new Point(190, 35);
comboBoxOwner.Name = "comboBoxOwner";
comboBoxOwner.Size = new Size(223, 28);
comboBoxOwner.TabIndex = 41;
//
// dateTimePicker
//
dateTimePicker.Location = new Point(190, 103);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(223, 27);
dateTimePicker.TabIndex = 43;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(61, 110);
label3.Name = "label3";
label3.Size = new Size(105, 20);
label3.TabIndex = 44;
label3.Text = "Дата покупки:";
//
// ColumnHorse
//
ColumnHorse.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnHorse.HeaderText = "Лошадь";
ColumnHorse.MinimumWidth = 6;
ColumnHorse.Name = "ColumnHorse";
//
// FormBuyHorse
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(490, 562);
Controls.Add(label3);
Controls.Add(dateTimePicker);
Controls.Add(label2);
Controls.Add(comboBoxOwner);
Controls.Add(groupBox);
Controls.Add(CancelButtonOwner);
Controls.Add(SaveButtonOwner);
Name = "FormBuyHorse";
StartPosition = FormStartPosition.CenterParent;
Text = "Покупка лошадей";
groupBox.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private Button CancelButtonOwner;
private Button SaveButtonOwner;
private ComboBox comboBoxCharacters;
private GroupBox groupBox1;
private GroupBox groupBox;
private DataGridView dataGridView;
private Label label2;
private ComboBox comboBoxOwner;
private DataGridViewComboBoxColumn ColumnHorse;
private DateTimePicker dateTimePicker;
private Label label3;
}
}

View File

@ -0,0 +1,65 @@
using ProjectHorseRacing.Entities;
using ProjectHorseRacing.Repositories;
namespace ProjectHorseRacing.Forms;
public partial class FormBuyHorse : Form
{
private readonly IBuyHorseRepository _buyHorseRepository;
public FormBuyHorse(
IBuyHorseRepository buyHorseRepository,
IOwnerRepository ownerRepository,
IHorseRepository horseRepository)
{
InitializeComponent();
_buyHorseRepository = buyHorseRepository ??
throw new ArgumentNullException(nameof(buyHorseRepository));
comboBoxOwner.DataSource = ownerRepository.ReadOwners();
comboBoxOwner.DisplayMember = "LastName";
comboBoxOwner.ValueMember = "Id";
ColumnHorse.DataSource = horseRepository.ReadHorses();
ColumnHorse.DisplayMember = "Nickname";
ColumnHorse.ValueMember = "Id";
}
private void SaveButtonOwner_Click(object sender, EventArgs e)
{
try
{
if (comboBoxOwner.SelectedIndex < 0 ||
dataGridView.RowCount < 1)
{
throw new Exception("Имеются незаполненные поля");
}
_buyHorseRepository.CreateBuyHorse(BuyHorse.CreateEntity(0,
(int)comboBoxOwner.SelectedValue!,
dateTimePicker.Value,
CreateListBuyHorsesListFromDataGrid()));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CancelButtonOwner_Click(object sender, EventArgs e) => Close();
private List<BuyHorseHorse> CreateListBuyHorsesListFromDataGrid()
{
var list = new List<BuyHorseHorse>();
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (row.Cells["ColumnHorse"].Value == null)
{
continue;
}
list.Add(BuyHorseHorse.CreateElement(
0,
Convert.ToInt32(row.Cells["ColumnHorse"].Value)));
}
return list;
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ColumnHorse.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,125 @@
namespace ProjectHorseRacing.Forms
{
partial class FormBuyHorses
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
dataGridView = new DataGridView();
buttonUpd = new Button();
buttonDel = new Button();
buttonAdd = new Button();
panelJockey = new Panel();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
panelJockey.SuspendLayout();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(637, 450);
dataGridView.TabIndex = 3;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.карандаш;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(34, 161);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(94, 94);
buttonUpd.TabIndex = 2;
buttonUpd.UseVisualStyleBackColor = true;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.минус;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(34, 287);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(94, 94);
buttonDel.TabIndex = 1;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.плюс;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(34, 38);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 94);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// panelJockey
//
panelJockey.Controls.Add(buttonUpd);
panelJockey.Controls.Add(buttonDel);
panelJockey.Controls.Add(buttonAdd);
panelJockey.Dock = DockStyle.Right;
panelJockey.Location = new Point(637, 0);
panelJockey.Name = "panelJockey";
panelJockey.Size = new Size(163, 450);
panelJockey.TabIndex = 2;
//
// FormBuyHorses
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panelJockey);
Name = "FormBuyHorses";
Text = "Покупка лошадей";
Load += FormBuyHorses_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
panelJockey.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonUpd;
private Button buttonDel;
private Button buttonAdd;
private Panel panelJockey;
}
}

View File

@ -0,0 +1,93 @@
using ProjectHorseRacing.Repositories;
using ProjectHorseRacing.Repositories.Implementation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectHorseRacing.Forms;
public partial class FormBuyHorses : Form
{
private readonly IUnityContainer _container;
private readonly IBuyHorseRepository _buyHorseRepository;
public FormBuyHorses(IUnityContainer container, IBuyHorseRepository buyHorseRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_buyHorseRepository = buyHorseRepository ??
throw new ArgumentNullException(nameof(buyHorseRepository));
}
private void FormBuyHorses_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<FormBuyHorse>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_buyHorseRepository.DeleteBuyHorse(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _buyHorseRepository.ReadBuyHorse();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
return true;
}
}

View File

@ -0,0 +1,169 @@
namespace ProjectHorseRacing.Forms
{
partial class FormHorse
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
comboBoxHorseGender = new ComboBox();
CancelButtonHorse = new Button();
SaveButtonHorse = new Button();
textBoxNicknameHorse = new TextBox();
NickNameHorse = new Label();
AgeHorse = new Label();
numericUpAgeHorse = new NumericUpDown();
GenderHorse = new Label();
Characters = new Label();
checkedListBoxHorseCharacters = new CheckedListBox();
((System.ComponentModel.ISupportInitialize)numericUpAgeHorse).BeginInit();
SuspendLayout();
//
// comboBoxHorseGender
//
comboBoxHorseGender.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxHorseGender.FormattingEnabled = true;
comboBoxHorseGender.Location = new Point(237, 87);
comboBoxHorseGender.Name = "comboBoxHorseGender";
comboBoxHorseGender.Size = new Size(151, 28);
comboBoxHorseGender.TabIndex = 0;
//
// CancelButtonHorse
//
CancelButtonHorse.Location = new Point(273, 376);
CancelButtonHorse.Name = "CancelButtonHorse";
CancelButtonHorse.Size = new Size(94, 29);
CancelButtonHorse.TabIndex = 17;
CancelButtonHorse.Text = "Отмена";
CancelButtonHorse.UseVisualStyleBackColor = true;
CancelButtonHorse.Click += CancelButtonHorse_Click_1;
//
// SaveButtonHorse
//
SaveButtonHorse.Location = new Point(138, 376);
SaveButtonHorse.Name = "SaveButtonHorse";
SaveButtonHorse.Size = new Size(94, 29);
SaveButtonHorse.TabIndex = 16;
SaveButtonHorse.Text = "Сохранить";
SaveButtonHorse.UseVisualStyleBackColor = true;
SaveButtonHorse.Click += SaveButtonHorse_Click;
//
// textBoxNicknameHorse
//
textBoxNicknameHorse.Location = new Point(237, 39);
textBoxNicknameHorse.Name = "textBoxNicknameHorse";
textBoxNicknameHorse.Size = new Size(241, 27);
textBoxNicknameHorse.TabIndex = 13;
//
// NickNameHorse
//
NickNameHorse.AutoSize = true;
NickNameHorse.Location = new Point(31, 46);
NickNameHorse.Name = "NickNameHorse";
NickNameHorse.Size = new Size(119, 20);
NickNameHorse.TabIndex = 10;
NickNameHorse.Text = "Кличка лошади:";
//
// AgeHorse
//
AgeHorse.AutoSize = true;
AgeHorse.Location = new Point(31, 141);
AgeHorse.Name = "AgeHorse";
AgeHorse.Size = new Size(125, 20);
AgeHorse.TabIndex = 18;
AgeHorse.Text = "Возраст лошади:";
//
// numericUpAgeHorse
//
numericUpAgeHorse.Location = new Point(238, 141);
numericUpAgeHorse.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
numericUpAgeHorse.Name = "numericUpAgeHorse";
numericUpAgeHorse.Size = new Size(150, 27);
numericUpAgeHorse.TabIndex = 19;
numericUpAgeHorse.Value = new decimal(new int[] { 1, 0, 0, 0 });
//
// GenderHorse
//
GenderHorse.AutoSize = true;
GenderHorse.Location = new Point(31, 95);
GenderHorse.Name = "GenderHorse";
GenderHorse.Size = new Size(98, 20);
GenderHorse.TabIndex = 20;
GenderHorse.Text = "Пол лошади:";
//
// Characters
//
Characters.AutoSize = true;
Characters.Location = new Point(31, 194);
Characters.Name = "Characters";
Characters.Size = new Size(180, 20);
Characters.TabIndex = 21;
Characters.Text = "Характеристика лошади:";
//
// checkedListBoxHorseCharacters
//
checkedListBoxHorseCharacters.FormattingEnabled = true;
checkedListBoxHorseCharacters.Location = new Point(237, 194);
checkedListBoxHorseCharacters.Name = "checkedListBoxHorseCharacters";
checkedListBoxHorseCharacters.Size = new Size(211, 136);
checkedListBoxHorseCharacters.TabIndex = 22;
//
// FormHorse
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(515, 450);
Controls.Add(checkedListBoxHorseCharacters);
Controls.Add(Characters);
Controls.Add(GenderHorse);
Controls.Add(numericUpAgeHorse);
Controls.Add(AgeHorse);
Controls.Add(CancelButtonHorse);
Controls.Add(SaveButtonHorse);
Controls.Add(textBoxNicknameHorse);
Controls.Add(NickNameHorse);
Controls.Add(comboBoxHorseGender);
Name = "FormHorse";
Text = "Лошадь";
((System.ComponentModel.ISupportInitialize)numericUpAgeHorse).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private ComboBox comboBoxHorseGender;
private ComboBox comboBoxCharactersHorse;
private Button CancelButtonHorse;
private Button SaveButtonHorse;
private TextBox textBoxNicknameHorse;
private Label NickNameHorse;
private Label AgeHorse;
private NumericUpDown numericUpAgeHorse;
private Label GenderHorse;
private Label Characters;
private CheckedListBox checkedListBoxHorseCharacters;
}
}

View File

@ -0,0 +1,116 @@
using ProjectHorseRacing.Entities;
using ProjectHorseRacing.Entities.Enums;
using ProjectHorseRacing.Repositories;
using ProjectHorseRacing.Repositories.Implementation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectHorseRacing.Forms;
public partial class FormHorse : Form
{
private readonly IHorseRepository _horseRepository;
private int? _horseId;
public int Id
{
set
{
try
{
var horse = _horseRepository.ReadHorseById(value);
if (horse == null)
{
throw new InvalidDataException(nameof(horse));
}
foreach (HorseCharacters elem in Enum.GetValues(typeof(HorseCharacters)))
{
if ((elem & horse.HorseCharacters) != 0)
{
checkedListBoxHorseCharacters.SetItemChecked(checkedListBoxHorseCharacters.Items.IndexOf(elem), true);
}
}
textBoxNicknameHorse.Text = horse.Nickname;
comboBoxHorseGender.SelectedItem = horse.HorseGender;
numericUpAgeHorse.Value = horse.AgeHorse;
_horseId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormHorse(IHorseRepository horseRepository)
{
InitializeComponent();
_horseRepository = horseRepository ??
throw new ArgumentNullException(nameof(horseRepository));
comboBoxHorseGender.DataSource = Enum.GetValues(typeof(HorseGender));
foreach (var elem in Enum.GetValues(typeof(HorseCharacters)))
{
checkedListBoxHorseCharacters.Items.Add(elem);
}
}
private void SaveButtonHorse_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxNicknameHorse.Text) ||
comboBoxHorseGender.SelectedIndex < 1 ||
checkedListBoxHorseCharacters.CheckedItems.Count == 0)
{
throw new Exception("Имеются незаполненные поля");
}
if (_horseId.HasValue)
{
_horseRepository.UpdateHorse(CreateHorse(_horseId.Value));
}
else
{
_horseRepository.CreateHorse(CreateHorse(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CancelButtonHorse_Click_1(object sender, EventArgs e) => Close();
private Horse CreateHorse(int id)
{
HorseCharacters horseCharacters = HorseCharacters.None;
foreach (var elem in checkedListBoxHorseCharacters.CheckedItems)
{
horseCharacters |= (HorseCharacters)elem;
}
return Horse.CreateHorse(id, textBoxNicknameHorse.Text, (HorseGender)comboBoxHorseGender.SelectedIndex,
Convert.ToInt32(numericUpAgeHorse.Value), horseCharacters);
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,126 @@
namespace ProjectHorseRacing.Forms
{
partial class FormHorses
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
panelHorses = new Panel();
ButtonUpd = new Button();
ButtonDel = new Button();
ButtonAdd = new Button();
dataGridView = new DataGridView();
panelHorses.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panelHorses
//
panelHorses.Controls.Add(ButtonUpd);
panelHorses.Controls.Add(ButtonDel);
panelHorses.Controls.Add(ButtonAdd);
panelHorses.Dock = DockStyle.Right;
panelHorses.Location = new Point(685, 0);
panelHorses.Name = "panelHorses";
panelHorses.Size = new Size(153, 427);
panelHorses.TabIndex = 0;
//
// ButtonUpd
//
ButtonUpd.BackgroundImage = Properties.Resources.карандаш;
ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch;
ButtonUpd.Location = new Point(29, 165);
ButtonUpd.Name = "ButtonUpd";
ButtonUpd.Size = new Size(94, 94);
ButtonUpd.TabIndex = 5;
ButtonUpd.UseVisualStyleBackColor = true;
ButtonUpd.Click += ButtonUpd_Click;
//
// ButtonDel
//
ButtonDel.BackgroundImage = Properties.Resources.минус;
ButtonDel.BackgroundImageLayout = ImageLayout.Stretch;
ButtonDel.Location = new Point(29, 291);
ButtonDel.Name = "ButtonDel";
ButtonDel.Size = new Size(94, 94);
ButtonDel.TabIndex = 4;
ButtonDel.UseVisualStyleBackColor = true;
ButtonDel.Click += ButtonDel_Click;
//
// ButtonAdd
//
ButtonAdd.BackgroundImage = Properties.Resources.плюс;
ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch;
ButtonAdd.Location = new Point(29, 42);
ButtonAdd.Name = "ButtonAdd";
ButtonAdd.Size = new Size(94, 94);
ButtonAdd.TabIndex = 3;
ButtonAdd.UseVisualStyleBackColor = true;
ButtonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(685, 427);
dataGridView.TabIndex = 1;
//
// FormHorses
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(838, 427);
Controls.Add(dataGridView);
Controls.Add(panelHorses);
Name = "FormHorses";
Text = "Лошади";
Load += FormHorses_Load;
Click += FormHorses_Load;
panelHorses.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panelHorses;
private DataGridView dataGridView;
private Button ButtonUpd;
private Button ButtonDel;
private Button ButtonAdd;
}
}

View File

@ -0,0 +1,113 @@
using ProjectHorseRacing.Repositories;
using ProjectHorseRacing.Repositories.Implementation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectHorseRacing.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<FormHorse>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormHorse>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(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 LoadList() => dataGridView.DataSource = _horseRepository.ReadHorses();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
return true;
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,171 @@
namespace ProjectHorseRacing.Forms
{
partial class FormJockey
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
FirstNameJokey = new Label();
AgeJockey = new Label();
RatingJockey = new Label();
textBoxFirstNameJokey = new TextBox();
numericUpDownAgeJockey = new NumericUpDown();
numericUpDownRatingJockey = new NumericUpDown();
SaveButtonJockey = new Button();
CancelButtonJockey = new Button();
textBoxLastNameJokey = new TextBox();
LastNameJokey = new Label();
((System.ComponentModel.ISupportInitialize)numericUpDownAgeJockey).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownRatingJockey).BeginInit();
SuspendLayout();
//
// FirstNameJokey
//
FirstNameJokey.AutoSize = true;
FirstNameJokey.Location = new Point(21, 38);
FirstNameJokey.Name = "FirstNameJokey";
FirstNameJokey.Size = new Size(89, 20);
FirstNameJokey.TabIndex = 0;
FirstNameJokey.Text = "Имя жокея:";
//
// AgeJockey
//
AgeJockey.AutoSize = true;
AgeJockey.Location = new Point(22, 131);
AgeJockey.Name = "AgeJockey";
AgeJockey.Size = new Size(114, 20);
AgeJockey.TabIndex = 1;
AgeJockey.Text = "Возраст жокея:";
//
// RatingJockey
//
RatingJockey.AutoSize = true;
RatingJockey.Location = new Point(22, 182);
RatingJockey.Name = "RatingJockey";
RatingJockey.Size = new Size(114, 20);
RatingJockey.TabIndex = 2;
RatingJockey.Text = "Рейтинг жокея:";
//
// textBoxFirstNameJokey
//
textBoxFirstNameJokey.Location = new Point(153, 31);
textBoxFirstNameJokey.Name = "textBoxFirstNameJokey";
textBoxFirstNameJokey.Size = new Size(234, 27);
textBoxFirstNameJokey.TabIndex = 3;
//
// numericUpDownAgeJockey
//
numericUpDownAgeJockey.Location = new Point(154, 124);
numericUpDownAgeJockey.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
numericUpDownAgeJockey.Name = "numericUpDownAgeJockey";
numericUpDownAgeJockey.Size = new Size(125, 27);
numericUpDownAgeJockey.TabIndex = 6;
numericUpDownAgeJockey.Value = new decimal(new int[] { 1, 0, 0, 0 });
//
// numericUpDownRatingJockey
//
numericUpDownRatingJockey.DecimalPlaces = 2;
numericUpDownRatingJockey.Location = new Point(154, 175);
numericUpDownRatingJockey.Minimum = new decimal(new int[] { 1, 0, 0, 131072 });
numericUpDownRatingJockey.Name = "numericUpDownRatingJockey";
numericUpDownRatingJockey.Size = new Size(125, 27);
numericUpDownRatingJockey.TabIndex = 7;
numericUpDownRatingJockey.Value = new decimal(new int[] { 1, 0, 0, 131072 });
//
// SaveButtonJockey
//
SaveButtonJockey.Location = new Point(96, 253);
SaveButtonJockey.Name = "SaveButtonJockey";
SaveButtonJockey.Size = new Size(94, 29);
SaveButtonJockey.TabIndex = 8;
SaveButtonJockey.Text = "Сохранить";
SaveButtonJockey.UseVisualStyleBackColor = true;
SaveButtonJockey.Click += SaveButtonJockey_Click;
//
// CancelButtonJockey
//
CancelButtonJockey.Location = new Point(231, 253);
CancelButtonJockey.Name = "CancelButtonJockey";
CancelButtonJockey.Size = new Size(94, 29);
CancelButtonJockey.TabIndex = 9;
CancelButtonJockey.Text = "Отмена";
CancelButtonJockey.UseVisualStyleBackColor = true;
CancelButtonJockey.Click += CancelButtonJockey_Click;
//
// textBoxLastNameJokey
//
textBoxLastNameJokey.Location = new Point(153, 77);
textBoxLastNameJokey.Name = "textBoxLastNameJokey";
textBoxLastNameJokey.Size = new Size(234, 27);
textBoxLastNameJokey.TabIndex = 11;
//
// LastNameJokey
//
LastNameJokey.AutoSize = true;
LastNameJokey.Location = new Point(21, 84);
LastNameJokey.Name = "LastNameJokey";
LastNameJokey.Size = new Size(123, 20);
LastNameJokey.TabIndex = 10;
LastNameJokey.Text = "Фамилия жокея:";
//
// FormJockey
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(425, 320);
Controls.Add(textBoxLastNameJokey);
Controls.Add(LastNameJokey);
Controls.Add(CancelButtonJockey);
Controls.Add(SaveButtonJockey);
Controls.Add(numericUpDownRatingJockey);
Controls.Add(numericUpDownAgeJockey);
Controls.Add(textBoxFirstNameJokey);
Controls.Add(RatingJockey);
Controls.Add(AgeJockey);
Controls.Add(FirstNameJokey);
Name = "FormJockey";
StartPosition = FormStartPosition.CenterParent;
Text = "Жокей";
((System.ComponentModel.ISupportInitialize)numericUpDownAgeJockey).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownRatingJockey).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label FirstNameJokey;
private Label AgeJockey;
private Label RatingJockey;
private TextBox textBoxFirstNameJokey;
private NumericUpDown numericUpDownAgeJockey;
private NumericUpDown numericUpDownRatingJockey;
private Button SaveButtonJockey;
private Button CancelButtonJockey;
private TextBox textBoxLastNameJokey;
private Label LastNameJokey;
}
}

View File

@ -0,0 +1,91 @@
using ProjectHorseRacing.Entities;
using ProjectHorseRacing.Repositories;
using ProjectHorseRacing.Repositories.Implementation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectHorseRacing.Forms;
public partial class FormJockey : Form
{
private readonly IJockeyRepository _jockeyRepository;
private int? _jockeyId;
public int Id
{
set
{
try
{
var jockey = _jockeyRepository.ReadJockeyById(value);
if (jockey == null)
{
throw new InvalidDataException(nameof(jockey));
}
textBoxFirstNameJokey.Text = jockey.FistName;
textBoxLastNameJokey.Text = jockey.LastName;
numericUpDownAgeJockey.Value = jockey.Age;
numericUpDownRatingJockey.Value = (decimal)jockey.Rating;
_jockeyId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormJockey(IJockeyRepository jockeyRepository)
{
InitializeComponent();
_jockeyRepository = jockeyRepository ??
throw new ArgumentNullException(nameof(jockeyRepository));
}
private void SaveButtonJockey_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxFirstNameJokey.Text) ||
string.IsNullOrWhiteSpace(textBoxLastNameJokey.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_jockeyId.HasValue)
{
_jockeyRepository.UpdateJockey(CreateJockey(_jockeyId.Value));
}
else
{
_jockeyRepository.CreateJockey(CreateJockey(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CancelButtonJockey_Click(object sender, EventArgs e) => Close();
private Jockey CreateJockey(int id) => Jockey.CreateEntity(id,
textBoxFirstNameJokey.Text, textBoxLastNameJokey.Text,
Convert.ToInt32(numericUpDownAgeJockey.Value),
Convert.ToDouble(numericUpDownRatingJockey.Value));
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,127 @@
namespace ProjectHorseRacing.Forms
{
partial class FormJockeys
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
panelJockey = new Panel();
buttonUpd = new Button();
buttonDel = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panelJockey.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panelJockey
//
panelJockey.Controls.Add(buttonUpd);
panelJockey.Controls.Add(buttonDel);
panelJockey.Controls.Add(buttonAdd);
panelJockey.Dock = DockStyle.Right;
panelJockey.Location = new Point(683, 0);
panelJockey.Name = "panelJockey";
panelJockey.Size = new Size(163, 425);
panelJockey.TabIndex = 0;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.карандаш;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(34, 161);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(94, 94);
buttonUpd.TabIndex = 2;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.минус;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(34, 287);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(94, 94);
buttonDel.TabIndex = 1;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.плюс;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(34, 38);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 94);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(683, 425);
dataGridView.TabIndex = 1;
//
// FormJockeys
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(846, 425);
Controls.Add(dataGridView);
Controls.Add(panelJockey);
Name = "FormJockeys";
StartPosition = FormStartPosition.CenterParent;
Text = "Жокеи";
Load += FormJockeys_Load;
panelJockey.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panelJockey;
private Button buttonUpd;
private Button buttonDel;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,115 @@
using ProjectHorseRacing.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectHorseRacing.Forms;
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<FormJockey>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormJockey>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(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 LoadList() => dataGridView.DataSource = _jockeyRepository.ReadJockeys();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
return true;
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,161 @@
namespace ProjectHorseRacing.Forms
{
partial class FormOwner
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
textBoxLastNameOwner = new TextBox();
LastNameJokey = new Label();
CancelButtonOwner = new Button();
SaveButtonOwner = new Button();
textBoxFirstNameOwner = new TextBox();
RatingJockey = new Label();
AgeJockey = new Label();
FirstNameJokey = new Label();
textBoxAddressOwner = new TextBox();
textBoxPhoneNumberOwner = new TextBox();
SuspendLayout();
//
// textBoxLastNameOwner
//
textBoxLastNameOwner.Location = new Point(245, 81);
textBoxLastNameOwner.Name = "textBoxLastNameOwner";
textBoxLastNameOwner.Size = new Size(234, 27);
textBoxLastNameOwner.TabIndex = 21;
//
// LastNameJokey
//
LastNameJokey.AutoSize = true;
LastNameJokey.Location = new Point(31, 84);
LastNameJokey.Name = "LastNameJokey";
LastNameJokey.Size = new Size(153, 20);
LastNameJokey.TabIndex = 20;
LastNameJokey.Text = "Фамилия владельца:";
//
// CancelButtonOwner
//
CancelButtonOwner.Location = new Point(293, 253);
CancelButtonOwner.Name = "CancelButtonOwner";
CancelButtonOwner.Size = new Size(94, 29);
CancelButtonOwner.TabIndex = 19;
CancelButtonOwner.Text = "Отмена";
CancelButtonOwner.UseVisualStyleBackColor = true;
CancelButtonOwner.Click += CancelButtonOwner_Click;
//
// SaveButtonOwner
//
SaveButtonOwner.Location = new Point(106, 253);
SaveButtonOwner.Name = "SaveButtonOwner";
SaveButtonOwner.Size = new Size(94, 29);
SaveButtonOwner.TabIndex = 18;
SaveButtonOwner.Text = "Сохранить";
SaveButtonOwner.UseVisualStyleBackColor = true;
SaveButtonOwner.Click += SaveButtonOwner_Click;
//
// textBoxFirstNameOwner
//
textBoxFirstNameOwner.Location = new Point(245, 35);
textBoxFirstNameOwner.Name = "textBoxFirstNameOwner";
textBoxFirstNameOwner.Size = new Size(234, 27);
textBoxFirstNameOwner.TabIndex = 15;
//
// RatingJockey
//
RatingJockey.AutoSize = true;
RatingJockey.Location = new Point(32, 182);
RatingJockey.Name = "RatingJockey";
RatingJockey.Size = new Size(207, 20);
RatingJockey.TabIndex = 14;
RatingJockey.Text = "Номер телефона владельца:";
//
// AgeJockey
//
AgeJockey.AutoSize = true;
AgeJockey.Location = new Point(32, 131);
AgeJockey.Name = "AgeJockey";
AgeJockey.Size = new Size(131, 20);
AgeJockey.TabIndex = 13;
AgeJockey.Text = "Адрес владельца:";
//
// FirstNameJokey
//
FirstNameJokey.AutoSize = true;
FirstNameJokey.Location = new Point(31, 38);
FirstNameJokey.Name = "FirstNameJokey";
FirstNameJokey.Size = new Size(119, 20);
FirstNameJokey.TabIndex = 12;
FirstNameJokey.Text = "Имя владельца:";
//
// textBoxAddressOwner
//
textBoxAddressOwner.Location = new Point(245, 128);
textBoxAddressOwner.Name = "textBoxAddressOwner";
textBoxAddressOwner.Size = new Size(234, 27);
textBoxAddressOwner.TabIndex = 22;
//
// textBoxPhoneNumberOwner
//
textBoxPhoneNumberOwner.Location = new Point(245, 179);
textBoxPhoneNumberOwner.Name = "textBoxPhoneNumberOwner";
textBoxPhoneNumberOwner.Size = new Size(234, 27);
textBoxPhoneNumberOwner.TabIndex = 23;
//
// FormOwner
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(513, 315);
Controls.Add(textBoxPhoneNumberOwner);
Controls.Add(textBoxAddressOwner);
Controls.Add(textBoxLastNameOwner);
Controls.Add(LastNameJokey);
Controls.Add(CancelButtonOwner);
Controls.Add(SaveButtonOwner);
Controls.Add(textBoxFirstNameOwner);
Controls.Add(RatingJockey);
Controls.Add(AgeJockey);
Controls.Add(FirstNameJokey);
Name = "FormOwner";
Text = "Владелец";
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBoxLastNameOwner;
private Label LastNameJokey;
private Button CancelButtonOwner;
private Button SaveButtonOwner;
private TextBox textBoxFirstNameOwner;
private Label RatingJockey;
private Label AgeJockey;
private Label FirstNameJokey;
private TextBox textBoxAddressOwner;
private TextBox textBoxPhoneNumberOwner;
}
}

View File

@ -0,0 +1,88 @@
using ProjectHorseRacing.Entities;
using ProjectHorseRacing.Repositories;
using ProjectHorseRacing.Repositories.Implementation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectHorseRacing.Forms;
public partial class FormOwner : Form
{
private readonly IOwnerRepository _ownerRepository;
private int? _ownerId;
public int Id
{
set
{
try
{
var owner = _ownerRepository.ReadOwnerById(value);
if (owner == null)
{
throw new InvalidDataException(nameof(owner));
}
textBoxFirstNameOwner.Text = owner.FistName;
textBoxLastNameOwner.Text = owner.LastName;
textBoxAddressOwner.Text = owner.Address;
textBoxPhoneNumberOwner.Text = owner.PhoneNumber;
_ownerId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormOwner(IOwnerRepository ownerRepository)
{
InitializeComponent();
_ownerRepository = ownerRepository ??
throw new ArgumentNullException(nameof(ownerRepository));
}
private void SaveButtonOwner_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxFirstNameOwner.Text) ||
string.IsNullOrWhiteSpace(textBoxLastNameOwner.Text) ||
string.IsNullOrWhiteSpace(textBoxAddressOwner.Text) ||
string.IsNullOrWhiteSpace(textBoxPhoneNumberOwner.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_ownerId.HasValue)
{
_ownerRepository.UpdateOwner(CreateOwner(_ownerId.Value));
}
else
{
_ownerRepository.CreateOwner(CreateOwner(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CancelButtonOwner_Click(object sender, EventArgs e) => Close();
private Owners CreateOwner(int id) => Owners.CreateEntity(id,
textBoxFirstNameOwner.Text, textBoxLastNameOwner.Text,
textBoxAddressOwner.Text, textBoxPhoneNumberOwner.Text);
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,125 @@
namespace ProjectHorseRacing.Forms
{
partial class FormOwners
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
buttonDel = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panelOwner = new Panel();
ButtonUpd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
panelOwner.SuspendLayout();
SuspendLayout();
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.минус;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(34, 287);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(94, 94);
buttonDel.TabIndex = 1;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.плюс;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(34, 38);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 94);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(637, 450);
dataGridView.TabIndex = 3;
//
// panelOwner
//
panelOwner.Controls.Add(ButtonUpd);
panelOwner.Controls.Add(buttonDel);
panelOwner.Controls.Add(buttonAdd);
panelOwner.Dock = DockStyle.Right;
panelOwner.Location = new Point(637, 0);
panelOwner.Name = "panelOwner";
panelOwner.Size = new Size(163, 450);
panelOwner.TabIndex = 2;
//
// ButtonUpd
//
ButtonUpd.BackgroundImage = Properties.Resources.карандаш;
ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch;
ButtonUpd.Location = new Point(34, 163);
ButtonUpd.Name = "ButtonUpd";
ButtonUpd.Size = new Size(94, 94);
ButtonUpd.TabIndex = 6;
ButtonUpd.UseVisualStyleBackColor = true;
ButtonUpd.Click += ButtonUpd_Click;
//
// FormOwners
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panelOwner);
Name = "FormOwners";
Text = "Владельцы";
Load += FormOwners_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
panelOwner.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private Button buttonDel;
private Button buttonAdd;
private DataGridView dataGridView;
private Panel panelOwner;
private Button ButtonUpd;
}
}

View File

@ -0,0 +1,114 @@
using ProjectHorseRacing.Repositories;
using ProjectHorseRacing.Repositories.Implementation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectHorseRacing.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<FormOwner>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(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 LoadList() => dataGridView.DataSource = _ownerRepository.ReadOwners();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
return true;
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormOwner>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,128 @@
namespace ProjectHorseRacing.Forms
{
partial class FormRace
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
GenderHorse = new Label();
CancelButtonHorse = new Button();
SaveButtonHorse = new Button();
DateTime = new Label();
comboBoxPlaceEvent = new ComboBox();
dateTimePicker = new DateTimePicker();
dateTimePicker1 = new DateTimePicker();
SuspendLayout();
//
// GenderHorse
//
GenderHorse.AutoSize = true;
GenderHorse.Location = new Point(30, 89);
GenderHorse.Name = "GenderHorse";
GenderHorse.Size = new Size(194, 20);
GenderHorse.TabIndex = 30;
GenderHorse.Text = "Место проведения скачки:";
//
// CancelButtonHorse
//
CancelButtonHorse.Location = new Point(265, 149);
CancelButtonHorse.Name = "CancelButtonHorse";
CancelButtonHorse.Size = new Size(94, 29);
CancelButtonHorse.TabIndex = 27;
CancelButtonHorse.Text = "Отмена";
CancelButtonHorse.UseVisualStyleBackColor = true;
CancelButtonHorse.Click += CancelButtonHorse_Click;
//
// SaveButtonHorse
//
SaveButtonHorse.Location = new Point(130, 149);
SaveButtonHorse.Name = "SaveButtonHorse";
SaveButtonHorse.Size = new Size(94, 29);
SaveButtonHorse.TabIndex = 26;
SaveButtonHorse.Text = "Сохранить";
SaveButtonHorse.UseVisualStyleBackColor = true;
SaveButtonHorse.Click += SaveButtonHorse_Click;
//
// DateTime
//
DateTime.AutoSize = true;
DateTime.Location = new Point(30, 35);
DateTime.Name = "DateTime";
DateTime.Size = new Size(183, 20);
DateTime.TabIndex = 24;
DateTime.Text = "Дата проведения скачки:";
//
// comboBoxPlaceEvent
//
comboBoxPlaceEvent.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxPlaceEvent.FormattingEnabled = true;
comboBoxPlaceEvent.Location = new Point(246, 81);
comboBoxPlaceEvent.Name = "comboBoxPlaceEvent";
comboBoxPlaceEvent.Size = new Size(190, 28);
comboBoxPlaceEvent.TabIndex = 22;
//
// dateTimePicker
//
dateTimePicker.Location = new Point(0, 0);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(200, 27);
dateTimePicker.TabIndex = 0;
//
// dateTimePicker1
//
dateTimePicker1.Location = new Point(244, 34);
dateTimePicker1.Name = "dateTimePicker1";
dateTimePicker1.Size = new Size(192, 27);
dateTimePicker1.TabIndex = 31;
//
// FormRace
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(477, 218);
Controls.Add(dateTimePicker1);
Controls.Add(GenderHorse);
Controls.Add(CancelButtonHorse);
Controls.Add(SaveButtonHorse);
Controls.Add(DateTime);
Controls.Add(comboBoxPlaceEvent);
Name = "FormRace";
StartPosition = FormStartPosition.CenterParent;
Text = "Скачка";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label GenderHorse;
private Button CancelButtonHorse;
private Button SaveButtonHorse;
private Label DateTime;
private ComboBox comboBoxPlaceEvent;
private DateTimePicker dateTimePicker;
private DateTimePicker dateTimePicker1;
}
}

View File

@ -0,0 +1,87 @@
using ProjectHorseRacing.Entities;
using ProjectHorseRacing.Entities.Enums;
using ProjectHorseRacing.Repositories;
using ProjectHorseRacing.Repositories.Implementation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectHorseRacing.Forms;
public partial class FormRace : Form
{
private readonly IRaceRepository _raceRepository;
private int? _raceId;
public int Id
{
set
{
try
{
var race = _raceRepository.ReadRaceById(value);
if (race == null)
{
throw new InvalidDataException(nameof(race));
}
dateTimePicker.Value = race.DateTime;
comboBoxPlaceEvent.SelectedItem = race.RacePlaceEvent;
_raceId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormRace(IRaceRepository raceRepository)
{
InitializeComponent();
_raceRepository = raceRepository ??
throw new ArgumentNullException(nameof(raceRepository));
comboBoxPlaceEvent.DataSource = Enum.GetValues(typeof(RacePlaceEvent));
}
private void SaveButtonHorse_Click(object sender, EventArgs e)
{
try
{
if (comboBoxPlaceEvent.SelectedIndex < 1)
{
throw new Exception("Имеются незаполненные поля");
}
if (_raceId.HasValue)
{
_raceRepository.UpdateRace(CreateRace(_raceId.Value));
}
else
{
_raceRepository.CreateRace(CreateRace(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CancelButtonHorse_Click(object sender, EventArgs e) => Close();
private Race CreateRace(int id) => Race.CreateOperation(id, dateTimePicker.Value, (RacePlaceEvent)comboBoxPlaceEvent.SelectedItem!);
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,126 @@
namespace ProjectHorseRacing.Forms
{
partial class FormRaces
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
panel1 = new Panel();
buttonUpd = new Button();
buttonDel = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonUpd);
panel1.Controls.Add(buttonDel);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(662, 0);
panel1.Name = "panel1";
panel1.Size = new Size(149, 450);
panel1.TabIndex = 0;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.карандаш;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(33, 177);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(94, 94);
buttonUpd.TabIndex = 5;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.минус;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(33, 303);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(94, 94);
buttonDel.TabIndex = 4;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.плюс;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(33, 54);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 94);
buttonAdd.TabIndex = 3;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(662, 450);
dataGridView.TabIndex = 1;
//
// FormRaces
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(811, 450);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormRaces";
StartPosition = FormStartPosition.CenterParent;
Text = "Скачки";
Load += FormRaces_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private DataGridView dataGridView;
private Button buttonUpd;
private Button buttonDel;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,109 @@
using ProjectHorseRacing.Repositories;
using ProjectHorseRacing.Repositories.Implementation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectHorseRacing.Forms;
public partial class FormRaces : Form
{
private readonly IUnityContainer _container;
private readonly IRaceRepository _raceRepository;
public FormRaces(IUnityContainer container, IRaceRepository raceRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_raceRepository = raceRepository ??
throw new ArgumentNullException(nameof(raceRepository));
}
private void FormRaces_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<FormRace>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormRace>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_raceRepository.DeleteRace(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _raceRepository.ReadRaces();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
return true;
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,172 @@
namespace ProjectHorseRacing.Forms
{
partial class FormResult
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
comboBoxRace = new ComboBox();
comboBoxJockey = new ComboBox();
comboBoxHorse = new ComboBox();
numericUpDownPosition = new NumericUpDown();
Position = new Label();
Race = new Label();
label1 = new Label();
label2 = new Label();
CancelButtonResult = new Button();
SaveButtonResult = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownPosition).BeginInit();
SuspendLayout();
//
// comboBoxRace
//
comboBoxRace.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxRace.FormattingEnabled = true;
comboBoxRace.Location = new Point(236, 80);
comboBoxRace.Name = "comboBoxRace";
comboBoxRace.Size = new Size(223, 28);
comboBoxRace.TabIndex = 0;
//
// comboBoxJockey
//
comboBoxJockey.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxJockey.FormattingEnabled = true;
comboBoxJockey.Location = new Point(236, 129);
comboBoxJockey.Name = "comboBoxJockey";
comboBoxJockey.Size = new Size(223, 28);
comboBoxJockey.TabIndex = 1;
//
// comboBoxHorse
//
comboBoxHorse.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxHorse.FormattingEnabled = true;
comboBoxHorse.Location = new Point(236, 176);
comboBoxHorse.Name = "comboBoxHorse";
comboBoxHorse.Size = new Size(223, 28);
comboBoxHorse.TabIndex = 2;
//
// numericUpDownPosition
//
numericUpDownPosition.Location = new Point(236, 36);
numericUpDownPosition.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
numericUpDownPosition.Name = "numericUpDownPosition";
numericUpDownPosition.Size = new Size(150, 27);
numericUpDownPosition.TabIndex = 3;
numericUpDownPosition.Value = new decimal(new int[] { 1, 0, 0, 0 });
//
// Position
//
Position.AutoSize = true;
Position.Location = new Point(24, 43);
Position.Name = "Position";
Position.Size = new Size(194, 20);
Position.TabIndex = 4;
Position.Text = "Место, занятое на скачках:";
//
// Race
//
Race.AutoSize = true;
Race.Location = new Point(24, 88);
Race.Name = "Race";
Race.Size = new Size(60, 20);
Race.TabIndex = 5;
Race.Text = "Скачки:";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(24, 137);
label1.Name = "label1";
label1.Size = new Size(58, 20);
label1.TabIndex = 6;
label1.Text = "Жокей:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(24, 184);
label2.Name = "label2";
label2.Size = new Size(67, 20);
label2.TabIndex = 7;
label2.Text = "Лошадь:";
//
// CancelButtonResult
//
CancelButtonResult.Location = new Point(270, 244);
CancelButtonResult.Name = "CancelButtonResult";
CancelButtonResult.Size = new Size(94, 29);
CancelButtonResult.TabIndex = 19;
CancelButtonResult.Text = "Отмена";
CancelButtonResult.UseVisualStyleBackColor = true;
CancelButtonResult.Click += CancelButtonResult_Click;
//
// SaveButtonResult
//
SaveButtonResult.Location = new Point(135, 244);
SaveButtonResult.Name = "SaveButtonResult";
SaveButtonResult.Size = new Size(94, 29);
SaveButtonResult.TabIndex = 18;
SaveButtonResult.Text = "Сохранить";
SaveButtonResult.UseVisualStyleBackColor = true;
SaveButtonResult.Click += SaveButtonResult_Click;
//
// FormResult
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(538, 307);
Controls.Add(CancelButtonResult);
Controls.Add(SaveButtonResult);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(Race);
Controls.Add(Position);
Controls.Add(numericUpDownPosition);
Controls.Add(comboBoxHorse);
Controls.Add(comboBoxJockey);
Controls.Add(comboBoxRace);
Name = "FormResult";
StartPosition = FormStartPosition.CenterParent;
Text = "Результат";
((System.ComponentModel.ISupportInitialize)numericUpDownPosition).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private ComboBox comboBoxRace;
private ComboBox comboBoxJockey;
private ComboBox comboBoxHorse;
private NumericUpDown numericUpDownPosition;
private Label Position;
private Label Race;
private Label label1;
private Label label2;
private Button CancelButtonResult;
private Button SaveButtonResult;
}
}

View File

@ -0,0 +1,66 @@
using ProjectHorseRacing.Entities;
using ProjectHorseRacing.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectHorseRacing.Forms;
public partial class FormResult : Form
{
private readonly IResultRepository _resultRepository;
public FormResult(IResultRepository resultRepository,
IRaceRepository raceRepository, IJockeyRepository jockeyRepository,
IHorseRepository horseRepository)
{
InitializeComponent();
_resultRepository = resultRepository ??
throw new ArgumentNullException(nameof(resultRepository));
comboBoxRace.DataSource =raceRepository.ReadRaces();
comboBoxRace.DisplayMember = "DateTime";
comboBoxRace.ValueMember = "Id";
comboBoxJockey.DataSource = jockeyRepository.ReadJockeys();
comboBoxJockey.DisplayMember = "FirstName";
comboBoxJockey.ValueMember = "Id";
comboBoxHorse.DataSource = horseRepository.ReadHorses();
comboBoxHorse.DisplayMember = "Nickname";
comboBoxHorse.ValueMember = "Id";
}
private void SaveButtonResult_Click(object sender, EventArgs e)
{
try
{
if (comboBoxRace.SelectedIndex < 0 ||
comboBoxJockey.SelectedIndex < 0 ||
comboBoxHorse.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
_resultRepository.CreateResult(Result.CreateEntity(0,
Convert.ToInt32(numericUpDownPosition.Value),
(int)comboBoxRace.SelectedValue!, (int)comboBoxJockey.SelectedValue!,
(int)comboBoxHorse.SelectedValue!));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CancelButtonResult_Click(object sender, EventArgs e) => Close();
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,92 @@
namespace ProjectHorseRacing.Forms
{
partial class FormResults
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
panel1 = new Panel();
dataGridView = new DataGridView();
ButtonAdd = new Button();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(ButtonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(652, 0);
panel1.Name = "panel1";
panel1.Size = new Size(148, 450);
panel1.TabIndex = 0;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersWidth = 51;
dataGridView.Size = new Size(652, 450);
dataGridView.TabIndex = 1;
//
// ButtonAdd
//
ButtonAdd.BackgroundImage = Properties.Resources.плюс;
ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch;
ButtonAdd.Location = new Point(29, 30);
ButtonAdd.Name = "ButtonAdd";
ButtonAdd.Size = new Size(94, 94);
ButtonAdd.TabIndex = 4;
ButtonAdd.UseVisualStyleBackColor = true;
ButtonAdd.Click += ButtonAdd_Click;
//
// FormResults
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panel1);
Name = "FormResults";
Text = "Результаты";
Load += FormResults_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private DataGridView dataGridView;
private Button ButtonAdd;
}
}

View File

@ -0,0 +1,60 @@
using ProjectHorseRacing.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectHorseRacing.Forms;
public partial class FormResults : Form
{
private readonly IUnityContainer _container;
private readonly IResultRepository _resultRepository;
public FormResults(IUnityContainer container, IResultRepository resultRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_resultRepository = resultRepository ??
throw new ArgumentNullException(nameof(resultRepository));
}
private void FormResults_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<FormResult>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _resultRepository.ReadResults();
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,3 +1,8 @@
using Unity.Lifetime;
using Unity;
using ProjectHorseRacing.Repositories.Implementation;
using ProjectHorseRacing.Repositories;
namespace ProjectHorseRacing
{
internal static class Program
@ -11,7 +16,21 @@ namespace ProjectHorseRacing
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(CreateContainer().Resolve<FormHorseRacing>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.RegisterType<IHorseRepository, HorseRepository>(new TransientLifetimeManager());
container.RegisterType<IJockeyRepository, JockeyRepository>(new TransientLifetimeManager());
container.RegisterType<IOwnerRepository, OwnerRepository>(new TransientLifetimeManager());
container.RegisterType<IRaceRepository, RaceRepository>(new TransientLifetimeManager());
container.RegisterType<IResultRepository, ResultRepository>(new TransientLifetimeManager());
container.RegisterType<IBuyHorseRepository, BuyHorseRepository>(new TransientLifetimeManager());
return container;
}
}
}

View File

@ -8,4 +8,23 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Unity" Version="5.11.10" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectHorseRacing.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом 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() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[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("ProjectHorseRacing.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap карандаш {
get {
object obj = ResourceManager.GetObject("карандаш", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap минус {
get {
object obj = ResourceManager.GetObject("минус", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap плюс {
get {
object obj = ResourceManager.GetObject("плюс", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap скачки {
get {
object obj = ResourceManager.GetObject("скачки", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="скачки" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\скачки.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="плюс" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\плюс.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="минус" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\минус.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="карандаш" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\карандаш.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,17 @@
using ProjectHorseRacing.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Repositories;
public interface IBuyHorseRepository
{
IEnumerable<BuyHorse> ReadBuyHorse();
void CreateBuyHorse(BuyHorse buyHorse);
void DeleteBuyHorse(int id);
}

View File

@ -0,0 +1,21 @@
using ProjectHorseRacing.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Repositories;
public interface IHorseRepository
{
IEnumerable<Horse> ReadHorses();
Horse ReadHorseById(int id);
void CreateHorse(Horse horse);
void UpdateHorse(Horse horse);
void DeleteHorse(int id);
}

View File

@ -0,0 +1,21 @@
using ProjectHorseRacing.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Repositories;
public interface IJockeyRepository
{
IEnumerable<Jockey> ReadJockeys();
Jockey ReadJockeyById(int id);
void CreateJockey(Jockey jockey);
void UpdateJockey(Jockey jockey);
void DeleteJockey(int id);
}

View File

@ -0,0 +1,16 @@
using ProjectHorseRacing.Entities;
namespace ProjectHorseRacing.Repositories;
public interface IOwnerRepository
{
IEnumerable<Owners> ReadOwners();
Owners ReadOwnerById(int id);
void CreateOwner(Owners owner);
void UpdateOwner(Owners owner);
void DeleteOwner(int id);
}

View File

@ -0,0 +1,21 @@
using ProjectHorseRacing.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Repositories;
public interface IRaceRepository
{
IEnumerable<Race> ReadRaces(DateTime? dateFrom = null, DateTime? dateTo = null);
Race ReadRaceById(int id);
void CreateRace(Race race);
void UpdateRace(Race race);
void DeleteRace(int id);
}

View File

@ -0,0 +1,16 @@
using ProjectHorseRacing.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Repositories;
public interface IResultRepository
{
IEnumerable<Result> ReadResults(int? RaceId = null, int? JockeyId = null, int? HorseId = null);
void CreateResult(Result result);
}

View File

@ -0,0 +1,24 @@
using ProjectHorseRacing.Entities.Enums;
using ProjectHorseRacing.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Repositories.Implementation;
public class BuyHorseRepository : IBuyHorseRepository
{
public void CreateBuyHorse(BuyHorse buyHorse)
{
}
public void DeleteBuyHorse(int id)
{
}
public IEnumerable<BuyHorse> ReadBuyHorse()
{
return [];
}
}

View File

@ -0,0 +1,31 @@
using ProjectHorseRacing.Entities;
using ProjectHorseRacing.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Repositories.Implementation;
public class HorseRepository : IHorseRepository
{
public void CreateHorse(Horse horse)
{
}
public void DeleteHorse(int id)
{
}
public Horse ReadHorseById(int id)
{
return Horse.CreateHorse(0, string.Empty, HorseGender.None, 0, HorseCharacters.None);
}
public IEnumerable<Horse> ReadHorses()
{
return [];
}
public void UpdateHorse(Horse horse)
{
}
}

View File

@ -0,0 +1,29 @@
using ProjectHorseRacing.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Repositories.Implementation;
public class JockeyRepository : IJockeyRepository
{
public void CreateJockey(Jockey jockey)
{
}
public void DeleteJockey(int id)
{
}
public Jockey ReadJockeyById(int id)
{
return Jockey.CreateEntity(0, string.Empty, string.Empty, 0, 0);
}
public IEnumerable<Jockey> ReadJockeys()
{
return [];
}
public void UpdateJockey(Jockey jockey)
{
}
}

View File

@ -0,0 +1,30 @@
using ProjectHorseRacing.Entities;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Repositories.Implementation;
public class OwnerRepository : IOwnerRepository
{
public void CreateOwner(Owners owner)
{
}
public void DeleteOwner(int id)
{
}
public Owners ReadOwnerById(int id)
{
return Owners.CreateEntity(0, string.Empty, string.Empty, string.Empty, string.Empty);
}
public IEnumerable<Owners> ReadOwners()
{
return [];
}
public void UpdateOwner(Owners owner)
{
}
}

View File

@ -0,0 +1,30 @@
using ProjectHorseRacing.Entities;
using ProjectHorseRacing.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Repositories.Implementation;
public class RaceRepository : IRaceRepository
{
public void CreateRace(Race race)
{
}
public void DeleteRace(int id)
{
}
public Race ReadRaceById(int id)
{
return Race.CreateOperation(0, DateTime.Now, RacePlaceEvent.None);
}
public IEnumerable<Race> ReadRaces(DateTime? dateFrom = null, DateTime? dateTo = null)
{
return [];
}
public void UpdateRace(Race race)
{
}
}

View File

@ -0,0 +1,22 @@
using ProjectHorseRacing.Entities.Enums;
using ProjectHorseRacing.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectHorseRacing.Repositories.Implementation;
public class ResultRepository : IResultRepository
{
public void CreateResult(Result result)
{
}
public IEnumerable<Result> ReadResults(int? RaceId = null, int? JockeyId = null, int? HorseId = null)
{
return [];
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB