From 3cb983b7dc836c61cf29e5ac27809fb8e7ffb8d5 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Wed, 10 May 2023 21:55:18 +0400 Subject: [PATCH] Another fixation. --- .../Implements/TruckingStorage.cs | 3 ++- .../TransportCompany/FormCreateTransport.cs | 1 + .../TransportCompany/FormTrucking.cs | 26 +++++++++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/TransportCompany/TransportCompamyMongoDBImplementer/Implements/TruckingStorage.cs b/TransportCompany/TransportCompamyMongoDBImplementer/Implements/TruckingStorage.cs index 7d384f8..5eaed82 100644 --- a/TransportCompany/TransportCompamyMongoDBImplementer/Implements/TruckingStorage.cs +++ b/TransportCompany/TransportCompamyMongoDBImplementer/Implements/TruckingStorage.cs @@ -62,7 +62,8 @@ namespace TransportCompamyMongoDBImplementer.Implements var truckingCollection = context.ConnectToMongo("trucking"); - return truckingCollection.Find(x => !string.IsNullOrEmpty(model.MongoId) && x.Id == model.MongoId) + //не забудь, что тут сделал исправление для поиска по id клиента в MongoDB + return truckingCollection.Find(x => x.Client.Id == model.MongoId) .ToList() .Select(x => x.GetViewModel) .ToList(); diff --git a/TransportCompany/TransportCompany/FormCreateTransport.cs b/TransportCompany/TransportCompany/FormCreateTransport.cs index 02b9e88..147acf6 100644 --- a/TransportCompany/TransportCompany/FormCreateTransport.cs +++ b/TransportCompany/TransportCompany/FormCreateTransport.cs @@ -50,6 +50,7 @@ namespace TransportCompany if (view != null) { textBoxTransport.Text = view.Tranport; + textBoxTypeTransportation.Text = view.TransportationType; } } catch (Exception ex) diff --git a/TransportCompany/TransportCompany/FormTrucking.cs b/TransportCompany/TransportCompany/FormTrucking.cs index 22db6a2..90591c7 100644 --- a/TransportCompany/TransportCompany/FormTrucking.cs +++ b/TransportCompany/TransportCompany/FormTrucking.cs @@ -29,6 +29,7 @@ namespace TransportCompany _logger = logger; _truckingLogic = truckingLogic; _clientLogic = clientLogic; + _mongo = false; } private void FormMain_Load(object sender, EventArgs e) @@ -70,7 +71,16 @@ namespace TransportCompany if (listClients != null) { comboBoxEmails.DisplayMember = "Email"; - comboBoxEmails.ValueMember = "Id"; + + if (_mongo) + { + comboBoxEmails.ValueMember = "MongoId"; + } + else + { + comboBoxEmails.ValueMember = "Id"; + } + comboBoxEmails.DataSource = listClients; comboBoxEmails.SelectedItem = null; } @@ -103,6 +113,8 @@ namespace TransportCompany if (service is FormTransport form) { + form.SetMongo = _mongo; + form.ShowDialog(); LoadData(); } @@ -180,7 +192,14 @@ namespace TransportCompany } else { - dataGridView.DataSource = _truckingLogic.ReadList(null).Where(x => x.ClientId == comboBoxEmails.SelectedIndex).ToList(); + if (_mongo) + { + dataGridView.DataSource = _truckingLogic.ReadList(new TruckingSearchModel { MongoId = comboBoxEmails.SelectedValue.ToString() }); + } + else + { + dataGridView.DataSource = _truckingLogic.ReadList(null).Where(x => x.ClientId == comboBoxEmails.SelectedIndex).ToList(); + } } } @@ -239,6 +258,7 @@ namespace TransportCompany } }*/ + // Postgresql MongoDB private void TransferDataToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormTransferData)); @@ -249,6 +269,7 @@ namespace TransportCompany } } + // Postgresql private void StartPostgresqlToolStripMenuItem_Click(object sender, EventArgs e) { _mongo = false; @@ -261,6 +282,7 @@ namespace TransportCompany LoadData(); } + // MongoBD private void StartMongoDBToolStripMenuItem_Click(object sender, EventArgs e) { _mongo = true;