Compare commits

..

No commits in common. "f47c1cda0bdbfb2892f2c4d49e6143be08da9142" and "083f7761aeaf4e128a2ad0044e1f5359776b2dcf" have entirely different histories.

15 changed files with 86 additions and 156 deletions

View File

@ -13,16 +13,14 @@ public class Client
public string FullName { get; private set; } = string.Empty; public string FullName { get; private set; } = string.Empty;
public DateTime BirthDate { get; private set; } public DateTime BirthDate { get; private set; }
public string PhoneNumber { get; private set; } = string.Empty; public string PhoneNumber { get; private set; } = string.Empty;
public ClientStatus ClientStatus { get; private set; }
public int Money { get; private set; } public int Money { get; private set; }
public static Client CreateEntity(int id, string fullName, public static Client CreateEntity(int id, string fullName,
DateTime birthDate, string phoneNumber, int money, ClientStatus cs) DateTime birthDate, string phoneNumber, int money)
{ {
return new Client return new Client
{ {
Id = id, Id = id,
ClientStatus = cs,
FullName = fullName, FullName = fullName,
BirthDate = birthDate, BirthDate = birthDate,
PhoneNumber = phoneNumber, PhoneNumber = phoneNumber,

View File

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectTourAgency.Enities.Enums;
[Flags]
public enum ClientStatus
{
None = 0,
RegularCustomer = 1,
AgressiveCustomer = 2,
FriendlyCustomer = 3,
VIPCustomer = 4
}

View File

@ -9,15 +9,17 @@ namespace ProjectTourAgency.Enities;
public class Route public class Route
{ {
public int Id { get; private set; } public int Id { get; private set; }
public int TourId { get; private set; }
public string Destination { get; private set; } = string.Empty; public string Destination { get; private set; } = string.Empty;
public string Departure { get; private set; } = string.Empty; public string Departure { get; private set; } = string.Empty;
public int Duration { get; private set; } public int Duration { get; private set; }
public static Route CreateEntity(int id, string destination, public static Route CreateEntity(int id, int TourId, string destination,
string departure, int duration) string departure, int duration)
{ {
return new Route return new Route
{ {
Id = id, Id = id,
TourId = TourId,
Destination = destination, Destination = destination,
Departure = departure, Departure = departure,
Duration = duration Duration = duration

View File

@ -23,7 +23,6 @@ namespace ProjectTourAgency.Forms
comboBoxClientId.DataSource = clientRepository.ReadClients(); comboBoxClientId.DataSource = clientRepository.ReadClients();
comboBoxClientId.DisplayMember = "Name"; comboBoxClientId.DisplayMember = "Name";
comboBoxClientId.ValueMember = "Id"; comboBoxClientId.ValueMember = "Id";
} }
private void buttonSave_Click(object sender, EventArgs e) private void buttonSave_Click(object sender, EventArgs e)

View File

@ -38,88 +38,77 @@
textBoxMoney = new TextBox(); textBoxMoney = new TextBox();
buttonSave = new Button(); buttonSave = new Button();
buttonCancel = new Button(); buttonCancel = new Button();
checkedListBoxClientStatus = new CheckedListBox();
labelClientStatus = new Label();
SuspendLayout(); SuspendLayout();
// //
// labelName // labelName
// //
labelName.AutoSize = true; labelName.AutoSize = true;
labelName.Location = new Point(17, 15); labelName.Location = new Point(12, 9);
labelName.Margin = new Padding(4, 0, 4, 0);
labelName.Name = "labelName"; labelName.Name = "labelName";
labelName.Size = new Size(112, 25); labelName.Size = new Size(75, 15);
labelName.TabIndex = 0; labelName.TabIndex = 0;
labelName.Text = "Полное имя"; labelName.Text = "Полное имя";
// //
// labelDate // labelDate
// //
labelDate.AutoSize = true; labelDate.AutoSize = true;
labelDate.Location = new Point(17, 75); labelDate.Location = new Point(12, 45);
labelDate.Margin = new Padding(4, 0, 4, 0);
labelDate.Name = "labelDate"; labelDate.Name = "labelDate";
labelDate.Size = new Size(137, 25); labelDate.Size = new Size(90, 15);
labelDate.TabIndex = 1; labelDate.TabIndex = 1;
labelDate.Text = "Дата рождения"; labelDate.Text = "Дата рождения";
// //
// labelNumber // labelNumber
// //
labelNumber.AutoSize = true; labelNumber.AutoSize = true;
labelNumber.Location = new Point(17, 147); labelNumber.Location = new Point(12, 88);
labelNumber.Margin = new Padding(4, 0, 4, 0);
labelNumber.Name = "labelNumber"; labelNumber.Name = "labelNumber";
labelNumber.Size = new Size(150, 25); labelNumber.Size = new Size(101, 15);
labelNumber.TabIndex = 2; labelNumber.TabIndex = 2;
labelNumber.Text = "Номер телефона"; labelNumber.Text = "Номер телефона";
// //
// labelMoney // labelMoney
// //
labelMoney.AutoSize = true; labelMoney.AutoSize = true;
labelMoney.Location = new Point(17, 213); labelMoney.Location = new Point(12, 128);
labelMoney.Margin = new Padding(4, 0, 4, 0);
labelMoney.Name = "labelMoney"; labelMoney.Name = "labelMoney";
labelMoney.Size = new Size(67, 25); labelMoney.Size = new Size(46, 15);
labelMoney.TabIndex = 3; labelMoney.TabIndex = 3;
labelMoney.Text = "Баланс"; labelMoney.Text = "Баланс";
// //
// textBoxName // textBoxName
// //
textBoxName.Location = new Point(187, 15); textBoxName.Location = new Point(131, 9);
textBoxName.Margin = new Padding(4, 5, 4, 5);
textBoxName.Name = "textBoxName"; textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(141, 31); textBoxName.Size = new Size(100, 23);
textBoxName.TabIndex = 4; textBoxName.TabIndex = 4;
// //
// dateTimePickerDate // dateTimePickerDate
// //
dateTimePickerDate.Location = new Point(187, 75); dateTimePickerDate.Location = new Point(131, 45);
dateTimePickerDate.Margin = new Padding(4, 5, 4, 5);
dateTimePickerDate.Name = "dateTimePickerDate"; dateTimePickerDate.Name = "dateTimePickerDate";
dateTimePickerDate.Size = new Size(284, 31); dateTimePickerDate.Size = new Size(200, 23);
dateTimePickerDate.TabIndex = 5; dateTimePickerDate.TabIndex = 5;
// //
// textBoxNumber // textBoxNumber
// //
textBoxNumber.Location = new Point(187, 142); textBoxNumber.Location = new Point(131, 85);
textBoxNumber.Margin = new Padding(4, 5, 4, 5);
textBoxNumber.Name = "textBoxNumber"; textBoxNumber.Name = "textBoxNumber";
textBoxNumber.Size = new Size(141, 31); textBoxNumber.Size = new Size(100, 23);
textBoxNumber.TabIndex = 6; textBoxNumber.TabIndex = 6;
// //
// textBoxMoney // textBoxMoney
// //
textBoxMoney.Location = new Point(187, 208); textBoxMoney.Location = new Point(131, 125);
textBoxMoney.Margin = new Padding(4, 5, 4, 5);
textBoxMoney.Name = "textBoxMoney"; textBoxMoney.Name = "textBoxMoney";
textBoxMoney.Size = new Size(141, 31); textBoxMoney.Size = new Size(100, 23);
textBoxMoney.TabIndex = 7; textBoxMoney.TabIndex = 7;
// //
// buttonSave // buttonSave
// //
buttonSave.Location = new Point(69, 378); buttonSave.Location = new Point(49, 198);
buttonSave.Margin = new Padding(4, 5, 4, 5);
buttonSave.Name = "buttonSave"; buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(107, 38); buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 8; buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранить"; buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true; buttonSave.UseVisualStyleBackColor = true;
@ -127,40 +116,19 @@
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Location = new Point(364, 378); buttonCancel.Location = new Point(173, 198);
buttonCancel.Margin = new Padding(4, 5, 4, 5);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(107, 38); buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 9; buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отменить"; buttonCancel.Text = "Отменить";
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click; buttonCancel.Click += buttonCancel_Click;
// //
// checkedListBoxClientStatus
//
checkedListBoxClientStatus.FormattingEnabled = true;
checkedListBoxClientStatus.Location = new Point(187, 247);
checkedListBoxClientStatus.Name = "checkedListBoxClientStatus";
checkedListBoxClientStatus.Size = new Size(284, 116);
checkedListBoxClientStatus.TabIndex = 10;
//
// labelClientStatus
//
labelClientStatus.AutoSize = true;
labelClientStatus.Location = new Point(17, 270);
labelClientStatus.Margin = new Padding(4, 0, 4, 0);
labelClientStatus.Name = "labelClientStatus";
labelClientStatus.Size = new Size(67, 25);
labelClientStatus.TabIndex = 11;
labelClientStatus.Text = "Баланс";
//
// FormClient // FormClient
// //
AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(556, 430); ClientSize = new Size(389, 251);
Controls.Add(labelClientStatus);
Controls.Add(checkedListBoxClientStatus);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonSave); Controls.Add(buttonSave);
Controls.Add(textBoxMoney); Controls.Add(textBoxMoney);
@ -171,7 +139,6 @@
Controls.Add(labelNumber); Controls.Add(labelNumber);
Controls.Add(labelDate); Controls.Add(labelDate);
Controls.Add(labelName); Controls.Add(labelName);
Margin = new Padding(4, 5, 4, 5);
Name = "FormClient"; Name = "FormClient";
Text = "FormClient"; Text = "FormClient";
ResumeLayout(false); ResumeLayout(false);
@ -190,7 +157,5 @@
private TextBox textBoxMoney; private TextBox textBoxMoney;
private Button buttonSave; private Button buttonSave;
private Button buttonCancel; private Button buttonCancel;
private CheckedListBox checkedListBoxClientStatus;
private Label labelClientStatus;
} }
} }

View File

@ -1,8 +1,6 @@
 
using Microsoft.VisualBasic.FileIO;
using ProjectRouteAgency.Repositories; using ProjectRouteAgency.Repositories;
using ProjectTourAgency.Enities; using ProjectTourAgency.Enities;
using ProjectTourAgency.Enities.Enums;
using ProjectTourAgency.Implementations; using ProjectTourAgency.Implementations;
using ProjectTourAgency.Repositories; using ProjectTourAgency.Repositories;
using System; using System;
@ -37,17 +35,7 @@ namespace ProjectTourAgency.Forms
textBoxNumber.Text = client.PhoneNumber; textBoxNumber.Text = client.PhoneNumber;
textBoxMoney.Text = client.Money.ToString(); textBoxMoney.Text = client.Money.ToString();
dateTimePickerDate.Value = client.BirthDate; dateTimePickerDate.Value = client.BirthDate;
foreach (ClientStatus elem in
Enum.GetValues(typeof(ClientStatus)))
{
if ((elem & client.ClientStatus) != 0)
{
checkedListBoxClientStatus.SetItemChecked(checkedListBoxClientStatus.Items.IndexOf(
elem), true);
}
}
_clientId = value;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -62,10 +50,6 @@ Enum.GetValues(typeof(ClientStatus)))
InitializeComponent(); InitializeComponent();
_clientRepository = clientRepository ?? _clientRepository = clientRepository ??
throw new ArgumentNullException(nameof(clientRepository)); throw new ArgumentNullException(nameof(clientRepository));
foreach (var elem in Enum.GetValues(typeof(ClientStatus)))
{
checkedListBoxClientStatus.Items.Add(elem);
}
} }
@ -75,8 +59,7 @@ Enum.GetValues(typeof(ClientStatus)))
{ {
if (string.IsNullOrWhiteSpace(textBoxName.Text) || if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
string.IsNullOrWhiteSpace(textBoxNumber.Text) string.IsNullOrWhiteSpace(textBoxNumber.Text)
|| string.IsNullOrWhiteSpace(textBoxMoney.Text) || string.IsNullOrWhiteSpace(dateTimePickerDate.Text) || string.IsNullOrWhiteSpace(textBoxMoney.Text) || string.IsNullOrWhiteSpace(dateTimePickerDate.Text))
|| checkedListBoxClientStatus.CheckedItems.Count == 0)
{ {
throw new Exception("Имеются незаполненные поля"); throw new Exception("Имеются незаполненные поля");
} }
@ -87,7 +70,7 @@ Enum.GetValues(typeof(ClientStatus)))
} }
else else
{ {
_clientRepository.CreateClient(CreateClient(0)); _clientRepository.CreateClient(CreateClient(_clientId.Value));
} }
Close(); Close();
} }
@ -100,17 +83,6 @@ Enum.GetValues(typeof(ClientStatus)))
private void buttonCancel_Click(object sender, EventArgs e) => Close(); private void buttonCancel_Click(object sender, EventArgs e) => Close();
private Client CreateClient(int id) private Client CreateClient(int id) => Client.CreateEntity(id, textBoxName.Text, dateTimePickerDate.Value,textBoxNumber.Text, Convert.ToInt32(textBoxMoney.Text));
{
ClientStatus clientStatus = ClientStatus.None;
foreach (var elem in checkedListBoxClientStatus.CheckedItems)
{
clientStatus |= (ClientStatus)elem;
}
return Client.CreateEntity(id, textBoxName.Text, dateTimePickerDate.Value, textBoxNumber.Text,
int.Parse(textBoxMoney.Text), clientStatus);
}
} }
} }

