Compare commits

..

No commits in common. "2f61afb63460843d05580947146d5c672dbcdc30" and "78d1fd1d8c077b8455239a3bafeed1b25313c56b" have entirely different histories.

6 changed files with 143 additions and 96 deletions

View File

@ -1,5 +1,4 @@
using ConfectioneryContracts.StoragesContracts; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -7,7 +6,7 @@ using System.Threading.Tasks;
namespace ConfectioneryListImplement.Implements namespace ConfectioneryListImplement.Implements
{ {
public class BackUpInfo : IBackUpInfo public class BackUpInfo
{ {
public List<T>? GetList<T>() where T : class, new() public List<T>? GetList<T>() where T : class, new()
{ {

View File

@ -1,6 +1,5 @@
using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts; using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.DI;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -27,12 +26,15 @@ namespace ConfectioneryView
private void buttonAdd_Click(object sender, EventArgs e) private void buttonAdd_Click(object sender, EventArgs e)
{ {
var form = DependencyManager.Instance.Resolve<FormComponent>(); var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
if (form.ShowDialog() == DialogResult.OK) if (service is FormComponent form)
{ {
LoadData(); if (form.ShowDialog() == DialogResult.OK)
} {
} LoadData();
}
}
}
private void FormComponents_Load(object sender, EventArgs e) private void FormComponents_Load(object sender, EventArgs e)
{ {
@ -56,14 +58,17 @@ namespace ConfectioneryView
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var form = DependencyManager.Instance.Resolve<FormComponent>(); var service =
Program.ServiceProvider?.GetService(typeof(FormComponent));
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (service is FormComponent form)
if (form.ShowDialog() == DialogResult.OK) {
{ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
LoadData(); if (form.ShowDialog() == DialogResult.OK)
} {
} LoadData();
}
}
}
} }
private void buttonDel_Click(object sender, EventArgs e) private void buttonDel_Click(object sender, EventArgs e)

View File

@ -1,6 +1,5 @@
using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts; using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.DI;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -48,10 +47,13 @@ namespace ConfectioneryView
private void buttonAdd_Click(object sender, EventArgs e) private void buttonAdd_Click(object sender, EventArgs e)
{ {
var form = DependencyManager.Instance.Resolve<FormImplementer>(); var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (form.ShowDialog() == DialogResult.OK) if (service is FormImplementer form)
{ {
LoadData(); if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
} }
} }
@ -59,11 +61,14 @@ namespace ConfectioneryView
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var form = DependencyManager.Instance.Resolve<FormImplementer>(); var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (service is FormImplementer form)
if (form.ShowDialog() == DialogResult.OK)
{ {
LoadData(); form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
} }
} }
} }

View File

