Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
1e2e1cf5c8 | |||
be54f3eb5a | |||
0e0c49137d | |||
bd2fa83d0c | |||
b12dc0640c | |||
a52015a455 | |||
c9057af05a | |||
d590a26fb9 |
38
ProjectHorseRacing/ProjectHorseRacing/Entities/BuyHorse.cs
Normal file
38
ProjectHorseRacing/ProjectHorseRacing/Entities/BuyHorse.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BuyHorse CreateEntity(TempBuyHorseHorse tempBuyHorseHorse, IEnumerable<BuyHorseHorse> buyHorseHorses)
|
||||||
|
{
|
||||||
|
return new BuyHorse
|
||||||
|
{
|
||||||
|
Id = tempBuyHorseHorse.Id,
|
||||||
|
OwnersId = tempBuyHorseHorse.OwnersId,
|
||||||
|
DatePurchase = tempBuyHorseHorse.DatePurchase,
|
||||||
|
BuyHorseHorses = buyHorseHorses
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
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 int Cost { get; private set; }
|
||||||
|
|
||||||
|
public static BuyHorseHorse CreateElement(int id, int horseId, int cost)
|
||||||
|
{
|
||||||
|
return new BuyHorseHorse
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
HorseId = horseId,
|
||||||
|
Cost = cost
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -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,
|
||||||
|
|
||||||
|
}
|
@ -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
|
||||||
|
}
|
@ -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
|
||||||
|
}
|
34
ProjectHorseRacing/ProjectHorseRacing/Entities/Horse.cs
Normal file
34
ProjectHorseRacing/ProjectHorseRacing/Entities/Horse.cs
Normal 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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
34
ProjectHorseRacing/ProjectHorseRacing/Entities/Jockey.cs
Normal file
34
ProjectHorseRacing/ProjectHorseRacing/Entities/Jockey.cs
Normal 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 FirstName { 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 firstName, string lastName, int age, double rating)
|
||||||
|
{
|
||||||
|
return new Jockey
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
FirstName = firstName,
|
||||||
|
LastName = lastName,
|
||||||
|
Age = age,
|
||||||
|
Rating = rating
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
29
ProjectHorseRacing/ProjectHorseRacing/Entities/Owners.cs
Normal file
29
ProjectHorseRacing/ProjectHorseRacing/Entities/Owners.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
namespace ProjectHorseRacing.Entities;
|
||||||
|
|
||||||
|
public class Owners
|
||||||
|
{
|
||||||
|
public int Id { get;private set; }
|
||||||
|
public string FirstName { 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 firstName, string lastName, string address, string phoneNumber)
|
||||||
|
{
|
||||||
|
return new Owners
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
FirstName = firstName,
|
||||||
|
LastName = lastName,
|
||||||
|
Address = address,
|
||||||
|
PhoneNumber = phoneNumber,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
29
ProjectHorseRacing/ProjectHorseRacing/Entities/Race.cs
Normal file
29
ProjectHorseRacing/ProjectHorseRacing/Entities/Race.cs
Normal 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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
34
ProjectHorseRacing/ProjectHorseRacing/Entities/Result.cs
Normal file
34
ProjectHorseRacing/ProjectHorseRacing/Entities/Result.cs
Normal 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 RaceId { get; private set; }
|
||||||
|
|
||||||
|
public int JockeyId { get; private set; }
|
||||||
|
|
||||||
|
public int HorseId { get; private set; }
|
||||||
|
|
||||||
|
public static Result CreateEntity(int id, int position, int raceId, int jockeyId, int horseId)
|
||||||
|
{
|
||||||
|
return new Result
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Position = position,
|
||||||
|
RaceId = raceId,
|
||||||
|
JockeyId = jockeyId,
|
||||||
|
HorseId = horseId
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Entities;
|
||||||
|
|
||||||
|
public class TempBuyHorseHorse
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
public int OwnersId { get; private set; }
|
||||||
|
public DateTime DatePurchase { get; private set; }
|
||||||
|
public int HorseId { get; private set; }
|
||||||
|
public int Cost { get; private set; }
|
||||||
|
}
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace ProjectHorseRacing
|
|
||||||
{
|
|
||||||
public partial class Form1 : Form
|
|
||||||
{
|
|
||||||
public Form1()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
178
ProjectHorseRacing/ProjectHorseRacing/FormHorseRacing.Designer.cs
generated
Normal file
178
ProjectHorseRacing/ProjectHorseRacing/FormHorseRacing.Designer.cs
generated
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
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();
|
||||||
|
OwnerToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ResultToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ListHorseToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
OwnerHorsesReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ResultReportToolStripMenuItem = 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, OwnerToolStripMenuItem });
|
||||||
|
справочники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;
|
||||||
|
//
|
||||||
|
// OwnerToolStripMenuItem
|
||||||
|
//
|
||||||
|
OwnerToolStripMenuItem.Name = "OwnerToolStripMenuItem";
|
||||||
|
OwnerToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
OwnerToolStripMenuItem.Text = "Владелец";
|
||||||
|
OwnerToolStripMenuItem.Click += OwnerToolStripMenuItem_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.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, OwnerHorsesReportToolStripMenuItem, ResultReportToolStripMenuItem });
|
||||||
|
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
|
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||||
|
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
|
//
|
||||||
|
// DirectoryReportToolStripMenuItem
|
||||||
|
//
|
||||||
|
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
|
||||||
|
DirectoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
||||||
|
DirectoryReportToolStripMenuItem.Size = new Size(350, 26);
|
||||||
|
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками";
|
||||||
|
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// OwnerHorsesReportToolStripMenuItem
|
||||||
|
//
|
||||||
|
OwnerHorsesReportToolStripMenuItem.Name = "OwnerHorsesReportToolStripMenuItem";
|
||||||
|
OwnerHorsesReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||||
|
OwnerHorsesReportToolStripMenuItem.Size = new Size(350, 26);
|
||||||
|
OwnerHorsesReportToolStripMenuItem.Text = "Отчет по покупке лошадей";
|
||||||
|
OwnerHorsesReportToolStripMenuItem.Click += OwnerHorsesReportToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// ResultReportToolStripMenuItem
|
||||||
|
//
|
||||||
|
ResultReportToolStripMenuItem.Name = "ResultReportToolStripMenuItem";
|
||||||
|
ResultReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
|
||||||
|
ResultReportToolStripMenuItem.Size = new Size(350, 26);
|
||||||
|
ResultReportToolStripMenuItem.Text = "Отчет по скачкам";
|
||||||
|
ResultReportToolStripMenuItem.Click += ResultReportToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// 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 OwnerToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem OwnerHorsesReportToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ResultReportToolStripMenuItem;
|
||||||
|
}
|
||||||
|
}
|
138
ProjectHorseRacing/ProjectHorseRacing/FormHorseRacing.cs
Normal file
138
ProjectHorseRacing/ProjectHorseRacing/FormHorseRacing.cs
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
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<FormResults>().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 OwnerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormOwners>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DirectoryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormDirectoryReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OwnerHorsesReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormOwnerHorsesReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResultReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormResultReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
123
ProjectHorseRacing/ProjectHorseRacing/FormHorseRacing.resx
Normal file
123
ProjectHorseRacing/ProjectHorseRacing/FormHorseRacing.resx
Normal 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>
|
179
ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorse.Designer.cs
generated
Normal file
179
ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorse.Designer.cs
generated
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
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();
|
||||||
|
ColumnCostHorse = new DataGridViewTextBoxColumn();
|
||||||
|
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, ColumnCostHorse });
|
||||||
|
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";
|
||||||
|
//
|
||||||
|
// ColumnCostHorse
|
||||||
|
//
|
||||||
|
ColumnCostHorse.HeaderText = "Цена";
|
||||||
|
ColumnCostHorse.MinimumWidth = 6;
|
||||||
|
ColumnCostHorse.Name = "ColumnCostHorse";
|
||||||
|
ColumnCostHorse.Width = 125;
|
||||||
|
//
|
||||||
|
// 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 DateTimePicker dateTimePicker;
|
||||||
|
private Label label3;
|
||||||
|
private DataGridViewComboBoxColumn ColumnHorse;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCostHorse;
|
||||||
|
}
|
||||||
|
}
|
65
ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorse.cs
Normal file
65
ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorse.cs
Normal 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),
|
||||||
|
Convert.ToInt32(row.Cells["ColumnCostHorse"].Value)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
126
ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorse.resx
Normal file
126
ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorse.resx
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
<?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>
|
||||||
|
<metadata name="ColumnCostHorse.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
112
ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorses.Designer.cs
generated
Normal file
112
ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorses.Designer.cs
generated
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
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();
|
||||||
|
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;
|
||||||
|
//
|
||||||
|
// 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(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 buttonDel;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Panel panelJockey;
|
||||||
|
}
|
||||||
|
}
|
93
ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorses.cs
Normal file
93
ProjectHorseRacing/ProjectHorseRacing/Forms/FormBuyHorses.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root>
|
<root>
|
||||||
<!--
|
<!--
|
||||||
Microsoft ResX Schema
|
Microsoft ResX Schema
|
||||||
|
|
||||||
Version 2.0
|
Version 2.0
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
The primary goals of this format is to allow a simple XML format
|
||||||
that is mostly human readable. The generation and parsing of the
|
that is mostly human readable. The generation and parsing of the
|
||||||
various data types are done through the TypeConverter classes
|
various data types are done through the TypeConverter classes
|
||||||
associated with the data types.
|
associated with the data types.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
... ado.net/XML headers & schema ...
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
<resheader name="version">2.0</resheader>
|
<resheader name="version">2.0</resheader>
|
||||||
@ -26,36 +26,36 @@
|
|||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
<comment>This is a comment</comment>
|
<comment>This is a comment</comment>
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
There are any number of "resheader" rows that contain simple
|
||||||
name/value pairs.
|
name/value pairs.
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
Each data row contains a name, and value. The row also contains a
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
text/value conversion through the TypeConverter architecture.
|
text/value conversion through the TypeConverter architecture.
|
||||||
Classes that don't support this are serialized and stored with the
|
Classes that don't support this are serialized and stored with the
|
||||||
mimetype set.
|
mimetype set.
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
The mimetype is used for serialized objects, and tells the
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
read any of the formats listed below.
|
read any of the formats listed below.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
value : The object must be serialized into a byte array
|
value : The object must be serialized into a byte array
|
||||||
: using a System.ComponentModel.TypeConverter
|
: using a System.ComponentModel.TypeConverter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
-->
|
-->
|
100
ProjectHorseRacing/ProjectHorseRacing/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
100
ProjectHorseRacing/ProjectHorseRacing/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
namespace ProjectHorseRacing.Forms
|
||||||
|
{
|
||||||
|
partial class FormDirectoryReport
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
ButtonBuild = new Button();
|
||||||
|
checkBoxHorses = new CheckBox();
|
||||||
|
checkBoxJockeys = new CheckBox();
|
||||||
|
checkBoxRace = new CheckBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// ButtonBuild
|
||||||
|
//
|
||||||
|
ButtonBuild.Location = new Point(204, 72);
|
||||||
|
ButtonBuild.Name = "ButtonBuild";
|
||||||
|
ButtonBuild.Size = new Size(140, 30);
|
||||||
|
ButtonBuild.TabIndex = 7;
|
||||||
|
ButtonBuild.Text = "Сформировать";
|
||||||
|
ButtonBuild.UseVisualStyleBackColor = true;
|
||||||
|
ButtonBuild.Click += ButtonBuild_Click;
|
||||||
|
//
|
||||||
|
// checkBoxHorses
|
||||||
|
//
|
||||||
|
checkBoxHorses.AutoSize = true;
|
||||||
|
checkBoxHorses.Location = new Point(32, 126);
|
||||||
|
checkBoxHorses.Name = "checkBoxHorses";
|
||||||
|
checkBoxHorses.Size = new Size(87, 24);
|
||||||
|
checkBoxHorses.TabIndex = 6;
|
||||||
|
checkBoxHorses.Text = "Лошади";
|
||||||
|
checkBoxHorses.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxJockeys
|
||||||
|
//
|
||||||
|
checkBoxJockeys.AutoSize = true;
|
||||||
|
checkBoxJockeys.Location = new Point(32, 76);
|
||||||
|
checkBoxJockeys.Name = "checkBoxJockeys";
|
||||||
|
checkBoxJockeys.Size = new Size(77, 24);
|
||||||
|
checkBoxJockeys.TabIndex = 5;
|
||||||
|
checkBoxJockeys.Text = "Жокеи";
|
||||||
|
checkBoxJockeys.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxRace
|
||||||
|
//
|
||||||
|
checkBoxRace.AutoSize = true;
|
||||||
|
checkBoxRace.Location = new Point(32, 25);
|
||||||
|
checkBoxRace.Name = "checkBoxRace";
|
||||||
|
checkBoxRace.Size = new Size(79, 24);
|
||||||
|
checkBoxRace.TabIndex = 4;
|
||||||
|
checkBoxRace.Text = "Скачки";
|
||||||
|
checkBoxRace.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// FormDirectoryReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(376, 175);
|
||||||
|
Controls.Add(ButtonBuild);
|
||||||
|
Controls.Add(checkBoxHorses);
|
||||||
|
Controls.Add(checkBoxJockeys);
|
||||||
|
Controls.Add(checkBoxRace);
|
||||||
|
Name = "FormDirectoryReport";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Выгрузка справочников";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button ButtonBuild;
|
||||||
|
private CheckBox checkBoxHorses;
|
||||||
|
private CheckBox checkBoxJockeys;
|
||||||
|
private CheckBox checkBoxRace;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
using ProjectHorseRacing.Reports;
|
||||||
|
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 FormDirectoryReport : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
public FormDirectoryReport(IUnityContainer container)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonBuild_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!checkBoxRace.Checked && !checkBoxJockeys.Checked && !checkBoxHorses.Checked)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран ни один справочник для выгрузки");
|
||||||
|
}
|
||||||
|
var sfd = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "Docx Files | *.docx"
|
||||||
|
};
|
||||||
|
if (sfd.ShowDialog() != DialogResult.OK)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран файла для отчета");
|
||||||
|
}
|
||||||
|
if
|
||||||
|
(_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxRace.Checked, checkBoxJockeys.Checked, checkBoxHorses.Checked))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Документ сформирован",
|
||||||
|
"Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Возникли ошибки при формировании документа. Подробности в логах",
|
||||||
|
"Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
169
ProjectHorseRacing/ProjectHorseRacing/Forms/FormHorse.Designer.cs
generated
Normal file
169
ProjectHorseRacing/ProjectHorseRacing/Forms/FormHorse.Designer.cs
generated
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
116
ProjectHorseRacing/ProjectHorseRacing/Forms/FormHorse.cs
Normal file
116
ProjectHorseRacing/ProjectHorseRacing/Forms/FormHorse.cs
Normal 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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormHorse.resx
Normal file
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormHorse.resx
Normal 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>
|
128
ProjectHorseRacing/ProjectHorseRacing/Forms/FormHorses.Designer.cs
generated
Normal file
128
ProjectHorseRacing/ProjectHorseRacing/Forms/FormHorses.Designer.cs
generated
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
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.RowHeadersVisible = false;
|
||||||
|
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";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
113
ProjectHorseRacing/ProjectHorseRacing/Forms/FormHorses.cs
Normal file
113
ProjectHorseRacing/ProjectHorseRacing/Forms/FormHorses.cs
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormHorses.resx
Normal file
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormHorses.resx
Normal 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>
|
171
ProjectHorseRacing/ProjectHorseRacing/Forms/FormJockey.Designer.cs
generated
Normal file
171
ProjectHorseRacing/ProjectHorseRacing/Forms/FormJockey.Designer.cs
generated
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
91
ProjectHorseRacing/ProjectHorseRacing/Forms/FormJockey.cs
Normal file
91
ProjectHorseRacing/ProjectHorseRacing/Forms/FormJockey.cs
Normal 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.FirstName;
|
||||||
|
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));
|
||||||
|
|
||||||
|
}
|
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormJockey.resx
Normal file
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormJockey.resx
Normal 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>
|
127
ProjectHorseRacing/ProjectHorseRacing/Forms/FormJockeys.Designer.cs
generated
Normal file
127
ProjectHorseRacing/ProjectHorseRacing/Forms/FormJockeys.Designer.cs
generated
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
115
ProjectHorseRacing/ProjectHorseRacing/Forms/FormJockeys.cs
Normal file
115
ProjectHorseRacing/ProjectHorseRacing/Forms/FormJockeys.cs
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormJockeys.resx
Normal file
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormJockeys.resx
Normal 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>
|
161
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwner.Designer.cs
generated
Normal file
161
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwner.Designer.cs
generated
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
88
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwner.cs
Normal file
88
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwner.cs
Normal 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.FirstName;
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwner.resx
Normal file
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwner.resx
Normal 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>
|
169
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwnerHorsesReport.Designer.cs
generated
Normal file
169
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwnerHorsesReport.Designer.cs
generated
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
namespace ProjectHorseRacing.Forms
|
||||||
|
{
|
||||||
|
partial class FormOwnerHorsesReport
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
label4 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
buttonBuild = new Button();
|
||||||
|
buttonFile = new Button();
|
||||||
|
textBoxFilePath = new TextBox();
|
||||||
|
comboBoxOwner = new ComboBox();
|
||||||
|
dateTimePickerStart = new DateTimePicker();
|
||||||
|
dateTimePickerEnd = new DateTimePicker();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(43, 186);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(90, 20);
|
||||||
|
label4.TabIndex = 39;
|
||||||
|
label4.Text = "Дата конца:";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(43, 137);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(97, 20);
|
||||||
|
label3.TabIndex = 38;
|
||||||
|
label3.Text = "Дата начала:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(43, 81);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(78, 20);
|
||||||
|
label2.TabIndex = 37;
|
||||||
|
label2.Text = "Владелец:";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(43, 29);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(112, 20);
|
||||||
|
label1.TabIndex = 36;
|
||||||
|
label1.Text = "Путь до файла:";
|
||||||
|
//
|
||||||
|
// buttonBuild
|
||||||
|
//
|
||||||
|
buttonBuild.Location = new Point(43, 239);
|
||||||
|
buttonBuild.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonBuild.Name = "buttonBuild";
|
||||||
|
buttonBuild.Size = new Size(338, 31);
|
||||||
|
buttonBuild.TabIndex = 35;
|
||||||
|
buttonBuild.Text = "Сформировать";
|
||||||
|
buttonBuild.UseVisualStyleBackColor = true;
|
||||||
|
buttonBuild.Click += ButtonBuild_Click;
|
||||||
|
//
|
||||||
|
// buttonFile
|
||||||
|
//
|
||||||
|
buttonFile.Location = new Point(349, 25);
|
||||||
|
buttonFile.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonFile.Name = "buttonFile";
|
||||||
|
buttonFile.Size = new Size(30, 31);
|
||||||
|
buttonFile.TabIndex = 34;
|
||||||
|
buttonFile.Text = "...";
|
||||||
|
buttonFile.UseVisualStyleBackColor = true;
|
||||||
|
buttonFile.Click += ButtonFile_Click;
|
||||||
|
//
|
||||||
|
// textBoxFilePath
|
||||||
|
//
|
||||||
|
textBoxFilePath.Location = new Point(153, 25);
|
||||||
|
textBoxFilePath.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxFilePath.Name = "textBoxFilePath";
|
||||||
|
textBoxFilePath.Size = new Size(189, 27);
|
||||||
|
textBoxFilePath.TabIndex = 33;
|
||||||
|
//
|
||||||
|
// comboBoxOwner
|
||||||
|
//
|
||||||
|
comboBoxOwner.FormattingEnabled = true;
|
||||||
|
comboBoxOwner.Location = new Point(153, 77);
|
||||||
|
comboBoxOwner.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
comboBoxOwner.Name = "comboBoxOwner";
|
||||||
|
comboBoxOwner.Size = new Size(226, 28);
|
||||||
|
comboBoxOwner.TabIndex = 32;
|
||||||
|
//
|
||||||
|
// dateTimePickerStart
|
||||||
|
//
|
||||||
|
dateTimePickerStart.Location = new Point(153, 130);
|
||||||
|
dateTimePickerStart.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dateTimePickerStart.Name = "dateTimePickerStart";
|
||||||
|
dateTimePickerStart.Size = new Size(228, 27);
|
||||||
|
dateTimePickerStart.TabIndex = 31;
|
||||||
|
//
|
||||||
|
// dateTimePickerEnd
|
||||||
|
//
|
||||||
|
dateTimePickerEnd.Location = new Point(153, 181);
|
||||||
|
dateTimePickerEnd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dateTimePickerEnd.Name = "dateTimePickerEnd";
|
||||||
|
dateTimePickerEnd.Size = new Size(228, 27);
|
||||||
|
dateTimePickerEnd.TabIndex = 30;
|
||||||
|
//
|
||||||
|
// FormOwnerHorsesReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(429, 297);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(buttonBuild);
|
||||||
|
Controls.Add(buttonFile);
|
||||||
|
Controls.Add(textBoxFilePath);
|
||||||
|
Controls.Add(comboBoxOwner);
|
||||||
|
Controls.Add(dateTimePickerStart);
|
||||||
|
Controls.Add(dateTimePickerEnd);
|
||||||
|
Name = "FormOwnerHorsesReport";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Отчет по покупке лошадей";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label4;
|
||||||
|
private Label label3;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private Button buttonBuild;
|
||||||
|
private Button buttonFile;
|
||||||
|
private TextBox textBoxFilePath;
|
||||||
|
private ComboBox comboBoxOwner;
|
||||||
|
private DateTimePicker dateTimePickerStart;
|
||||||
|
private DateTimePicker dateTimePickerEnd;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
using ProjectHorseRacing.Reports;
|
||||||
|
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 FormOwnerHorsesReport : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
public FormOwnerHorsesReport(IUnityContainer container, IOwnerRepository ownerRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
|
||||||
|
comboBoxOwner.DataSource = ownerRepository.ReadOwners();
|
||||||
|
comboBoxOwner.DisplayMember = "LastName";
|
||||||
|
comboBoxOwner.ValueMember = "Id";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonBuild_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
|
||||||
|
{
|
||||||
|
throw new Exception("Отсутствует имя файла для отчета");
|
||||||
|
}
|
||||||
|
if (comboBoxOwner.SelectedIndex < 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран корм");
|
||||||
|
}
|
||||||
|
if (dateTimePickerEnd.Value <= dateTimePickerStart.Value)
|
||||||
|
{
|
||||||
|
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||||
|
}
|
||||||
|
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxOwner.SelectedValue!, dateTimePickerStart.Value, dateTimePickerEnd.Value))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Документ сформирован",
|
||||||
|
"Формирование документа",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
||||||
|
"Формирование документа",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при создании отчета",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonFile_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var sfd = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "Excel Files | *.xlsx"
|
||||||
|
};
|
||||||
|
if (sfd.ShowDialog() != DialogResult.OK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
textBoxFilePath.Text = sfd.FileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
125
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwners.Designer.cs
generated
Normal file
125
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwners.Designer.cs
generated
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
114
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwners.cs
Normal file
114
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwners.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwners.resx
Normal file
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormOwners.resx
Normal 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>
|
128
ProjectHorseRacing/ProjectHorseRacing/Forms/FormRace.Designer.cs
generated
Normal file
128
ProjectHorseRacing/ProjectHorseRacing/Forms/FormRace.Designer.cs
generated
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
87
ProjectHorseRacing/ProjectHorseRacing/Forms/FormRace.cs
Normal file
87
ProjectHorseRacing/ProjectHorseRacing/Forms/FormRace.cs
Normal 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
dateTimePicker1.Value = race.DateTime.Date;
|
||||||
|
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, dateTimePicker1.Value, (RacePlaceEvent)comboBoxPlaceEvent.SelectedItem!);
|
||||||
|
|
||||||
|
}
|
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormRace.resx
Normal file
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormRace.resx
Normal 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>
|
126
ProjectHorseRacing/ProjectHorseRacing/Forms/FormRaces.Designer.cs
generated
Normal file
126
ProjectHorseRacing/ProjectHorseRacing/Forms/FormRaces.Designer.cs
generated
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
109
ProjectHorseRacing/ProjectHorseRacing/Forms/FormRaces.cs
Normal file
109
ProjectHorseRacing/ProjectHorseRacing/Forms/FormRaces.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormRaces.resx
Normal file
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormRaces.resx
Normal 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>
|
172
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResult.Designer.cs
generated
Normal file
172
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResult.Designer.cs
generated
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
66
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResult.cs
Normal file
66
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResult.cs
Normal 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();
|
||||||
|
}
|
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResult.resx
Normal file
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResult.resx
Normal 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>
|
111
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResultReport.Designer.cs
generated
Normal file
111
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResultReport.Designer.cs
generated
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
namespace ProjectHorseRacing.Forms
|
||||||
|
{
|
||||||
|
partial class FormResultReport
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
ButtonBuild = new Button();
|
||||||
|
label3 = new Label();
|
||||||
|
labelFilePath = new Label();
|
||||||
|
ButtonFile = new Button();
|
||||||
|
dateTimePicker = new DateTimePicker();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// ButtonBuild
|
||||||
|
//
|
||||||
|
ButtonBuild.Location = new Point(36, 124);
|
||||||
|
ButtonBuild.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
ButtonBuild.Name = "ButtonBuild";
|
||||||
|
ButtonBuild.Size = new Size(275, 31);
|
||||||
|
ButtonBuild.TabIndex = 39;
|
||||||
|
ButtonBuild.Text = "Сформировать";
|
||||||
|
ButtonBuild.UseVisualStyleBackColor = true;
|
||||||
|
ButtonBuild.Click += ButtonBuild_Click;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(36, 76);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(44, 20);
|
||||||
|
label3.TabIndex = 38;
|
||||||
|
label3.Text = "Дата:";
|
||||||
|
//
|
||||||
|
// labelFilePath
|
||||||
|
//
|
||||||
|
labelFilePath.AutoSize = true;
|
||||||
|
labelFilePath.Location = new Point(137, 26);
|
||||||
|
labelFilePath.Name = "labelFilePath";
|
||||||
|
labelFilePath.Size = new Size(45, 20);
|
||||||
|
labelFilePath.TabIndex = 37;
|
||||||
|
labelFilePath.Text = "Файл";
|
||||||
|
//
|
||||||
|
// ButtonFile
|
||||||
|
//
|
||||||
|
ButtonFile.Location = new Point(36, 20);
|
||||||
|
ButtonFile.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
ButtonFile.Name = "ButtonFile";
|
||||||
|
ButtonFile.Size = new Size(95, 31);
|
||||||
|
ButtonFile.TabIndex = 36;
|
||||||
|
ButtonFile.Text = "Выбрать";
|
||||||
|
ButtonFile.UseVisualStyleBackColor = true;
|
||||||
|
ButtonFile.Click += ButtonFile_Click_1;
|
||||||
|
//
|
||||||
|
// dateTimePicker
|
||||||
|
//
|
||||||
|
dateTimePicker.Location = new Point(86, 69);
|
||||||
|
dateTimePicker.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dateTimePicker.Name = "dateTimePicker";
|
||||||
|
dateTimePicker.Size = new Size(228, 27);
|
||||||
|
dateTimePicker.TabIndex = 35;
|
||||||
|
//
|
||||||
|
// FormResultReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(347, 182);
|
||||||
|
Controls.Add(ButtonBuild);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(labelFilePath);
|
||||||
|
Controls.Add(ButtonFile);
|
||||||
|
Controls.Add(dateTimePicker);
|
||||||
|
Name = "FormResultReport";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Отчет по скачкам";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button ButtonBuild;
|
||||||
|
private Label label3;
|
||||||
|
private Label labelFilePath;
|
||||||
|
private Button ButtonFile;
|
||||||
|
private DateTimePicker dateTimePicker;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
using ProjectHorseRacing.Reports;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Forms
|
||||||
|
{
|
||||||
|
public partial class FormResultReport : Form
|
||||||
|
{
|
||||||
|
private string _fileName = string.Empty;
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
public FormResultReport(IUnityContainer container)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonBuild_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(_fileName))
|
||||||
|
{
|
||||||
|
throw new Exception("Отсутствует имя файла для отчета");
|
||||||
|
}
|
||||||
|
if
|
||||||
|
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.Value))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Документ сформирован",
|
||||||
|
"Формирование документа",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
||||||
|
"Формирование документа",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при создании очета",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ButtonFile_Click_1(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var sfd = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "Pdf Files | *.pdf"
|
||||||
|
};
|
||||||
|
if (sfd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_fileName = sfd.FileName;
|
||||||
|
labelFilePath.Text = Path.GetFileName(_fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
94
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResults.Designer.cs
generated
Normal file
94
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResults.Designer.cs
generated
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
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();
|
||||||
|
ButtonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
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;
|
||||||
|
//
|
||||||
|
// 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;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.Size = new Size(652, 450);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
62
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResults.cs
Normal file
62
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResults.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Npgsql;
|
||||||
|
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 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();
|
||||||
|
|
||||||
|
}
|
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResults.resx
Normal file
120
ProjectHorseRacing/ProjectHorseRacing/Forms/FormResults.resx
Normal 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>
|
@ -1,3 +1,12 @@
|
|||||||
|
using Unity.Lifetime;
|
||||||
|
using Unity;
|
||||||
|
using ProjectHorseRacing.Repositories.Implementation;
|
||||||
|
using ProjectHorseRacing.Repositories;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Serilog;
|
||||||
|
using Unity.Microsoft.Logging;
|
||||||
|
|
||||||
namespace ProjectHorseRacing
|
namespace ProjectHorseRacing
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
@ -11,7 +20,38 @@ namespace ProjectHorseRacing
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new Form1());
|
Application.Run(CreateContainer().Resolve<FormHorseRacing>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IUnityContainer CreateContainer()
|
||||||
|
{
|
||||||
|
var container = new UnityContainer();
|
||||||
|
|
||||||
|
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
|
container.RegisterType<IConnectionString, ConnectionString>(new TransientLifetimeManager());
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static LoggerFactory CreateLoggerFactory()
|
||||||
|
{
|
||||||
|
var loggerFactory = new LoggerFactory();
|
||||||
|
loggerFactory.AddSerilog(new LoggerConfiguration()
|
||||||
|
.ReadFrom.Configuration(new ConfigurationBuilder()
|
||||||
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile("appsettings.json")
|
||||||
|
.Build())
|
||||||
|
.CreateLogger());
|
||||||
|
return loggerFactory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,4 +8,42 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||||
|
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="Npgsql" Version="9.0.1" />
|
||||||
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
|
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Unity" Version="5.11.10" />
|
||||||
|
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||||
|
</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>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
103
ProjectHorseRacing/ProjectHorseRacing/Properties/Resources.Designer.cs
generated
Normal file
103
ProjectHorseRacing/ProjectHorseRacing/Properties/Resources.Designer.cs
generated
Normal 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
133
ProjectHorseRacing/ProjectHorseRacing/Properties/Resources.resx
Normal file
133
ProjectHorseRacing/ProjectHorseRacing/Properties/Resources.resx
Normal 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>
|
65
ProjectHorseRacing/ProjectHorseRacing/Reports/ChartReport.cs
Normal file
65
ProjectHorseRacing/ProjectHorseRacing/Reports/ChartReport.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ProjectHorseRacing.Repositories;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Reports;
|
||||||
|
|
||||||
|
internal class ChartReport
|
||||||
|
{
|
||||||
|
private readonly IResultRepository _resultRepository;
|
||||||
|
private readonly IHorseRepository _horseRepository;
|
||||||
|
private readonly IRaceRepository _raceRepository;
|
||||||
|
private readonly ILogger<ChartReport> _logger;
|
||||||
|
|
||||||
|
public ChartReport(IResultRepository resultRepository, IHorseRepository horseRepository, IRaceRepository raceRepository, ILogger<ChartReport> logger)
|
||||||
|
{
|
||||||
|
_raceRepository = raceRepository ?? throw new ArgumentNullException(nameof(raceRepository));
|
||||||
|
_resultRepository = resultRepository ?? throw new ArgumentNullException(nameof(resultRepository));
|
||||||
|
_horseRepository = horseRepository ?? throw new ArgumentNullException(nameof(horseRepository));
|
||||||
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateChart(string filePath, DateTime dateTime)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new PdfBuilder(filePath)
|
||||||
|
.AddHeader("Результаты заездов")
|
||||||
|
.AddPieChart("1 места занятые лошадьми", GetData(dateTime))
|
||||||
|
.Build();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
||||||
|
{
|
||||||
|
var horseNames = _horseRepository.ReadHorses()
|
||||||
|
.ToDictionary(f => f.Id, f => f.Nickname);
|
||||||
|
|
||||||
|
var racesOnDate = _raceRepository
|
||||||
|
.ReadRaces()
|
||||||
|
.Where(r => r.DateTime.Date == dateTime.Date)
|
||||||
|
.Select(r => r.Id)
|
||||||
|
.ToHashSet();
|
||||||
|
|
||||||
|
var firstPlaceResults = _resultRepository
|
||||||
|
.ReadResults()
|
||||||
|
.Where(r => racesOnDate.Contains(r.RaceId) && r.Position == 1)
|
||||||
|
.GroupBy(r => r.HorseId)
|
||||||
|
.Select(g => new
|
||||||
|
{
|
||||||
|
HorseId = g.Key,
|
||||||
|
Wins = g.Count()
|
||||||
|
});
|
||||||
|
|
||||||
|
return firstPlaceResults
|
||||||
|
.Select(r => (
|
||||||
|
Caption: horseNames.TryGetValue(r.HorseId, out var nickname) ? nickname : $"Лошадь {r.HorseId}",
|
||||||
|
Value: (double)r.Wins
|
||||||
|
))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
102
ProjectHorseRacing/ProjectHorseRacing/Reports/DocReport.cs
Normal file
102
ProjectHorseRacing/ProjectHorseRacing/Reports/DocReport.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ProjectHorseRacing.Repositories;
|
||||||
|
using ProjectHorseRacing.Repositories.Implementation;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Reports;
|
||||||
|
|
||||||
|
internal class DocReport
|
||||||
|
{
|
||||||
|
private readonly IRaceRepository _raceRepository;
|
||||||
|
private readonly IJockeyRepository _jockeyRepository;
|
||||||
|
private readonly IHorseRepository _horseRepository;
|
||||||
|
|
||||||
|
private readonly ILogger<DocReport> _logger;
|
||||||
|
|
||||||
|
public DocReport(IRaceRepository raceRepository, IJockeyRepository jockeyRepository,
|
||||||
|
IHorseRepository horseRepository, ILogger<DocReport> logger)
|
||||||
|
{
|
||||||
|
_raceRepository = raceRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(raceRepository));
|
||||||
|
_jockeyRepository = jockeyRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(jockeyRepository));
|
||||||
|
_horseRepository = horseRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(horseRepository));
|
||||||
|
_logger = logger ??
|
||||||
|
throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateDoc(string filePath, bool includeRaces, bool includeJockeys, bool includeHorses)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var builder = new WordBuilder(filePath)
|
||||||
|
.AddHeader("Документ со справочниками");
|
||||||
|
|
||||||
|
if (includeRaces)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Скачки")
|
||||||
|
.AddTable([2400, 2400], GetRaces());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeJockeys)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Жокеи")
|
||||||
|
.AddTable([2400, 1200, 2400, 2400], GetJockeys());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeHorses)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Лошади")
|
||||||
|
.AddTable([2400, 1200, 2400, 2400], GetHorses());
|
||||||
|
}
|
||||||
|
builder.Build();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetRaces()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Дата", "Место проведения"],
|
||||||
|
.. _raceRepository
|
||||||
|
.ReadRaces().Select
|
||||||
|
(x => new string[] { x.DateTime.ToString(), x.RacePlaceEvent.ToString() }),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetJockeys()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Имя", "Фамилия", "Возраст", "Рейтинг"],
|
||||||
|
.. _jockeyRepository
|
||||||
|
.ReadJockeys().Select
|
||||||
|
(x => new string[] { x.FirstName, x.LastName, x.Age.ToString(),
|
||||||
|
x.Rating.ToString() }),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetHorses()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Кличка", "Пол", "Возраст", "Характер"],
|
||||||
|
.. _horseRepository
|
||||||
|
.ReadHorses().Select
|
||||||
|
(x => new string[] { x.Nickname, x.HorseGender.ToString(), x.AgeHorse.ToString(),
|
||||||
|
x.HorseCharacters.ToString() }),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
318
ProjectHorseRacing/ProjectHorseRacing/Reports/ExcelBuilder.cs
Normal file
318
ProjectHorseRacing/ProjectHorseRacing/Reports/ExcelBuilder.cs
Normal file
@ -0,0 +1,318 @@
|
|||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Reports;
|
||||||
|
|
||||||
|
internal class ExcelBuilder
|
||||||
|
{
|
||||||
|
private readonly string _filePath;
|
||||||
|
private readonly SheetData _sheetData;
|
||||||
|
private readonly MergeCells _mergeCells;
|
||||||
|
private readonly Columns _columns;
|
||||||
|
private uint _rowIndex = 0;
|
||||||
|
|
||||||
|
public ExcelBuilder(string filePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(filePath));
|
||||||
|
}
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
_filePath = filePath;
|
||||||
|
_sheetData = new SheetData();
|
||||||
|
_mergeCells = new MergeCells();
|
||||||
|
_columns = new Columns();
|
||||||
|
_rowIndex = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
||||||
|
{
|
||||||
|
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
|
||||||
|
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
||||||
|
{
|
||||||
|
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
|
||||||
|
}
|
||||||
|
_mergeCells.Append(new MergeCell()
|
||||||
|
{
|
||||||
|
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
|
||||||
|
});
|
||||||
|
_rowIndex++;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExcelBuilder AddParagraph(string text, int columnIndex)
|
||||||
|
{
|
||||||
|
CreateCell(columnIndex, _rowIndex++, text, StyleIndex.SimpleTextWithoutBorder);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
|
||||||
|
{
|
||||||
|
if (columnsWidths == null || columnsWidths.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(columnsWidths));
|
||||||
|
}
|
||||||
|
if (data == null || data.Count == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(data));
|
||||||
|
}
|
||||||
|
if (data.Any(x => x.Length != columnsWidths.Length))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("widths.Length != data.Length");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint counter = 1;
|
||||||
|
int coef = 2;
|
||||||
|
_columns.Append(columnsWidths.Select(x => new Column
|
||||||
|
{
|
||||||
|
Min = counter,
|
||||||
|
Max = counter++,
|
||||||
|
Width = x * coef,
|
||||||
|
CustomWidth = true
|
||||||
|
}));
|
||||||
|
|
||||||
|
for (var j = 0; j < data.First().Length; ++j)
|
||||||
|
{
|
||||||
|
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder);
|
||||||
|
}
|
||||||
|
|
||||||
|
_rowIndex++;
|
||||||
|
for (var i = 1; i < data.Count - 1; ++i)
|
||||||
|
{
|
||||||
|
for (var j = 0; j < data[i].Length; ++j)
|
||||||
|
{
|
||||||
|
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorder);
|
||||||
|
}
|
||||||
|
_rowIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var j = 0; j < data.Last().Length; ++j)
|
||||||
|
{
|
||||||
|
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
|
||||||
|
}
|
||||||
|
_rowIndex++;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Build()
|
||||||
|
{
|
||||||
|
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath, SpreadsheetDocumentType.Workbook);
|
||||||
|
var workbookpart = spreadsheetDocument.AddWorkbookPart();
|
||||||
|
GenerateStyle(workbookpart);
|
||||||
|
workbookpart.Workbook = new Workbook();
|
||||||
|
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||||
|
worksheetPart.Worksheet = new Worksheet();
|
||||||
|
|
||||||
|
if (_columns.HasChildren)
|
||||||
|
{
|
||||||
|
worksheetPart.Worksheet.Append(_columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
worksheetPart.Worksheet.Append(_sheetData);
|
||||||
|
var sheets = spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
||||||
|
var sheet = new Sheet()
|
||||||
|
{
|
||||||
|
Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||||
|
SheetId = 1,
|
||||||
|
Name = "Лист 1"
|
||||||
|
};
|
||||||
|
sheets.Append(sheet);
|
||||||
|
if (_mergeCells.HasChildren)
|
||||||
|
{
|
||||||
|
worksheetPart.Worksheet.InsertAfter(_mergeCells,
|
||||||
|
worksheetPart.Worksheet.Elements<SheetData>().First());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void GenerateStyle(WorkbookPart workbookPart)
|
||||||
|
{
|
||||||
|
var workbookStylesPart = workbookPart.AddNewPart<WorkbookStylesPart>();
|
||||||
|
workbookStylesPart.Stylesheet = new Stylesheet();
|
||||||
|
|
||||||
|
var fonts = new Fonts()
|
||||||
|
{
|
||||||
|
Count = 2,
|
||||||
|
KnownFonts = BooleanValue.FromBoolean(true)
|
||||||
|
};
|
||||||
|
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||||
|
{
|
||||||
|
FontSize = new FontSize() { Val = 11 },
|
||||||
|
FontName = new FontName() { Val = "Calibri" },
|
||||||
|
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||||
|
FontScheme = new FontScheme()
|
||||||
|
{
|
||||||
|
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||||
|
{
|
||||||
|
FontSize = new FontSize() { Val = 11 },
|
||||||
|
FontName = new FontName() { Val = "Calibri" },
|
||||||
|
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||||
|
FontScheme = new FontScheme()
|
||||||
|
{
|
||||||
|
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||||
|
},
|
||||||
|
Bold = new Bold() { Val = true }
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(fonts);
|
||||||
|
|
||||||
|
|
||||||
|
var fills = new Fills() { Count = 1 };
|
||||||
|
fills.Append(new Fill
|
||||||
|
{
|
||||||
|
PatternFill = new PatternFill()
|
||||||
|
{
|
||||||
|
PatternType = new EnumValue<PatternValues>(PatternValues.None)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(fills);
|
||||||
|
|
||||||
|
|
||||||
|
var borders = new Borders() { Count = 2 };
|
||||||
|
borders.Append(new Border
|
||||||
|
{
|
||||||
|
LeftBorder = new LeftBorder(),
|
||||||
|
RightBorder = new RightBorder(),
|
||||||
|
TopBorder = new TopBorder(),
|
||||||
|
BottomBorder = new BottomBorder(),
|
||||||
|
DiagonalBorder = new DiagonalBorder()
|
||||||
|
});
|
||||||
|
borders.Append(new Border
|
||||||
|
{
|
||||||
|
LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin },
|
||||||
|
RightBorder = new RightBorder() { Style = BorderStyleValues.Thin },
|
||||||
|
TopBorder = new TopBorder() { Style = BorderStyleValues.Thin },
|
||||||
|
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin },
|
||||||
|
DiagonalBorder = new DiagonalBorder()
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(borders);
|
||||||
|
|
||||||
|
|
||||||
|
var cellFormats = new CellFormats() { Count = 4 };
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 0,
|
||||||
|
BorderId = 0,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Left,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 0,
|
||||||
|
BorderId = 1,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Right,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 1,
|
||||||
|
BorderId = 0,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Center,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 1,
|
||||||
|
BorderId = 1,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Center,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum StyleIndex
|
||||||
|
{
|
||||||
|
SimpleTextWithoutBorder = 0,
|
||||||
|
SimpleTextWithBorder = 1,
|
||||||
|
BoldTextWithoutBorder = 2,
|
||||||
|
BoldTextWithBorder = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateCell(int columnIndex, uint rowIndex, string text, StyleIndex styleIndex)
|
||||||
|
{
|
||||||
|
var columnName = GetExcelColumnName(columnIndex);
|
||||||
|
var cellReference = columnName + rowIndex;
|
||||||
|
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex! == rowIndex);
|
||||||
|
if (row == null)
|
||||||
|
{
|
||||||
|
row = new Row() { RowIndex = rowIndex };
|
||||||
|
_sheetData.Append(row);
|
||||||
|
}
|
||||||
|
var newCell = row.Elements<Cell>().FirstOrDefault(c => c.CellReference != null &&
|
||||||
|
c.CellReference.Value == columnName + rowIndex);
|
||||||
|
if (newCell == null)
|
||||||
|
{
|
||||||
|
Cell? refCell = null;
|
||||||
|
foreach (Cell cell in row.Elements<Cell>())
|
||||||
|
{
|
||||||
|
if (cell.CellReference?.Value != null &&
|
||||||
|
cell.CellReference.Value.Length == cellReference.Length)
|
||||||
|
{
|
||||||
|
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
|
||||||
|
{
|
||||||
|
refCell = cell;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newCell = new Cell() { CellReference = cellReference };
|
||||||
|
row.InsertBefore(newCell, refCell);
|
||||||
|
}
|
||||||
|
newCell.CellValue = new CellValue(text);
|
||||||
|
newCell.DataType = CellValues.String;
|
||||||
|
newCell.StyleIndex = (uint)styleIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetExcelColumnName(int columnNumber)
|
||||||
|
{
|
||||||
|
columnNumber += 1;
|
||||||
|
int dividend = columnNumber;
|
||||||
|
string columnName = string.Empty;
|
||||||
|
int modulo;
|
||||||
|
while (dividend > 0)
|
||||||
|
{
|
||||||
|
modulo = (dividend - 1) % 26;
|
||||||
|
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
|
||||||
|
dividend = (dividend - modulo) / 26;
|
||||||
|
}
|
||||||
|
return columnName;
|
||||||
|
}
|
||||||
|
}
|
81
ProjectHorseRacing/ProjectHorseRacing/Reports/PdfBuilder.cs
Normal file
81
ProjectHorseRacing/ProjectHorseRacing/Reports/PdfBuilder.cs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.Rendering;
|
||||||
|
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Reports;
|
||||||
|
|
||||||
|
internal class PdfBuilder
|
||||||
|
{
|
||||||
|
private readonly string _filePath;
|
||||||
|
private readonly Document _document;
|
||||||
|
|
||||||
|
public PdfBuilder(string filePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(filePath));
|
||||||
|
}
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
_filePath = filePath;
|
||||||
|
_document = new Document();
|
||||||
|
DefineStyles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PdfBuilder AddHeader(string header)
|
||||||
|
{
|
||||||
|
_document.AddSection().AddParagraph(header, "NormalBold");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
|
||||||
|
{
|
||||||
|
if (data == null || data.Count == 0)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
var chart = new Chart(ChartType.Pie2D);
|
||||||
|
var series = chart.SeriesCollection.AddSeries();
|
||||||
|
series.Add(data.Select(x => x.Value).ToArray());
|
||||||
|
var xseries = chart.XValues.AddXSeries();
|
||||||
|
xseries.Add(data.Select(x => x.Caption).ToArray());
|
||||||
|
chart.DataLabel.Type = DataLabelType.Percent;
|
||||||
|
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
|
||||||
|
chart.Width = Unit.FromCentimeter(16);
|
||||||
|
chart.Height = Unit.FromCentimeter(12);
|
||||||
|
chart.TopArea.AddParagraph(title);
|
||||||
|
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||||
|
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
||||||
|
chart.YAxis.HasMajorGridlines = true;
|
||||||
|
chart.PlotArea.LineFormat.Width = 1;
|
||||||
|
chart.PlotArea.LineFormat.Visible = true;
|
||||||
|
chart.TopArea.AddLegend();
|
||||||
|
_document.LastSection.Add(chart);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Build()
|
||||||
|
{
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
|
{
|
||||||
|
Document = _document
|
||||||
|
};
|
||||||
|
renderer.RenderDocument();
|
||||||
|
renderer.PdfDocument.Save(_filePath);
|
||||||
|
}
|
||||||
|
private void DefineStyles()
|
||||||
|
{
|
||||||
|
var headerStyle = _document.Styles.AddStyle("NormalBold", "Normal");
|
||||||
|
headerStyle.Font.Bold = true;
|
||||||
|
headerStyle.Font.Size = 14;
|
||||||
|
}
|
||||||
|
}
|
62
ProjectHorseRacing/ProjectHorseRacing/Reports/TableReport.cs
Normal file
62
ProjectHorseRacing/ProjectHorseRacing/Reports/TableReport.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ProjectHorseRacing.Repositories;
|
||||||
|
using ProjectHorseRacing.Repositories.Implementation;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Reports;
|
||||||
|
|
||||||
|
internal class TableReport
|
||||||
|
{
|
||||||
|
private readonly IResultRepository _resultRepository;
|
||||||
|
private readonly IBuyHorseRepository _buyHorseRepository;
|
||||||
|
private readonly ILogger<TableReport> _logger;
|
||||||
|
internal static readonly string[] item = ["Лошадь", "Дата", "Стоимость"];
|
||||||
|
|
||||||
|
public TableReport(IResultRepository resultRepository, IBuyHorseRepository buyHorseRepository, ILogger<TableReport> logger)
|
||||||
|
{
|
||||||
|
_resultRepository = resultRepository ?? throw new ArgumentNullException(nameof(ResultRepository));
|
||||||
|
_buyHorseRepository = buyHorseRepository ?? throw new ArgumentNullException(nameof(BuyHorseRepository));
|
||||||
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateTable(string filePath, int ownersId, DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new ExcelBuilder(filePath)
|
||||||
|
.AddHeader("Сводка по покупке лошадей", 0, 2)
|
||||||
|
.AddParagraph("за период", 0)
|
||||||
|
.AddTable([10, 10, 10], GetData(ownersId, startDate, endDate))
|
||||||
|
.Build();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetData(int ownerId, DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
var buyHorses = _buyHorseRepository
|
||||||
|
.ReadBuyHorse()
|
||||||
|
.Where(x => x.DatePurchase >= startDate && x.DatePurchase <= endDate && x.OwnersId == ownerId)
|
||||||
|
.SelectMany(bh => bh.BuyHorseHorses, (bh, bhh) => new
|
||||||
|
{
|
||||||
|
Date = bh.DatePurchase,
|
||||||
|
OwnerId = bh.OwnersId,
|
||||||
|
HorseId = bhh.HorseId,
|
||||||
|
Cost = bhh.Cost
|
||||||
|
})
|
||||||
|
.OrderBy(x => x.Date);
|
||||||
|
|
||||||
|
return new List<string[]>() { item }
|
||||||
|
.Union(buyHorses
|
||||||
|
.Select(x => new string[] { x.HorseId.ToString(), x.Date.ToString("dd.MM.yyyy"), x.Cost.ToString()! }))
|
||||||
|
.Union(new[]
|
||||||
|
{
|
||||||
|
new string[] { "Всего", "", buyHorses.Sum(x => x.Cost).ToString()! }
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
109
ProjectHorseRacing/ProjectHorseRacing/Reports/WordBuilder.cs
Normal file
109
ProjectHorseRacing/ProjectHorseRacing/Reports/WordBuilder.cs
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Reports;
|
||||||
|
|
||||||
|
internal class WordBuilder
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly string _filePath;
|
||||||
|
|
||||||
|
private readonly Document _document;
|
||||||
|
|
||||||
|
private readonly Body _body;
|
||||||
|
|
||||||
|
public WordBuilder(string filePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(filePath));
|
||||||
|
}
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filePath = filePath;
|
||||||
|
_document = new Document();
|
||||||
|
_body = _document.AppendChild(new Body());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public WordBuilder AddHeader(string header)
|
||||||
|
{
|
||||||
|
var paragraph = _body.AppendChild(new Paragraph());
|
||||||
|
var run = paragraph.AppendChild(new Run());
|
||||||
|
|
||||||
|
var runProperties = new RunProperties();
|
||||||
|
runProperties.AppendChild(new Bold());
|
||||||
|
run.RunProperties = runProperties;
|
||||||
|
|
||||||
|
run.AppendChild(new Text(header));
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WordBuilder AddParagraph(string text)
|
||||||
|
{
|
||||||
|
var paragraph = _body.AppendChild(new Paragraph());
|
||||||
|
var run = paragraph.AppendChild(new Run());
|
||||||
|
run.AppendChild(new Text(text));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WordBuilder AddTable(int[] widths, List<string[]> data)
|
||||||
|
{
|
||||||
|
if (widths == null || widths.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(widths));
|
||||||
|
}
|
||||||
|
if (data == null || data.Count == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(data));
|
||||||
|
}
|
||||||
|
if (data.Any(x => x.Length != widths.Length))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("widths.Length != data.Length");
|
||||||
|
}
|
||||||
|
var table = new Table();
|
||||||
|
table.AppendChild(new TableProperties(
|
||||||
|
new TableBorders(
|
||||||
|
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 }
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
var tr = new TableRow();
|
||||||
|
for (var j = 0; j < widths.Length; ++j)
|
||||||
|
{
|
||||||
|
tr.Append(new TableCell(
|
||||||
|
new TableCellProperties(new TableCellWidth() { Width = widths[j].ToString() }),
|
||||||
|
new Paragraph(new Run(new RunProperties(new Bold()), new Text(data.First()[j])))));
|
||||||
|
}
|
||||||
|
table.Append(tr);
|
||||||
|
|
||||||
|
table.Append(data.Skip(1).Select(x =>
|
||||||
|
new TableRow(x.Select(y => new TableCell(new Paragraph(new Run(new Text(y))))))));
|
||||||
|
_body.Append(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Build()
|
||||||
|
{
|
||||||
|
using var wordDocument = WordprocessingDocument.Create(_filePath, WordprocessingDocumentType.Document);
|
||||||
|
var mainPart = wordDocument.AddMainDocumentPart();
|
||||||
|
mainPart.Document = _document;
|
||||||
|
}
|
||||||
|
}
|
@ -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(DateTime? dateForm = null, DateTime? dateTo = null, int? ownersId = null);
|
||||||
|
|
||||||
|
void CreateBuyHorse(BuyHorse buyHorse);
|
||||||
|
|
||||||
|
void DeleteBuyHorse(int id);
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Repositories;
|
||||||
|
|
||||||
|
public interface IConnectionString
|
||||||
|
{
|
||||||
|
public string ConnectionString { get; }
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
@ -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);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
using ProjectHorseRacing.Entities;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using Dapper;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Repositories.Implementation;
|
||||||
|
|
||||||
|
public class BuyHorseRepository : IBuyHorseRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<BuyHorseRepository> _logger;
|
||||||
|
|
||||||
|
public BuyHorseRepository(IConnectionString connectionString, ILogger<BuyHorseRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateBuyHorse(BuyHorse buyHorse)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(buyHorse));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
using var transaction = connection.BeginTransaction();
|
||||||
|
var queryInsert = @"
|
||||||
|
INSERT INTO BuyHorse (OwnersId, DatePurchase)
|
||||||
|
VALUES (@OwnersId, @DatePurchase);
|
||||||
|
SELECT MAX(Id) FROM BuyHorse";
|
||||||
|
var buyHorseId = connection.QueryFirst<int>(queryInsert, buyHorse, transaction);
|
||||||
|
var queryBuyInsert = @"
|
||||||
|
INSERT INTO BuyHorseHorse (BuyHorseId, HorseId, Cost)
|
||||||
|
VALUES (@BuyHorseId, @HorseId, @Cost)";
|
||||||
|
|
||||||
|
foreach (var elem in buyHorse.BuyHorseHorses)
|
||||||
|
{
|
||||||
|
connection.Execute(queryBuyInsert, new
|
||||||
|
{
|
||||||
|
buyHorseId,
|
||||||
|
elem.HorseId,
|
||||||
|
elem.Cost
|
||||||
|
}, transaction);
|
||||||
|
}
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DeleteBuyHorse(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
using var transaction = connection.BeginTransaction();
|
||||||
|
var queryDeleteSub = @"
|
||||||
|
DELETE FROM BuyHorseHorse
|
||||||
|
WHERE BuyHorseId = @id";
|
||||||
|
connection.Execute(queryDeleteSub, new { id }, transaction);
|
||||||
|
|
||||||
|
var queryDelete = @"
|
||||||
|
DELETE FROM BuyHorse
|
||||||
|
WHERE Id = @id";
|
||||||
|
connection.Execute(queryDelete, new { id }, transaction);
|
||||||
|
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<BuyHorse> ReadBuyHorse(DateTime? dateForm = null, DateTime? dateTo = null, int? ownersId = null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"SELECT bh.*, bhh.HorseId, bhh.Cost FROM BuyHorse bh
|
||||||
|
INNER JOIN BuyHorseHorse bhh on bhh.BuyHorseId = bh.Id";
|
||||||
|
var buyHorse = connection.Query<TempBuyHorseHorse>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(buyHorse));
|
||||||
|
return buyHorse.GroupBy(x => x.Id, y => y, (key, value) => BuyHorse.CreateEntity(value.First(), value.Select(z => BuyHorseHorse.CreateElement(0, z.HorseId, z.Cost)))).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Repositories.Implementation;
|
||||||
|
|
||||||
|
public class ConnectionString : IConnectionString
|
||||||
|
{
|
||||||
|
string IConnectionString.ConnectionString => "Host=localhost;Port=5432;Username=postgres;Password=postgres;Database=otp;Include Error Detail=true";
|
||||||
|
}
|
@ -0,0 +1,133 @@
|
|||||||
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.VisualBasic.Devices;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using ProjectHorseRacing.Entities;
|
||||||
|
using ProjectHorseRacing.Entities.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Repositories.Implementation;
|
||||||
|
|
||||||
|
public class HorseRepository : IHorseRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<HorseRepository> _logger;
|
||||||
|
|
||||||
|
public HorseRepository(IConnectionString connectionString, ILogger<HorseRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateHorse(Horse horse)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(horse));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryInsert = @"
|
||||||
|
INSERT INTO Horse (Nickname, HorseGender, AgeHorse, HorseCharacters)
|
||||||
|
VALUES (@Nickname, @HorseGender, @AgeHorse, @HorseCharacters)";
|
||||||
|
connection.Execute(queryInsert, horse);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DeleteHorse(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"
|
||||||
|
DELETE FROM Horse
|
||||||
|
WHERE Id=@id";
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Horse ReadHorseById(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение объекта по идентификатору");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"
|
||||||
|
SELECT * FROM Horse
|
||||||
|
WHERE Id=@id";
|
||||||
|
var horse = connection.QueryFirst<Horse>(querySelect, new { id });
|
||||||
|
_logger.LogDebug("Найденный объект: {json}",
|
||||||
|
JsonConvert.SerializeObject(horse));
|
||||||
|
return horse;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IEnumerable<Horse> ReadHorses()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = "SELECT * FROM Horse";
|
||||||
|
var horses = connection.Query<Horse>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
|
JsonConvert.SerializeObject(horses));
|
||||||
|
return horses;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void UpdateHorse(Horse horse)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Редактирование объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}",
|
||||||
|
JsonConvert.SerializeObject(horse));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryUpdate = @"
|
||||||
|
UPDATE Horse
|
||||||
|
SET
|
||||||
|
Nickname = @Nickname,
|
||||||
|
HorseGender = @HorseGender,
|
||||||
|
AgeHorse = @AgeHorse,
|
||||||
|
HorseCharacters = @HorseCharacters
|
||||||
|
WHERE Id= @Id";
|
||||||
|
connection.Execute(queryUpdate, horse);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,130 @@
|
|||||||
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using ProjectHorseRacing.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Repositories.Implementation;
|
||||||
|
|
||||||
|
public class JockeyRepository : IJockeyRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<JockeyRepository> _logger;
|
||||||
|
|
||||||
|
public JockeyRepository(IConnectionString connectionString, ILogger<JockeyRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateJockey(Jockey jockey)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(jockey));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryInsert = @"
|
||||||
|
INSERT INTO Jockey (FirstName, LastName, Age, Rating)
|
||||||
|
VALUES (@FirstName, @LastName, @Age, @Rating)";
|
||||||
|
connection.Execute(queryInsert, jockey);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DeleteJockey(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"
|
||||||
|
DELETE FROM Jockey
|
||||||
|
WHERE Id=@id";
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Jockey ReadJockeyById(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение объекта по идентификатору");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"
|
||||||
|
SELECT * FROM Jockey
|
||||||
|
WHERE Id=@id";
|
||||||
|
var jockey = connection.QueryFirst<Jockey>(querySelect, new { id });
|
||||||
|
_logger.LogDebug("Найденный объект: {json}",
|
||||||
|
JsonConvert.SerializeObject(jockey));
|
||||||
|
return jockey;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IEnumerable<Jockey> ReadJockeys()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = "SELECT * FROM Jockey";
|
||||||
|
var jockeys = connection.Query<Jockey>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
|
JsonConvert.SerializeObject(jockeys));
|
||||||
|
return jockeys;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void UpdateJockey(Jockey jockey)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Редактирование объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}",
|
||||||
|
JsonConvert.SerializeObject(jockey));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryUpdate = @"
|
||||||
|
UPDATE Jockey
|
||||||
|
SET
|
||||||
|
FirstName= @FirstName,
|
||||||
|
LastName= @LastName,
|
||||||
|
Age= @Age,
|
||||||
|
Rating= @Rating
|
||||||
|
WHERE Id= @Id";
|
||||||
|
connection.Execute(queryUpdate, jockey);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,130 @@
|
|||||||
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using ProjectHorseRacing.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Repositories.Implementation;
|
||||||
|
|
||||||
|
public class OwnerRepository : IOwnerRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
private readonly ILogger<OwnerRepository> _logger;
|
||||||
|
|
||||||
|
public OwnerRepository(IConnectionString connectionString, ILogger<OwnerRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateOwner(Owners owner)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(owner));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryInsert = @"
|
||||||
|
INSERT INTO Owners (FirstName, LastName, Address, PhoneNumber)
|
||||||
|
VALUES (@FirstName, @LastName, @Address, @PhoneNumber)";
|
||||||
|
connection.Execute(queryInsert, owner);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DeleteOwner(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"
|
||||||
|
DELETE FROM Owners
|
||||||
|
WHERE Id=@id";
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Owners ReadOwnerById(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение объекта по идентификатору");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"
|
||||||
|
SELECT * FROM Owners
|
||||||
|
WHERE Id=@id";
|
||||||
|
var owner = connection.QueryFirst<Owners>(querySelect, new { id });
|
||||||
|
_logger.LogDebug("Найденный объект: {json}",
|
||||||
|
JsonConvert.SerializeObject(owner));
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IEnumerable<Owners> ReadOwners()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = "SELECT * FROM Owners";
|
||||||
|
var owners = connection.Query<Owners>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
|
JsonConvert.SerializeObject(owners));
|
||||||
|
return owners;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void UpdateOwner(Owners owner)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Редактирование объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}",
|
||||||
|
JsonConvert.SerializeObject(owner));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryUpdate = @"
|
||||||
|
UPDATE Owners
|
||||||
|
SET
|
||||||
|
FirstName= @FirstName,
|
||||||
|
LastName= @LastName,
|
||||||
|
Address= @Address,
|
||||||
|
PhoneNumber= @PhoneNumber
|
||||||
|
WHERE Id= @Id";
|
||||||
|
connection.Execute(queryUpdate, owner);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,130 @@
|
|||||||
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using ProjectHorseRacing.Entities;
|
||||||
|
using ProjectHorseRacing.Entities.Enums;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Repositories.Implementation;
|
||||||
|
|
||||||
|
public class RaceRepository : IRaceRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<RaceRepository> _logger;
|
||||||
|
|
||||||
|
public RaceRepository(IConnectionString connectionString, ILogger<RaceRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateRace(Race race)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(race));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryInsert = @"
|
||||||
|
INSERT INTO Race (DateTime, RacePlaceEvent)
|
||||||
|
VALUES (@DateTime, @RacePlaceEvent)";
|
||||||
|
connection.Execute(queryInsert, race);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DeleteRace(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"
|
||||||
|
DELETE FROM Race
|
||||||
|
WHERE Id=@id";
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Race ReadRaceById(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение объекта по идентификатору");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"
|
||||||
|
SELECT * FROM Race
|
||||||
|
WHERE Id=@id";
|
||||||
|
var race = connection.QueryFirst<Race>(querySelect, new { id });
|
||||||
|
_logger.LogDebug("Найденный объект: {json}",
|
||||||
|
JsonConvert.SerializeObject(race));
|
||||||
|
return race;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IEnumerable<Race> ReadRaces(DateTime? dateFrom = null, DateTime? dateTo = null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = "SELECT * FROM Race";
|
||||||
|
var races = connection.Query<Race>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
|
JsonConvert.SerializeObject(races));
|
||||||
|
return races;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void UpdateRace(Race race)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Редактирование объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}",
|
||||||
|
JsonConvert.SerializeObject(race));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryUpdate = @"
|
||||||
|
UPDATE Race
|
||||||
|
SET
|
||||||
|
DateTime= @DateTime,
|
||||||
|
RacePlaceEvent= @RacePlaceEvent
|
||||||
|
WHERE Id= @Id";
|
||||||
|
connection.Execute(queryUpdate, race);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
using ProjectHorseRacing.Entities.Enums;
|
||||||
|
using ProjectHorseRacing.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using Dapper;
|
||||||
|
|
||||||
|
namespace ProjectHorseRacing.Repositories.Implementation;
|
||||||
|
|
||||||
|
public class ResultRepository : IResultRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<ResultRepository> _logger;
|
||||||
|
|
||||||
|
public ResultRepository(IConnectionString connectionString, ILogger<ResultRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateResult(Result result)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(result));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryInsert = @"
|
||||||
|
INSERT INTO Result (Position, RaceId, JockeyId, HorseId)
|
||||||
|
VALUES (@Position, @RaceId, @JockeyId, @HorseId)";
|
||||||
|
connection.Execute(queryInsert, result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Result> ReadResults(int? RaceId = null, int? JockeyId = null, int? HorseId = null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = "SELECT * FROM Result";
|
||||||
|
var results = connection.Query<Result>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
|
JsonConvert.SerializeObject(results));
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
BIN
ProjectHorseRacing/ProjectHorseRacing/Resources/карандаш.png
Normal file
BIN
ProjectHorseRacing/ProjectHorseRacing/Resources/карандаш.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
BIN
ProjectHorseRacing/ProjectHorseRacing/Resources/минус.png
Normal file
BIN
ProjectHorseRacing/ProjectHorseRacing/Resources/минус.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
ProjectHorseRacing/ProjectHorseRacing/Resources/плюс.png
Normal file
BIN
ProjectHorseRacing/ProjectHorseRacing/Resources/плюс.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 85 KiB |
BIN
ProjectHorseRacing/ProjectHorseRacing/Resources/скачки.jpg
Normal file
BIN
ProjectHorseRacing/ProjectHorseRacing/Resources/скачки.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 75 KiB |
15
ProjectHorseRacing/ProjectHorseRacing/appsettings.json
Normal file
15
ProjectHorseRacing/ProjectHorseRacing/appsettings.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"Serilog": {
|
||||||
|
"Using": [ "Serilog.Sinks.File" ],
|
||||||
|
"MinimumLevel": "Debug",
|
||||||
|
"WriteTo": [
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "Logs/log.txt",
|
||||||
|
"rollingInterval": "Day"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user