View File

@ -98,7 +98,6 @@ namespace ProjectTourAgency.Forms
private bool TryGetIdentifierFromSelectedRow(out int id) private bool TryGetIdentifierFromSelectedRow(out int id)
{ {
id = 0; id = 0;
if(dataGridViewData.SelectedRows.Count < 1) if(dataGridViewData.SelectedRows.Count < 1)
{ {
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

View File

@ -2,7 +2,6 @@
using ProjectEmployeeAgency.Repositories; using ProjectEmployeeAgency.Repositories;
using ProjectRouteAgency.Repositories; using ProjectRouteAgency.Repositories;
using ProjectTourAgency.Enities; using ProjectTourAgency.Enities;
using ProjectTourAgency.Enities.Enums;
using ProjectTourAgency.Implementations; using ProjectTourAgency.Implementations;
using ProjectTourAgency.Repositories; using ProjectTourAgency.Repositories;
using System; using System;
@ -35,7 +34,7 @@ namespace ProjectTourAgency.Forms
} }
textBoxName.Text = employee.FullName; textBoxName.Text = employee.FullName;
comboBoxJob.SelectedItem = employee.EmployeeJob; comboBoxJob.SelectedItem = employee.EmployeeJob;
_employeeId = value;
} }
catch (Exception ex) catch (Exception ex)
@ -51,7 +50,6 @@ namespace ProjectTourAgency.Forms
InitializeComponent(); InitializeComponent();
_employeeRepository = employeeRepository ?? _employeeRepository = employeeRepository ??
throw new ArgumentNullException(nameof(employeeRepository)); throw new ArgumentNullException(nameof(employeeRepository));
comboBoxJob.DataSource = Enum.GetValues(typeof(EmpoyeeJob));
} }
@ -71,7 +69,7 @@ namespace ProjectTourAgency.Forms
} }
else else
{ {
_employeeRepository.CreateEmployee(CreateEmployee(0)); _employeeRepository.CreateEmployee(CreateEmployee(_employeeId.Value));
} }
Close(); Close();
} }

