diff --git a/TransportCompany/TransportCompany/FormTransferData.Designer.cs b/TransportCompany/TransportCompany/FormTransferData.Designer.cs index 151ef0c..64e4928 100644 --- a/TransportCompany/TransportCompany/FormTransferData.Designer.cs +++ b/TransportCompany/TransportCompany/FormTransferData.Designer.cs @@ -28,12 +28,35 @@ /// 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 = "FormTransferData"; + buttonStartTransfer = new Button(); + SuspendLayout(); + // + // buttonStartTransfer + // + buttonStartTransfer.BackColor = Color.Red; + buttonStartTransfer.BackgroundImageLayout = ImageLayout.Zoom; + buttonStartTransfer.Font = new Font("Snap ITC", 9F, FontStyle.Bold, GraphicsUnit.Point); + buttonStartTransfer.Location = new Point(102, 12); + buttonStartTransfer.Name = "buttonStartTransfer"; + buttonStartTransfer.Size = new Size(213, 36); + buttonStartTransfer.TabIndex = 0; + buttonStartTransfer.Text = "НУ ЧЁ, ПОГНАЛИ"; + buttonStartTransfer.UseVisualStyleBackColor = false; + buttonStartTransfer.Click += ButtonStartTransfer_Click; + // + // FormTransferData + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(415, 60); + Controls.Add(buttonStartTransfer); + Name = "FormTransferData"; + Text = "Передача данных"; + ResumeLayout(false); } #endregion + + private Button buttonStartTransfer; } } \ No newline at end of file diff --git a/TransportCompany/TransportCompany/FormTransferData.cs b/TransportCompany/TransportCompany/FormTransferData.cs index c6348d5..ee62224 100644 --- a/TransportCompany/TransportCompany/FormTransferData.cs +++ b/TransportCompany/TransportCompany/FormTransferData.cs @@ -4,17 +4,67 @@ using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; +using System.Media; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using TransportCompanyBusinessLogic.BusinessLogic; +using TransportCompanyContracts.BusinessLogicsContracts; namespace TransportCompany { + //форма для перегона данных в MongoDB public partial class FormTransferData : Form { - public FormTransferData() + private ICargoLogic _cargoLogic; + + private ITruckingLogic _truckingLogic; + + private ITransportLogic _transportLogic; + + private IClientLogic _clientLogic; + + public FormTransferData(ICargoLogic cargoLogic, ITruckingLogic truckingLogic, IClientLogic clientLogic, ITransportLogic transportLogic) { InitializeComponent(); + + _cargoLogic = cargoLogic; + _truckingLogic = truckingLogic; + _clientLogic = clientLogic; + _transportLogic = transportLogic; + } + + private void ButtonStartTransfer_Click(object sender, EventArgs e) + { + /*using (var soundPlayer = new SoundPlayer(@"c:\Windows\Media\chimes.wav")) + { + soundPlayer.Play(); // can also use soundPlayer.PlaySync() + }*/ + + Program.ConnectPostgres(); + + _cargoLogic = Program.ServiceProvider.GetService(typeof(ICargoLogic)) as CargoLogic; + _clientLogic = Program.ServiceProvider.GetService(typeof(IClientLogic)) as ClientLogic; + _truckingLogic = Program.ServiceProvider.GetService(typeof(ITruckingLogic)) as TruckingLogic; + _transportLogic = Program.ServiceProvider.GetService(typeof(ITransportLogic)) as TransportLogic; + + var cargolist = _cargoLogic.ReadList(null); + var clientlist = _clientLogic.ReadList(null); + var truckinglist = _truckingLogic.ReadList(null); + var transportlist = _transportLogic.ReadList(null); + + Program.ConnectMongo(); + + _cargoLogic = Program.ServiceProvider.GetService(typeof(ICargoLogic)) as CargoLogic; + _clientLogic = Program.ServiceProvider.GetService(typeof(IClientLogic)) as ClientLogic; + _truckingLogic = Program.ServiceProvider.GetService(typeof(ITruckingLogic)) as TruckingLogic; + _transportLogic = Program.ServiceProvider.GetService(typeof(ITransportLogic)) as TransportLogic; + + + + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + + Program.ConnectPostgres(); } } } diff --git a/TransportCompany/TransportCompany/FormTransferData.resx b/TransportCompany/TransportCompany/FormTransferData.resx index 1af7de1..f298a7b 100644 --- a/TransportCompany/TransportCompany/FormTransferData.resx +++ b/TransportCompany/TransportCompany/FormTransferData.resx @@ -1,64 +1,4 @@ - - - + diff --git a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/CargoLogic.cs b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/CargoLogic.cs index 7b166e1..73dd298 100644 --- a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/CargoLogic.cs +++ b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/CargoLogic.cs @@ -145,5 +145,10 @@ namespace TransportCompanyBusinessLogic.BusinessLogic throw new InvalidOperationException("Такой тип груза уже есть"); } } + + public bool TransferData(List model) + { + return _cargoStorage.InsertFromPostgres(model); + } } } diff --git a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/ClientLogic.cs b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/ClientLogic.cs index a1a4da4..caa1a08 100644 --- a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/ClientLogic.cs +++ b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/ClientLogic.cs @@ -182,5 +182,10 @@ namespace TransportCompanyBusinessLogic.BusinessLogic throw new InvalidOperationException("Клиент с такой почтой уже есть"); } } - } + + public bool TransferData(List model) + { + return _clientStorage.InsertFromPostgres(model); + } + } } diff --git a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TransportLogic.cs b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TransportLogic.cs index 8102dab..f588c34 100644 --- a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TransportLogic.cs +++ b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TransportLogic.cs @@ -144,5 +144,10 @@ namespace TransportCompanyBusinessLogic.BusinessLogic throw new InvalidOperationException("Такое транспортное средство уже есть"); } } + + public bool TransferData(List model) + { + return _transportStorage.InsertFromPostgres(model); + } } } diff --git a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TruckingLogic.cs b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TruckingLogic.cs index de7b905..260a4cf 100644 --- a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TruckingLogic.cs +++ b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TruckingLogic.cs @@ -175,5 +175,10 @@ namespace TransportCompanyBusinessLogic.BusinessLogic "TransportationId:{TransportationId}. DateStart:{DateStart}. DateEnd:{DateEnd}. Id:{Id}", model.ClientId, model.CargoId, model.TransportId, model.TransportationId, model.DateStart, model.DateEnd, model.Id); } - } + + public bool TransferData(List model) + { + return _truckingStorage.InsertFromPostgres(model); + } + } } diff --git a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ICargoLogic.cs b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ICargoLogic.cs index 1328559..36fbfd6 100644 --- a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ICargoLogic.cs +++ b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ICargoLogic.cs @@ -20,5 +20,7 @@ namespace TransportCompanyContracts.BusinessLogicsContracts bool Update(CargoBindingModel model); bool Delete(CargoBindingModel model); + + bool TransferData(List model); } } diff --git a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/IClientLogic.cs b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/IClientLogic.cs index 8f318c6..4ddf549 100644 --- a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/IClientLogic.cs +++ b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/IClientLogic.cs @@ -24,5 +24,7 @@ namespace TransportCompanyContracts.BusinessLogicsContracts bool Update(ClientBindingModel model); bool Delete(ClientBindingModel model); + + bool TransferData(List model); } } diff --git a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITransportLogic.cs b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITransportLogic.cs index ba6f076..3ef1bdd 100644 --- a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITransportLogic.cs +++ b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITransportLogic.cs @@ -20,5 +20,7 @@ namespace TransportCompanyContracts.BusinessLogicsContracts bool Update(TransportBindingModel model); bool Delete(TransportBindingModel model); + + bool TransferData(List model); } } diff --git a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITruckingLogic.cs b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITruckingLogic.cs index 5fd7d83..178f0cc 100644 --- a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITruckingLogic.cs +++ b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITruckingLogic.cs @@ -26,5 +26,7 @@ namespace TransportCompanyContracts.BusinessLogicsContracts bool Update(TruckingBindingModel model); bool Delete(TruckingBindingModel model); + + bool TransferData(List model); } }