Compare commits

...

5 Commits

65 changed files with 5159 additions and 88 deletions

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Entities;
public class Check
{
public int Id { get; private set; }
//public string TripTitle { get; private set; } = string.Empty;
public DateTime PurchaseDate { get; private set; }
public int Price { get; private set; }
public int TripId { get; private set; }
public int ClientId { get; private set; }
public static Check CreateCheck(int id, DateTime purchaseDate, int price, int tripId, int clientId)//string triptitle,
{
return new Check() { Id = id, PurchaseDate = purchaseDate, Price = price, TripId = tripId, ClientId = clientId };//TripTitle = triptitle,
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Entities.Enums;
public class Client
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public DateTime BirthDate { get; private set; }
public ClientStatus Status { get; private set; }
public string Phone { get; private set; }= string.Empty;
public static Client CreateClient(int id, string name, DateTime birth, ClientStatus status, string phone)
{
return new Client()
{
Id = id,
Name = name,
BirthDate = birth,
Status = status,
Phone = phone
};
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Entities;
public class Company
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public int CountryId { get; private set; }
public static Company CreateCompany(int id, string name, int countryId)
{
return new Company() { Id = id, Name = name, CountryId = countryId};
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Entities;
public class CompanyTrip
{
public int Id { get; private set; }
public int CompanyId { get; private set; }
//public int TripId { get; private set; }
public int AdditionalPrice { get; private set; }
public static CompanyTrip CreateCompanyTrip(int id, int companyId , int additionalPrice)//int tripId,
{
return new CompanyTrip()
{
Id = id,
CompanyId = companyId,
//TripId = tripId,
AdditionalPrice = additionalPrice
};
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Entities;
public class Country
{
public int Id { get; private set; }
public string CountryName { get; private set; }=string.Empty;
public static Country CreateCountry(int id, string countryName)
{
return new Country
{
Id = id,
CountryName = countryName,
};
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Entities.Enums;
public enum ClientStatus
{
None = 0,
Student = 1,
Veteran = 3,
Invalid = 4,
Parent = 5,
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Entities.Enums;
[Flags]
public enum TravelType
{
None = 0,
Hiking = 1,
Bus = 2,
Sights = 4,
Water = 8,
Event = 16
}

View File

@ -0,0 +1,44 @@
using ProjectTourismCompany.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Entities;
public class Trip
{
public int Id { get; private set; }
public string Title { get; private set; } = string.Empty;
public int Price { get; private set; }
public int HumanCapacity { get; private set; }
public DateTime StartDate { get; private set; }
public DateTime EndDate { get; private set;}
public string StartCity { get; private set; }=string.Empty;
public string EndCity { get; private set;} =string.Empty;
public TravelType TravelType { get; private set; }
public IEnumerable<CompanyTrip> CompanyTrip
{
get;
private set;
} = [];
public static Trip CreateOpeartion(int id, string title, int price, int humanCapacity, DateTime startDate, DateTime endDate, string startCity, string endCity, TravelType travelType, IEnumerable<CompanyTrip> companyTrip)
{
return new Trip
{
Title = title,
Id = id,
Price = price,
HumanCapacity = humanCapacity,
StartDate = startDate,
EndDate = endDate,
StartCity = startCity,
EndCity = endCity,
TravelType = travelType,
CompanyTrip = companyTrip
};
}
}

View File

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

View File

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

View File

@ -0,0 +1,137 @@
namespace ProjectTourismCompany
{
partial class FormTourismCompany
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
menuStrip1 = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem();
ClientsToolStripMenuItem = new ToolStripMenuItem();
CompaniesToolStripMenuItem = new ToolStripMenuItem();
CountriesToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
ChecksToolStripMenuItem = new ToolStripMenuItem();
ToursToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
SuspendLayout();
//
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(20, 20);
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(800, 28);
menuStrip1.TabIndex = 0;
menuStrip1.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ClientsToolStripMenuItem, CompaniesToolStripMenuItem, CountriesToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники";
//
// ClientsToolStripMenuItem
//
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
ClientsToolStripMenuItem.Size = new Size(165, 26);
ClientsToolStripMenuItem.Text = "Клиенты";
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
//
// CompaniesToolStripMenuItem
//
CompaniesToolStripMenuItem.Name = "CompaniesToolStripMenuItem";
CompaniesToolStripMenuItem.Size = new Size(165, 26);
CompaniesToolStripMenuItem.Text = "Компании";
CompaniesToolStripMenuItem.Click += CompaniesToolStripMenuItem_Click;
//
// CountriesToolStripMenuItem
//
CountriesToolStripMenuItem.Name = "CountriesToolStripMenuItem";
CountriesToolStripMenuItem.Size = new Size(165, 26);
CountriesToolStripMenuItem.Text = "Страны";
CountriesToolStripMenuItem.Click += CountriesToolStripMenuItem_Click;
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ChecksToolStripMenuItem, ToursToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(95, 24);
операцииToolStripMenuItem.Text = "Операции";
//
// ChecksToolStripMenuItem
//
ChecksToolStripMenuItem.Name = "ChecksToolStripMenuItem";
ChecksToolStripMenuItem.Size = new Size(302, 26);
ChecksToolStripMenuItem.Text = "Заключение договоров (чеки)";
ChecksToolStripMenuItem.Click += ChecksToolStripMenuItem_Click;
//
// ToursToolStripMenuItem
//
ToursToolStripMenuItem.Name = "ToursToolStripMenuItem";
ToursToolStripMenuItem.Size = new Size(302, 26);
ToursToolStripMenuItem.Text = "Проведенные туры";
ToursToolStripMenuItem.Click += TripsToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(73, 24);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// FormTourismCompany
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.Карта_мира;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(800, 450);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
Name = "FormTourismCompany";
Text = "Туристическое агенство";
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip1;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem ClientsToolStripMenuItem;
private ToolStripMenuItem CompaniesToolStripMenuItem;
private ToolStripMenuItem CountriesToolStripMenuItem;
private ToolStripMenuItem ChecksToolStripMenuItem;
private ToolStripMenuItem ToursToolStripMenuItem;
}
}

View File

@ -0,0 +1,88 @@
using ProjectTourismCompany.Forms;
using System.ComponentModel;
using Unity;
namespace ProjectTourismCompany;
public partial class FormTourismCompany : Form
{
private readonly IUnityContainer _container;
public FormTourismCompany(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void TripsToolStripMenuItem_Click(object sender,
EventArgs e)
{
try
{
_container.Resolve<FormTrips>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CompaniesToolStripMenuItem_Click(object sender,
EventArgs e)
{
try
{
_container.Resolve<FormCompanies>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ChecksToolStripMenuItem_Click(object sender,
EventArgs e)
{
try
{
_container.Resolve<FormChecks>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CountriesToolStripMenuItem_Click(object sender,
EventArgs e)
{
try
{
_container.Resolve<FormCountries>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ClientsToolStripMenuItem_Click(object sender,
EventArgs e)
{
try
{
_container.Resolve<FormClients>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

View File

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

View File

@ -0,0 +1,173 @@
namespace ProjectTourismCompany.Forms
{
partial class FormCheck
{
/// <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()
{
buttonCancel = new Button();
buttonSave = new Button();
dateTimePickerPurchaseDate = new DateTimePicker();
labelStartDate = new Label();
label1 = new Label();
numericUpDownPrice = new NumericUpDown();
label2 = new Label();
label4 = new Label();
comboBoxClient = new ComboBox();
comboBoxTripId = new ComboBox();
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.BackColor = Color.IndianRed;
buttonCancel.Location = new Point(220, 207);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(135, 51);
buttonCancel.TabIndex = 31;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = false;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.BackColor = Color.LimeGreen;
buttonSave.Location = new Point(366, 207);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(135, 51);
buttonSave.TabIndex = 30;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = false;
buttonSave.Click += buttonSave_Click;
//
// dateTimePickerPurchaseDate
//
dateTimePickerPurchaseDate.Location = new Point(281, 13);
dateTimePickerPurchaseDate.Name = "dateTimePickerPurchaseDate";
dateTimePickerPurchaseDate.Size = new Size(220, 27);
dateTimePickerPurchaseDate.TabIndex = 25;
//
// labelStartDate
//
labelStartDate.AutoSize = true;
labelStartDate.Location = new Point(44, 18);
labelStartDate.Name = "labelStartDate";
labelStartDate.Size = new Size(92, 20);
labelStartDate.TabIndex = 18;
labelStartDate.Text = "Дата сделки";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(63, 64);
label1.Name = "label1";
label1.Size = new Size(45, 20);
label1.TabIndex = 34;
label1.Text = "Цена";
//
// numericUpDownPrice
//
numericUpDownPrice.Location = new Point(283, 57);
numericUpDownPrice.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
numericUpDownPrice.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
numericUpDownPrice.Name = "numericUpDownPrice";
numericUpDownPrice.Size = new Size(217, 27);
numericUpDownPrice.TabIndex = 35;
numericUpDownPrice.Value = new decimal(new int[] { 1, 0, 0, 0 });
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(44, 110);
label2.Name = "label2";
label2.Size = new Size(101, 20);
label2.TabIndex = 36;
label2.Text = "ФИО клиента";
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(44, 155);
label4.Name = "label4";
label4.Size = new Size(64, 20);
label4.TabIndex = 39;
label4.Text = "Путевка";
//
// comboBoxClient
//
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxClient.FormattingEnabled = true;
comboBoxClient.Location = new Point(281, 110);
comboBoxClient.Name = "comboBoxClient";
comboBoxClient.Size = new Size(217, 28);
comboBoxClient.TabIndex = 41;
//
// comboBoxTripId
//
comboBoxTripId.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxTripId.FormattingEnabled = true;
comboBoxTripId.Location = new Point(281, 155);
comboBoxTripId.Name = "comboBoxTripId";
comboBoxTripId.Size = new Size(217, 28);
comboBoxTripId.TabIndex = 42;
//
// FormCheck
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(516, 281);
Controls.Add(comboBoxTripId);
Controls.Add(comboBoxClient);
Controls.Add(label4);
Controls.Add(label2);
Controls.Add(numericUpDownPrice);
Controls.Add(label1);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(dateTimePickerPurchaseDate);
Controls.Add(labelStartDate);
Name = "FormCheck";
StartPosition = FormStartPosition.CenterParent;
Text = "Чек";
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private DateTimePicker dateTimePickerPurchaseDate;
private Label labelStartDate;
private Label label1;
private NumericUpDown numericUpDownPrice;
private Label label2;
private Label label4;
private ComboBox comboBoxClient;
private ComboBox comboBoxTripId;
}
}

View File

@ -0,0 +1,86 @@
using Microsoft.VisualBasic.FileIO;
using ProjectTourismCompany.Entities;
using ProjectTourismCompany.Repositories;
using ProjectTourismCompany.Repositories.Implementations;
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 ProjectTourismCompany.Forms;
public partial class FormCheck : Form
{
private readonly ICheckRepository _checkRepository;
private int _checkId;
public int Id
{
set
{
try
{
var check = _checkRepository.ReadCheckById(value);
if (check == null)
{
throw new
InvalidDataException(nameof(check));
}
dateTimePickerPurchaseDate.Value = check.PurchaseDate;
numericUpDownPrice.Value = check.Price;
_checkId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormCheck(ICheckRepository checkRepository, IClientRepository clientRepository, ITripRepository tripRepository)
{
InitializeComponent();
_checkRepository = checkRepository ?? throw new ArgumentNullException(nameof(checkRepository));
comboBoxClient.DataSource = clientRepository.ReadClients();
comboBoxClient.DisplayMember = "Name";
comboBoxClient.ValueMember = "Id";
comboBoxTripId.DataSource = tripRepository.ReadTrips();
comboBoxTripId.DisplayMember = "Title";
comboBoxTripId.ValueMember = "Id";
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxTripId.SelectedIndex < 0 ||
comboBoxClient.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
_checkRepository.CreateCheck(Check.CreateCheck(_checkId , dateTimePickerPurchaseDate.Value,
(int)numericUpDownPrice.Value, (int)comboBoxTripId.SelectedValue!,
(int)comboBoxClient.SelectedValue!));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) =>
Close();
}

View File

@ -0,0 +1,112 @@
namespace ProjectTourismCompany.Forms
{
partial class FormChecks
{
/// <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()
{
dataGridViewChecks = new DataGridView();
panel1 = new Panel();
buttonDelCheck = new Button();
buttonAddCheck = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewChecks).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridViewChecks
//
dataGridViewChecks.AllowUserToAddRows = false;
dataGridViewChecks.AllowUserToDeleteRows = false;
dataGridViewChecks.AllowUserToResizeColumns = false;
dataGridViewChecks.AllowUserToResizeRows = false;
dataGridViewChecks.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewChecks.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewChecks.Dock = DockStyle.Fill;
dataGridViewChecks.Location = new Point(0, 0);
dataGridViewChecks.MultiSelect = false;
dataGridViewChecks.Name = "dataGridViewChecks";
dataGridViewChecks.ReadOnly = true;
dataGridViewChecks.RowHeadersVisible = false;
dataGridViewChecks.RowHeadersWidth = 51;
dataGridViewChecks.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewChecks.Size = new Size(643, 450);
dataGridViewChecks.TabIndex = 0;
//
// panel1
//
panel1.Controls.Add(buttonDelCheck);
panel1.Controls.Add(buttonAddCheck);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(643, 0);
panel1.Name = "panel1";
panel1.Size = new Size(157, 450);
panel1.TabIndex = 1;
//
// buttonDelCheck
//
buttonDelCheck.BackgroundImage = Properties.Resources.minus;
buttonDelCheck.BackgroundImageLayout = ImageLayout.Stretch;
buttonDelCheck.Location = new Point(17, 184);
buttonDelCheck.Name = "buttonDelCheck";
buttonDelCheck.Size = new Size(94, 80);
buttonDelCheck.TabIndex = 5;
buttonDelCheck.UseVisualStyleBackColor = true;
buttonDelCheck.Click += buttonDel_Click;
//
// buttonAddCheck
//
buttonAddCheck.BackgroundImage = Properties.Resources.plus;
buttonAddCheck.BackgroundImageLayout = ImageLayout.Stretch;
buttonAddCheck.Location = new Point(17, 12);
buttonAddCheck.Name = "buttonAddCheck";
buttonAddCheck.Size = new Size(94, 80);
buttonAddCheck.TabIndex = 3;
buttonAddCheck.UseVisualStyleBackColor = true;
buttonAddCheck.Click += ButtonAdd_Click;
//
// FormChecks
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridViewChecks);
Controls.Add(panel1);
Name = "FormChecks";
Text = "Чеки";
Load += FormChecks_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewChecks).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewChecks;
private Panel panel1;
private Button buttonDelCheck;
private Button buttonAddCheck;
}
}

View File

@ -0,0 +1,100 @@
using ProjectTourismCompany.Repositories;
using ProjectTourismCompany.Repositories.Implementations;
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 ProjectTourismCompany.Forms;
public partial class FormChecks : Form
{
private readonly IUnityContainer _container;
private readonly ICheckRepository _checkRepository;
public FormChecks(IUnityContainer container, ICheckRepository checkRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_checkRepository = checkRepository ??
throw new
ArgumentNullException(nameof(checkRepository));
}
private void FormChecks_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<FormCheck>().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
{
_checkRepository.DeleteCheck(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewChecks.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewChecks.SelectedRows[0].Cells["Id"].Value);
return true;
}
private void LoadList() => dataGridViewChecks.DataSource =
_checkRepository.ReadChecks();
}

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,166 @@
namespace ProjectTourismCompany.Forms
{
partial class FormClient
{
/// <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()
{
textBoxName = new TextBox();
textBoxPhoneNumber = new TextBox();
label1 = new Label();
dateTimePickerBirthDate = new DateTimePicker();
label2 = new Label();
label3 = new Label();
label4 = new Label();
buttonSave = new Button();
buttonCancel = new Button();
comboBoxStatus = new ComboBox();
SuspendLayout();
//
// textBoxName
//
textBoxName.Location = new Point(230, 12);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(198, 27);
textBoxName.TabIndex = 0;
//
// textBoxPhoneNumber
//
textBoxPhoneNumber.Location = new Point(230, 198);
textBoxPhoneNumber.Name = "textBoxPhoneNumber";
textBoxPhoneNumber.Size = new Size(198, 27);
textBoxPhoneNumber.TabIndex = 1;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(63, 15);
label1.Name = "label1";
label1.Size = new Size(42, 20);
label1.TabIndex = 2;
label1.Text = "ФИО";
//
// dateTimePickerBirthDate
//
dateTimePickerBirthDate.Location = new Point(230, 45);
dateTimePickerBirthDate.Name = "dateTimePickerBirthDate";
dateTimePickerBirthDate.Size = new Size(198, 27);
dateTimePickerBirthDate.TabIndex = 3;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(63, 50);
label2.Name = "label2";
label2.Size = new Size(116, 20);
label2.TabIndex = 4;
label2.Text = "Дата рождения";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(63, 121);
label3.Name = "label3";
label3.Size = new Size(52, 20);
label3.TabIndex = 5;
label3.Text = "Статус";
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(63, 201);
label4.Name = "label4";
label4.Size = new Size(69, 20);
label4.TabIndex = 6;
label4.Text = "Телефон";
//
// buttonSave
//
buttonSave.BackColor = Color.LimeGreen;
buttonSave.Location = new Point(293, 281);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(135, 51);
buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = false;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.BackColor = Color.IndianRed;
buttonCancel.Location = new Point(147, 281);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(135, 51);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = false;
buttonCancel.Click += ButtonCancel_Click;
//
// comboBoxStatus
//
comboBoxStatus.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxStatus.FormattingEnabled = true;
comboBoxStatus.Location = new Point(230, 121);
comboBoxStatus.Name = "comboBoxStatus";
comboBoxStatus.Size = new Size(198, 28);
comboBoxStatus.TabIndex = 10;
//
// FormClient
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(442, 344);
Controls.Add(comboBoxStatus);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(dateTimePickerBirthDate);
Controls.Add(label1);
Controls.Add(textBoxPhoneNumber);
Controls.Add(textBoxName);
Name = "FormClient";
StartPosition = FormStartPosition.CenterParent;
Text = "Клиент";
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBoxName;
private TextBox textBoxPhoneNumber;
private Label label1;
private DateTimePicker dateTimePickerBirthDate;
private Label label2;
private Label label3;
private Label label4;
private Button buttonSave;
private Button buttonCancel;
private ComboBox comboBoxStatus;
}
}

View File

@ -0,0 +1,91 @@
using Microsoft.VisualBasic.FileIO;
using ProjectTourismCompany.Entities.Enums;
using ProjectTourismCompany.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 ProjectTourismCompany.Forms;
public partial class FormClient : Form
{
private readonly IClientRepository _clientRepository;
private int? _clientId;
public int Id
{
set
{
try
{
var client = _clientRepository.ReadClientById(value);
if (client == null)
{
throw new InvalidDataException(nameof(client));
}
textBoxName.Text = client.Name;
textBoxPhoneNumber.Text = client.Phone;
comboBoxStatus.SelectedItem = client.Status;
dateTimePickerBirthDate.Value = client.BirthDate;
_clientId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormClient(IClientRepository clientRepository)
{
InitializeComponent();
_clientRepository = clientRepository ??
throw new
ArgumentNullException(nameof(clientRepository));
comboBoxStatus.DataSource =
Enum.GetValues(typeof(ClientStatus));
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxName.Text)
||
string.IsNullOrWhiteSpace(textBoxPhoneNumber.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_clientId.HasValue)
{
_clientRepository.UpdateClient(CreateClient(_clientId.Value));
}
else
{
_clientRepository.CreateClient(CreateClient(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Client CreateClient(int id)
{
return Client.CreateClient(id, textBoxName.Text, dateTimePickerBirthDate.Value, (ClientStatus)comboBoxStatus.SelectedItem!, textBoxPhoneNumber.Text);
}
}

View File

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

View File

@ -0,0 +1,127 @@
namespace ProjectTourismCompany.Forms
{
partial class FormClients
{
/// <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();
buttonDelClient = new Button();
buttonUpdClient = new Button();
buttonAddClient = new Button();
dataGridViewClient = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewClient).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonDelClient);
panel1.Controls.Add(buttonUpdClient);
panel1.Controls.Add(buttonAddClient);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(669, 0);
panel1.Name = "panel1";
panel1.Size = new Size(131, 450);
panel1.TabIndex = 0;
//
// buttonDelClient
//
buttonDelClient.BackgroundImage = Properties.Resources.minus;
buttonDelClient.BackgroundImageLayout = ImageLayout.Stretch;
buttonDelClient.Location = new Point(6, 184);
buttonDelClient.Name = "buttonDelClient";
buttonDelClient.Size = new Size(94, 80);
buttonDelClient.TabIndex = 2;
buttonDelClient.UseVisualStyleBackColor = true;
buttonDelClient.Click += buttonDel_Click;
//
// buttonUpdClient
//
buttonUpdClient.BackgroundImage = Properties.Resources.pencil;
buttonUpdClient.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdClient.Location = new Point(6, 98);
buttonUpdClient.Name = "buttonUpdClient";
buttonUpdClient.Size = new Size(94, 80);
buttonUpdClient.TabIndex = 1;
buttonUpdClient.UseVisualStyleBackColor = true;
buttonUpdClient.Click += buttonUpd_Click;
//
// buttonAddClient
//
buttonAddClient.BackgroundImage = Properties.Resources.plus;
buttonAddClient.BackgroundImageLayout = ImageLayout.Stretch;
buttonAddClient.Location = new Point(6, 12);
buttonAddClient.Name = "buttonAddClient";
buttonAddClient.Size = new Size(94, 80);
buttonAddClient.TabIndex = 0;
buttonAddClient.UseVisualStyleBackColor = true;
buttonAddClient.Click += buttonAdd_Click;
//
// dataGridViewClient
//
dataGridViewClient.AllowUserToAddRows = false;
dataGridViewClient.AllowUserToDeleteRows = false;
dataGridViewClient.AllowUserToResizeColumns = false;
dataGridViewClient.AllowUserToResizeRows = false;
dataGridViewClient.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewClient.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewClient.Dock = DockStyle.Fill;
dataGridViewClient.Location = new Point(0, 0);
dataGridViewClient.MultiSelect = false;
dataGridViewClient.Name = "dataGridViewClient";
dataGridViewClient.ReadOnly = true;
dataGridViewClient.RowHeadersVisible = false;
dataGridViewClient.RowHeadersWidth = 51;
dataGridViewClient.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewClient.Size = new Size(669, 450);
dataGridViewClient.TabIndex = 1;
//
// FormClients
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridViewClient);
Controls.Add(panel1);
Name = "FormClients";
StartPosition = FormStartPosition.CenterParent;
Text = "Клиенты";
Load += FormClients_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewClient).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonDelClient;
private Button buttonUpdClient;
private Button buttonAddClient;
private DataGridView dataGridViewClient;
}
}

View File

@ -0,0 +1,107 @@
using ProjectTourismCompany.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 ProjectTourismCompany.Forms;
public partial class FormClients : Form
{
private readonly IUnityContainer _container;
private readonly IClientRepository _clientRepository;
public FormClients(IUnityContainer container, IClientRepository clientRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
}
private void FormClients_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<FormClient>().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<FormClient>();
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
{
_clientRepository.DeleteClient(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewClient.DataSource =
_clientRepository.ReadClients();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewClient.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewClient.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,127 @@
namespace ProjectTourismCompany.Forms
{
partial class FormCompanies
{
/// <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()
{
dataGridViewCompanies = new DataGridView();
panel1 = new Panel();
buttonDelCompany = new Button();
buttonUpdCompany = new Button();
buttonAddCompany = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewCompanies).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridViewCompanies
//
dataGridViewCompanies.AllowUserToAddRows = false;
dataGridViewCompanies.AllowUserToDeleteRows = false;
dataGridViewCompanies.AllowUserToResizeColumns = false;
dataGridViewCompanies.AllowUserToResizeRows = false;
dataGridViewCompanies.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewCompanies.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewCompanies.Dock = DockStyle.Fill;
dataGridViewCompanies.Location = new Point(0, 0);
dataGridViewCompanies.MultiSelect = false;
dataGridViewCompanies.Name = "dataGridViewCompanies";
dataGridViewCompanies.ReadOnly = true;
dataGridViewCompanies.RowHeadersVisible = false;
dataGridViewCompanies.RowHeadersWidth = 51;
dataGridViewCompanies.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewCompanies.Size = new Size(800, 450);
dataGridViewCompanies.TabIndex = 0;
//
// panel1
//
panel1.Controls.Add(buttonDelCompany);
panel1.Controls.Add(buttonUpdCompany);
panel1.Controls.Add(buttonAddCompany);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(665, 0);
panel1.Name = "panel1";
panel1.Size = new Size(135, 450);
panel1.TabIndex = 1;
//
// buttonDelCompany
//
buttonDelCompany.BackgroundImage = Properties.Resources.minus;
buttonDelCompany.BackgroundImageLayout = ImageLayout.Stretch;
buttonDelCompany.Location = new Point(29, 183);
buttonDelCompany.Name = "buttonDelCompany";
buttonDelCompany.Size = new Size(94, 80);
buttonDelCompany.TabIndex = 5;
buttonDelCompany.UseVisualStyleBackColor = true;
buttonDelCompany.Click += buttonDel_Click;
//
// buttonUpdCompany
//
buttonUpdCompany.BackgroundImage = Properties.Resources.pencil;
buttonUpdCompany.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdCompany.Location = new Point(29, 97);
buttonUpdCompany.Name = "buttonUpdCompany";
buttonUpdCompany.Size = new Size(94, 80);
buttonUpdCompany.TabIndex = 4;
buttonUpdCompany.UseVisualStyleBackColor = true;
buttonUpdCompany.Click += buttonUpd_Click;
//
// buttonAddCompany
//
buttonAddCompany.BackgroundImage = Properties.Resources.plus;
buttonAddCompany.BackgroundImageLayout = ImageLayout.Stretch;
buttonAddCompany.Location = new Point(29, 11);
buttonAddCompany.Name = "buttonAddCompany";
buttonAddCompany.Size = new Size(94, 80);
buttonAddCompany.TabIndex = 3;
buttonAddCompany.UseVisualStyleBackColor = true;
buttonAddCompany.Click += buttonAdd_Click;
//
// FormCompanies
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panel1);
Controls.Add(dataGridViewCompanies);
Name = "FormCompanies";
StartPosition = FormStartPosition.CenterParent;
Text = "Компании";
Load += FormCompanies_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewCompanies).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewCompanies;
private Panel panel1;
private Button buttonDelCompany;
private Button buttonUpdCompany;
private Button buttonAddCompany;
}
}

View File

@ -0,0 +1,111 @@
using ProjectTourismCompany.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 ProjectTourismCompany.Forms;
public partial class FormCompanies : Form
{
private readonly IUnityContainer _container;
private readonly ICompanyRepository _companyRepository;
public FormCompanies(IUnityContainer container, ICompanyRepository
companyRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_companyRepository = companyRepository ?? throw new ArgumentNullException(nameof(companyRepository));
}
private void FormCompanies_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<FormCompany>().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<FormCompany>();
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
{
_companyRepository.DeleteCompany(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewCompanies.DataSource =
_companyRepository.ReadCompanies();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewCompanies.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewCompanies.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,123 @@
namespace ProjectTourismCompany.Forms
{
partial class FormCompany
{
/// <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()
{
label1 = new Label();
textBoxName = new TextBox();
buttonCancel = new Button();
buttonSave = new Button();
comboBoxCountry = new ComboBox();
label2 = new Label();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 9);
label1.Name = "label1";
label1.Size = new Size(77, 20);
label1.TabIndex = 0;
label1.Text = "Название";
//
// textBoxName
//
textBoxName.Location = new Point(107, 6);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(150, 27);
textBoxName.TabIndex = 3;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.BackColor = Color.IndianRed;
buttonCancel.Location = new Point(17, 117);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(135, 51);
buttonCancel.TabIndex = 17;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = false;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonSave.BackColor = Color.LimeGreen;
buttonSave.Location = new Point(158, 117);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(135, 51);
buttonSave.TabIndex = 16;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = false;
buttonSave.Click += ButtonSave_Click;
//
// comboBoxCountry
//
comboBoxCountry.FormattingEnabled = true;
comboBoxCountry.Location = new Point(107, 67);
comboBoxCountry.Name = "comboBoxCountry";
comboBoxCountry.Size = new Size(150, 28);
comboBoxCountry.TabIndex = 20;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(12, 67);
label2.Name = "label2";
label2.Size = new Size(58, 20);
label2.TabIndex = 21;
label2.Text = "Страна";
//
// FormCompany
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(305, 180);
Controls.Add(label2);
Controls.Add(comboBoxCountry);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxName);
Controls.Add(label1);
Name = "FormCompany";
StartPosition = FormStartPosition.CenterParent;
Text = "Компания";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private TextBox textBoxName;
private Button buttonCancel;
private Button buttonSave;
private ComboBox comboBoxCountry;
private Label label2;
}
}

View File

@ -0,0 +1,99 @@
using Microsoft.VisualBasic.FileIO;
using ProjectTourismCompany.Entities;
using ProjectTourismCompany.Entities.Enums;
using ProjectTourismCompany.Repositories;
using ProjectTourismCompany.Repositories.Implementations;
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 ProjectTourismCompany.Forms;
public partial class FormCompany : Form
{
private readonly ICompanyRepository _companyRepository;
private int? _companyId;
public int Id
{
set
{
try
{
var client = _companyRepository.ReadCompanyById(value);
if (client == null)
{
throw new InvalidDataException(nameof(client));
}
textBoxName.Text = client.Name;
comboBoxCountry.SelectedItem = client.CountryId;
comboBoxCountry.SelectedValue = client.CountryId;
_companyId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormCompany(
ICompanyRepository companyRepository,
ITripRepository tripRepository,
ICountryRepository countryRepository)
{
InitializeComponent();
_companyRepository = companyRepository ??
throw new ArgumentNullException(nameof(companyRepository));
comboBoxCountry.DataSource = countryRepository.ReadCountries();
comboBoxCountry.DisplayMember = "CountryName";
comboBoxCountry.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxName.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_companyId.HasValue)
{
_companyRepository.UpdateCompany(CreateCompany(_companyId.Value));
}
else
{
_companyRepository.CreateCompany(CreateCompany(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) =>
Close();
private Company CreateCompany(int id)
{
return Company.CreateCompany(id, textBoxName.Text, (int)comboBoxCountry.SelectedValue!);
}
}

View File

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

View File

@ -0,0 +1,127 @@
namespace ProjectTourismCompany.Forms
{
partial class FormCountries
{
/// <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()
{
dataGridView1 = new DataGridView();
panel1 = new Panel();
buttonDelCountry = new Button();
buttonUpdCountry = new Button();
buttonAddCountry = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.AllowUserToResizeColumns = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.Location = new Point(0, 0);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true;
dataGridView1.RowHeadersVisible = false;
dataGridView1.RowHeadersWidth = 51;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(642, 450);
dataGridView1.TabIndex = 0;
//
// panel1
//
panel1.Controls.Add(buttonDelCountry);
panel1.Controls.Add(buttonUpdCountry);
panel1.Controls.Add(buttonAddCountry);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(642, 0);
panel1.Name = "panel1";
panel1.Size = new Size(158, 450);
panel1.TabIndex = 1;
//
// buttonDelCountry
//
buttonDelCountry.BackgroundImage = Properties.Resources.minus;
buttonDelCountry.BackgroundImageLayout = ImageLayout.Stretch;
buttonDelCountry.Location = new Point(38, 198);
buttonDelCountry.Name = "buttonDelCountry";
buttonDelCountry.Size = new Size(94, 80);
buttonDelCountry.TabIndex = 7;
buttonDelCountry.UseVisualStyleBackColor = true;
buttonDelCountry.Click += buttonDel_Click;
//
// buttonUpdCountry
//
buttonUpdCountry.BackgroundImage = Properties.Resources.pencil;
buttonUpdCountry.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdCountry.Location = new Point(38, 112);
buttonUpdCountry.Name = "buttonUpdCountry";
buttonUpdCountry.Size = new Size(94, 80);
buttonUpdCountry.TabIndex = 6;
buttonUpdCountry.UseVisualStyleBackColor = true;
buttonUpdCountry.Click += buttonUpd_Click;
//
// buttonAddCountry
//
buttonAddCountry.BackgroundImage = Properties.Resources.plus;
buttonAddCountry.BackgroundImageLayout = ImageLayout.Stretch;
buttonAddCountry.Location = new Point(38, 26);
buttonAddCountry.Name = "buttonAddCountry";
buttonAddCountry.Size = new Size(94, 80);
buttonAddCountry.TabIndex = 4;
buttonAddCountry.UseVisualStyleBackColor = true;
buttonAddCountry.Click += buttonAdd_Click;
//
// FormCountries
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView1);
Controls.Add(panel1);
Name = "FormCountries";
StartPosition = FormStartPosition.CenterParent;
Text = "Страны";
Load += FormCountries_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Panel panel1;
private Button buttonAddCountry;
private Button buttonDelCountry;
private Button buttonUpdCountry;
}
}

View File

@ -0,0 +1,117 @@
using ProjectTourismCompany.Repositories;
using ProjectTourismCompany.Repositories.Implementations;
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 ProjectTourismCompany.Forms;
public partial class FormCountries : Form
{
private readonly IUnityContainer _container;
private readonly ICountryRepository _countryRepository;
public FormCountries(IUnityContainer container, ICountryRepository countryRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_countryRepository = countryRepository ?? throw new ArgumentNullException(nameof(countryRepository));
}
private void FormCountries_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<FormCountry>().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<FormCountry>();
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
{
_countryRepository.DeleteCountry(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView1.DataSource =
_countryRepository.ReadCountries();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView1.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView1.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,98 @@
namespace ProjectTourismCompany.Forms
{
partial class FormCountry
{
/// <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()
{
buttonCancel = new Button();
buttonSave = new Button();
textBoxName = new TextBox();
label1 = new Label();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.BackColor = Color.IndianRed;
buttonCancel.Location = new Point(33, 76);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(135, 51);
buttonCancel.TabIndex = 17;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = false;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.BackColor = Color.LimeGreen;
buttonSave.Location = new Point(174, 76);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(135, 51);
buttonSave.TabIndex = 16;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = false;
buttonSave.Click += buttonSave_Click;
//
// textBoxName
//
textBoxName.Location = new Point(107, 6);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(150, 27);
textBoxName.TabIndex = 21;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 9);
label1.Name = "label1";
label1.Size = new Size(77, 20);
label1.TabIndex = 18;
label1.Text = "Название";
//
// FormCountry
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(321, 139);
Controls.Add(textBoxName);
Controls.Add(label1);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Name = "FormCountry";
StartPosition = FormStartPosition.CenterParent;
Text = "Страна";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private TextBox textBoxName;
private Label label1;
}
}

View File

@ -0,0 +1,81 @@
using ProjectTourismCompany.Entities;
using ProjectTourismCompany.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 ProjectTourismCompany.Forms;
public partial class FormCountry : Form
{
private readonly ICountryRepository _countryRepository;
private int? _countryId;
public int Id
{
set
{
try
{
var country = _countryRepository.ReadCountryById(value);
if (country == null)
{
throw new InvalidDataException(nameof(country));
}
textBoxName.Text = country.CountryName;
_countryId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormCountry(ICountryRepository countryRepository)
{
InitializeComponent();
_countryRepository = countryRepository ?? throw new ArgumentNullException(nameof(countryRepository));
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxName.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_countryId.HasValue)
{
_countryRepository.UpdateCountry(CreateCountry(_countryId.Value));
}
else
{
_countryRepository.CreateCountry(CreateCountry(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private Country CreateCountry(int id)
{
return Country.CreateCountry(id, textBoxName.Text);
}
}

View File

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

View File

@ -0,0 +1,319 @@
namespace ProjectTourismCompany.Forms
{
partial class FormTrip
{
/// <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()
{
labelPrice = new Label();
labelHumanCapacity = new Label();
labelStartDate = new Label();
labelEndDate = new Label();
labelStartCity = new Label();
labelEndCity = new Label();
labelTravelType = new Label();
numericUpDownPrice = new NumericUpDown();
numericUpDownHumanCapacity = new NumericUpDown();
dateTimePickerStartDate = new DateTimePicker();
dateTimePickerEndDate = new DateTimePicker();
textBoxStartCity = new TextBox();
textBoxEndCity = new TextBox();
checkedListBoxTravelType = new CheckedListBox();
buttonCancel = new Button();
buttonSave = new Button();
label1 = new Label();
textBoxTitle = new TextBox();
groupBox1 = new GroupBox();
dataGridView1 = new DataGridView();
columnCompanyName = new DataGridViewComboBoxColumn();
ColumnAdditionalPrice = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownHumanCapacity).BeginInit();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// labelPrice
//
labelPrice.AutoSize = true;
labelPrice.Location = new Point(36, 71);
labelPrice.Name = "labelPrice";
labelPrice.Size = new Size(45, 20);
labelPrice.TabIndex = 0;
labelPrice.Text = "Цена";
//
// labelHumanCapacity
//
labelHumanCapacity.AutoSize = true;
labelHumanCapacity.Location = new Point(36, 116);
labelHumanCapacity.Name = "labelHumanCapacity";
labelHumanCapacity.Size = new Size(142, 20);
labelHumanCapacity.TabIndex = 1;
labelHumanCapacity.Text = "Человек максимум";
//
// labelStartDate
//
labelStartDate.AutoSize = true;
labelStartDate.Location = new Point(36, 172);
labelStartDate.Name = "labelStartDate";
labelStartDate.Size = new Size(94, 20);
labelStartDate.TabIndex = 2;
labelStartDate.Text = "Дата начала";
//
// labelEndDate
//
labelEndDate.AutoSize = true;
labelEndDate.Location = new Point(36, 227);
labelEndDate.Name = "labelEndDate";
labelEndDate.Size = new Size(87, 20);
labelEndDate.TabIndex = 3;
labelEndDate.Text = "Дата конца";
//
// labelStartCity
//
labelStartCity.AutoSize = true;
labelStartCity.Location = new Point(36, 285);
labelStartCity.Name = "labelStartCity";
labelStartCity.Size = new Size(129, 20);
labelStartCity.TabIndex = 4;
labelStartCity.Text = "Стартовый город";
//
// labelEndCity
//
labelEndCity.AutoSize = true;
labelEndCity.Location = new Point(36, 339);
labelEndCity.Name = "labelEndCity";
labelEndCity.Size = new Size(126, 20);
labelEndCity.TabIndex = 5;
labelEndCity.Text = "Конечный город";
//
// labelTravelType
//
labelTravelType.AutoSize = true;
labelTravelType.Location = new Point(35, 427);
labelTravelType.Name = "labelTravelType";
labelTravelType.Size = new Size(127, 20);
labelTravelType.TabIndex = 6;
labelTravelType.Text = "Тип путешествия";
//
// numericUpDownPrice
//
numericUpDownPrice.Location = new Point(273, 69);
numericUpDownPrice.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
numericUpDownPrice.Minimum = new decimal(new int[] { 10000, 0, 0, 0 });
numericUpDownPrice.Name = "numericUpDownPrice";
numericUpDownPrice.Size = new Size(220, 27);
numericUpDownPrice.TabIndex = 7;
numericUpDownPrice.Value = new decimal(new int[] { 10000, 0, 0, 0 });
//
// numericUpDownHumanCapacity
//
numericUpDownHumanCapacity.Location = new Point(273, 114);
numericUpDownHumanCapacity.Minimum = new decimal(new int[] { 5, 0, 0, 0 });
numericUpDownHumanCapacity.Name = "numericUpDownHumanCapacity";
numericUpDownHumanCapacity.Size = new Size(220, 27);
numericUpDownHumanCapacity.TabIndex = 8;
numericUpDownHumanCapacity.Value = new decimal(new int[] { 5, 0, 0, 0 });
//
// dateTimePickerStartDate
//
dateTimePickerStartDate.Location = new Point(273, 167);
dateTimePickerStartDate.Name = "dateTimePickerStartDate";
dateTimePickerStartDate.Size = new Size(220, 27);
dateTimePickerStartDate.TabIndex = 9;
//
// dateTimePickerEndDate
//
dateTimePickerEndDate.Location = new Point(273, 222);
dateTimePickerEndDate.Name = "dateTimePickerEndDate";
dateTimePickerEndDate.Size = new Size(220, 27);
dateTimePickerEndDate.TabIndex = 10;
//
// textBoxStartCity
//
textBoxStartCity.Location = new Point(273, 285);
textBoxStartCity.Name = "textBoxStartCity";
textBoxStartCity.Size = new Size(220, 27);
textBoxStartCity.TabIndex = 11;
//
// textBoxEndCity
//
textBoxEndCity.Location = new Point(273, 339);
textBoxEndCity.Name = "textBoxEndCity";
textBoxEndCity.Size = new Size(220, 27);
textBoxEndCity.TabIndex = 12;
//
// checkedListBoxTravelType
//
checkedListBoxTravelType.FormattingEnabled = true;
checkedListBoxTravelType.Location = new Point(273, 383);
checkedListBoxTravelType.Name = "checkedListBoxTravelType";
checkedListBoxTravelType.Size = new Size(220, 114);
checkedListBoxTravelType.TabIndex = 13;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCancel.BackColor = Color.IndianRed;
buttonCancel.Location = new Point(605, 512);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(135, 51);
buttonCancel.TabIndex = 15;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = false;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonSave.BackColor = Color.LimeGreen;
buttonSave.Location = new Point(796, 512);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(135, 51);
buttonSave.TabIndex = 14;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = false;
buttonSave.Click += ButtonSave_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(36, 12);
label1.Name = "label1";
label1.Size = new Size(111, 20);
label1.TabIndex = 16;
label1.Text = "Название тура";
//
// textBoxTitle
//
textBoxTitle.Location = new Point(273, 12);
textBoxTitle.Name = "textBoxTitle";
textBoxTitle.Size = new Size(220, 27);
textBoxTitle.TabIndex = 17;
//
// groupBox1
//
groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBox1.Controls.Add(dataGridView1);
groupBox1.Location = new Point(499, 12);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(432, 476);
groupBox1.TabIndex = 20;
groupBox1.TabStop = false;
groupBox1.Text = "groupBox1";
//
// dataGridView1
//
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.AllowUserToResizeColumns = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { columnCompanyName, ColumnAdditionalPrice });
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.Location = new Point(3, 23);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.RowHeadersVisible = false;
dataGridView1.RowHeadersWidth = 51;
dataGridView1.Size = new Size(426, 450);
dataGridView1.TabIndex = 0;
//
// columnCompanyName
//
columnCompanyName.HeaderText = "Название компании";
columnCompanyName.MinimumWidth = 6;
columnCompanyName.Name = "columnCompanyName";
//
// ColumnAdditionalPrice
//
ColumnAdditionalPrice.HeaderText = "Добавочная стоимость";
ColumnAdditionalPrice.MinimumWidth = 6;
ColumnAdditionalPrice.Name = "ColumnAdditionalPrice";
ColumnAdditionalPrice.Resizable = DataGridViewTriState.True;
ColumnAdditionalPrice.SortMode = DataGridViewColumnSortMode.NotSortable;
//
// FormTrip
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(943, 573);
Controls.Add(groupBox1);
Controls.Add(textBoxTitle);
Controls.Add(label1);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(checkedListBoxTravelType);
Controls.Add(textBoxEndCity);
Controls.Add(textBoxStartCity);
Controls.Add(dateTimePickerEndDate);
Controls.Add(dateTimePickerStartDate);
Controls.Add(numericUpDownHumanCapacity);
Controls.Add(numericUpDownPrice);
Controls.Add(labelTravelType);
Controls.Add(labelEndCity);
Controls.Add(labelStartCity);
Controls.Add(labelEndDate);
Controls.Add(labelStartDate);
Controls.Add(labelHumanCapacity);
Controls.Add(labelPrice);
Name = "FormTrip";
StartPosition = FormStartPosition.CenterParent;
Text = "Туры";
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownHumanCapacity).EndInit();
groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelPrice;
private Label labelHumanCapacity;
private Label labelStartDate;
private Label labelEndDate;
private Label labelStartCity;
private Label labelEndCity;
private Label labelTravelType;
private NumericUpDown numericUpDownPrice;
private NumericUpDown numericUpDownHumanCapacity;
private DateTimePicker dateTimePickerStartDate;
private DateTimePicker dateTimePickerEndDate;
private TextBox textBoxStartCity;
private TextBox textBoxEndCity;
private CheckedListBox checkedListBoxTravelType;
private Button buttonCancel;
private Button buttonSave;
private Label label1;
private TextBox textBoxTitle;
private GroupBox groupBox1;
private DataGridView dataGridView1;
private DataGridViewComboBoxColumn columnCompanyName;
private DataGridViewTextBoxColumn ColumnAdditionalPrice;
}
}

View File

@ -0,0 +1,123 @@
using Microsoft.VisualBasic.FileIO;
using ProjectTourismCompany.Entities;
using ProjectTourismCompany.Entities.Enums;
using ProjectTourismCompany.Repositories;
using ProjectTourismCompany.Repositories.Implementations;
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 ProjectTourismCompany.Forms;
public partial class FormTrip : Form
{
private readonly ITripRepository _tripRepository;
private int? _tripId;
public int Id
{
set
{
try
{
var trip = _tripRepository.ReadTripById(value);
if (trip == null)
{
throw new
InvalidDataException(nameof(trip));
}
textBoxStartCity.Text = trip.StartCity;
textBoxEndCity.Text = trip.EndCity;
numericUpDownHumanCapacity.Value = trip.HumanCapacity;
numericUpDownPrice.Value = trip.Price;
dateTimePickerEndDate.Value = trip.EndDate;
dateTimePickerStartDate.Value = trip.StartDate;
_tripId = value;
foreach (TravelType elem in
Enum.GetValues(typeof(TravelType)))
{
if ((elem & trip.TravelType) != 0)
{
checkedListBoxTravelType.SetItemChecked(checkedListBoxTravelType.Items.IndexOf(
elem), true);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormTrip(ITripRepository tripRepository, ICompanyRepository companyRepository)
{
InitializeComponent();
_tripRepository = tripRepository ?? throw new ArgumentNullException(nameof(tripRepository));
foreach (var elem in Enum.GetValues(typeof(TravelType)))
{
checkedListBoxTravelType.Items.Add(elem);
}
columnCompanyName.DataSource = companyRepository.ReadCompanies();
columnCompanyName.DisplayMember = "Name";
columnCompanyName.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxStartCity.Text) ||
string.IsNullOrWhiteSpace(textBoxEndCity.Text) || dataGridView1.RowCount < 1 || dateTimePickerStartDate.Value > dateTimePickerEndDate.Value)
{
throw new Exception("Имеются незаполненные или некорректно заполненные поля");
}
_tripRepository.CreateTrip(CreateTrip(0));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) =>
Close();
private Trip CreateTrip(int id)
{
TravelType tr = TravelType.None;
foreach (var elem in checkedListBoxTravelType.CheckedItems)
{
tr |= (TravelType)elem;
}
return Trip.CreateOpeartion(id, textBoxTitle.Text, (int)numericUpDownPrice.Value,
(int)numericUpDownHumanCapacity.Value, dateTimePickerStartDate.Value, dateTimePickerEndDate.Value,
textBoxStartCity.Text, textBoxEndCity.Text, tr, CreateListCompanyTripFromDataGrid());
}
private List<CompanyTrip> CreateListCompanyTripFromDataGrid()
{
var list = new List<CompanyTrip>();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells["ColumnAdditionalPrice"].Value == null ||
row.Cells["ColumnCompanyName"].Value == null)
{
continue;
}
list.Add(CompanyTrip.CreateCompanyTrip(0,
Convert.ToInt32(row.Cells["ColumnCompanyName"].Value),
Convert.ToInt32(row.Cells["ColumnAdditionalPrice"].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="columnCompanyName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnAdditionalPrice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,99 @@
namespace ProjectTourismCompany.Forms
{
partial class FormTrips
{
/// <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()
{
dataGridView1 = new DataGridView();
panel1 = new Panel();
buttonAddTrip = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.AllowUserToResizeColumns = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.Location = new Point(0, 0);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true;
dataGridView1.RowHeadersVisible = false;
dataGridView1.RowHeadersWidth = 51;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(645, 450);
dataGridView1.TabIndex = 0;
//
// panel1
//
panel1.Controls.Add(buttonAddTrip);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(645, 0);
panel1.Name = "panel1";
panel1.Size = new Size(155, 450);
panel1.TabIndex = 1;
//
// buttonAddTrip
//
buttonAddTrip.BackgroundImage = Properties.Resources.plus;
buttonAddTrip.BackgroundImageLayout = ImageLayout.Stretch;
buttonAddTrip.Location = new Point(34, 31);
buttonAddTrip.Name = "buttonAddTrip";
buttonAddTrip.Size = new Size(94, 80);
buttonAddTrip.TabIndex = 5;
buttonAddTrip.UseVisualStyleBackColor = true;
buttonAddTrip.Click += ButtonAdd_Click;
//
// FormTrips
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridView1);
Controls.Add(panel1);
Name = "FormTrips";
StartPosition = FormStartPosition.CenterParent;
Text = "Туры";
Load += FormTrips_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Panel panel1;
private Button buttonAddTrip;
}
}

View File

@ -0,0 +1,65 @@
using ProjectTourismCompany.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 ProjectTourismCompany.Forms;
public partial class FormTrips : Form
{
private readonly IUnityContainer _container;
private readonly ITripRepository _tripRepository;
public FormTrips(IUnityContainer container, ITripRepository tripRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_tripRepository = tripRepository ??
throw new
ArgumentNullException(nameof(tripRepository));
}
private void FormTrips_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<FormTrip>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView1.DataSource =
_tripRepository.ReadTrips();
}

View File

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

View File

@ -1,17 +1,50 @@
namespace ProjectTourismCompany
using Unity.Lifetime;
using Unity;
using ProjectTourismCompany.Repositories;
using ProjectTourismCompany.Repositories.Implementations;
using ProjectTourismCompany;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Serilog;
using Unity.Microsoft.Logging;
internal static class Program
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(CreateContainer().Resolve<FormTourismCompany>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
container.RegisterType<ICheckRepository, CheckRepository>(new TransientLifetimeManager());
container.RegisterType<IClientRepository, ClientRepository>(new TransientLifetimeManager());
container.RegisterType<ICompanyRepository, CompanyRepository>(new TransientLifetimeManager());
container.RegisterType<ICountryRepository, CountryRepository>(new TransientLifetimeManager());
container.RegisterType<ITripRepository, TripRepository>();
container.RegisterType<IConnectionString, ConnectionString>();
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;
}
}

View File

@ -8,4 +8,40 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql" Version="9.0.2" />
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.1-dev-02308" />
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="Country" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>ProjectTourismCompany.Entities.Country, ProjectTourismCompany, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectTourismCompany.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("ProjectTourismCompany.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 minus {
get {
object obj = ResourceManager.GetObject("minus", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap pencil {
get {
object obj = ResourceManager.GetObject("pencil", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap plus {
get {
object obj = ResourceManager.GetObject("plus", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Карта_мира {
get {
object obj = ResourceManager.GetObject("Карта мира", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

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

View File

@ -0,0 +1,16 @@
using ProjectTourismCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Repositories;
public interface ICheckRepository
{
IEnumerable<Check> ReadChecks(DateTime? dateFrom = null, DateTime? dateTo = null, int? tripId = null, int? clientId = null);
Check ReadCheckById(int id);
void CreateCheck(Check check);
void DeleteCheck(int id);
}

View File

@ -0,0 +1,17 @@
using ProjectTourismCompany.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Repositories;
public interface IClientRepository
{
IEnumerable<Client> ReadClients();
Client ReadClientById(int id);
void CreateClient(Client client);
void UpdateClient(Client client);
void DeleteClient(int id);
}

View File

@ -0,0 +1,18 @@
using ProjectTourismCompany.Entities;
using ProjectTourismCompany.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Repositories;
public interface ICompanyRepository
{
IEnumerable<Company> ReadCompanies();
Company ReadCompanyById(int id);
void CreateCompany(Company company);
void UpdateCompany(Company company);
void DeleteCompany(int id);
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Repositories;
public interface IConnectionString
{
public string ConnectionString { get;}
}

View File

@ -0,0 +1,17 @@
using ProjectTourismCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Repositories;
public interface ICountryRepository
{
IEnumerable<Country> ReadCountries();
Country ReadCountryById(int id);
void CreateCountry(Country country);
void UpdateCountry(Country country);
void DeleteCountry(int id);
}

View File

@ -0,0 +1,21 @@
using ProjectTourismCompany.Entities;
using ProjectTourismCompany.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Repositories;
public interface ITripRepository
{
IEnumerable<Trip> ReadTrips(DateTime? dateForm = null,
DateTime? dateTo = null, int? tripId = null,
int? companyId = null, int? countryId = null);
Trip ReadTripById(int id);
void CreateTrip(Trip trip);
}

View File

@ -0,0 +1,104 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic.FileIO;
using Newtonsoft.Json;
using Npgsql;
using ProjectTourismCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Repositories.Implementations;
internal class CheckRepository : ICheckRepository
{
private readonly IConnectionString _connectionString;
public ILogger<CheckRepository> _logger;
public CheckRepository(IConnectionString connectionString, ILogger<CheckRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateCheck(Check check)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(check));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Receipt (PurchaseDate, Price, TripId, ClientId)
VALUES (@PurchaseDate, @Price, @TripId, @ClientId)";
connection.Execute(queryInsert, check);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteCheck(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Receipt
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Check> ReadChecks(DateTime? dateFrom = null, DateTime? dateTo = null, int? tripId = null, int? clientId = null)
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Receipt";
var expenses = connection.Query<Check>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(expenses));
return expenses;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public Check ReadCheckById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Receipt
WHERE Id=@id";
var expense = connection.QueryFirst<Check>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(expense));
return expense;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
}

View File

@ -0,0 +1,126 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectTourismCompany.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Repositories.Implementations;
internal class ClientRepository : IClientRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<ClientRepository> _logger;
public ClientRepository(IConnectionString connectionString, ILogger<ClientRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateClient(Client client)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Client (Name, BirthDate, Status, Phone)
VALUES (@Name, @BirthDate, @Status, @Phone)";
connection.Execute(queryInsert, client);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteClient(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Client
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Client ReadClientById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Client
WHERE Id=@id";
var expense = connection.QueryFirst<Client>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(expense));
return expense;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Client> ReadClients()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Client";
var expenses = connection.Query<Client>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(expenses));
return expenses;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public void UpdateClient(Client client)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Client
SET
Name=@Name,
BirthDate=@BirthDate,
Status=@Status,
Phone=@Phone
WHERE Id=@Id";
connection.Execute(queryUpdate, client);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

View File

@ -0,0 +1,142 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectTourismCompany.Entities;
using ProjectTourismCompany.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace ProjectTourismCompany.Repositories.Implementations;
internal class CompanyRepository : ICompanyRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<CompanyRepository> _logger;
public CompanyRepository(IConnectionString connectionString, ILogger<CompanyRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateCompany(Company company)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(company));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Company (Name, CountryId)
VALUES (@Name, @CountryId)";
connection.Execute(queryInsert, company);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteCompany(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryDeleteSub = @"
DELETE FROM CompanyTrip
WHERE CompanyId = @id";
connection.Execute(queryDeleteSub, new { id }, transaction);
var queryDelete = @"
DELETE FROM Company
WHERE Id = @id";
connection.Execute(queryDelete, new { id }, transaction);
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Company> ReadCompanies()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Company";
var peopleExpenses = connection.Query<Company>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(peopleExpenses));
return peopleExpenses;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public Company ReadCompanyById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Company
WHERE Id=@id";
var expense = connection.QueryFirst<Company>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(expense));
return expense;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public void UpdateCompany(Company company)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(company));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Company
SET
Name=@Name,
CountryId=@CountryId
WHERE Id=@Id";
connection.Execute(queryUpdate, company);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Repositories.Implementations;
public class ConnectionString : IConnectionString
{
string IConnectionString.ConnectionString => "Host=localhost;Port=5432;Username=postgres;Password=postgres;Database=postgres1";
}

View File

@ -0,0 +1,124 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectTourismCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Repositories.Implementations;
public class CountryRepository : ICountryRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<CountryRepository> _logger;
public CountryRepository(IConnectionString connectionString, ILogger<CountryRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateCountry(Country country)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(country));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Country (CountryName)
VALUES (@CountryName)";
connection.Execute(queryInsert, country);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteCountry(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Country
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Country> ReadCountries()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Country";
var expenses = connection.Query<Country>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(expenses));
return expenses;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public Country ReadCountryById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Country
WHERE Id=@id";
var expense = connection.QueryFirst<Country>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(expense));
return expense;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public void UpdateCountry(Country country)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(country));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Country
SET
CountryName=@CountryName
WHERE Id=@Id";
connection.Execute(queryUpdate, country);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

View File

@ -0,0 +1,102 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectTourismCompany.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourismCompany.Repositories.Implementations;
internal class TripRepository : ITripRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<TripRepository> _logger;
public TripRepository(IConnectionString connectionString, ILogger<TripRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateTrip(Trip trip)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(trip));
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryInsert = @"
INSERT INTO Trip (Title, Price, HumanCapacity, StartDate, EndDate, StartCity, EndCity, TravelType)
VALUES (@Title, @Price, @HumanCapacity, @StartDate, @EndDate, @StartCity, @EndCity, @TravelType);
SELECT MAX(Id) FROM Trip";
var companyTripId =
connection.QueryFirst<int>(queryInsert, trip, transaction);
var querySubInsert = @"
INSERT INTO CompanyTrip (CompanyId, AdditionalPrice)
VALUES (@CompanyId, @AdditionalPrice)";
foreach (var elem in trip.CompanyTrip)
{
connection.Execute(querySubInsert, new
{
companyTripId,
elem.CompanyId,
elem.AdditionalPrice
}, transaction);
}
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public Trip ReadTripById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Trip
WHERE Id=@id";
var expense = connection.QueryFirst<Trip>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(expense));
return expense;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Trip> ReadTrips(DateTime? dateForm = null, DateTime? dateTo = null, int? tripId = null, int? companyId = null, int? countryId = null)
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Trip";
var expenses = connection.Query<Trip>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(expenses));
return expenses;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -0,0 +1,15 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "Logs/tourism_log.txt",
"rollingInterval": "Day"
}
}
]
}
}