View File

@ -43,7 +43,7 @@ namespace ProjectTourAgency.Forms
{ {
try try
{ {
_container.Resolve<FormEmployee>().ShowDialog(); _container.Resolve<FormClient>().ShowDialog();
LoadList(); LoadList();
} }
catch (Exception ex) catch (Exception ex)

View File

@ -32,72 +32,76 @@
labelDestination = new Label(); labelDestination = new Label();
labelDeparture = new Label(); labelDeparture = new Label();
textBoxDuration = new TextBox(); textBoxDuration = new TextBox();
labelTourId = new Label();
textBoxDeparture = new TextBox(); textBoxDeparture = new TextBox();
labelDuration = new Label(); labelDuration = new Label();
buttonSave = new Button(); buttonSave = new Button();
buttonCancel = new Button(); buttonCancel = new Button();
comboBoxTourId = new ComboBox();
SuspendLayout(); SuspendLayout();
// //
// textBoxDestination // textBoxDestination
// //
textBoxDestination.Location = new Point(206, 53); textBoxDestination.Location = new Point(144, 32);
textBoxDestination.Margin = new Padding(4, 5, 4, 5);
textBoxDestination.Name = "textBoxDestination"; textBoxDestination.Name = "textBoxDestination";
textBoxDestination.Size = new Size(321, 31); textBoxDestination.Size = new Size(226, 23);
textBoxDestination.TabIndex = 4; textBoxDestination.TabIndex = 4;
// //
// labelDestination // labelDestination
// //
labelDestination.AutoSize = true; labelDestination.AutoSize = true;
labelDestination.Location = new Point(24, 53); labelDestination.Location = new Point(38, 32);
labelDestination.Margin = new Padding(4, 0, 4, 0);
labelDestination.Name = "labelDestination"; labelDestination.Name = "labelDestination";
labelDestination.Size = new Size(148, 25); labelDestination.Size = new Size(100, 15);
labelDestination.TabIndex = 3; labelDestination.TabIndex = 3;
labelDestination.Text = "Место прибытия"; labelDestination.Text = "Место прибытия";
// //
// labelDeparture // labelDeparture
// //
labelDeparture.AutoSize = true; labelDeparture.AutoSize = true;
labelDeparture.Location = new Point(15, 128); labelDeparture.Location = new Point(38, 78);
labelDeparture.Margin = new Padding(4, 0, 4, 0);
labelDeparture.Name = "labelDeparture"; labelDeparture.Name = "labelDeparture";
labelDeparture.Size = new Size(135, 25); labelDeparture.Size = new Size(91, 15);
labelDeparture.TabIndex = 5; labelDeparture.TabIndex = 5;
labelDeparture.Text = "Место отбытия"; labelDeparture.Text = "Место отбытия";
// //
// textBoxDuration // textBoxDuration
// //
textBoxDuration.Location = new Point(206, 190); textBoxDuration.Location = new Point(144, 114);
textBoxDuration.Margin = new Padding(4, 5, 4, 5);
textBoxDuration.Name = "textBoxDuration"; textBoxDuration.Name = "textBoxDuration";
textBoxDuration.Size = new Size(321, 31); textBoxDuration.Size = new Size(226, 23);
textBoxDuration.TabIndex = 7; textBoxDuration.TabIndex = 7;
// //
// labelTourId
//
labelTourId.AutoSize = true;
labelTourId.Location = new Point(38, 163);
labelTourId.Name = "labelTourId";
labelTourId.Size = new Size(94, 15);
labelTourId.TabIndex = 6;
labelTourId.Text = "Стоимость тура";
//
// textBoxDeparture // textBoxDeparture
// //
textBoxDeparture.Location = new Point(206, 125); textBoxDeparture.Location = new Point(144, 75);
textBoxDeparture.Margin = new Padding(4, 5, 4, 5);
textBoxDeparture.Name = "textBoxDeparture"; textBoxDeparture.Name = "textBoxDeparture";
textBoxDeparture.Size = new Size(321, 31); textBoxDeparture.Size = new Size(226, 23);
textBoxDeparture.TabIndex = 8; textBoxDeparture.TabIndex = 8;
// //
// labelDuration // labelDuration
// //
labelDuration.AutoSize = true; labelDuration.AutoSize = true;
labelDuration.Location = new Point(15, 190); labelDuration.Location = new Point(45, 117);
labelDuration.Margin = new Padding(4, 0, 4, 0);
labelDuration.Name = "labelDuration"; labelDuration.Name = "labelDuration";
labelDuration.Size = new Size(179, 25); labelDuration.Size = new Size(84, 15);
labelDuration.TabIndex = 10; labelDuration.TabIndex = 10;
labelDuration.Text = "Продолжительность"; labelDuration.Text = "Дата отбытия";
// //
// buttonSave // buttonSave
// //
buttonSave.Location = new Point(98, 250); buttonSave.Location = new Point(63, 251);
buttonSave.Margin = new Padding(4, 5, 4, 5);
buttonSave.Name = "buttonSave"; buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(107, 38); buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 12; buttonSave.TabIndex = 12;
buttonSave.Text = "Сохранить"; buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true; buttonSave.UseVisualStyleBackColor = true;
@ -105,29 +109,37 @@
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Location = new Point(366, 250); buttonCancel.Location = new Point(256, 251);
buttonCancel.Margin = new Padding(4, 5, 4, 5);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(107, 38); buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 13; buttonCancel.TabIndex = 13;
buttonCancel.Text = "Отмена"; buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click; buttonCancel.Click += buttonCancel_Click;
// //
// comboBoxTourId
//
comboBoxTourId.FormattingEnabled = true;
comboBoxTourId.Location = new Point(144, 163);
comboBoxTourId.Name = "comboBoxTourId";
comboBoxTourId.Size = new Size(226, 23);
comboBoxTourId.TabIndex = 14;
//
// FormRoute // FormRoute
// //
AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(591, 310); ClientSize = new Size(414, 284);
Controls.Add(comboBoxTourId);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonSave); Controls.Add(buttonSave);
Controls.Add(labelDuration); Controls.Add(labelDuration);
Controls.Add(textBoxDeparture); Controls.Add(textBoxDeparture);
Controls.Add(textBoxDuration); Controls.Add(textBoxDuration);
Controls.Add(labelTourId);
Controls.Add(labelDeparture); Controls.Add(labelDeparture);
Controls.Add(textBoxDestination); Controls.Add(textBoxDestination);
Controls.Add(labelDestination); Controls.Add(labelDestination);
Margin = new Padding(4, 5, 4, 5);
Name = "FormRoute"; Name = "FormRoute";
StartPosition = FormStartPosition.CenterParent; StartPosition = FormStartPosition.CenterParent;
Text = "Тур"; Text = "Тур";
@ -141,11 +153,13 @@
private Label labelDestination; private Label labelDestination;
private Label labelDeparture; private Label labelDeparture;
private TextBox textBoxDuration; private TextBox textBoxDuration;
private Label labelTourId;
private TextBox textBoxDeparture; private TextBox textBoxDeparture;
private Label labelDate; private Label labelDate;
private Label labelDuration; private Label labelDuration;
private TextBox textBoxPrice; private TextBox textBoxPrice;
private Button buttonSave; private Button buttonSave;
private Button buttonCancel; private Button buttonCancel;
private ComboBox comboBoxTourId;
} }
} }