@ -2,7 +2,6 @@
using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts; using ConfectioneryContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using ConfectioneryContracts.DI;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -52,20 +51,29 @@ namespace ConfectioneryView
} }
private void componentsToolStripMenuItem_Click(object sender, EventArgs e) private void componentsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var form = DependencyManager.Instance.Resolve<FormComponents>(); var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
form.ShowDialog(); if (service is FormComponents form)
{
form.ShowDialog();
}
} }
private void pastryToolStripMenuItem_Click(object sender, EventArgs e) private void pastryToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var form = DependencyManager.Instance.Resolve<FormPastrys>(); var service = Program.ServiceProvider?.GetService(typeof(FormPastrys));
form.ShowDialog(); if (service is FormPastrys form)
{
form.ShowDialog();
}
} }
private void buttonCreateOrder_Click(object sender, EventArgs e) private void buttonCreateOrder_Click(object sender, EventArgs e)
{ {
var form = DependencyManager.Instance.Resolve<FormCreateOrder>(); var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
form.ShowDialog(); if (service is FormCreateOrder form)
LoadData(); {
form.ShowDialog();
LoadData();
}
} }
private void buttonTakeOrderInWork_Click(object sender, EventArgs e) private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
@ -153,14 +161,21 @@ namespace ConfectioneryView
private void componentPastryToolStripMenuItem_Click(object sender, EventArgs e) private void componentPastryToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var form = DependencyManager.Instance.Resolve<FormReportPastryComponents>(); var service = Program.ServiceProvider?.GetService(typeof(FormReportPastryComponents));
form.ShowDialog(); if (service is FormReportPastryComponents form)
{
form.ShowDialog();
}
} }
private void ordersListToolStripMenuItem_Click(object sender, EventArgs e) private void ordersListToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var form = DependencyManager.Instance.Resolve<FormReportOrders>(); var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
form.ShowDialog(); if (service is FormReportOrders form)
{
form.ShowDialog();
}
} }
private void pastrysListToolStripMenuItem_Click(object sender, EventArgs e) private void pastrysListToolStripMenuItem_Click(object sender, EventArgs e)
@ -179,26 +194,35 @@ namespace ConfectioneryView
private void clientsToolStripMenuItem_Click(object sender, EventArgs e) private void clientsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var form = DependencyManager.Instance.Resolve<FormClients>(); var service = Program.ServiceProvider?.GetService(typeof(FormClients));
form.ShowDialog(); if (service is FormClients form)
{
form.ShowDialog();
}
} }
private void implementersToolStripMenuItem_Click(object sender, EventArgs e) private void implementersToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var form = DependencyManager.Instance.Resolve<FormImplementers>(); var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
form.ShowDialog(); if (service is FormImplementers form)
{
form.ShowDialog();
}
} }
private void startWorkToolStripMenuItem_Click(object sender, EventArgs e) private void startWorkToolStripMenuItem_Click(object sender, EventArgs e)
{ {
_workProcess.DoWork(DependencyManager.Instance.Resolve<IImplementerLogic>(), _orderLogic); _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
private void mailToolStripMenuItem_Click(object sender, EventArgs e) private void mailToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var form = DependencyManager.Instance.Resolve<FormMail>(); var service = Program.ServiceProvider?.GetService(typeof(FormMail));
form.ShowDialog(); if (service is FormMail form)
{
form.ShowDialog();
}
} }
private void createBackupToolStripMenuItem_Click(object sender, EventArgs e) private void createBackupToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -1,6 +1,5 @@
using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts; using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.DI;
using ConfectioneryContracts.SearchModels; using ConfectioneryContracts.SearchModels;
using ConfectioneryDataModels.Models; using ConfectioneryDataModels.Models;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -149,45 +148,55 @@ namespace ConfectioneryView
private void buttonAdd_Click(object sender, EventArgs e) private void buttonAdd_Click(object sender, EventArgs e)
{ {
var form = DependencyManager.Instance.Resolve<FormPastryComponent>(); var service = Program.ServiceProvider?.GetService(typeof(FormPastryComponent));
if (form.ShowDialog() == DialogResult.OK) if (service is FormPastryComponent form)
{ {
return; if (form.ShowDialog() == DialogResult.OK)
} {
_logger.LogInformation("Добавление нового ингридиента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); if (form.ComponentModel == null)
if (_pastryComponents.ContainsKey(form.Id)) {
{ return;
_pastryComponents[form.Id] = (form.ComponentModel, }
form.Count); _logger.LogInformation("Добавление нового компонента:{ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
} if (_pastryComponents.ContainsKey(form.Id))
else {
{ _pastryComponents[form.Id] = (form.ComponentModel,
_pastryComponents.Add(form.Id, (form.ComponentModel, form.Count);
form.Count)); }
} else
LoadData(); {
} _pastryComponents.Add(form.Id, (form.ComponentModel,
form.Count));
}
LoadData();
}
}
}
private void buttonUpd_Click(object sender, EventArgs e) private void buttonUpd_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var form = DependencyManager.Instance.Resolve<FormPastryComponent>(); var service =
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); Program.ServiceProvider?.GetService(typeof(FormPastryComponent));
form.Id = id; if (service is FormPastryComponent form)
form.Count = _pastryComponents[id].Item2; {
if (form.ShowDialog() == DialogResult.OK) int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
{ form.Id = id;
if (form.ComponentModel == null) form.Count = _pastryComponents[id].Item2;
{ if (form.ShowDialog() == DialogResult.OK)
return; {
} if (form.ComponentModel == null)
_logger.LogInformation("Изменение ингридиента:{ ComponentName}-{ Count}", form.ComponentModel.ComponentName, form.Count); {
_pastryComponents[form.Id] = (form.ComponentModel, form.Count); return;
LoadData(); }
} _logger.LogInformation("Изменение компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
} _pastryComponents[form.Id] = (form.ComponentModel, form.Count);
} LoadData();
}
}
}
}
private void buttonDel_Click(object sender, EventArgs e) private void buttonDel_Click(object sender, EventArgs e)
{ {

View File

@ -10,7 +10,6 @@ using System.Windows.Forms;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.BusinessLogicsContracts; using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.DI;
namespace ConfectioneryView namespace ConfectioneryView
{ {
@ -45,24 +44,30 @@ namespace ConfectioneryView
private void buttonAdd_Click(object sender, EventArgs e) private void buttonAdd_Click(object sender, EventArgs e)
{ {
var form = DependencyManager.Instance.Resolve<FormPastry>(); var service = Program.ServiceProvider?.GetService(typeof(FormPastry));
if (form.ShowDialog() == DialogResult.OK) if (service is FormPastry form)
{ {
LoadData(); if (form.ShowDialog() == DialogResult.OK)
} {
} LoadData();
}
}
}
private void buttonUpd_Click(object sender, EventArgs e) private void buttonUpd_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var form = DependencyManager.Instance.Resolve<FormPastry>(); var service = Program.ServiceProvider?.GetService(typeof(FormPastry));
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); if (service is FormPastry form)
if (form.ShowDialog() == DialogResult.OK) {
{ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
LoadData(); if (form.ShowDialog() == DialogResult.OK)
} {
} LoadData();
}
}
}
} }
private void buttonDel_Click(object sender, EventArgs e) private void buttonDel_Click(object sender, EventArgs e)