replace ServiceProvider with DependencyManager in Forms
This commit is contained in:
parent
20cf8869fa
commit
662f9f18d3
@ -9,7 +9,7 @@ namespace AutoWorkshopDatabaseImplement
|
||||
{
|
||||
if (OptionsBuilder.IsConfigured == false)
|
||||
{
|
||||
OptionsBuilder.UseNpgsql(@"Host=localhost;Database=AutoWorkshop;Username=postgres;Password=admin");
|
||||
OptionsBuilder.UseNpgsql(@"Host=localhost;Database=AutoWorkshop;Port=5000;Username=postgres;Password=admin");
|
||||
}
|
||||
|
||||
base.OnConfiguring(OptionsBuilder);
|
||||
|
@ -1,5 +1,6 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using AutoWorkshopContracts.DI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView.Forms
|
||||
@ -37,9 +38,9 @@ namespace AutoWorkshopView.Forms
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||
|
||||
if (Service is FormComponent Form)
|
||||
var Service = DependencyManager.Instance.Resolve<FormComponent>();
|
||||
|
||||
if (Service is FormComponent Form)
|
||||
{
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
@ -52,8 +53,8 @@ namespace AutoWorkshopView.Forms
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormComponent));
|
||||
if (Service is FormComponent Form)
|
||||
var Service = DependencyManager.Instance.Resolve<FormComponent>();
|
||||
if (Service is FormComponent Form)
|
||||
{
|
||||
Form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
|
@ -1,5 +1,6 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using AutoWorkshopContracts.DI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView.Forms
|
||||
@ -38,9 +39,9 @@ namespace AutoWorkshopView.Forms
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
|
||||
if (Service is FormImplementer Form)
|
||||
var Service = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||
|
||||
if (Service is FormImplementer Form)
|
||||
{
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
@ -53,7 +54,7 @@ namespace AutoWorkshopView.Forms
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||
var service = DependencyManager.Instance.Resolve<FormImplementer>();
|
||||
if (service is FormImplementer Form)
|
||||
{
|
||||
Form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
@ -1,5 +1,6 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using AutoWorkshopContracts.DI;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -82,7 +83,7 @@ namespace AutoWorkshopView.Forms
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormRepairComponent));
|
||||
var Service = DependencyManager.Instance.Resolve<FormRepairComponent>();
|
||||
|
||||
if (Service is FormRepairComponent Form)
|
||||
{
|
||||
@ -113,8 +114,8 @@ namespace AutoWorkshopView.Forms
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormRepairComponent));
|
||||
if (service is FormRepairComponent Form)
|
||||
var service = DependencyManager.Instance.Resolve<FormRepairComponent>();
|
||||
if (service is FormRepairComponent Form)
|
||||
{
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value);
|
||||
Form.Id = id;
|
||||
|
@ -1,5 +1,6 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using AutoWorkshopContracts.DI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView.Forms
|
||||
@ -38,7 +39,7 @@ namespace AutoWorkshopView.Forms
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormRepair));
|
||||
var Service = DependencyManager.Instance.Resolve<FormRepair>();
|
||||
|
||||
if (Service is FormRepair Form)
|
||||
{
|
||||
@ -53,7 +54,7 @@ namespace AutoWorkshopView.Forms
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormRepair));
|
||||
var Service = DependencyManager.Instance.Resolve<FormRepair>();
|
||||
|
||||
if (Service is FormRepair Form)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using AutoWorkshopContracts.DI;
|
||||
using AutoWorkshopView.Forms;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@ -49,7 +50,7 @@ namespace AutoWorkshopView
|
||||
|
||||
private void ComponentsStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
var Service = DependencyManager.Instance.Resolve<FormComponents>();
|
||||
|
||||
if (Service is FormComponents Form)
|
||||
{
|
||||
@ -59,7 +60,7 @@ namespace AutoWorkshopView
|
||||
|
||||
private void RepairsStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormRepairs));
|
||||
var Service = DependencyManager.Instance.Resolve<FormRepairs>();
|
||||
|
||||
if (Service is FormRepairs Form)
|
||||
{
|
||||
@ -69,7 +70,7 @@ namespace AutoWorkshopView
|
||||
|
||||
private void CreateOrderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
var Service = DependencyManager.Instance.Resolve<FormCreateOrder>();
|
||||
|
||||
if (Service is FormCreateOrder Form)
|
||||
{
|
||||
@ -179,7 +180,7 @@ namespace AutoWorkshopView
|
||||
|
||||
private void ComponentRepairToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormReportRepairComponents));
|
||||
var Service = DependencyManager.Instance.Resolve<FormReportRepairComponents>();
|
||||
|
||||
if (Service is FormReportRepairComponents Form)
|
||||
{
|
||||
@ -189,7 +190,7 @@ namespace AutoWorkshopView
|
||||
|
||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
var Service = DependencyManager.Instance.Resolve<FormReportOrders>();
|
||||
|
||||
if (Service is FormReportOrders Form)
|
||||
{
|
||||
@ -199,7 +200,7 @@ namespace AutoWorkshopView
|
||||
|
||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
var Service = DependencyManager.Instance.Resolve<FormClients>();
|
||||
|
||||
if (Service is FormClients Form)
|
||||
{
|
||||
@ -209,7 +210,7 @@ namespace AutoWorkshopView
|
||||
|
||||
private void EmployersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
||||
var Service = DependencyManager.Instance.Resolve<FormImplementers>();
|
||||
|
||||
if (Service is FormImplementers Form)
|
||||
{
|
||||
@ -219,15 +220,15 @@ namespace AutoWorkshopView
|
||||
|
||||
private void StartWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var ImplementerLogic = Program.ServiceProvider?.GetService(typeof(IImplementerLogic));
|
||||
_workProcess.DoWork((ImplementerLogic as IImplementerLogic)!, _orderLogic);
|
||||
var ImplementerLogic = DependencyManager.Instance.Resolve<IImplementerLogic>();
|
||||
_workProcess.DoWork(ImplementerLogic, _orderLogic);
|
||||
|
||||
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
private void MailToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormMail));
|
||||
var Service = DependencyManager.Instance.Resolve<FormMail>();
|
||||
|
||||
if (Service is FormMail Form)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user