View File

@ -34,7 +34,6 @@ namespace ProjectTourAgency.Forms
textBoxDestination.Text = route.Destination; textBoxDestination.Text = route.Destination;
textBoxDeparture.Text = route.Departure; textBoxDeparture.Text = route.Departure;
textBoxDuration.Text = route.Duration.ToString(); textBoxDuration.Text = route.Duration.ToString();
_routeId = value;
} }
catch(Exception ex) catch(Exception ex)
@ -50,7 +49,9 @@ namespace ProjectTourAgency.Forms
InitializeComponent(); InitializeComponent();
_routeRepository = routeRepository ?? _routeRepository = routeRepository ??
throw new ArgumentNullException(nameof(routeRepository)); throw new ArgumentNullException(nameof(routeRepository));
comboBoxTourId.DataSource = tourRepository.ReadTours();
comboBoxTourId.DisplayMember = "FullName";
comboBoxTourId.ValueMember = "Id";
} }
@ -71,7 +72,7 @@ namespace ProjectTourAgency.Forms
} }
else else
{ {
_routeRepository.CreateRoute(CreateRoute(0)); _routeRepository.CreateRoute(CreateRoute(_routeId.Value));
} }
Close(); Close();
} }
@ -84,7 +85,7 @@ namespace ProjectTourAgency.Forms
private void buttonCancel_Click(object sender, EventArgs e) => Close(); private void buttonCancel_Click(object sender, EventArgs e) => Close();
private Route CreateRoute(int id) => Route.CreateEntity(id, textBoxDestination.Text, private Route CreateRoute(int id) => Route.CreateEntity(id, (int)comboBoxTourId.SelectedValue!, textBoxDestination.Text,
textBoxDeparture.Text, int.Parse(textBoxDuration.Text)); textBoxDeparture.Text, int.Parse(textBoxDuration.Text));
} }
} }

View File

@ -20,7 +20,7 @@ public class ClientRepository : IClientRepository
public Client ReadClientById(int id) public Client ReadClientById(int id)
{ {
return Client.CreateEntity(0, string.Empty, DateTime.Now, string.Empty, 0, Enities.Enums.ClientStatus.None); return Client.CreateEntity(0, string.Empty, DateTime.Now, string.Empty, 0);
} }
public IEnumerable<Client> ReadClients() public IEnumerable<Client> ReadClients()

View File

@ -23,7 +23,7 @@ public class RouteRepository : IRouteRepository
public Route ReadRouteById(int id) public Route ReadRouteById(int id)
{ {
return Route.CreateEntity(0, string.Empty,string.Empty, 0); return Route.CreateEntity(0,0, string.Empty,string.Empty, 0);
} }
public IEnumerable<Route> ReadRoutes() public IEnumerable<Route> ReadRoutes()