Кажется все. На этом первая лаба заканчивается.

This commit is contained in:
Tonb73 2024-11-11 15:05:13 +04:00
parent 59b1054873
commit 083f7761ae
15 changed files with 1040 additions and 13 deletions

View File

@ -9,18 +9,20 @@ namespace ProjectTourAgency.Enities;
public class ClientTour
{
public int Id { get; private set; }
public int ClientId { get; private set; }
public int TourId { get; private set; }
public int Count { get; private set; }
public int Cost { get; private set; }
public static ClientTour CreateEntity(int clientId, int tourId, int count)
public static ClientTour CreateEntity(int id,int clientId, int tourId, int cost)
{
return new ClientTour
{
Id = id,
ClientId = clientId,
TourId = tourId,
Count = count
Cost = cost
};
}

View File

@ -10,16 +10,20 @@ namespace ProjectTourAgency.Enities;
public class Tour
{
public int Id { get; private set; }
public int EmployeeId { get; private set; }
public int RouteId { get; private set; }
public DateTime DepartureDate { get; private set; }
public int Cost { get; private set; }
public static Tour CreateEntity(int id,
DateTime date,int cost)
public IEnumerable<ClientTour> ClientTours { get; private set; } = [];
public static Tour CreateEntity(int id, int employeeId, int routeId,
DateTime date,IEnumerable<ClientTour> clientTours)
{
return new Tour
{
Id = id,
EmployeeId = employeeId,
RouteId = routeId,
DepartureDate = date,
Cost = cost
ClientTours = clientTours
};
}
}

View File

@ -89,13 +89,14 @@
пополнитьБалансПользователяToolStripMenuItem.Name = "пополнитьБалансПользователяToolStripMenuItem";
пополнитьБалансПользователяToolStripMenuItem.Size = new Size(256, 22);
пополнитьБалансПользователяToolStripMenuItem.Text = "Пополнить баланс пользователя";
пополнитьБалансПользователяToolStripMenuItem.Click += пополнитьБалансПользователяToolStripMenuItem_Click;
пополнитьБалансПользователяToolStripMenuItem.Click += AddMoneyToolStripMenuItem_Click;
//
// турToolStripMenuItem
//
турToolStripMenuItem.Name = урToolStripMenuItem";
турToolStripMenuItem.Size = new Size(256, 22);
турToolStripMenuItem.Text = "Тур";
турToolStripMenuItem.Click += ToursToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//

View File

@ -50,11 +50,23 @@ public partial class FormTourAgency : Form
}
}
private void ïîïîëíèòüÁàëàíñÏîëüçîâàòåëÿToolStripMenuItem_Click(object sender, EventArgs e)
private void AddMoneyToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormAddMoney>().ShowDialog();
_container.Resolve<FormAddMoneys>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ToursToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormTours>().ShowDialog();
}
catch (Exception ex)
{

View File

@ -0,0 +1,97 @@
namespace ProjectTourAgency.Forms
{
partial class FormAddMoneys
{
/// <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()
{
dataGridViewData = new DataGridView();
panel1 = new Panel();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(699, 362);
dataGridViewData.TabIndex = 3;
//
// panel1
//
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(699, 0);
panel1.Name = "panel1";
panel1.Size = new Size(149, 362);
panel1.TabIndex = 2;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.free_icon_add_button_5974633;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(43, 25);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(61, 59);
buttonAdd.TabIndex = 1;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// FormAddMoneys
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(848, 362);
Controls.Add(dataGridViewData);
Controls.Add(panel1);
Name = "FormAddMoneys";
Text = "FormAddMoneys";
Load += FormAddMoneys_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Panel panel1;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,68 @@
using ProjectTourAgency.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectTourAgency.Forms
{
public partial class FormAddMoneys : Form
{
private readonly IUnityContainer _container;
private readonly IAddMoneyRepository _addMoneyRepository;
public FormAddMoneys(IAddMoneyRepository addMoneyRepository, IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_addMoneyRepository = addMoneyRepository ?? throw new ArgumentNullException(nameof(_addMoneyRepository));
}
private void FormAddMoneys_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<FormAddMoney>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _addMoneyRepository.ReadAddMoneys();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["ID"].Value);
return true;
}
}
}

View File

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

View File

@ -0,0 +1,191 @@
namespace ProjectTourAgency.Forms
{
partial class FormClientTour
{
/// <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()
{
labelEmployeeName = new Label();
labelDate = new Label();
groupBoxTour = new GroupBox();
dataGridView = new DataGridView();
ColumnClient = new DataGridViewComboBoxColumn();
ColumnCost = new DataGridViewTextBoxColumn();
labelRoute = new Label();
buttonSave = new Button();
buttonCancel = new Button();
comboBoxEmployeeId = new ComboBox();
comboBoxRouteId = new ComboBox();
dateTimePicker = new DateTimePicker();
groupBoxTour.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// labelEmployeeName
//
labelEmployeeName.AutoSize = true;
labelEmployeeName.Location = new Point(12, 19);
labelEmployeeName.Name = "labelEmployeeName";
labelEmployeeName.Size = new Size(59, 15);
labelEmployeeName.TabIndex = 0;
labelEmployeeName.Text = "Работник";
//
// labelDate
//
labelDate.AutoSize = true;
labelDate.Location = new Point(12, 95);
labelDate.Name = "labelDate";
labelDate.Size = new Size(127, 15);
labelDate.TabIndex = 1;
labelDate.Text = "Дата проведения тура";
//
// groupBoxTour
//
groupBoxTour.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBoxTour.Controls.Add(dataGridView);
groupBoxTour.Location = new Point(18, 123);
groupBoxTour.Name = "groupBoxTour";
groupBoxTour.Size = new Size(360, 248);
groupBoxTour.TabIndex = 2;
groupBoxTour.TabStop = false;
groupBoxTour.Text = "Клиенты";
//
// dataGridView
//
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnClient, ColumnCost });
dataGridView.Location = new Point(6, 22);
dataGridView.Name = "dataGridView";
dataGridView.Size = new Size(348, 220);
dataGridView.TabIndex = 0;
dataGridView.CellContentClick += dataGridView_CellContentClick;
//
// ColumnClient
//
ColumnClient.HeaderText = "Клиент";
ColumnClient.Name = "ColumnClient";
ColumnClient.Resizable = DataGridViewTriState.True;
ColumnClient.SortMode = DataGridViewColumnSortMode.Automatic;
//
// ColumnCost
//
ColumnCost.HeaderText = "Цена";
ColumnCost.Name = "ColumnCost";
//
// labelRoute
//
labelRoute.AutoSize = true;
labelRoute.Location = new Point(12, 61);
labelRoute.Name = "labelRoute";
labelRoute.Size = new Size(60, 15);
labelRoute.TabIndex = 3;
labelRoute.Text = "Маршрут";
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonSave.Location = new Point(29, 400);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(110, 25);
buttonSave.TabIndex = 4;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(249, 400);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(110, 25);
buttonCancel.TabIndex = 5;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// comboBoxEmployeeId
//
comboBoxEmployeeId.FormattingEnabled = true;
comboBoxEmployeeId.Location = new Point(145, 16);
comboBoxEmployeeId.Name = "comboBoxEmployeeId";
comboBoxEmployeeId.Size = new Size(186, 23);
comboBoxEmployeeId.TabIndex = 6;
//
// comboBoxRouteId
//
comboBoxRouteId.FormattingEnabled = true;
comboBoxRouteId.Location = new Point(145, 58);
comboBoxRouteId.Name = "comboBoxRouteId";
comboBoxRouteId.Size = new Size(186, 23);
comboBoxRouteId.TabIndex = 7;
//
// dateTimePicker
//
dateTimePicker.Location = new Point(145, 89);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(186, 23);
dateTimePicker.TabIndex = 8;
//
// FormClientTour
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(406, 456);
Controls.Add(dateTimePicker);
Controls.Add(comboBoxRouteId);
Controls.Add(comboBoxEmployeeId);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(labelRoute);
Controls.Add(groupBoxTour);
Controls.Add(labelDate);
Controls.Add(labelEmployeeName);
Name = "FormClientTour";
Text = "FormClientTour";
groupBoxTour.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelEmployeeName;
private Label labelDate;
private GroupBox groupBoxTour;
private DataGridView dataGridView;
private DataGridViewComboBoxColumn ColumnClient;
private DataGridViewTextBoxColumn ColumnCost;
private Label labelRoute;
private Button buttonSave;
private Button buttonCancel;
private ComboBox comboBoxEmployeeId;
private ComboBox comboBoxRouteId;
private DateTimePicker dateTimePicker;
}
}

View File

@ -0,0 +1,83 @@
using ProjectEmployeeAgency.Repositories;
using ProjectRouteAgency.Repositories;
using ProjectTourAgency.Enities;
using ProjectTourAgency.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectTourAgency.Forms
{
public partial class FormClientTour : Form
{
private readonly ITourRepository _tourRepository;
public FormClientTour(ITourRepository tourRepository,
IEmployeeRepository employeeRepository,
IRouteRepository routeRepository, IClientRepository clientRepository)
{
InitializeComponent();
_tourRepository = tourRepository ??
throw new ArgumentNullException(nameof(tourRepository));
comboBoxEmployeeId.DataSource = employeeRepository.ReadEmployees();
comboBoxEmployeeId.DisplayMember = "FullName";
comboBoxEmployeeId.ValueMember = "Id";
comboBoxRouteId.DataSource = routeRepository.ReadRoutes();
comboBoxRouteId.DisplayMember = "Destination";
comboBoxRouteId.ValueMember = "Id";
ColumnClient.DataSource = clientRepository.ReadClients();
ColumnClient.DisplayMember = "FullName";
ColumnClient.ValueMember = "Id";
}
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (dataGridView.RowCount < 1
|| comboBoxEmployeeId.SelectedIndex < 0
|| comboBoxRouteId.SelectedIndex < 0)
{
throw new Exception("Есть незаполненные поля");
}
_tourRepository.CreateTour(Tour.CreateEntity(0, comboBoxEmployeeId.SelectedIndex,
comboBoxRouteId.SelectedIndex, dateTimePicker.Value,CreateListClientTourFromDataGrid()));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private List<ClientTour> CreateListClientTourFromDataGrid()
{
var list = new List<ClientTour>();
foreach(DataGridViewRow row in dataGridView.Rows)
{
if (row.Cells["ColumnClient"].Value == null
|| row.Cells["ColumnCost"].Value == null)
{
continue;
}
list.Add(ClientTour.CreateEntity(0, Convert.ToInt32(row.Cells["ColumnClient"].Value), 0,
Convert.ToInt32(row.Cells["ColumnCost"].Value)));
}
return list;
}
}
}

View File

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

View File

@ -0,0 +1,111 @@
namespace ProjectTourAgency.Forms
{
partial class FormTours
{
/// <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()
{
dataGridViewData = new DataGridView();
panel1 = new Panel();
buttonDelete = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(746, 462);
dataGridViewData.TabIndex = 3;
//
// panel1
//
panel1.Controls.Add(buttonDelete);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(746, 0);
panel1.Name = "panel1";
panel1.Size = new Size(149, 462);
panel1.TabIndex = 2;
//
// buttonDelete
//
buttonDelete.BackgroundImage = Properties.Resources.free_icon_delete_3807871;
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
buttonDelete.Location = new Point(43, 276);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(61, 59);
buttonDelete.TabIndex = 3;
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += buttonDelete_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.free_icon_add_button_5974633;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(43, 25);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(61, 59);
buttonAdd.TabIndex = 1;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// FormTours
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(895, 462);
Controls.Add(dataGridViewData);
Controls.Add(panel1);
Name = "FormTours";
Text = "FormTours";
Load += FormTours_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Panel panel1;
private Button buttonDelete;
private Button buttonAdd;
}
}

View File

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

View File

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

View File

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace ProjectTourAgency.Implementations;
public class TourRepositiry : ITourRepository
public class TourRepository : ITourRepository
{
public void CreateTour(Tour tour)
{
@ -21,7 +21,7 @@ public class TourRepositiry : ITourRepository
public Tour ReadTourById(int id)
{
return Tour.CreateEntity(0,DateTime.Now,0);
return Tour.CreateEntity(0,0, 0,DateTime.Now, []);
}
public IEnumerable<Tour> ReadTours()

View File

@ -24,11 +24,12 @@ namespace ProjectTourAgency
{
var container = new UnityContainer();
container.RegisterType<ITourRepository, TourRepository>();
container.RegisterType<IAddMoneyRepository, AddMoneyRepository>();
container.RegisterType<IClientRepository, ClientRepository>();
container.RegisterType<IRouteRepository, RouteRepository>();
container.RegisterType<IEmployeeRepository, EmployeeRepository>();
container.RegisterType<ITourRepository, TourRepositiry>();
container.RegisterType<ITourRepository, TourRepository>();
return container;
}