From 34a69d1793050b6168170e1eb39bf83fddd6f479 Mon Sep 17 00:00:00 2001 From: Tonb73 Date: Sun, 24 Nov 2024 17:14:45 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D1=81=D1=82=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=B1=D0=B4=20=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D0=B0=D1=82=D1=82=D1=8C=20=D1=81=20=D0=BF=D1=80=D0=B8=D0=BB?= =?UTF-8?q?=D0=BE=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC,=20=D0=B2=D1=81=D0=B5=20?= =?UTF-8?q?=D0=B5=D1=89=D0=B5...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/ProjectTourAgency/Enities/Route.cs | 4 +- project/ProjectTourAgency/Forms/FormClient.cs | 4 +- .../ProjectTourAgency/Forms/FormEmployee.cs | 5 +- .../ProjectTourAgency/Forms/FormEmployees.cs | 2 +- .../Forms/FormRoute.Designer.cs | 72 ++++++++----------- project/ProjectTourAgency/Forms/FormRoute.cs | 11 ++- .../ProjectTourAgency/Forms/FormRoute.resx | 4 +- .../Implementations/AddMoneyRepository.cs | 31 ++++++-- .../Implementations/ClientRepository.cs | 13 ++-- .../Implementations/ConnectionString.cs | 2 +- .../Implementations/EmployeeRepository.cs | 13 ++-- .../Implementations/RouteRepository.cs | 18 ++--- .../Implementations/TourRepository.cs | 14 ++-- .../ProjectTourAgency.csproj | 1 + 14 files changed, 101 insertions(+), 93 deletions(-) diff --git a/project/ProjectTourAgency/Enities/Route.cs b/project/ProjectTourAgency/Enities/Route.cs index 4d760ce..09e80b9 100644 --- a/project/ProjectTourAgency/Enities/Route.cs +++ b/project/ProjectTourAgency/Enities/Route.cs @@ -9,17 +9,15 @@ namespace ProjectTourAgency.Enities; public class Route { public int Id { get; private set; } - public int TourId { get; private set; } public string Destination { get; private set; } = string.Empty; public string Departure { get; private set; } = string.Empty; public int Duration { get; private set; } - public static Route CreateEntity(int id, int TourId, string destination, + public static Route CreateEntity(int id, string destination, string departure, int duration) { return new Route { Id = id, - TourId = TourId, Destination = destination, Departure = departure, Duration = duration diff --git a/project/ProjectTourAgency/Forms/FormClient.cs b/project/ProjectTourAgency/Forms/FormClient.cs index 9ee0970..fcafb8b 100644 --- a/project/ProjectTourAgency/Forms/FormClient.cs +++ b/project/ProjectTourAgency/Forms/FormClient.cs @@ -35,7 +35,7 @@ namespace ProjectTourAgency.Forms textBoxNumber.Text = client.PhoneNumber; textBoxMoney.Text = client.Money.ToString(); dateTimePickerDate.Value = client.BirthDate; - + _clientId = value; } catch (Exception ex) { @@ -70,7 +70,7 @@ namespace ProjectTourAgency.Forms } else { - _clientRepository.CreateClient(CreateClient(_clientId.Value)); + _clientRepository.CreateClient(CreateClient(0)); } Close(); } diff --git a/project/ProjectTourAgency/Forms/FormEmployee.cs b/project/ProjectTourAgency/Forms/FormEmployee.cs index 0026bde..94d94ac 100644 --- a/project/ProjectTourAgency/Forms/FormEmployee.cs +++ b/project/ProjectTourAgency/Forms/FormEmployee.cs @@ -2,6 +2,7 @@ using ProjectEmployeeAgency.Repositories; using ProjectRouteAgency.Repositories; using ProjectTourAgency.Enities; +using ProjectTourAgency.Enities.Enums; using ProjectTourAgency.Implementations; using ProjectTourAgency.Repositories; using System; @@ -34,6 +35,7 @@ namespace ProjectTourAgency.Forms } textBoxName.Text = employee.FullName; comboBoxJob.SelectedItem = employee.EmployeeJob; + _employeeId = value; } @@ -50,6 +52,7 @@ namespace ProjectTourAgency.Forms InitializeComponent(); _employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository)); + comboBoxJob.DataSource = Enum.GetValues(typeof(EmpoyeeJob)); } @@ -69,7 +72,7 @@ namespace ProjectTourAgency.Forms } else { - _employeeRepository.CreateEmployee(CreateEmployee(_employeeId.Value)); + _employeeRepository.CreateEmployee(CreateEmployee(0)); } Close(); } diff --git a/project/ProjectTourAgency/Forms/FormEmployees.cs b/project/ProjectTourAgency/Forms/FormEmployees.cs index 458e5e0..2e8bdae 100644 --- a/project/ProjectTourAgency/Forms/FormEmployees.cs +++ b/project/ProjectTourAgency/Forms/FormEmployees.cs @@ -43,7 +43,7 @@ namespace ProjectTourAgency.Forms { try { - _container.Resolve().ShowDialog(); + _container.Resolve().ShowDialog(); LoadList(); } catch (Exception ex) diff --git a/project/ProjectTourAgency/Forms/FormRoute.Designer.cs b/project/ProjectTourAgency/Forms/FormRoute.Designer.cs index e2d0566..3e77211 100644 --- a/project/ProjectTourAgency/Forms/FormRoute.Designer.cs +++ b/project/ProjectTourAgency/Forms/FormRoute.Designer.cs @@ -32,76 +32,72 @@ labelDestination = new Label(); labelDeparture = new Label(); textBoxDuration = new TextBox(); - labelTourId = new Label(); textBoxDeparture = new TextBox(); labelDuration = new Label(); buttonSave = new Button(); buttonCancel = new Button(); - comboBoxTourId = new ComboBox(); SuspendLayout(); // // textBoxDestination // - textBoxDestination.Location = new Point(144, 32); + textBoxDestination.Location = new Point(206, 53); + textBoxDestination.Margin = new Padding(4, 5, 4, 5); textBoxDestination.Name = "textBoxDestination"; - textBoxDestination.Size = new Size(226, 23); + textBoxDestination.Size = new Size(321, 31); textBoxDestination.TabIndex = 4; // // labelDestination // labelDestination.AutoSize = true; - labelDestination.Location = new Point(38, 32); + labelDestination.Location = new Point(15, 53); + labelDestination.Margin = new Padding(4, 0, 4, 0); labelDestination.Name = "labelDestination"; - labelDestination.Size = new Size(100, 15); + labelDestination.Size = new Size(148, 25); labelDestination.TabIndex = 3; labelDestination.Text = "Место прибытия"; // // labelDeparture // labelDeparture.AutoSize = true; - labelDeparture.Location = new Point(38, 78); + labelDeparture.Location = new Point(15, 131); + labelDeparture.Margin = new Padding(4, 0, 4, 0); labelDeparture.Name = "labelDeparture"; - labelDeparture.Size = new Size(91, 15); + labelDeparture.Size = new Size(135, 25); labelDeparture.TabIndex = 5; labelDeparture.Text = "Место отбытия"; // // textBoxDuration // - textBoxDuration.Location = new Point(144, 114); + textBoxDuration.Location = new Point(206, 190); + textBoxDuration.Margin = new Padding(4, 5, 4, 5); textBoxDuration.Name = "textBoxDuration"; - textBoxDuration.Size = new Size(226, 23); + textBoxDuration.Size = new Size(321, 31); 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.Location = new Point(144, 75); + textBoxDeparture.Location = new Point(206, 125); + textBoxDeparture.Margin = new Padding(4, 5, 4, 5); textBoxDeparture.Name = "textBoxDeparture"; - textBoxDeparture.Size = new Size(226, 23); + textBoxDeparture.Size = new Size(321, 31); textBoxDeparture.TabIndex = 8; // // labelDuration // labelDuration.AutoSize = true; - labelDuration.Location = new Point(45, 117); + labelDuration.Location = new Point(15, 193); + labelDuration.Margin = new Padding(4, 0, 4, 0); labelDuration.Name = "labelDuration"; - labelDuration.Size = new Size(84, 15); + labelDuration.Size = new Size(179, 25); labelDuration.TabIndex = 10; - labelDuration.Text = "Дата отбытия"; + labelDuration.Text = "Продолжительность"; // // buttonSave // - buttonSave.Location = new Point(63, 251); + buttonSave.Location = new Point(87, 285); + buttonSave.Margin = new Padding(4, 5, 4, 5); buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(75, 23); + buttonSave.Size = new Size(107, 38); buttonSave.TabIndex = 12; buttonSave.Text = "Сохранить"; buttonSave.UseVisualStyleBackColor = true; @@ -109,40 +105,32 @@ // // buttonCancel // - buttonCancel.Location = new Point(256, 251); + buttonCancel.Location = new Point(363, 285); + buttonCancel.Margin = new Padding(4, 5, 4, 5); buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(75, 23); + buttonCancel.Size = new Size(107, 38); buttonCancel.TabIndex = 13; buttonCancel.Text = "Отмена"; buttonCancel.UseVisualStyleBackColor = true; 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 // - AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(414, 284); - Controls.Add(comboBoxTourId); + ClientSize = new Size(591, 337); Controls.Add(buttonCancel); Controls.Add(buttonSave); Controls.Add(labelDuration); Controls.Add(textBoxDeparture); Controls.Add(textBoxDuration); - Controls.Add(labelTourId); Controls.Add(labelDeparture); Controls.Add(textBoxDestination); Controls.Add(labelDestination); + Margin = new Padding(4, 5, 4, 5); Name = "FormRoute"; StartPosition = FormStartPosition.CenterParent; - Text = "Тур"; + Text = "Маршрут"; ResumeLayout(false); PerformLayout(); } @@ -153,13 +141,11 @@ private Label labelDestination; private Label labelDeparture; private TextBox textBoxDuration; - private Label labelTourId; private TextBox textBoxDeparture; private Label labelDate; private Label labelDuration; private TextBox textBoxPrice; private Button buttonSave; private Button buttonCancel; - private ComboBox comboBoxTourId; } } \ No newline at end of file diff --git a/project/ProjectTourAgency/Forms/FormRoute.cs b/project/ProjectTourAgency/Forms/FormRoute.cs index 4603fb4..5d12658 100644 --- a/project/ProjectTourAgency/Forms/FormRoute.cs +++ b/project/ProjectTourAgency/Forms/FormRoute.cs @@ -34,7 +34,7 @@ namespace ProjectTourAgency.Forms textBoxDestination.Text = route.Destination; textBoxDeparture.Text = route.Departure; textBoxDuration.Text = route.Duration.ToString(); - + _routeId = value; } catch(Exception ex) { @@ -49,9 +49,6 @@ namespace ProjectTourAgency.Forms InitializeComponent(); _routeRepository = routeRepository ?? throw new ArgumentNullException(nameof(routeRepository)); - comboBoxTourId.DataSource = tourRepository.ReadTours(); - comboBoxTourId.DisplayMember = "FullName"; - comboBoxTourId.ValueMember = "Id"; } @@ -61,7 +58,7 @@ namespace ProjectTourAgency.Forms { if (string.IsNullOrWhiteSpace(textBoxDestination.Text) || string.IsNullOrWhiteSpace(textBoxDeparture.Text) || string.IsNullOrWhiteSpace(textBoxDuration.Text) - || string.IsNullOrWhiteSpace(textBoxPrice.Text) || string.IsNullOrWhiteSpace(dateTimePickerDepartureDate.Text)) + ) { throw new Exception("Имеются незаполненные поля"); } @@ -72,7 +69,7 @@ namespace ProjectTourAgency.Forms } else { - _routeRepository.CreateRoute(CreateRoute(_routeId.Value)); + _routeRepository.CreateRoute(CreateRoute(0)); } Close(); } @@ -85,7 +82,7 @@ namespace ProjectTourAgency.Forms private void buttonCancel_Click(object sender, EventArgs e) => Close(); - private Route CreateRoute(int id) => Route.CreateEntity(id, (int)comboBoxTourId.SelectedValue!, textBoxDestination.Text, + private Route CreateRoute(int id) => Route.CreateEntity(id, textBoxDestination.Text, textBoxDeparture.Text, int.Parse(textBoxDuration.Text)); } } diff --git a/project/ProjectTourAgency/Forms/FormRoute.resx b/project/ProjectTourAgency/Forms/FormRoute.resx index af32865..8b2ff64 100644 --- a/project/ProjectTourAgency/Forms/FormRoute.resx +++ b/project/ProjectTourAgency/Forms/FormRoute.resx @@ -1,7 +1,7 @@