Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
21a4ca5b54 | |||
576315f37e | |||
fb1d67338c | |||
ffcf9d2df8 | |||
570615e48a | |||
745617d8b5 | |||
5112c074d3 |
@ -0,0 +1,29 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities.Enums;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Entities;
|
||||||
|
|
||||||
|
public class Athlete
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Surname { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public KindOfSport KindOfSport { get; private set; }
|
||||||
|
|
||||||
|
public AthleteClassification AthleteClassification { get; private set; }
|
||||||
|
|
||||||
|
public static Athlete CreateEntity(int id, string name, string surname,
|
||||||
|
KindOfSport sport, AthleteClassification athleteClassification)
|
||||||
|
{
|
||||||
|
return new Athlete
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Name = name ?? string.Empty,
|
||||||
|
Surname = surname ?? string.Empty,
|
||||||
|
KindOfSport = sport,
|
||||||
|
AthleteClassification = athleteClassification
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Entities;
|
||||||
|
|
||||||
|
public class AthleteAccommodation
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public int RoomId { get; private set; }
|
||||||
|
|
||||||
|
public int AthleteId { get; private set; }
|
||||||
|
|
||||||
|
public decimal Price { get; private set; }
|
||||||
|
|
||||||
|
public DateTime DateStart { get; private set; }
|
||||||
|
|
||||||
|
public DateTime DateEnd { get; private set; }
|
||||||
|
|
||||||
|
public static AthleteAccommodation CreateOpeartion(int id, int roomId, int athleteId, decimal price)
|
||||||
|
{
|
||||||
|
var dateStart = DateTime.Now;
|
||||||
|
return new AthleteAccommodation
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
RoomId = roomId,
|
||||||
|
AthleteId = athleteId,
|
||||||
|
Price = price,
|
||||||
|
DateStart = dateStart,
|
||||||
|
DateEnd = dateStart.AddMonths(1)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Entities.Enums;
|
||||||
|
|
||||||
|
public enum AthleteClassification
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
FirstCategory = 1,
|
||||||
|
|
||||||
|
SecondCategory = 2,
|
||||||
|
|
||||||
|
ThirdCategory = 3
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Entities.Enums;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum KindOfSport
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
Football = 1,
|
||||||
|
|
||||||
|
Basketball = 2,
|
||||||
|
|
||||||
|
Hockey = 4,
|
||||||
|
|
||||||
|
Tennis = 8,
|
||||||
|
|
||||||
|
Handball = 16
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Entities.Enums;
|
||||||
|
|
||||||
|
public enum TypeOfRoom
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
Single = 1,
|
||||||
|
|
||||||
|
Double = 2,
|
||||||
|
|
||||||
|
Triple = 3
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Entities;
|
||||||
|
|
||||||
|
public class Hotel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public static Hotel CreateEntity(int id, string name)
|
||||||
|
{
|
||||||
|
return new Hotel
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Name = name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities.Enums;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Entities;
|
||||||
|
|
||||||
|
public class Room
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public int HotelId { get; private set; }
|
||||||
|
|
||||||
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public TypeOfRoom TypeOfRoom { get; private set; }
|
||||||
|
|
||||||
|
public static Room CreateEntity(int id, int hotelId, string name,
|
||||||
|
TypeOfRoom typeOfRoom)
|
||||||
|
{
|
||||||
|
return new Room
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
HotelId = hotelId,
|
||||||
|
Name = name ?? string.Empty,
|
||||||
|
TypeOfRoom = typeOfRoom
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Entities;
|
||||||
|
|
||||||
|
public class ServiceProvision
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public int HotelId { get; private set; }
|
||||||
|
|
||||||
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
|
public IEnumerable<ServiceProvisionConnection> ServiceProvisionConnection { get; private set; } = [];
|
||||||
|
|
||||||
|
public static ServiceProvision CreateOpeartion(int id, int hotelId, string name,
|
||||||
|
IEnumerable<ServiceProvisionConnection> serviceProvisionConnection)
|
||||||
|
{
|
||||||
|
return new ServiceProvision
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
HotelId = hotelId,
|
||||||
|
Name = name ?? string.Empty,
|
||||||
|
Date = DateTime.Now,
|
||||||
|
ServiceProvisionConnection = serviceProvisionConnection
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ServiceProvision CreateOpeartion(TempServiceProvisionConnection tempServiceProvisionConnection,
|
||||||
|
IEnumerable<ServiceProvisionConnection> serviceProvisionConnection)
|
||||||
|
{
|
||||||
|
return new ServiceProvision
|
||||||
|
{
|
||||||
|
Id = tempServiceProvisionConnection.Id,
|
||||||
|
HotelId = tempServiceProvisionConnection.HotelId,
|
||||||
|
Name = tempServiceProvisionConnection.Name,
|
||||||
|
Date = tempServiceProvisionConnection.Date,
|
||||||
|
ServiceProvisionConnection = serviceProvisionConnection
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Entities;
|
||||||
|
|
||||||
|
public class ServiceProvisionConnection
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public int AthleteId { get; private set; }
|
||||||
|
|
||||||
|
public decimal Price { get; private set; }
|
||||||
|
|
||||||
|
public static ServiceProvisionConnection CreateElement(int id, int athleteId, decimal price)
|
||||||
|
{
|
||||||
|
return new ServiceProvisionConnection
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
AthleteId = athleteId,
|
||||||
|
Price = price
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Entities;
|
||||||
|
|
||||||
|
public class TempServiceProvisionConnection
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public int HotelId { get; private set; }
|
||||||
|
|
||||||
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
|
public int AthleteId { get; private set; }
|
||||||
|
|
||||||
|
public decimal Price { get; private set; }
|
||||||
|
}
|
@ -1,39 +0,0 @@
|
|||||||
namespace ProjectAthletesAccommodation
|
|
||||||
{
|
|
||||||
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 ProjectAthletesAccommodation
|
|
||||||
{
|
|
||||||
public partial class Form1 : Form
|
|
||||||
{
|
|
||||||
public Form1()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
169
ProjectAthletesAccommodation/ProjectAthletesAccommodation/FormAthleteAccommodation.Designer.cs
generated
Normal file
169
ProjectAthletesAccommodation/ProjectAthletesAccommodation/FormAthleteAccommodation.Designer.cs
generated
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
namespace ProjectAthletesAccommodation
|
||||||
|
{
|
||||||
|
partial class FormAthleteAccommodation
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
DirectoryToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
AthletesToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
HotelsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
RoomsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
OperationsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
AthletesAccommodationToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ServicesProvisionToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ReportsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
AthleteReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
AccommodationOfAthletesToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
menuStrip1.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// menuStrip1
|
||||||
|
//
|
||||||
|
menuStrip1.Items.AddRange(new ToolStripItem[] { DirectoryToolStripMenuItem, OperationsToolStripMenuItem, ReportsToolStripMenuItem });
|
||||||
|
menuStrip1.Location = new Point(0, 0);
|
||||||
|
menuStrip1.Name = "menuStrip1";
|
||||||
|
menuStrip1.Size = new Size(784, 24);
|
||||||
|
menuStrip1.TabIndex = 0;
|
||||||
|
menuStrip1.Text = "menuStrip";
|
||||||
|
//
|
||||||
|
// DirectoryToolStripMenuItem
|
||||||
|
//
|
||||||
|
DirectoryToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { AthletesToolStripMenuItem, HotelsToolStripMenuItem, RoomsToolStripMenuItem });
|
||||||
|
DirectoryToolStripMenuItem.Name = "DirectoryToolStripMenuItem";
|
||||||
|
DirectoryToolStripMenuItem.Size = new Size(94, 20);
|
||||||
|
DirectoryToolStripMenuItem.Text = "Справочники";
|
||||||
|
//
|
||||||
|
// AthletesToolStripMenuItem
|
||||||
|
//
|
||||||
|
AthletesToolStripMenuItem.Name = "AthletesToolStripMenuItem";
|
||||||
|
AthletesToolStripMenuItem.Size = new Size(145, 22);
|
||||||
|
AthletesToolStripMenuItem.Text = "Спортсмены";
|
||||||
|
AthletesToolStripMenuItem.Click += AthletesToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// HotelsToolStripMenuItem
|
||||||
|
//
|
||||||
|
HotelsToolStripMenuItem.Name = "HotelsToolStripMenuItem";
|
||||||
|
HotelsToolStripMenuItem.Size = new Size(145, 22);
|
||||||
|
HotelsToolStripMenuItem.Text = "Гостиницы";
|
||||||
|
HotelsToolStripMenuItem.Click += HotelsToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// RoomsToolStripMenuItem
|
||||||
|
//
|
||||||
|
RoomsToolStripMenuItem.Name = "RoomsToolStripMenuItem";
|
||||||
|
RoomsToolStripMenuItem.Size = new Size(145, 22);
|
||||||
|
RoomsToolStripMenuItem.Text = "Номера";
|
||||||
|
RoomsToolStripMenuItem.Click += RoomsToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// OperationsToolStripMenuItem
|
||||||
|
//
|
||||||
|
OperationsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { AthletesAccommodationToolStripMenuItem, ServicesProvisionToolStripMenuItem });
|
||||||
|
OperationsToolStripMenuItem.Name = "OperationsToolStripMenuItem";
|
||||||
|
OperationsToolStripMenuItem.Size = new Size(75, 20);
|
||||||
|
OperationsToolStripMenuItem.Text = "Операции";
|
||||||
|
//
|
||||||
|
// AthletesAccommodationToolStripMenuItem
|
||||||
|
//
|
||||||
|
AthletesAccommodationToolStripMenuItem.Name = "AthletesAccommodationToolStripMenuItem";
|
||||||
|
AthletesAccommodationToolStripMenuItem.Size = new Size(220, 22);
|
||||||
|
AthletesAccommodationToolStripMenuItem.Text = "Размещение спортсменов";
|
||||||
|
AthletesAccommodationToolStripMenuItem.Click += AthletesAccommodationToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// ServicesProvisionToolStripMenuItem
|
||||||
|
//
|
||||||
|
ServicesProvisionToolStripMenuItem.Name = "ServicesProvisionToolStripMenuItem";
|
||||||
|
ServicesProvisionToolStripMenuItem.Size = new Size(220, 22);
|
||||||
|
ServicesProvisionToolStripMenuItem.Text = "Предоставление услуг";
|
||||||
|
ServicesProvisionToolStripMenuItem.Click += ServicesProvisionToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// ReportsToolStripMenuItem
|
||||||
|
//
|
||||||
|
ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, AthleteReportToolStripMenuItem, AccommodationOfAthletesToolStripMenuItem });
|
||||||
|
ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem";
|
||||||
|
ReportsToolStripMenuItem.Size = new Size(60, 20);
|
||||||
|
ReportsToolStripMenuItem.Text = "Отчёты";
|
||||||
|
//
|
||||||
|
// DirectoryReportToolStripMenuItem
|
||||||
|
//
|
||||||
|
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
|
||||||
|
DirectoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
||||||
|
DirectoryReportToolStripMenuItem.Size = new Size(280, 22);
|
||||||
|
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками";
|
||||||
|
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// AthleteReportToolStripMenuItem
|
||||||
|
//
|
||||||
|
AthleteReportToolStripMenuItem.Name = "AthleteReportToolStripMenuItem";
|
||||||
|
AthleteReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||||
|
AthleteReportToolStripMenuItem.Size = new Size(280, 22);
|
||||||
|
AthleteReportToolStripMenuItem.Text = "Сведения о спортсменах";
|
||||||
|
AthleteReportToolStripMenuItem.Click += AthleteReportToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// AccommodationOfAthletesToolStripMenuItem
|
||||||
|
//
|
||||||
|
AccommodationOfAthletesToolStripMenuItem.Name = "AccommodationOfAthletesToolStripMenuItem";
|
||||||
|
AccommodationOfAthletesToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
|
||||||
|
AccommodationOfAthletesToolStripMenuItem.Size = new Size(280, 22);
|
||||||
|
AccommodationOfAthletesToolStripMenuItem.Text = "Заселение спортсменов";
|
||||||
|
AccommodationOfAthletesToolStripMenuItem.Click += AccommodationOfAthletesToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// FormAthleteAccommodation
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
BackgroundImage = Properties.Resources.Гостиница1;
|
||||||
|
BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
ClientSize = new Size(784, 461);
|
||||||
|
Controls.Add(menuStrip1);
|
||||||
|
DoubleBuffered = true;
|
||||||
|
MainMenuStrip = menuStrip1;
|
||||||
|
Name = "FormAthleteAccommodation";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
Text = "Размещение спортсменов";
|
||||||
|
menuStrip1.ResumeLayout(false);
|
||||||
|
menuStrip1.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private MenuStrip menuStrip1;
|
||||||
|
private ToolStripMenuItem DirectoryToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem AthletesToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem HotelsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem RoomsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem OperationsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem AthletesAccommodationToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ServicesProvisionToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ReportsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem AthleteReportToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem AccommodationOfAthletesToolStripMenuItem;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,120 @@
|
|||||||
|
using ProjectAthletesAccommodation.Forms;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation
|
||||||
|
{
|
||||||
|
public partial class FormAthleteAccommodation : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
public FormAthleteAccommodation(IUnityContainer container)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AthletesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormAthletes>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HotelsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormHotels>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RoomsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormRooms>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AthletesAccommodationToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormAthletesAccommodation>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ServicesProvisionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormServicesProvision>().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 AthleteReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormAthleteReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AccommodationOfAthletesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormAthleteAccommodationReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
165
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormAthlete.Designer.cs
generated
Normal file
165
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormAthlete.Designer.cs
generated
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
partial class FormAthlete
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
labelName = new Label();
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
labelSurname = new Label();
|
||||||
|
textBoxSurname = new TextBox();
|
||||||
|
comboBoxClassification = new ComboBox();
|
||||||
|
labelClassification = new Label();
|
||||||
|
labelSport = new Label();
|
||||||
|
buttonSave = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
checkedListBoxSport = new CheckedListBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
labelName.AutoSize = true;
|
||||||
|
labelName.Location = new Point(88, 28);
|
||||||
|
labelName.Name = "labelName";
|
||||||
|
labelName.Size = new Size(31, 15);
|
||||||
|
labelName.TabIndex = 0;
|
||||||
|
labelName.Text = "Имя";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(125, 25);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(202, 23);
|
||||||
|
textBoxName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelSurname
|
||||||
|
//
|
||||||
|
labelSurname.AutoSize = true;
|
||||||
|
labelSurname.Location = new Point(61, 72);
|
||||||
|
labelSurname.Name = "labelSurname";
|
||||||
|
labelSurname.Size = new Size(58, 15);
|
||||||
|
labelSurname.TabIndex = 2;
|
||||||
|
labelSurname.Text = "Фамилия";
|
||||||
|
//
|
||||||
|
// textBoxSurname
|
||||||
|
//
|
||||||
|
textBoxSurname.Location = new Point(125, 69);
|
||||||
|
textBoxSurname.Name = "textBoxSurname";
|
||||||
|
textBoxSurname.Size = new Size(202, 23);
|
||||||
|
textBoxSurname.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// comboBoxClassification
|
||||||
|
//
|
||||||
|
comboBoxClassification.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxClassification.FormattingEnabled = true;
|
||||||
|
comboBoxClassification.Location = new Point(125, 113);
|
||||||
|
comboBoxClassification.Name = "comboBoxClassification";
|
||||||
|
comboBoxClassification.Size = new Size(202, 23);
|
||||||
|
comboBoxClassification.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// labelClassification
|
||||||
|
//
|
||||||
|
labelClassification.AutoSize = true;
|
||||||
|
labelClassification.Location = new Point(25, 116);
|
||||||
|
labelClassification.Name = "labelClassification";
|
||||||
|
labelClassification.Size = new Size(94, 15);
|
||||||
|
labelClassification.TabIndex = 5;
|
||||||
|
labelClassification.Text = "Классификация";
|
||||||
|
//
|
||||||
|
// labelSport
|
||||||
|
//
|
||||||
|
labelSport.AutoSize = true;
|
||||||
|
labelSport.Location = new Point(51, 157);
|
||||||
|
labelSport.Name = "labelSport";
|
||||||
|
labelSport.Size = new Size(68, 15);
|
||||||
|
labelSport.TabIndex = 6;
|
||||||
|
labelSport.Text = "Вид спорта";
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(25, 268);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(142, 49);
|
||||||
|
buttonSave.TabIndex = 7;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(185, 268);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(142, 49);
|
||||||
|
buttonCancel.TabIndex = 8;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// checkedListBoxSport
|
||||||
|
//
|
||||||
|
checkedListBoxSport.FormattingEnabled = true;
|
||||||
|
checkedListBoxSport.Location = new Point(125, 157);
|
||||||
|
checkedListBoxSport.Name = "checkedListBoxSport";
|
||||||
|
checkedListBoxSport.Size = new Size(202, 94);
|
||||||
|
checkedListBoxSport.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// FormAthlete
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(352, 335);
|
||||||
|
Controls.Add(checkedListBoxSport);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(labelSport);
|
||||||
|
Controls.Add(labelClassification);
|
||||||
|
Controls.Add(comboBoxClassification);
|
||||||
|
Controls.Add(textBoxSurname);
|
||||||
|
Controls.Add(labelSurname);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(labelName);
|
||||||
|
Name = "FormAthlete";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Спортсмен";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelName;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Label labelSurname;
|
||||||
|
private TextBox textBoxSurname;
|
||||||
|
private ComboBox comboBoxClassification;
|
||||||
|
private Label labelClassification;
|
||||||
|
private Label labelSport;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private CheckedListBox checkedListBoxSport;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
using ProjectAthletesAccommodation.Entities.Enums;
|
||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
public partial class FormAthlete : Form
|
||||||
|
{
|
||||||
|
private readonly IAthleteRepository _athleteRepository;
|
||||||
|
|
||||||
|
private int? _athleteId;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var athlete = _athleteRepository.ReadAthleteById(value);
|
||||||
|
|
||||||
|
if (athlete == null)
|
||||||
|
{
|
||||||
|
throw new
|
||||||
|
InvalidDataException(nameof(athlete));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (KindOfSport elem in Enum.GetValues(typeof(KindOfSport)))
|
||||||
|
{
|
||||||
|
if ((elem & athlete.KindOfSport) != 0)
|
||||||
|
{
|
||||||
|
checkedListBoxSport.SetItemChecked(checkedListBoxSport.Items.IndexOf(elem), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
textBoxName.Text = athlete.Name;
|
||||||
|
textBoxSurname.Text = athlete.Surname;
|
||||||
|
comboBoxClassification.SelectedItem = athlete.AthleteClassification;
|
||||||
|
_athleteId = value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormAthlete(IAthleteRepository athleteRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_athleteRepository = athleteRepository ?? throw new ArgumentNullException(nameof(athleteRepository));
|
||||||
|
comboBoxClassification.DataSource = Enum.GetValues(typeof(AthleteClassification));
|
||||||
|
|
||||||
|
foreach (var elem in Enum.GetValues(typeof(KindOfSport)))
|
||||||
|
{
|
||||||
|
checkedListBoxSport.Items.Add(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
|
||||||
|
string.IsNullOrWhiteSpace(textBoxSurname.Text) ||
|
||||||
|
comboBoxClassification.SelectedIndex < 1 ||
|
||||||
|
checkedListBoxSport.CheckedItems.Count == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_athleteId.HasValue)
|
||||||
|
{
|
||||||
|
_athleteRepository.UpdateAthlete(CreateAthlete(_athleteId.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_athleteRepository.CreateAthlete(CreateAthlete(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private Athlete CreateAthlete(int id)
|
||||||
|
{
|
||||||
|
KindOfSport kindOfSport = KindOfSport.None;
|
||||||
|
foreach (var elem in checkedListBoxSport.CheckedItems)
|
||||||
|
{
|
||||||
|
kindOfSport |= (KindOfSport)elem;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Athlete.CreateEntity(id, textBoxName.Text, textBoxSurname.Text,
|
||||||
|
kindOfSport, (AthleteClassification)comboBoxClassification.SelectedItem!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
196
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormAthleteAccommodation.Designer.cs
generated
Normal file
196
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormAthleteAccommodation.Designer.cs
generated
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
partial class FormAthleteAccommodation
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
labelRoom = new Label();
|
||||||
|
labelAthlete = new Label();
|
||||||
|
labelDateStart = new Label();
|
||||||
|
labelDateEnd = new Label();
|
||||||
|
comboBoxRoom = new ComboBox();
|
||||||
|
comboBoxAthlete = new ComboBox();
|
||||||
|
dateTimePickerDateStart = new DateTimePicker();
|
||||||
|
dateTimePickerDateEnd = new DateTimePicker();
|
||||||
|
buttonSave = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
labelPrice = new Label();
|
||||||
|
numericUpDownPrice = new NumericUpDown();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelRoom
|
||||||
|
//
|
||||||
|
labelRoom.AutoSize = true;
|
||||||
|
labelRoom.Location = new Point(106, 27);
|
||||||
|
labelRoom.Name = "labelRoom";
|
||||||
|
labelRoom.Size = new Size(45, 15);
|
||||||
|
labelRoom.TabIndex = 0;
|
||||||
|
labelRoom.Text = "Номер";
|
||||||
|
//
|
||||||
|
// labelAthlete
|
||||||
|
//
|
||||||
|
labelAthlete.AutoSize = true;
|
||||||
|
labelAthlete.Location = new Point(82, 60);
|
||||||
|
labelAthlete.Name = "labelAthlete";
|
||||||
|
labelAthlete.Size = new Size(69, 15);
|
||||||
|
labelAthlete.TabIndex = 1;
|
||||||
|
labelAthlete.Text = "Спортсмен";
|
||||||
|
//
|
||||||
|
// labelDateStart
|
||||||
|
//
|
||||||
|
labelDateStart.AutoSize = true;
|
||||||
|
labelDateStart.Location = new Point(82, 128);
|
||||||
|
labelDateStart.Name = "labelDateStart";
|
||||||
|
labelDateStart.Size = new Size(69, 15);
|
||||||
|
labelDateStart.TabIndex = 2;
|
||||||
|
labelDateStart.Text = "Дата заезда";
|
||||||
|
//
|
||||||
|
// labelDateEnd
|
||||||
|
//
|
||||||
|
labelDateEnd.AutoSize = true;
|
||||||
|
labelDateEnd.Location = new Point(78, 163);
|
||||||
|
labelDateEnd.Name = "labelDateEnd";
|
||||||
|
labelDateEnd.Size = new Size(73, 15);
|
||||||
|
labelDateEnd.TabIndex = 3;
|
||||||
|
labelDateEnd.Text = "Дата выезда";
|
||||||
|
//
|
||||||
|
// comboBoxRoom
|
||||||
|
//
|
||||||
|
comboBoxRoom.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxRoom.FormattingEnabled = true;
|
||||||
|
comboBoxRoom.Location = new Point(157, 24);
|
||||||
|
comboBoxRoom.Name = "comboBoxRoom";
|
||||||
|
comboBoxRoom.Size = new Size(200, 23);
|
||||||
|
comboBoxRoom.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// comboBoxAthlete
|
||||||
|
//
|
||||||
|
comboBoxAthlete.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxAthlete.FormattingEnabled = true;
|
||||||
|
comboBoxAthlete.Location = new Point(157, 57);
|
||||||
|
comboBoxAthlete.Name = "comboBoxAthlete";
|
||||||
|
comboBoxAthlete.Size = new Size(200, 23);
|
||||||
|
comboBoxAthlete.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// dateTimePickerDateStart
|
||||||
|
//
|
||||||
|
dateTimePickerDateStart.Enabled = false;
|
||||||
|
dateTimePickerDateStart.Location = new Point(157, 122);
|
||||||
|
dateTimePickerDateStart.Name = "dateTimePickerDateStart";
|
||||||
|
dateTimePickerDateStart.Size = new Size(200, 23);
|
||||||
|
dateTimePickerDateStart.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// dateTimePickerDateEnd
|
||||||
|
//
|
||||||
|
dateTimePickerDateEnd.Enabled = false;
|
||||||
|
dateTimePickerDateEnd.Location = new Point(157, 157);
|
||||||
|
dateTimePickerDateEnd.Name = "dateTimePickerDateEnd";
|
||||||
|
dateTimePickerDateEnd.Size = new Size(200, 23);
|
||||||
|
dateTimePickerDateEnd.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(18, 202);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(159, 45);
|
||||||
|
buttonSave.TabIndex = 8;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(197, 202);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(160, 45);
|
||||||
|
buttonCancel.TabIndex = 9;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// labelPrice
|
||||||
|
//
|
||||||
|
labelPrice.AutoSize = true;
|
||||||
|
labelPrice.Location = new Point(12, 92);
|
||||||
|
labelPrice.Name = "labelPrice";
|
||||||
|
labelPrice.Size = new Size(139, 15);
|
||||||
|
labelPrice.TabIndex = 10;
|
||||||
|
labelPrice.Text = "Стоимость проживания";
|
||||||
|
//
|
||||||
|
// numericUpDownPrice
|
||||||
|
//
|
||||||
|
numericUpDownPrice.DecimalPlaces = 2;
|
||||||
|
numericUpDownPrice.Location = new Point(157, 90);
|
||||||
|
numericUpDownPrice.Maximum = new decimal(new int[] { 999999999, 0, 0, 0 });
|
||||||
|
numericUpDownPrice.Minimum = new decimal(new int[] { 1, 0, 0, 131072 });
|
||||||
|
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||||
|
numericUpDownPrice.Size = new Size(200, 23);
|
||||||
|
numericUpDownPrice.TabIndex = 11;
|
||||||
|
numericUpDownPrice.Value = new decimal(new int[] { 1, 0, 0, 131072 });
|
||||||
|
//
|
||||||
|
// FormAthleteAccommodation
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(380, 267);
|
||||||
|
Controls.Add(numericUpDownPrice);
|
||||||
|
Controls.Add(labelPrice);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(dateTimePickerDateEnd);
|
||||||
|
Controls.Add(dateTimePickerDateStart);
|
||||||
|
Controls.Add(comboBoxAthlete);
|
||||||
|
Controls.Add(comboBoxRoom);
|
||||||
|
Controls.Add(labelDateEnd);
|
||||||
|
Controls.Add(labelDateStart);
|
||||||
|
Controls.Add(labelAthlete);
|
||||||
|
Controls.Add(labelRoom);
|
||||||
|
Name = "FormAthleteAccommodation";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Размещение спортсмена";
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelRoom;
|
||||||
|
private Label labelAthlete;
|
||||||
|
private Label labelDateStart;
|
||||||
|
private Label labelDateEnd;
|
||||||
|
private ComboBox comboBoxRoom;
|
||||||
|
private ComboBox comboBoxAthlete;
|
||||||
|
private DateTimePicker dateTimePickerDateStart;
|
||||||
|
private DateTimePicker dateTimePickerDateEnd;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Label labelPrice;
|
||||||
|
private NumericUpDown numericUpDownPrice;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
public partial class FormAthleteAccommodation : Form
|
||||||
|
{
|
||||||
|
private readonly IAthleteAccommodationRepository _athleteAccommodationRepository;
|
||||||
|
|
||||||
|
public FormAthleteAccommodation(IAthleteAccommodationRepository athleteAccommodationRepository,
|
||||||
|
IRoomRepository roomRepository, IAthleteRepository athleteRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_athleteAccommodationRepository = athleteAccommodationRepository
|
||||||
|
?? throw new ArgumentNullException(nameof(athleteAccommodationRepository));
|
||||||
|
|
||||||
|
comboBoxRoom.DataSource = roomRepository.ReadRooms();
|
||||||
|
comboBoxRoom.DisplayMember = "Name";
|
||||||
|
comboBoxRoom.ValueMember = "Id";
|
||||||
|
|
||||||
|
comboBoxAthlete.DataSource = athleteRepository.ReadAthletes();
|
||||||
|
comboBoxAthlete.DisplayMember = "Name";
|
||||||
|
comboBoxAthlete.ValueMember = "Id";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (comboBoxRoom.SelectedIndex < 0 || comboBoxAthlete.SelectedIndex < 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
|
||||||
|
_athleteAccommodationRepository.CreateAthleteAccommodation
|
||||||
|
(AthleteAccommodation.CreateOpeartion(0, (int)comboBoxRoom.SelectedValue!,
|
||||||
|
(int)comboBoxAthlete.SelectedValue!, Convert.ToDecimal(numericUpDownPrice.Value)));
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
@ -0,0 +1,108 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
partial class FormAthleteAccommodationReport
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
buttonSelectFileName = new Button();
|
||||||
|
labelFileName = new Label();
|
||||||
|
labelDate = new Label();
|
||||||
|
dateTimePicker = new DateTimePicker();
|
||||||
|
buttonBuild = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonSelectFileName
|
||||||
|
//
|
||||||
|
buttonSelectFileName.Location = new Point(28, 23);
|
||||||
|
buttonSelectFileName.Name = "buttonSelectFileName";
|
||||||
|
buttonSelectFileName.Size = new Size(75, 23);
|
||||||
|
buttonSelectFileName.TabIndex = 0;
|
||||||
|
buttonSelectFileName.Text = "Выбрать";
|
||||||
|
buttonSelectFileName.UseVisualStyleBackColor = true;
|
||||||
|
buttonSelectFileName.Click += ButtonSelectFileName_Click;
|
||||||
|
//
|
||||||
|
// labelFileName
|
||||||
|
//
|
||||||
|
labelFileName.AutoSize = true;
|
||||||
|
labelFileName.Location = new Point(109, 27);
|
||||||
|
labelFileName.Name = "labelFileName";
|
||||||
|
labelFileName.Size = new Size(36, 15);
|
||||||
|
labelFileName.TabIndex = 1;
|
||||||
|
labelFileName.Text = "Файл";
|
||||||
|
//
|
||||||
|
// labelDate
|
||||||
|
//
|
||||||
|
labelDate.AutoSize = true;
|
||||||
|
labelDate.Location = new Point(28, 60);
|
||||||
|
labelDate.Name = "labelDate";
|
||||||
|
labelDate.Size = new Size(32, 15);
|
||||||
|
labelDate.TabIndex = 2;
|
||||||
|
labelDate.Text = "Дата";
|
||||||
|
//
|
||||||
|
// dateTimePicker
|
||||||
|
//
|
||||||
|
dateTimePicker.Location = new Point(66, 54);
|
||||||
|
dateTimePicker.Name = "dateTimePicker";
|
||||||
|
dateTimePicker.Size = new Size(209, 23);
|
||||||
|
dateTimePicker.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonBuild
|
||||||
|
//
|
||||||
|
buttonBuild.Location = new Point(28, 92);
|
||||||
|
buttonBuild.Name = "buttonBuild";
|
||||||
|
buttonBuild.Size = new Size(247, 48);
|
||||||
|
buttonBuild.TabIndex = 4;
|
||||||
|
buttonBuild.Text = "Сформировать";
|
||||||
|
buttonBuild.UseVisualStyleBackColor = true;
|
||||||
|
buttonBuild.Click += ButtonBuild_Click;
|
||||||
|
//
|
||||||
|
// FormAthleteAccommodationReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(304, 156);
|
||||||
|
Controls.Add(buttonBuild);
|
||||||
|
Controls.Add(dateTimePicker);
|
||||||
|
Controls.Add(labelDate);
|
||||||
|
Controls.Add(labelFileName);
|
||||||
|
Controls.Add(buttonSelectFileName);
|
||||||
|
Name = "FormAthleteAccommodationReport";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Заселение спортсменов";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonSelectFileName;
|
||||||
|
private Label labelFileName;
|
||||||
|
private Label labelDate;
|
||||||
|
private DateTimePicker dateTimePicker;
|
||||||
|
private Button buttonBuild;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
using ProjectAthletesAccommodation.Reports;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
public partial class FormAthleteAccommodationReport : Form
|
||||||
|
{
|
||||||
|
private string _fileName = string.Empty;
|
||||||
|
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
public FormAthleteAccommodationReport(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 ButtonSelectFileName_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var sfd = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "Pdf Files | *.pdf"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (sfd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_fileName = sfd.FileName;
|
||||||
|
labelFileName.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>
|
165
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormAthleteReport.Designer.cs
generated
Normal file
165
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormAthleteReport.Designer.cs
generated
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
partial class FormAthleteReport
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
dateTimePickerDateBegin = new DateTimePicker();
|
||||||
|
dateTimePickerDateEnd = new DateTimePicker();
|
||||||
|
labelFilePath = new Label();
|
||||||
|
labelAthlete = new Label();
|
||||||
|
labelDateStart = new Label();
|
||||||
|
labelDateEnd = new Label();
|
||||||
|
buttonSelectFilePath = new Button();
|
||||||
|
textBoxFilePath = new TextBox();
|
||||||
|
comboBoxAthlete = new ComboBox();
|
||||||
|
buttonBuild = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dateTimePickerDateBegin
|
||||||
|
//
|
||||||
|
dateTimePickerDateBegin.Location = new Point(114, 102);
|
||||||
|
dateTimePickerDateBegin.Name = "dateTimePickerDateBegin";
|
||||||
|
dateTimePickerDateBegin.Size = new Size(228, 23);
|
||||||
|
dateTimePickerDateBegin.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// dateTimePickerDateEnd
|
||||||
|
//
|
||||||
|
dateTimePickerDateEnd.Location = new Point(114, 141);
|
||||||
|
dateTimePickerDateEnd.Name = "dateTimePickerDateEnd";
|
||||||
|
dateTimePickerDateEnd.Size = new Size(228, 23);
|
||||||
|
dateTimePickerDateEnd.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelFilePath
|
||||||
|
//
|
||||||
|
labelFilePath.AutoSize = true;
|
||||||
|
labelFilePath.Location = new Point(21, 32);
|
||||||
|
labelFilePath.Name = "labelFilePath";
|
||||||
|
labelFilePath.Size = new Size(87, 15);
|
||||||
|
labelFilePath.TabIndex = 2;
|
||||||
|
labelFilePath.Text = "Путь до файла";
|
||||||
|
//
|
||||||
|
// labelAthlete
|
||||||
|
//
|
||||||
|
labelAthlete.AutoSize = true;
|
||||||
|
labelAthlete.Location = new Point(39, 70);
|
||||||
|
labelAthlete.Name = "labelAthlete";
|
||||||
|
labelAthlete.Size = new Size(69, 15);
|
||||||
|
labelAthlete.TabIndex = 3;
|
||||||
|
labelAthlete.Text = "Спортсмен";
|
||||||
|
//
|
||||||
|
// labelDateStart
|
||||||
|
//
|
||||||
|
labelDateStart.AutoSize = true;
|
||||||
|
labelDateStart.Location = new Point(34, 108);
|
||||||
|
labelDateStart.Name = "labelDateStart";
|
||||||
|
labelDateStart.Size = new Size(74, 15);
|
||||||
|
labelDateStart.TabIndex = 4;
|
||||||
|
labelDateStart.Text = "Дата начала";
|
||||||
|
//
|
||||||
|
// labelDateEnd
|
||||||
|
//
|
||||||
|
labelDateEnd.AutoSize = true;
|
||||||
|
labelDateEnd.Location = new Point(40, 147);
|
||||||
|
labelDateEnd.Name = "labelDateEnd";
|
||||||
|
labelDateEnd.Size = new Size(68, 15);
|
||||||
|
labelDateEnd.TabIndex = 5;
|
||||||
|
labelDateEnd.Text = "Дата конца";
|
||||||
|
//
|
||||||
|
// buttonSelectFilePath
|
||||||
|
//
|
||||||
|
buttonSelectFilePath.Location = new Point(320, 29);
|
||||||
|
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
||||||
|
buttonSelectFilePath.Size = new Size(22, 22);
|
||||||
|
buttonSelectFilePath.TabIndex = 6;
|
||||||
|
buttonSelectFilePath.Text = "..";
|
||||||
|
buttonSelectFilePath.UseVisualStyleBackColor = true;
|
||||||
|
buttonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
||||||
|
//
|
||||||
|
// textBoxFilePath
|
||||||
|
//
|
||||||
|
textBoxFilePath.Location = new Point(114, 29);
|
||||||
|
textBoxFilePath.Name = "textBoxFilePath";
|
||||||
|
textBoxFilePath.ReadOnly = true;
|
||||||
|
textBoxFilePath.Size = new Size(200, 23);
|
||||||
|
textBoxFilePath.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// comboBoxAthlete
|
||||||
|
//
|
||||||
|
comboBoxAthlete.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxAthlete.FormattingEnabled = true;
|
||||||
|
comboBoxAthlete.Location = new Point(114, 67);
|
||||||
|
comboBoxAthlete.Name = "comboBoxAthlete";
|
||||||
|
comboBoxAthlete.Size = new Size(228, 23);
|
||||||
|
comboBoxAthlete.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// buttonBuild
|
||||||
|
//
|
||||||
|
buttonBuild.Location = new Point(95, 184);
|
||||||
|
buttonBuild.Name = "buttonBuild";
|
||||||
|
buttonBuild.Size = new Size(177, 45);
|
||||||
|
buttonBuild.TabIndex = 9;
|
||||||
|
buttonBuild.Text = "Сформировать";
|
||||||
|
buttonBuild.UseVisualStyleBackColor = true;
|
||||||
|
buttonBuild.Click += ButtonBuild_Click;
|
||||||
|
//
|
||||||
|
// FormAthleteReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(371, 247);
|
||||||
|
Controls.Add(buttonBuild);
|
||||||
|
Controls.Add(comboBoxAthlete);
|
||||||
|
Controls.Add(textBoxFilePath);
|
||||||
|
Controls.Add(buttonSelectFilePath);
|
||||||
|
Controls.Add(labelDateEnd);
|
||||||
|
Controls.Add(labelDateStart);
|
||||||
|
Controls.Add(labelAthlete);
|
||||||
|
Controls.Add(labelFilePath);
|
||||||
|
Controls.Add(dateTimePickerDateEnd);
|
||||||
|
Controls.Add(dateTimePickerDateBegin);
|
||||||
|
Name = "FormAthleteReport";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Отчёт по спортсмену";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DateTimePicker dateTimePickerDateBegin;
|
||||||
|
private DateTimePicker dateTimePickerDateEnd;
|
||||||
|
private Label labelFilePath;
|
||||||
|
private Label labelAthlete;
|
||||||
|
private Label labelDateStart;
|
||||||
|
private Label labelDateEnd;
|
||||||
|
private Button buttonSelectFilePath;
|
||||||
|
private TextBox textBoxFilePath;
|
||||||
|
private ComboBox comboBoxAthlete;
|
||||||
|
private Button buttonBuild;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
using ProjectAthletesAccommodation.Reports;
|
||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Forms;
|
||||||
|
|
||||||
|
public partial class FormAthleteReport : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
public FormAthleteReport(IUnityContainer container, IAthleteRepository athleteRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentNullException(nameof(container));
|
||||||
|
|
||||||
|
comboBoxAthlete.DataSource = athleteRepository.ReadAthletes();
|
||||||
|
comboBoxAthlete.DisplayMember = "Name";
|
||||||
|
comboBoxAthlete.ValueMember = "Id";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSelectFilePath_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var sfd = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "Excel Files | *.xlsx"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (sfd.ShowDialog() != DialogResult.OK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
textBoxFilePath.Text = sfd.FileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonBuild_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
|
||||||
|
{
|
||||||
|
throw new Exception("Отсутствует имя файла для отчета");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (comboBoxAthlete.SelectedIndex < 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран спортсмен");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dateTimePickerDateEnd.Value <= dateTimePickerDateBegin.Value)
|
||||||
|
{
|
||||||
|
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxAthlete.SelectedValue!, dateTimePickerDateBegin.Value, dateTimePickerDateEnd.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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -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
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormAthletes.Designer.cs
generated
Normal file
127
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormAthletes.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
partial class FormAthletes
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
buttonDel = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
panel1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
panel1.Controls.Add(buttonUpd);
|
||||||
|
panel1.Controls.Add(buttonAdd);
|
||||||
|
panel1.Controls.Add(buttonDel);
|
||||||
|
panel1.Dock = DockStyle.Right;
|
||||||
|
panel1.Location = new Point(719, 0);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(115, 361);
|
||||||
|
panel1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
buttonUpd.BackgroundImage = Properties.Resources.Редактировать;
|
||||||
|
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonUpd.Location = new Point(21, 174);
|
||||||
|
buttonUpd.Name = "buttonUpd";
|
||||||
|
buttonUpd.Size = new Size(75, 75);
|
||||||
|
buttonUpd.TabIndex = 2;
|
||||||
|
buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpd.Click += ButtonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.BackgroundImage = Properties.Resources.Создать;
|
||||||
|
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonAdd.Location = new Point(21, 12);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(75, 75);
|
||||||
|
buttonAdd.TabIndex = 0;
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.BackgroundImage = Properties.Resources.Удалить;
|
||||||
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDel.Location = new Point(21, 93);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(75, 75);
|
||||||
|
buttonDel.TabIndex = 1;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(719, 361);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// FormAthletes
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(834, 361);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panel1);
|
||||||
|
Name = "FormAthletes";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Спортсмены";
|
||||||
|
Load += FormAthletes_Load;
|
||||||
|
Click += FormAthletes_Load;
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel1;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,107 @@
|
|||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
public partial class FormAthletes : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
private readonly IAthleteRepository _athleteRepository;
|
||||||
|
|
||||||
|
public FormAthletes(IUnityContainer container, IAthleteRepository athleteRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
_athleteRepository = athleteRepository ?? throw new ArgumentNullException(nameof(athleteRepository));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormAthletes_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<FormAthlete>().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<FormAthlete>();
|
||||||
|
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
|
||||||
|
{
|
||||||
|
_athleteRepository.DeleteAthlete(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadList() => dataGridView.DataSource = _athleteRepository.ReadAthletes();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
112
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormAthletesAccommodation.Designer.cs
generated
Normal file
112
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormAthletesAccommodation.Designer.cs
generated
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
partial class FormAthletesAccommodation
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
panel1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
panel1.Controls.Add(buttonDel);
|
||||||
|
panel1.Controls.Add(buttonAdd);
|
||||||
|
panel1.Dock = DockStyle.Right;
|
||||||
|
panel1.Location = new Point(710, 0);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(124, 361);
|
||||||
|
panel1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.BackgroundImage = Properties.Resources.Удалить;
|
||||||
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDel.Location = new Point(25, 93);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(75, 75);
|
||||||
|
buttonDel.TabIndex = 1;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.BackgroundImage = Properties.Resources.Создать;
|
||||||
|
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonAdd.Location = new Point(25, 12);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(75, 75);
|
||||||
|
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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(710, 361);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// FormAthletesAccommodation
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(834, 361);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panel1);
|
||||||
|
Name = "FormAthletesAccommodation";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Размещение спортсменов";
|
||||||
|
Load += FormAthletesAccommodation_Load;
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel1;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonDel;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
public partial class FormAthletesAccommodation : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
private readonly IAthleteAccommodationRepository _athleteAccommodationRepository;
|
||||||
|
|
||||||
|
public FormAthletesAccommodation(IUnityContainer container,
|
||||||
|
IAthleteAccommodationRepository athleteAccommodationRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
_athleteAccommodationRepository = athleteAccommodationRepository
|
||||||
|
?? throw new ArgumentNullException(nameof(athleteAccommodationRepository));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormAthletesAccommodation_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<FormAthleteAccommodation>().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
|
||||||
|
{
|
||||||
|
_athleteAccommodationRepository.DeleteAthleteAccommodation(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadList() => dataGridView.DataSource =
|
||||||
|
_athleteAccommodationRepository.ReadAthleteAccommodation();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
100
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
100
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.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()
|
||||||
|
{
|
||||||
|
checkBoxAthletes = new CheckBox();
|
||||||
|
checkBoxRooms = new CheckBox();
|
||||||
|
checkBoxHotels = new CheckBox();
|
||||||
|
buttonBuild = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// checkBoxAthletes
|
||||||
|
//
|
||||||
|
checkBoxAthletes.AutoSize = true;
|
||||||
|
checkBoxAthletes.Location = new Point(33, 29);
|
||||||
|
checkBoxAthletes.Name = "checkBoxAthletes";
|
||||||
|
checkBoxAthletes.Size = new Size(97, 19);
|
||||||
|
checkBoxAthletes.TabIndex = 0;
|
||||||
|
checkBoxAthletes.Text = "Спортсмены";
|
||||||
|
checkBoxAthletes.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxRooms
|
||||||
|
//
|
||||||
|
checkBoxRooms.AutoSize = true;
|
||||||
|
checkBoxRooms.Location = new Point(33, 97);
|
||||||
|
checkBoxRooms.Name = "checkBoxRooms";
|
||||||
|
checkBoxRooms.Size = new Size(124, 19);
|
||||||
|
checkBoxRooms.TabIndex = 1;
|
||||||
|
checkBoxRooms.Text = "Номера гостиниц";
|
||||||
|
checkBoxRooms.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxHotels
|
||||||
|
//
|
||||||
|
checkBoxHotels.AutoSize = true;
|
||||||
|
checkBoxHotels.Location = new Point(33, 63);
|
||||||
|
checkBoxHotels.Name = "checkBoxHotels";
|
||||||
|
checkBoxHotels.Size = new Size(87, 19);
|
||||||
|
checkBoxHotels.TabIndex = 2;
|
||||||
|
checkBoxHotels.Text = "Гостиницы";
|
||||||
|
checkBoxHotels.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// buttonBuild
|
||||||
|
//
|
||||||
|
buttonBuild.Location = new Point(182, 33);
|
||||||
|
buttonBuild.Name = "buttonBuild";
|
||||||
|
buttonBuild.Size = new Size(112, 76);
|
||||||
|
buttonBuild.TabIndex = 3;
|
||||||
|
buttonBuild.Text = "Сформировать";
|
||||||
|
buttonBuild.UseVisualStyleBackColor = true;
|
||||||
|
buttonBuild.Click += ButtonBuild_Click;
|
||||||
|
//
|
||||||
|
// FormDirectoryReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(324, 140);
|
||||||
|
Controls.Add(buttonBuild);
|
||||||
|
Controls.Add(checkBoxHotels);
|
||||||
|
Controls.Add(checkBoxRooms);
|
||||||
|
Controls.Add(checkBoxAthletes);
|
||||||
|
Name = "FormDirectoryReport";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Выгрузка справочников";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private CheckBox checkBoxAthletes;
|
||||||
|
private CheckBox checkBoxRooms;
|
||||||
|
private CheckBox checkBoxHotels;
|
||||||
|
private Button buttonBuild;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
using ProjectAthletesAccommodation.Reports;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.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 (!checkBoxAthletes.Checked && !checkBoxHotels.Checked && !checkBoxRooms.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, checkBoxAthletes.Checked,
|
||||||
|
checkBoxHotels.Checked, checkBoxRooms.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>
|
96
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormHotel.Designer.cs
generated
Normal file
96
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormHotel.Designer.cs
generated
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
partial class FormHotel
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
labelHotelName = new Label();
|
||||||
|
textBoxHotelName = new TextBox();
|
||||||
|
buttonSave = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelHotelName
|
||||||
|
//
|
||||||
|
labelHotelName.AutoSize = true;
|
||||||
|
labelHotelName.Location = new Point(12, 41);
|
||||||
|
labelHotelName.Name = "labelHotelName";
|
||||||
|
labelHotelName.Size = new Size(59, 15);
|
||||||
|
labelHotelName.TabIndex = 0;
|
||||||
|
labelHotelName.Text = "Название";
|
||||||
|
//
|
||||||
|
// textBoxHotelName
|
||||||
|
//
|
||||||
|
textBoxHotelName.Location = new Point(77, 38);
|
||||||
|
textBoxHotelName.Name = "textBoxHotelName";
|
||||||
|
textBoxHotelName.Size = new Size(149, 23);
|
||||||
|
textBoxHotelName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(12, 84);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(97, 42);
|
||||||
|
buttonSave.TabIndex = 2;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(129, 84);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(97, 42);
|
||||||
|
buttonCancel.TabIndex = 3;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// FormHotel
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(238, 150);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(textBoxHotelName);
|
||||||
|
Controls.Add(labelHotelName);
|
||||||
|
Name = "FormHotel";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Гостиница";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelHotelName;
|
||||||
|
private TextBox textBoxHotelName;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
public partial class FormHotel : Form
|
||||||
|
{
|
||||||
|
private readonly IHotelRepository _hotelRepository;
|
||||||
|
|
||||||
|
private int? _hotelId;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var hotel = _hotelRepository.ReadHotelById(value);
|
||||||
|
|
||||||
|
if (hotel == null)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException(nameof(hotel));
|
||||||
|
}
|
||||||
|
|
||||||
|
textBoxHotelName.Text = hotel.Name;
|
||||||
|
_hotelId = value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormHotel(IHotelRepository hotelRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_hotelRepository = hotelRepository ?? throw new ArgumentNullException(nameof(hotelRepository));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(textBoxHotelName.Text))
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_hotelId.HasValue)
|
||||||
|
{
|
||||||
|
_hotelRepository.UpdateHotel(CreateHotel(_hotelId.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_hotelRepository.CreateHotel(CreateHotel(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private Hotel CreateHotel(int id) => Hotel.CreateEntity(id, textBoxHotelName.Text);
|
||||||
|
}
|
||||||
|
}
|
@ -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
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormHotels.Designer.cs
generated
Normal file
126
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormHotels.Designer.cs
generated
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
partial class FormHotels
|
||||||
|
{
|
||||||
|
/// <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(714, 0);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(120, 361);
|
||||||
|
panel1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
buttonUpd.BackgroundImage = Properties.Resources.Редактировать;
|
||||||
|
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonUpd.Location = new Point(24, 174);
|
||||||
|
buttonUpd.Name = "buttonUpd";
|
||||||
|
buttonUpd.Size = new Size(75, 75);
|
||||||
|
buttonUpd.TabIndex = 2;
|
||||||
|
buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpd.Click += ButtonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.BackgroundImage = Properties.Resources.Удалить;
|
||||||
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDel.Location = new Point(24, 93);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(75, 75);
|
||||||
|
buttonDel.TabIndex = 1;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.BackgroundImage = Properties.Resources.Создать;
|
||||||
|
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonAdd.Location = new Point(24, 12);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(75, 75);
|
||||||
|
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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(714, 361);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// FormHotels
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(834, 361);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panel1);
|
||||||
|
Name = "FormHotels";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Гостиницы";
|
||||||
|
Load += FormHotels_Load;
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel1;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonDel;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
public partial class FormHotels : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
private readonly IHotelRepository _hotelRepository;
|
||||||
|
|
||||||
|
public FormHotels(IUnityContainer container, IHotelRepository hotelRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
_hotelRepository = hotelRepository ?? throw new ArgumentNullException(nameof(hotelRepository));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormHotels_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<FormHotel>().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
|
||||||
|
{
|
||||||
|
_hotelRepository.DeleteHotel(findId);
|
||||||
|
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<FormHotel>();
|
||||||
|
form.Id = findId;
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadList() => dataGridView.DataSource = _hotelRepository.ReadHotels();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
144
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormRoom.Designer.cs
generated
Normal file
144
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormRoom.Designer.cs
generated
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
partial class FormRoom
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
labelHotel = new Label();
|
||||||
|
labelRoomName = new Label();
|
||||||
|
labelRoomType = new Label();
|
||||||
|
buttonSave = new Button();
|
||||||
|
textBoxRoomName = new TextBox();
|
||||||
|
comboBoxRoomType = new ComboBox();
|
||||||
|
comboBoxHotel = new ComboBox();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelHotel
|
||||||
|
//
|
||||||
|
labelHotel.AutoSize = true;
|
||||||
|
labelHotel.Location = new Point(32, 29);
|
||||||
|
labelHotel.Name = "labelHotel";
|
||||||
|
labelHotel.Size = new Size(65, 15);
|
||||||
|
labelHotel.TabIndex = 0;
|
||||||
|
labelHotel.Text = "Гостиница";
|
||||||
|
//
|
||||||
|
// labelRoomName
|
||||||
|
//
|
||||||
|
labelRoomName.AutoSize = true;
|
||||||
|
labelRoomName.Location = new Point(52, 69);
|
||||||
|
labelRoomName.Name = "labelRoomName";
|
||||||
|
labelRoomName.Size = new Size(45, 15);
|
||||||
|
labelRoomName.TabIndex = 1;
|
||||||
|
labelRoomName.Text = "Номер";
|
||||||
|
//
|
||||||
|
// labelRoomType
|
||||||
|
//
|
||||||
|
labelRoomType.AutoSize = true;
|
||||||
|
labelRoomType.Location = new Point(25, 108);
|
||||||
|
labelRoomType.Name = "labelRoomType";
|
||||||
|
labelRoomType.Size = new Size(72, 15);
|
||||||
|
labelRoomType.TabIndex = 2;
|
||||||
|
labelRoomType.Text = "Тип номера";
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(32, 146);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(83, 45);
|
||||||
|
buttonSave.TabIndex = 3;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// textBoxRoomName
|
||||||
|
//
|
||||||
|
textBoxRoomName.Location = new Point(103, 66);
|
||||||
|
textBoxRoomName.Name = "textBoxRoomName";
|
||||||
|
textBoxRoomName.Size = new Size(121, 23);
|
||||||
|
textBoxRoomName.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// comboBoxRoomType
|
||||||
|
//
|
||||||
|
comboBoxRoomType.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxRoomType.FormattingEnabled = true;
|
||||||
|
comboBoxRoomType.Location = new Point(103, 105);
|
||||||
|
comboBoxRoomType.Name = "comboBoxRoomType";
|
||||||
|
comboBoxRoomType.Size = new Size(121, 23);
|
||||||
|
comboBoxRoomType.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// comboBoxHotel
|
||||||
|
//
|
||||||
|
comboBoxHotel.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxHotel.FormattingEnabled = true;
|
||||||
|
comboBoxHotel.Location = new Point(103, 26);
|
||||||
|
comboBoxHotel.Name = "comboBoxHotel";
|
||||||
|
comboBoxHotel.Size = new Size(121, 23);
|
||||||
|
comboBoxHotel.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(141, 146);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(83, 45);
|
||||||
|
buttonCancel.TabIndex = 7;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// FormRoom
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(260, 208);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(comboBoxHotel);
|
||||||
|
Controls.Add(comboBoxRoomType);
|
||||||
|
Controls.Add(textBoxRoomName);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(labelRoomType);
|
||||||
|
Controls.Add(labelRoomName);
|
||||||
|
Controls.Add(labelHotel);
|
||||||
|
Name = "FormRoom";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Номер гостиницы";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelHotel;
|
||||||
|
private Label labelRoomName;
|
||||||
|
private Label labelRoomType;
|
||||||
|
private Button buttonSave;
|
||||||
|
private TextBox textBoxRoomName;
|
||||||
|
private ComboBox comboBoxRoomType;
|
||||||
|
private ComboBox comboBoxHotel;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities.Enums;
|
||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
public partial class FormRoom : Form
|
||||||
|
{
|
||||||
|
private readonly IRoomRepository _roomRepository;
|
||||||
|
|
||||||
|
private int? _roomId;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var room = _roomRepository.ReadRoomById(value);
|
||||||
|
|
||||||
|
if (room == null)
|
||||||
|
{
|
||||||
|
throw new
|
||||||
|
InvalidDataException(nameof(room));
|
||||||
|
}
|
||||||
|
|
||||||
|
textBoxRoomName.Text = room.Name;
|
||||||
|
comboBoxRoomType.SelectedItem = room.TypeOfRoom;
|
||||||
|
comboBoxHotel.SelectedItem = room.HotelId;
|
||||||
|
_roomId = value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormRoom(IRoomRepository roomRepository, IHotelRepository hotelRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_roomRepository = roomRepository ?? throw new ArgumentNullException(nameof(roomRepository));
|
||||||
|
|
||||||
|
comboBoxRoomType.DataSource = Enum.GetValues(typeof(TypeOfRoom));
|
||||||
|
|
||||||
|
comboBoxHotel.DataSource = hotelRepository.ReadHotels();
|
||||||
|
comboBoxHotel.DisplayMember = "Name";
|
||||||
|
comboBoxHotel.ValueMember = "Id";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(textBoxRoomName.Text) ||
|
||||||
|
comboBoxHotel.SelectedIndex < 0 ||
|
||||||
|
comboBoxRoomType.SelectedIndex < 1)
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_roomId.HasValue)
|
||||||
|
{
|
||||||
|
_roomRepository.UpdateRoom(CreateRoom(_roomId.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_roomRepository.CreateRoom(CreateRoom(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private Room CreateRoom(int id) => Room.CreateEntity(id, (int)comboBoxHotel.SelectedValue!,
|
||||||
|
textBoxRoomName.Text, (TypeOfRoom)comboBoxRoomType.SelectedItem!);
|
||||||
|
}
|
||||||
|
}
|
@ -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
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormRooms.Designer.cs
generated
Normal file
127
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormRooms.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
partial class FormRooms
|
||||||
|
{
|
||||||
|
/// <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(717, 0);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(117, 361);
|
||||||
|
panel1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
buttonUpd.BackColor = SystemColors.Control;
|
||||||
|
buttonUpd.BackgroundImage = Properties.Resources.Редактировать;
|
||||||
|
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonUpd.Location = new Point(21, 174);
|
||||||
|
buttonUpd.Name = "buttonUpd";
|
||||||
|
buttonUpd.Size = new Size(75, 75);
|
||||||
|
buttonUpd.TabIndex = 2;
|
||||||
|
buttonUpd.UseVisualStyleBackColor = false;
|
||||||
|
buttonUpd.Click += ButtonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.BackgroundImage = Properties.Resources.Удалить;
|
||||||
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDel.Location = new Point(21, 93);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(75, 75);
|
||||||
|
buttonDel.TabIndex = 1;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.BackgroundImage = Properties.Resources.Создать;
|
||||||
|
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonAdd.Location = new Point(21, 12);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(75, 75);
|
||||||
|
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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(717, 361);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// FormRooms
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(834, 361);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panel1);
|
||||||
|
Name = "FormRooms";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Номера гостиниц";
|
||||||
|
Load += FormRooms_Load;
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel1;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,107 @@
|
|||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
public partial class FormRooms : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
private readonly IRoomRepository _roomRepository;
|
||||||
|
|
||||||
|
public FormRooms(IUnityContainer container, IRoomRepository roomRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
_roomRepository = roomRepository ?? throw new ArgumentNullException(nameof(roomRepository));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormRooms_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<FormRoom>().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
|
||||||
|
{
|
||||||
|
_roomRepository.DeleteRoom(findId);
|
||||||
|
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<FormRoom>();
|
||||||
|
form.Id = findId;
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadList() => dataGridView.DataSource = _roomRepository.ReadRooms();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
195
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormServiceProvision.Designer.cs
generated
Normal file
195
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormServiceProvision.Designer.cs
generated
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
partial class FormServiceProvision
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
comboBoxHotel = new ComboBox();
|
||||||
|
labelHotel = new Label();
|
||||||
|
groupBox = new GroupBox();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
ColumnAthlete = new DataGridViewComboBoxColumn();
|
||||||
|
ColumnPrice = new DataGridViewTextBoxColumn();
|
||||||
|
labelName = new Label();
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
labelDate = new Label();
|
||||||
|
dateTimePicker = new DateTimePicker();
|
||||||
|
buttonSave = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
groupBox.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// comboBoxHotel
|
||||||
|
//
|
||||||
|
comboBoxHotel.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxHotel.FormattingEnabled = true;
|
||||||
|
comboBoxHotel.Location = new Point(123, 21);
|
||||||
|
comboBoxHotel.Name = "comboBoxHotel";
|
||||||
|
comboBoxHotel.Size = new Size(173, 23);
|
||||||
|
comboBoxHotel.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// labelHotel
|
||||||
|
//
|
||||||
|
labelHotel.AutoSize = true;
|
||||||
|
labelHotel.Location = new Point(52, 24);
|
||||||
|
labelHotel.Name = "labelHotel";
|
||||||
|
labelHotel.Size = new Size(65, 15);
|
||||||
|
labelHotel.TabIndex = 7;
|
||||||
|
labelHotel.Text = "Гостиница";
|
||||||
|
//
|
||||||
|
// groupBox
|
||||||
|
//
|
||||||
|
groupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
groupBox.Controls.Add(dataGridView);
|
||||||
|
groupBox.Location = new Point(27, 125);
|
||||||
|
groupBox.Name = "groupBox";
|
||||||
|
groupBox.Size = new Size(275, 221);
|
||||||
|
groupBox.TabIndex = 9;
|
||||||
|
groupBox.TabStop = false;
|
||||||
|
groupBox.Text = "Услуги предоставлены:";
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
|
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnAthlete, ColumnPrice });
|
||||||
|
dataGridView.Location = new Point(6, 22);
|
||||||
|
dataGridView.MultiSelect = false;
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(263, 193);
|
||||||
|
dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ColumnAthlete
|
||||||
|
//
|
||||||
|
ColumnAthlete.HeaderText = "Спортсмен";
|
||||||
|
ColumnAthlete.Name = "ColumnAthlete";
|
||||||
|
//
|
||||||
|
// ColumnPrice
|
||||||
|
//
|
||||||
|
ColumnPrice.HeaderText = "Стоимость";
|
||||||
|
ColumnPrice.Name = "ColumnPrice";
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
labelName.AutoSize = true;
|
||||||
|
labelName.Location = new Point(27, 56);
|
||||||
|
labelName.Name = "labelName";
|
||||||
|
labelName.Size = new Size(90, 15);
|
||||||
|
labelName.TabIndex = 10;
|
||||||
|
labelName.Text = "Наименование";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(123, 53);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(173, 23);
|
||||||
|
textBoxName.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// labelDate
|
||||||
|
//
|
||||||
|
labelDate.AutoSize = true;
|
||||||
|
labelDate.Location = new Point(85, 92);
|
||||||
|
labelDate.Name = "labelDate";
|
||||||
|
labelDate.Size = new Size(32, 15);
|
||||||
|
labelDate.TabIndex = 12;
|
||||||
|
labelDate.Text = "Дата";
|
||||||
|
//
|
||||||
|
// dateTimePicker
|
||||||
|
//
|
||||||
|
dateTimePicker.Enabled = false;
|
||||||
|
dateTimePicker.Location = new Point(123, 86);
|
||||||
|
dateTimePicker.Name = "dateTimePicker";
|
||||||
|
dateTimePicker.Size = new Size(173, 23);
|
||||||
|
dateTimePicker.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonSave.Location = new Point(27, 369);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(126, 40);
|
||||||
|
buttonSave.TabIndex = 14;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonCancel.Location = new Point(177, 369);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(122, 40);
|
||||||
|
buttonCancel.TabIndex = 15;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// FormServiceProvision
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(332, 431);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(dateTimePicker);
|
||||||
|
Controls.Add(labelDate);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(labelName);
|
||||||
|
Controls.Add(groupBox);
|
||||||
|
Controls.Add(comboBoxHotel);
|
||||||
|
Controls.Add(labelHotel);
|
||||||
|
Name = "FormServiceProvision";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Предоставление услуг";
|
||||||
|
groupBox.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ComboBox comboBoxHotel;
|
||||||
|
private Label labelHotel;
|
||||||
|
private GroupBox groupBox;
|
||||||
|
private Label labelName;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Label labelDate;
|
||||||
|
private DateTimePicker dateTimePicker;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private DataGridViewComboBoxColumn ColumnAthlete;
|
||||||
|
private DataGridViewTextBoxColumn ColumnPrice;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
public partial class FormServiceProvision : Form
|
||||||
|
{
|
||||||
|
private readonly IServiceProvisionRepository _serviceProvisionRepository;
|
||||||
|
|
||||||
|
public FormServiceProvision(IServiceProvisionRepository serviceProvisionRepository,
|
||||||
|
IHotelRepository hotelRepository, IAthleteRepository athleteRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_serviceProvisionRepository = serviceProvisionRepository
|
||||||
|
?? throw new ArgumentNullException(nameof(serviceProvisionRepository));
|
||||||
|
|
||||||
|
comboBoxHotel.DataSource = hotelRepository.ReadHotels();
|
||||||
|
comboBoxHotel.DisplayMember = "Name";
|
||||||
|
comboBoxHotel.ValueMember = "Id";
|
||||||
|
|
||||||
|
ColumnAthlete.DataSource = athleteRepository.ReadAthletes();
|
||||||
|
ColumnAthlete.DisplayMember = "Name";
|
||||||
|
ColumnAthlete.ValueMember = "Id";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (dataGridView.RowCount < 1 ||
|
||||||
|
comboBoxHotel.SelectedIndex < 0 ||
|
||||||
|
string.IsNullOrWhiteSpace(textBoxName.Text))
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
|
||||||
|
_serviceProvisionRepository.CreateServiceProvision
|
||||||
|
(ServiceProvision.CreateOpeartion(0, (int)comboBoxHotel.SelectedValue!,
|
||||||
|
textBoxName.Text, CreateListServiceProvisionConnectionFromDataGrid()));
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private List<ServiceProvisionConnection> CreateListServiceProvisionConnectionFromDataGrid()
|
||||||
|
{
|
||||||
|
var list = new List<ServiceProvisionConnection>();
|
||||||
|
|
||||||
|
foreach (DataGridViewRow row in dataGridView.Rows)
|
||||||
|
{
|
||||||
|
if (row.Cells["ColumnAthlete"].Value == null || row.Cells["ColumnPrice"].Value == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Add(ServiceProvisionConnection.CreateElement
|
||||||
|
(0, Convert.ToInt32(row.Cells["ColumnAthlete"].Value),
|
||||||
|
Convert.ToDecimal(row.Cells["ColumnPrice"].Value)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return list.GroupBy(x => x.AthleteId, x => x.Price, (id, prices) =>
|
||||||
|
ServiceProvisionConnection.CreateElement(0, id, prices.Sum())).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,132 @@
|
|||||||
|
<?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="ColumnAthlete.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnPrice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnAthlete.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnPrice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
109
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormServicesProvision.Designer.cs
generated
Normal file
109
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormServicesProvision.Designer.cs
generated
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
partial class FormServicesProvision
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
panel1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
panel1.Controls.Add(buttonDel);
|
||||||
|
panel1.Controls.Add(buttonAdd);
|
||||||
|
panel1.Dock = DockStyle.Right;
|
||||||
|
panel1.Location = new Point(792, 0);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(122, 361);
|
||||||
|
panel1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.BackgroundImage = Properties.Resources.Удалить;
|
||||||
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDel.Location = new Point(24, 93);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(75, 75);
|
||||||
|
buttonDel.TabIndex = 2;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.BackgroundImage = Properties.Resources.Создать;
|
||||||
|
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonAdd.Location = new Point(24, 12);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(75, 75);
|
||||||
|
buttonAdd.TabIndex = 1;
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(792, 361);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// FormServicesProvision
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(914, 361);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panel1);
|
||||||
|
Name = "FormServicesProvision";
|
||||||
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
|
Text = "Предоставление услуг";
|
||||||
|
Load += FormServicesProvision_Load;
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel1;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonDel;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Forms
|
||||||
|
{
|
||||||
|
public partial class FormServicesProvision : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
private readonly IServiceProvisionRepository _serviceProvisionRepository;
|
||||||
|
|
||||||
|
public FormServicesProvision(IUnityContainer container,
|
||||||
|
IServiceProvisionRepository serviceProvisionRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
_serviceProvisionRepository = serviceProvisionRepository
|
||||||
|
?? throw new ArgumentNullException(nameof(serviceProvisionRepository));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormServicesProvision_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
_serviceProvisionRepository.DeleteServiceProvision(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormServiceProvision>().ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadList() => dataGridView.DataSource =
|
||||||
|
_serviceProvisionRepository.ReadServiceProvision();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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 ProjectAthletesAccommodation.Repositories.Implementations;
|
||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
using Unity.Lifetime;
|
||||||
|
using Unity;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Serilog;
|
||||||
|
using Unity.Microsoft.Logging;
|
||||||
|
|
||||||
namespace ProjectAthletesAccommodation
|
namespace ProjectAthletesAccommodation
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
@ -11,7 +20,36 @@ namespace ProjectAthletesAccommodation
|
|||||||
// 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<FormAthleteAccommodation>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IUnityContainer CreateContainer()
|
||||||
|
{
|
||||||
|
var container = new UnityContainer();
|
||||||
|
|
||||||
|
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
||||||
|
|
||||||
|
container.RegisterType<IAthleteRepository, AthleteRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<IHotelRepository, HotelRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<IRoomRepository, RoomRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<IAthleteAccommodationRepository, AthleteAccommodationRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<IServiceProvisionRepository, ServiceProvisionRepository>(new TransientLifetimeManager());
|
||||||
|
|
||||||
|
container.RegisterType<IConnectionString, ConnectionString>(new SingletonLifetimeManager());
|
||||||
|
|
||||||
|
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,47 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="Resources\Создать1.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||||
|
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
|
||||||
|
<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.0.2" />
|
||||||
|
<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="System.Data.SqlClient" Version="4.9.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>
|
113
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Properties/Resources.Designer.cs
generated
Normal file
113
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан программой.
|
||||||
|
// Исполняемая версия:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||||
|
// повторной генерации кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.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("ProjectAthletesAccommodation.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 Гостиница1 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("Гостиница1", 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 Создать1 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("Создать1", 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,136 @@
|
|||||||
|
<?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\Создать.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="Гостиница1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\Гостиница1.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="Создать1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\Создать1.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>
|
@ -0,0 +1,50 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Reports;
|
||||||
|
|
||||||
|
public class ChartReport
|
||||||
|
{
|
||||||
|
private readonly IAthleteAccommodationRepository _athleteAccommodationRepository;
|
||||||
|
|
||||||
|
private readonly ILogger<ChartReport> _logger;
|
||||||
|
public ChartReport(IAthleteAccommodationRepository athleteAccommodationRepository,
|
||||||
|
ILogger<ChartReport> logger)
|
||||||
|
{
|
||||||
|
_athleteAccommodationRepository = athleteAccommodationRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(athleteAccommodationRepository));
|
||||||
|
_logger = logger ??
|
||||||
|
throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateChart(string filePath, DateTime dateTime)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new PdfBuilder(filePath)
|
||||||
|
.AddHeader("Размещение спортсменов")
|
||||||
|
.AddPieChart("Заселенные спортсмены (Соотношение стоимостей их проживания)", GetData(dateTime))
|
||||||
|
.Build();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
||||||
|
{
|
||||||
|
return _athleteAccommodationRepository
|
||||||
|
.ReadAthleteAccommodation()
|
||||||
|
.Where(x => x.DateStart.Date == dateTime.Date)
|
||||||
|
.GroupBy(x => x.AthleteId, (key, group) => new
|
||||||
|
{
|
||||||
|
Id = key,
|
||||||
|
Count = group.Sum(x => x.Price)
|
||||||
|
})
|
||||||
|
.Select(x => (x.Id.ToString(), (double)x.Count))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Reports;
|
||||||
|
|
||||||
|
public class DocReport
|
||||||
|
{
|
||||||
|
private readonly IAthleteRepository _athleteRepository;
|
||||||
|
|
||||||
|
private readonly IRoomRepository _roomRepository;
|
||||||
|
|
||||||
|
private readonly IHotelRepository _hotelRepository;
|
||||||
|
|
||||||
|
private readonly ILogger<DocReport> _logger;
|
||||||
|
|
||||||
|
public DocReport(IAthleteRepository athleteRepository, IRoomRepository roomRepository,
|
||||||
|
IHotelRepository hotelRepository, ILogger<DocReport> logger)
|
||||||
|
{
|
||||||
|
_athleteRepository = athleteRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(athleteRepository));
|
||||||
|
_roomRepository = roomRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(roomRepository));
|
||||||
|
_hotelRepository = hotelRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(hotelRepository));
|
||||||
|
_logger = logger ??
|
||||||
|
throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateDoc(string filePath, bool includeAthletes, bool includeRooms, bool includeHotels)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var builder = new WordBuilder(filePath).AddHeader("Документ со справочниками");
|
||||||
|
|
||||||
|
if(includeAthletes)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Спортсмены").AddTable([2400, 2400, 2000, 2000], GetAthletes());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(includeRooms)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Номера").AddTable([2400, 2400, 2400], GetRooms());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(includeHotels)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Гостиницы").AddTable([2400], GetHotels());
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.Build();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetAthletes()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Имя", "Фамилия", "Вид спорта", "Классификация"],
|
||||||
|
.. _athleteRepository
|
||||||
|
.ReadAthletes()
|
||||||
|
.Select(x => new string[]
|
||||||
|
{x.Name, x.Surname, x.KindOfSport.ToString(), x.AthleteClassification.ToString()}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetHotels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Название"],
|
||||||
|
.. _hotelRepository
|
||||||
|
.ReadHotels()
|
||||||
|
.Select(x => new string[]
|
||||||
|
{x.Name}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetRooms()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Гостиница (Id)", "Номер", "Тип номера"],
|
||||||
|
.. _roomRepository
|
||||||
|
.ReadRooms()
|
||||||
|
.Select(x => new string[]
|
||||||
|
{x.HotelId.ToString(), x.Name, x.TypeOfRoom.ToString()}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,325 @@
|
|||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Reports;
|
||||||
|
|
||||||
|
public 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.BoldTextWithoutBorder);
|
||||||
|
}
|
||||||
|
|
||||||
|
_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 },
|
||||||
|
Bold = new Bold(),
|
||||||
|
FontScheme = new FontScheme()
|
||||||
|
{
|
||||||
|
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
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 = 1,
|
||||||
|
BorderId = 1,
|
||||||
|
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.Left,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 1,
|
||||||
|
BorderId = 0,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Left,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum StyleIndex
|
||||||
|
{
|
||||||
|
SimpleTextWithoutBorder = 0,
|
||||||
|
BoldTextWithBorder = 1,
|
||||||
|
SimpleTextWithBorder = 2,
|
||||||
|
BoldTextWithoutBorder = 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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||||
|
using MigraDoc.Rendering;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Reports;
|
||||||
|
|
||||||
|
public 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()
|
||||||
|
{
|
||||||
|
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 = 16;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Reports;
|
||||||
|
|
||||||
|
public class TableReport
|
||||||
|
{
|
||||||
|
private readonly IAthleteAccommodationRepository _athleteAccommodationRepository;
|
||||||
|
|
||||||
|
private readonly IServiceProvisionRepository _serviceProvisionRepository;
|
||||||
|
|
||||||
|
private readonly ILogger<TableReport> _logger;
|
||||||
|
|
||||||
|
internal static readonly string[] item = ["Дата", "Траты на услуги", "Оплата проживания в номере"];
|
||||||
|
|
||||||
|
public TableReport(IAthleteAccommodationRepository athleteAccommodationRepository,
|
||||||
|
IServiceProvisionRepository serviceProvisionRepository, ILogger<TableReport> logger)
|
||||||
|
{
|
||||||
|
_athleteAccommodationRepository = athleteAccommodationRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(athleteAccommodationRepository));
|
||||||
|
_serviceProvisionRepository = serviceProvisionRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(serviceProvisionRepository));
|
||||||
|
_logger = logger ??
|
||||||
|
throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateTable(string filePath, int athleteId, DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new ExcelBuilder(filePath)
|
||||||
|
.AddHeader("Сводка по спортсмену", 0, 3)
|
||||||
|
.AddParagraph("За период", 0)
|
||||||
|
.AddTable([15, 15, 15], GetData(athleteId, startDate, endDate))
|
||||||
|
.Build();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetData(int athleteId, DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
var data = _serviceProvisionRepository
|
||||||
|
.ReadServiceProvision()
|
||||||
|
.Where(x => x.Date >= startDate && x.Date <= endDate && x.ServiceProvisionConnection.Any(y => y.AthleteId == athleteId))
|
||||||
|
.Select(x => new { Date = x.Date, PriceService = x.ServiceProvisionConnection.FirstOrDefault(y => y.AthleteId == athleteId)?.Price, PriceRoom = (decimal?)null })
|
||||||
|
.Union(
|
||||||
|
_athleteAccommodationRepository
|
||||||
|
.ReadAthleteAccommodation()
|
||||||
|
.Where(x => x.DateStart >= startDate && x.DateStart <= endDate && x.AthleteId == athleteId)
|
||||||
|
.Select(x => new {Date = x.DateStart, PriceService = (decimal?)null, PriceRoom = (decimal?)x.Price }))
|
||||||
|
.OrderBy(x => x.Date);
|
||||||
|
|
||||||
|
return
|
||||||
|
new List<string[]>() { item }
|
||||||
|
.Union(
|
||||||
|
data
|
||||||
|
.Select(x => new string[] {x.Date.ToString(), x.PriceService?.ToString() ?? string.Empty, x.PriceRoom?.ToString() ?? string.Empty }))
|
||||||
|
.Union(
|
||||||
|
[["Всего", data.Sum(x => x.PriceService ?? 0).ToString(), data.Sum(x => x.PriceRoom ?? 0).ToString()]])
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,105 @@
|
|||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Reports;
|
||||||
|
|
||||||
|
public 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 = run.AppendChild(new RunProperties());
|
||||||
|
runProperties.AppendChild(new Bold());
|
||||||
|
|
||||||
|
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,13 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
public interface IAthleteAccommodationRepository
|
||||||
|
{
|
||||||
|
IEnumerable<AthleteAccommodation> ReadAthleteAccommodation(DateTime? dateFrom = null, DateTime? dateTo = null,
|
||||||
|
int? roomId = null, int? athleteId = null);
|
||||||
|
|
||||||
|
void CreateAthleteAccommodation(AthleteAccommodation athleteAccommodation);
|
||||||
|
|
||||||
|
void DeleteAthleteAccommodation(int id);
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
public interface IAthleteRepository
|
||||||
|
{
|
||||||
|
IEnumerable<Athlete> ReadAthletes();
|
||||||
|
Athlete ReadAthleteById(int id);
|
||||||
|
void CreateAthlete(Athlete athlete);
|
||||||
|
void UpdateAthlete(Athlete athlete);
|
||||||
|
void DeleteAthlete(int id);
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
public interface IConnectionString
|
||||||
|
{
|
||||||
|
public string ConnectionString { get; }
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
public interface IHotelRepository
|
||||||
|
{
|
||||||
|
IEnumerable<Hotel> ReadHotels();
|
||||||
|
Hotel ReadHotelById(int id);
|
||||||
|
void CreateHotel(Hotel hotel);
|
||||||
|
void UpdateHotel(Hotel hotel);
|
||||||
|
void DeleteHotel(int id);
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
public interface IRoomRepository
|
||||||
|
{
|
||||||
|
IEnumerable<Room> ReadRooms();
|
||||||
|
Room ReadRoomById(int id);
|
||||||
|
void CreateRoom(Room room);
|
||||||
|
void UpdateRoom(Room room);
|
||||||
|
void DeleteRoom(int id);
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
|
||||||
|
namespace ProjectAthletesAccommodation.Repositories;
|
||||||
|
|
||||||
|
public interface IServiceProvisionRepository
|
||||||
|
{
|
||||||
|
IEnumerable<ServiceProvision> ReadServiceProvision(DateTime? dateFrom = null, DateTime? dateTo = null,
|
||||||
|
int? hotelId = null, int? athleteId = null);
|
||||||
|
|
||||||
|
void CreateServiceProvision(ServiceProvision serviceProvision);
|
||||||
|
|
||||||
|
void DeleteServiceProvision(int id);
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
namespace ProjectAthletesAccommodation.Repositories.Implementations;
|
||||||
|
|
||||||
|
public class AthleteAccommodationRepository : IAthleteAccommodationRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<AthleteAccommodationRepository> _logger;
|
||||||
|
|
||||||
|
public AthleteAccommodationRepository(IConnectionString connectionString,
|
||||||
|
ILogger<AthleteAccommodationRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateAthleteAccommodation(AthleteAccommodation athleteAccommodation)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(athleteAccommodation));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryInsert =
|
||||||
|
@"INSERT INTO AthleteAccommodation (RoomId, AthleteId, Price, DateStart, DateEnd)
|
||||||
|
VALUES (@RoomId, @AthleteId, @Price, @DateStart, @DateEnd)";
|
||||||
|
connection.Execute(queryInsert, athleteAccommodation);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteAthleteAccommodation(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"DELETE FROM AthleteAccommodation WHERE Id=@id";
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<AthleteAccommodation> ReadAthleteAccommodation(DateTime? dateFrom = null, DateTime? dateTo = null,
|
||||||
|
int? roomId = null, int? athleteId = null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = "SELECT * FROM AthleteAccommodation";
|
||||||
|
var athleteAccommodation = connection.Query<AthleteAccommodation>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(athleteAccommodation));
|
||||||
|
return athleteAccommodation;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using Dapper;
|
||||||
|
namespace ProjectAthletesAccommodation.Repositories.Implementations;
|
||||||
|
|
||||||
|
public class AthleteRepository : IAthleteRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<AthleteRepository> _logger;
|
||||||
|
|
||||||
|
public AthleteRepository(IConnectionString connectionString, ILogger<AthleteRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateAthlete(Athlete athlete)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(athlete));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryInsert =
|
||||||
|
@"INSERT INTO Athlete (Name, Surname, KindOfSport, AthleteClassification)
|
||||||
|
VALUES (@Name, @Surname, @KindOfSport, @AthleteClassification)";
|
||||||
|
connection.Execute(queryInsert, athlete);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateAthlete(Athlete athlete)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Редактирование объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(athlete));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryUpdate = @"UPDATE Athlete SET
|
||||||
|
Name=@Name,
|
||||||
|
Surname=@Surname,
|
||||||
|
KindOfSport=@KindOfSport,
|
||||||
|
AthleteClassification=@AthleteClassification
|
||||||
|
WHERE Id=@Id";
|
||||||
|
connection.Execute(queryUpdate, athlete);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteAthlete(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"DELETE FROM Athlete WHERE Id=@id";
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Athlete ReadAthleteById(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение объекта по идентификатору");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"SELECT * FROM Athlete WHERE Id=@id";
|
||||||
|
var ahlete = connection.QueryFirst<Athlete>(querySelect, new { id });
|
||||||
|
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(ahlete));
|
||||||
|
return ahlete;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Athlete> ReadAthletes()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = "SELECT * FROM Athlete";
|
||||||
|
var ahletes = connection.Query<Athlete>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(ahletes));
|
||||||
|
return ahletes;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
namespace ProjectAthletesAccommodation.Repositories.Implementations;
|
||||||
|
|
||||||
|
public class ConnectionString : IConnectionString
|
||||||
|
{
|
||||||
|
string IConnectionString.ConnectionString
|
||||||
|
=> "Host=localhost;Port=5432;Database=accommodation;Username=postgres;Password=postgres";
|
||||||
|
}
|
@ -0,0 +1,109 @@
|
|||||||
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
namespace ProjectAthletesAccommodation.Repositories.Implementations;
|
||||||
|
|
||||||
|
public class HotelRepository : IHotelRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<HotelRepository> _logger;
|
||||||
|
|
||||||
|
public HotelRepository(IConnectionString connectionString, ILogger<HotelRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateHotel(Hotel hotel)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(hotel));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryInsert = @"INSERT INTO Hotel (Name) VALUES (@Name)";
|
||||||
|
connection.Execute(queryInsert, hotel);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateHotel(Hotel hotel)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Редактирование объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(hotel));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryUpdate = @"UPDATE Hotel SET
|
||||||
|
Name=@Name
|
||||||
|
WHERE Id=@Id";
|
||||||
|
connection.Execute(queryUpdate, hotel);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteHotel(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"DELETE FROM Hotel WHERE Id=@id";
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Hotel ReadHotelById(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение объекта по идентификатору");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"SELECT * FROM Hotel WHERE Id=@id";
|
||||||
|
var hotel = connection.QueryFirst<Hotel>(querySelect, new { id });
|
||||||
|
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(hotel));
|
||||||
|
return hotel;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Hotel> ReadHotels()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = "SELECT * FROM Hotel";
|
||||||
|
var hotels = connection.Query<Hotel>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(hotels));
|
||||||
|
return hotels;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,113 @@
|
|||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using Dapper;
|
||||||
|
namespace ProjectAthletesAccommodation.Repositories.Implementations;
|
||||||
|
|
||||||
|
public class RoomRepository : IRoomRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<RoomRepository> _logger;
|
||||||
|
|
||||||
|
public RoomRepository(IConnectionString connectionString, ILogger<RoomRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateRoom(Room room)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(room));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryInsert =
|
||||||
|
@"INSERT INTO Room (HotelId, Name, TypeOfRoom)
|
||||||
|
VALUES (@HotelId, @Name, @TypeOfRoom)";
|
||||||
|
connection.Execute(queryInsert, room);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateRoom(Room room)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Редактирование объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(room));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryUpdate = @"UPDATE Room SET
|
||||||
|
HotelId=@HotelId,
|
||||||
|
Name=@Name,
|
||||||
|
TypeOfRoom=@TypeOfRoom
|
||||||
|
WHERE Id=@Id";
|
||||||
|
connection.Execute(queryUpdate, room);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteRoom(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"DELETE FROM Room WHERE Id=@id";
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Room ReadRoomById(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение объекта по идентификатору");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"SELECT * FROM Room WHERE Id=@id";
|
||||||
|
var room = connection.QueryFirst<Room>(querySelect, new { id });
|
||||||
|
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(room));
|
||||||
|
return room;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Room> ReadRooms()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = "SELECT * FROM Room";
|
||||||
|
var rooms = connection.Query<Room>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(rooms));
|
||||||
|
return rooms;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using ProjectAthletesAccommodation.Entities;
|
||||||
|
namespace ProjectAthletesAccommodation.Repositories.Implementations;
|
||||||
|
|
||||||
|
public class ServiceProvisionRepository : IServiceProvisionRepository
|
||||||
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
|
||||||
|
private readonly ILogger<ServiceProvisionRepository> _logger;
|
||||||
|
|
||||||
|
public ServiceProvisionRepository(IConnectionString connectionString,
|
||||||
|
ILogger<ServiceProvisionRepository> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateServiceProvision(ServiceProvision serviceProvision)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Добавление объекта");
|
||||||
|
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(serviceProvision));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
using var transaction = connection.BeginTransaction();
|
||||||
|
var queryInsert =
|
||||||
|
@"INSERT INTO ServiceProvision (HotelId, Name, Date)
|
||||||
|
VALUES (@HotelId, @Name, @Date);
|
||||||
|
SELECT MAX(Id) FROM ServiceProvision";
|
||||||
|
var serviceProvisionId = connection.QueryFirst<int>(queryInsert, serviceProvision, transaction);
|
||||||
|
var querySubInsert =
|
||||||
|
@"INSERT INTO ServiceProvisionConnection (ServiceProvisionId, AthleteId, Price)
|
||||||
|
VALUES (@ServiceProvisionId, @AthleteId, @Price)";
|
||||||
|
foreach (var elem in serviceProvision.ServiceProvisionConnection)
|
||||||
|
{
|
||||||
|
connection.Execute(querySubInsert, new { serviceProvisionId, elem.AthleteId, elem.Price }, transaction);
|
||||||
|
}
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteServiceProvision(int id)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление объекта");
|
||||||
|
_logger.LogDebug("Объект: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"DELETE FROM ServiceProvision WHERE Id=@id";
|
||||||
|
connection.Execute(queryDelete, new { id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<ServiceProvision> ReadServiceProvision(DateTime? dateFrom = null, DateTime? dateTo = null,
|
||||||
|
int? hotelId = null, int? athleteId = null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Получение всех объектов");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect =
|
||||||
|
@"SELECT sp.*, spc.AthleteId, spc.Price FROM ServiceProvision sp
|
||||||
|
INNER JOIN ServiceProvisionConnection spc ON spc.ServiceProvisionId = sp.Id";
|
||||||
|
var serviceProvision = connection.Query<TempServiceProvisionConnection>(querySelect);
|
||||||
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(serviceProvision));
|
||||||
|
return serviceProvision.GroupBy(x => x.Id, y => y,
|
||||||
|
(key, value) => ServiceProvision.CreateOpeartion(value.First(),
|
||||||
|
value.Select(z => ServiceProvisionConnection.CreateElement(0, z.AthleteId, z.Price)))).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
Binary file not shown.
After Width: | Height: | Size: 100 KiB |
Binary file not shown.
After Width: | Height: | Size: 100 KiB |
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"Serilog": {
|
||||||
|
"Using": [ "Serilog.Sinks.File" ],
|
||||||
|
"MinimumLevel": "Debug",
|
||||||
|
"WriteTo": [
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "Logs/accomodation_log.txt",
|
||||||
|
"rollingInterval": "Day"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user