Report + additional timing fixes
This commit is contained in:
parent
b3ae7e1f76
commit
4fbeb3c6e6
@ -106,5 +106,17 @@ namespace ConstructionCompanyBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
_logger.LogInformation("Material. IngredietnName:{MaterialName}. Cost:{Quantity}. Id:{Id}", model.MaterialName, model.Quantity, model.Id);
|
_logger.LogInformation("Material. IngredietnName:{MaterialName}. Cost:{Quantity}. Id:{Id}", model.MaterialName, model.Quantity, model.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<EmployeeViewModel>? ReadEmployeesUsingMaterial(MaterialBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
var list = _materialStorage.GetEmployeesUsingMaterial(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ namespace ConstructionCompanyBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. Adress:{Adress}. Id:{Id}", model?.Id);
|
_logger.LogInformation("ReadList. Id:{Id}", model?.Id);
|
||||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ namespace ConstructionCompanyBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public void GenerateEmployees()
|
public void GenerateEmployees()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 70; i++)
|
for (int i = 0; i < 400; i++)
|
||||||
{
|
{
|
||||||
_employee.Create(new EmployeeBindingModel { EmployeeName = "testEmp", PositionID = 1 });
|
_employee.Create(new EmployeeBindingModel { EmployeeName = "testEmp", PositionID = 1 });
|
||||||
}
|
}
|
||||||
@ -38,23 +38,31 @@ namespace ConstructionCompanyBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public void GenerateEmployeesOrders()
|
public void GenerateEmployeesOrders()
|
||||||
{
|
{
|
||||||
for (int i = 2; i < 50; i++)
|
for (int i = 0; i < 2000; i++)
|
||||||
{
|
{
|
||||||
_employeeOrder.Create(new EmployeeOrderBindingModel { EmployeeId = i, OrderId = i });
|
Random rand = new Random();
|
||||||
|
int emp = rand.Next(1, 600);
|
||||||
|
int ord = rand.Next(1, 2000);
|
||||||
|
if (_employeeOrder.ReadList(null)?.FirstOrDefault(x => x.OrderId == ord && x.EmployeeId == emp) != null) continue;
|
||||||
|
_employeeOrder.Create(new EmployeeOrderBindingModel { EmployeeId = emp, OrderId = ord});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateMaterialOrders()
|
public void GenerateMaterialOrders()
|
||||||
{
|
{
|
||||||
for (int i = 2; i < 40; i++)
|
for (int i = 0; i < 50; i++)
|
||||||
{
|
{
|
||||||
_materialOrder.Create(new MaterialOrderBindingModel { MaterialId = i, OrderId = i, Quantity = 1});
|
Random rand = new Random();
|
||||||
|
int mat = rand.Next(1, 10);
|
||||||
|
int ord = rand.Next(1, 200);
|
||||||
|
if (_materialOrder.ReadList(null)?.FirstOrDefault(x => x.OrderId == ord && x.MaterialId == mat) != null) continue;
|
||||||
|
_materialOrder.Create(new MaterialOrderBindingModel { MaterialId = mat, OrderId = ord, Quantity = 1});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateMaterials()
|
public void GenerateMaterials()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
_material.Create(new MaterialBindingModel { MaterialName = "testMat", Quantity = 2000 });
|
_material.Create(new MaterialBindingModel { MaterialName = "testMat", Quantity = 2000 });
|
||||||
}
|
}
|
||||||
@ -64,11 +72,6 @@ namespace ConstructionCompanyBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < 2000; i++)
|
for (int i = 0; i < 2000; i++)
|
||||||
{
|
{
|
||||||
if (i == 733)
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
_order.CreateOrder(new OrderBindingModel { Description = "snfjknfjksfns", Adress = "dsdsdssd", Price=20000, Status=OrderStatus.Неизвестен, CustomerNumber="+7838347475"});
|
_order.CreateOrder(new OrderBindingModel { Description = "snfjknfjksfns", Adress = "dsdsdssd", Price=20000, Status=OrderStatus.Неизвестен, CustomerNumber="+7838347475"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace ConstructionCompanyContracts.BusinessLogicContracts
|
|||||||
{
|
{
|
||||||
List<MaterialViewModel>? ReadList(MaterialSearchModel? model);
|
List<MaterialViewModel>? ReadList(MaterialSearchModel? model);
|
||||||
MaterialViewModel? ReadElement(MaterialSearchModel model);
|
MaterialViewModel? ReadElement(MaterialSearchModel model);
|
||||||
|
List<EmployeeViewModel>? ReadEmployeesUsingMaterial(MaterialBindingModel model);
|
||||||
bool Create(MaterialBindingModel model);
|
bool Create(MaterialBindingModel model);
|
||||||
bool Update(MaterialBindingModel model);
|
bool Update(MaterialBindingModel model);
|
||||||
bool Delete(MaterialBindingModel model);
|
bool Delete(MaterialBindingModel model);
|
||||||
|
@ -13,6 +13,7 @@ namespace ConstructionCompanyContracts.StorageContracts
|
|||||||
{
|
{
|
||||||
List<MaterialViewModel> GetFullList();
|
List<MaterialViewModel> GetFullList();
|
||||||
List<MaterialViewModel> GetFilteredList(MaterialSearchModel model);
|
List<MaterialViewModel> GetFilteredList(MaterialSearchModel model);
|
||||||
|
List<EmployeeViewModel>? GetEmployeesUsingMaterial(MaterialBindingModel model);
|
||||||
MaterialViewModel? GetElement(MaterialSearchModel model);
|
MaterialViewModel? GetElement(MaterialSearchModel model);
|
||||||
MaterialViewModel? Insert(MaterialBindingModel model);
|
MaterialViewModel? Insert(MaterialBindingModel model);
|
||||||
MaterialViewModel? Update(MaterialBindingModel model);
|
MaterialViewModel? Update(MaterialBindingModel model);
|
||||||
|
@ -8,12 +8,14 @@ using ConstructionCompanyContracts.BindingModels;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Npgsql;
|
using Npgsql;
|
||||||
using ConstructionCompanyDataModels.Enums;
|
using ConstructionCompanyDataModels.Enums;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace ConstructionCompanyPsqlImplement
|
namespace ConstructionCompanyPsqlImplement
|
||||||
{
|
{
|
||||||
public class ConstructionCompanyDatabase
|
public class ConstructionCompanyDatabase
|
||||||
{
|
{
|
||||||
static string connectionString = "Server=172.20.10.10;Port=5432;Database=ConstructionCompanyForwardEngineerd;User Id=postgres;Password=postgres;";
|
static string connectionString = "Server=192.168.1.35;Port=5432;Database=ConstructionCompanyForwardEngineerd;User Id=postgres;Password=postgres;";
|
||||||
|
|
||||||
private static ConstructionCompanyDatabase? _instance;
|
private static ConstructionCompanyDatabase? _instance;
|
||||||
private List<Material> _materials = new List<Material>();
|
private List<Material> _materials = new List<Material>();
|
||||||
@ -93,6 +95,22 @@ namespace ConstructionCompanyPsqlImplement
|
|||||||
connection.Close();
|
connection.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<int> ExecuteReader(string commandString)
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(connectionString);
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
using var commandMaterials = connection.CreateCommand();
|
||||||
|
commandMaterials.CommandText = commandString;
|
||||||
|
using var reader = commandMaterials.ExecuteReader();
|
||||||
|
List<int> ids = new List<int>();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
ids.Add(reader.GetInt32(0));
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
private void refreshDb()
|
private void refreshDb()
|
||||||
{
|
{
|
||||||
_materials.Clear();
|
_materials.Clear();
|
||||||
@ -106,7 +124,11 @@ namespace ConstructionCompanyPsqlImplement
|
|||||||
|
|
||||||
using var commandMaterials = connection.CreateCommand();
|
using var commandMaterials = connection.CreateCommand();
|
||||||
commandMaterials.CommandText = "SELECT * FROM material;";
|
commandMaterials.CommandText = "SELECT * FROM material;";
|
||||||
|
Stopwatch stopwatch = new Stopwatch();
|
||||||
|
stopwatch.Start();
|
||||||
using var readerMaterials = commandMaterials.ExecuteReader();
|
using var readerMaterials = commandMaterials.ExecuteReader();
|
||||||
|
stopwatch.Stop();
|
||||||
|
long materialsTime = stopwatch.ElapsedMilliseconds;
|
||||||
while (readerMaterials.Read())
|
while (readerMaterials.Read())
|
||||||
{
|
{
|
||||||
int id = readerMaterials.GetInt32(0);
|
int id = readerMaterials.GetInt32(0);
|
||||||
@ -119,7 +141,10 @@ namespace ConstructionCompanyPsqlImplement
|
|||||||
|
|
||||||
using var commandPositions = connection.CreateCommand();
|
using var commandPositions = connection.CreateCommand();
|
||||||
commandPositions.CommandText = "SELECT * FROM position;";
|
commandPositions.CommandText = "SELECT * FROM position;";
|
||||||
|
stopwatch.Restart();
|
||||||
using var readerPositions = commandPositions.ExecuteReader();
|
using var readerPositions = commandPositions.ExecuteReader();
|
||||||
|
stopwatch.Stop();
|
||||||
|
long positionsTime = stopwatch.ElapsedMilliseconds;
|
||||||
while (readerPositions.Read())
|
while (readerPositions.Read())
|
||||||
{
|
{
|
||||||
int id = readerPositions.GetInt32(0);
|
int id = readerPositions.GetInt32(0);
|
||||||
@ -132,7 +157,10 @@ namespace ConstructionCompanyPsqlImplement
|
|||||||
|
|
||||||
using var commandEmployees = connection.CreateCommand();
|
using var commandEmployees = connection.CreateCommand();
|
||||||
commandEmployees.CommandText = "SELECT * FROM employee;";
|
commandEmployees.CommandText = "SELECT * FROM employee;";
|
||||||
|
stopwatch.Restart();
|
||||||
using var readerEmployees = commandEmployees.ExecuteReader();
|
using var readerEmployees = commandEmployees.ExecuteReader();
|
||||||
|
stopwatch.Stop();
|
||||||
|
long employeesTime = stopwatch.ElapsedMilliseconds;
|
||||||
while (readerEmployees.Read())
|
while (readerEmployees.Read())
|
||||||
{
|
{
|
||||||
int id = readerEmployees.GetInt32(0);
|
int id = readerEmployees.GetInt32(0);
|
||||||
@ -145,7 +173,10 @@ namespace ConstructionCompanyPsqlImplement
|
|||||||
|
|
||||||
using var commandOrders = connection.CreateCommand();
|
using var commandOrders = connection.CreateCommand();
|
||||||
commandOrders.CommandText = "SELECT * FROM \"order\";";
|
commandOrders.CommandText = "SELECT * FROM \"order\";";
|
||||||
|
stopwatch.Restart();
|
||||||
using var readerOrders = commandOrders.ExecuteReader();
|
using var readerOrders = commandOrders.ExecuteReader();
|
||||||
|
stopwatch.Stop();
|
||||||
|
long ordersTime = stopwatch.ElapsedMilliseconds;
|
||||||
while (readerOrders.Read())
|
while (readerOrders.Read())
|
||||||
{
|
{
|
||||||
int id = readerOrders.GetInt32(0);
|
int id = readerOrders.GetInt32(0);
|
||||||
@ -186,8 +217,13 @@ namespace ConstructionCompanyPsqlImplement
|
|||||||
readerOrders.Close();
|
readerOrders.Close();
|
||||||
|
|
||||||
using var commandEmployeeOrders = connection.CreateCommand();
|
using var commandEmployeeOrders = connection.CreateCommand();
|
||||||
|
|
||||||
commandEmployeeOrders.CommandText = "SELECT * FROM employee_order;";
|
commandEmployeeOrders.CommandText = "SELECT * FROM employee_order;";
|
||||||
|
|
||||||
|
stopwatch.Restart();
|
||||||
using var readerEmployeeOrders = commandEmployeeOrders.ExecuteReader();
|
using var readerEmployeeOrders = commandEmployeeOrders.ExecuteReader();
|
||||||
|
stopwatch.Stop();
|
||||||
|
long employeeOrderTime = stopwatch.ElapsedMilliseconds;
|
||||||
while (readerEmployeeOrders.Read())
|
while (readerEmployeeOrders.Read())
|
||||||
{
|
{
|
||||||
int employeeId = readerEmployeeOrders.GetInt32(0);
|
int employeeId = readerEmployeeOrders.GetInt32(0);
|
||||||
@ -199,7 +235,10 @@ namespace ConstructionCompanyPsqlImplement
|
|||||||
|
|
||||||
using var commandMaterialOrders = connection.CreateCommand();
|
using var commandMaterialOrders = connection.CreateCommand();
|
||||||
commandMaterialOrders.CommandText = "SELECT * FROM material_order;";
|
commandMaterialOrders.CommandText = "SELECT * FROM material_order;";
|
||||||
|
stopwatch.Restart();
|
||||||
using var readerMaterialOrders = commandMaterialOrders.ExecuteReader();
|
using var readerMaterialOrders = commandMaterialOrders.ExecuteReader();
|
||||||
|
stopwatch.Stop();
|
||||||
|
long materialOrderTime = stopwatch.ElapsedMilliseconds;
|
||||||
while (readerMaterialOrders.Read())
|
while (readerMaterialOrders.Read())
|
||||||
{
|
{
|
||||||
int materialId = readerMaterialOrders.GetInt32(0);
|
int materialId = readerMaterialOrders.GetInt32(0);
|
||||||
@ -211,6 +250,7 @@ namespace ConstructionCompanyPsqlImplement
|
|||||||
readerMaterialOrders.Close();
|
readerMaterialOrders.Close();
|
||||||
|
|
||||||
connection.Close();
|
connection.Close();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,5 +97,20 @@ namespace ConstructionCompanyPsqlImplement.Implements
|
|||||||
_source.ExecuteSql(command);
|
_source.ExecuteSql(command);
|
||||||
return deletedMaterial;
|
return deletedMaterial;
|
||||||
}
|
}
|
||||||
|
public List<EmployeeViewModel>? GetEmployeesUsingMaterial(MaterialBindingModel model)
|
||||||
|
{
|
||||||
|
var command = Material.GetEmployeeCommand(model);
|
||||||
|
if (string.IsNullOrEmpty(command))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var employeesId = _source.ExecuteReader(command);
|
||||||
|
List<EmployeeViewModel> employees = new List<EmployeeViewModel>();
|
||||||
|
foreach (var id in employeesId)
|
||||||
|
{
|
||||||
|
employees.Add(_source.Employees.First(x => x.Id == id).GetViewModel);
|
||||||
|
}
|
||||||
|
return employees;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,15 @@ namespace ConstructionCompanyPsqlImplement.Models
|
|||||||
}
|
}
|
||||||
return $"DELETE FROM material WHERE id = {model.Id}";
|
return $"DELETE FROM material WHERE id = {model.Id}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetEmployeeCommand(MaterialBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return $"SELECT e.id FROM employee e JOIN employee_order ON employee_order.employee_id = e.id JOIN \"order\" ON \"order\".id = employee_order.order_id JOIN material_order ON material_order.order_id = \"order\".id JOIN material mat ON mat.id = material_order.material_id WHERE mat.id = {model.Id};";
|
||||||
|
}
|
||||||
public void Update(MaterialBindingModel? model)
|
public void Update(MaterialBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -49,4 +49,10 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="nlogConstruction.config">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -57,31 +57,32 @@ namespace ConstructionCompanyView
|
|||||||
|
|
||||||
private void buttonGenerate_Click(object sender, EventArgs e)
|
private void buttonGenerate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Stopwatch stopwatch = new Stopwatch();
|
//Stopwatch stopwatch = new Stopwatch();
|
||||||
stopwatch.Start();
|
//stopwatch.Start();
|
||||||
_random.GenerateMaterials();
|
//_random.GenerateMaterials();
|
||||||
stopwatch.Stop();
|
//stopwatch.Stop();
|
||||||
long materials = stopwatch.ElapsedMilliseconds;
|
//long materials = stopwatch.ElapsedMilliseconds;
|
||||||
stopwatch.Restart();
|
//stopwatch.Restart();
|
||||||
_random.GeneratePositions();
|
//_random.GeneratePositions();
|
||||||
stopwatch.Stop();
|
//stopwatch.Stop();
|
||||||
long positions = stopwatch.ElapsedMilliseconds;
|
//long positions = stopwatch.ElapsedMilliseconds;
|
||||||
stopwatch.Restart();
|
//stopwatch.Restart();
|
||||||
_random.GenerateEmployees();
|
//_random.GenerateEmployees();
|
||||||
stopwatch.Stop();
|
//stopwatch.Stop();
|
||||||
long employees = stopwatch.ElapsedMilliseconds;
|
//long employees = stopwatch.ElapsedMilliseconds;
|
||||||
stopwatch.Restart();
|
//stopwatch.Restart();
|
||||||
_random.GenerateOrders();
|
//_random.GenerateOrders();
|
||||||
stopwatch.Stop();
|
//stopwatch.Stop();
|
||||||
long orders = stopwatch.ElapsedMilliseconds;
|
//long orders = stopwatch.ElapsedMilliseconds;
|
||||||
stopwatch.Restart();
|
//stopwatch.Restart();
|
||||||
_random.GenerateEmployeesOrders();
|
//_random.GenerateEmployeesOrders();
|
||||||
long employeesOrders = stopwatch.ElapsedMilliseconds;
|
//long employeesOrders = stopwatch.ElapsedMilliseconds;
|
||||||
stopwatch.Restart();
|
//stopwatch.Restart();
|
||||||
_random.GenerateMaterialOrders();
|
_random.GenerateMaterialOrders();
|
||||||
stopwatch.Stop();
|
//stopwatch.Stop();
|
||||||
long materialOrders = stopwatch.ElapsedMilliseconds;
|
//long materialOrders = stopwatch.ElapsedMilliseconds;
|
||||||
MessageBox.Show($"materials={materials}, positions={positions}, employees={employees}, orders={orders}, materialOrders={materialOrders}, employeeOrders={employeesOrders}", "Результаты");
|
//MessageBox.Show($"materials={materials}, positions={positions}, employees={employees}, orders={orders}, materialOrders={materialOrders}, employeeOrders={employeesOrders}", "Результаты");
|
||||||
|
MessageBox.Show("Готово!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -6,6 +6,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
this.материалыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.материалыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.поставкиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.поставкиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.отчётОИспользованииToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.panel1.SuspendLayout();
|
this.panel1.SuspendLayout();
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -53,7 +54,8 @@
|
|||||||
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.материалыToolStripMenuItem,
|
this.материалыToolStripMenuItem,
|
||||||
this.поставкиToolStripMenuItem});
|
this.поставкиToolStripMenuItem,
|
||||||
|
this.отчётОИспользованииToolStripMenuItem});
|
||||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.menuStrip1.Name = "menuStrip1";
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
this.menuStrip1.Size = new System.Drawing.Size(542, 28);
|
this.menuStrip1.Size = new System.Drawing.Size(542, 28);
|
||||||
@ -74,6 +76,13 @@
|
|||||||
this.поставкиToolStripMenuItem.Text = "Поставки";
|
this.поставкиToolStripMenuItem.Text = "Поставки";
|
||||||
this.поставкиToolStripMenuItem.Click += new System.EventHandler(this.поставкиToolStripMenuItem_Click);
|
this.поставкиToolStripMenuItem.Click += new System.EventHandler(this.поставкиToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// отчётОИспользованииToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.отчётОИспользованииToolStripMenuItem.Name = "отчётОИспользованииToolStripMenuItem";
|
||||||
|
this.отчётОИспользованииToolStripMenuItem.Size = new System.Drawing.Size(188, 24);
|
||||||
|
this.отчётОИспользованииToolStripMenuItem.Text = "Отчёт о использовании";
|
||||||
|
this.отчётОИспользованииToolStripMenuItem.Click += new System.EventHandler(this.отчётОИспользованииToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// FormWarehouseMenu
|
// FormWarehouseMenu
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
@ -96,5 +105,6 @@
|
|||||||
private MenuStrip menuStrip1;
|
private MenuStrip menuStrip1;
|
||||||
private ToolStripMenuItem материалыToolStripMenuItem;
|
private ToolStripMenuItem материалыToolStripMenuItem;
|
||||||
private ToolStripMenuItem поставкиToolStripMenuItem;
|
private ToolStripMenuItem поставкиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem отчётОИспользованииToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,5 +35,14 @@ namespace ConstructionCompanyView
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void отчётОИспользованииToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormWarehouseReport));
|
||||||
|
if (service is FormWarehouseReport form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
116
ConstructionCompany/ConstructionCompanyView/FormWarehouseReport.Designer.cs
generated
Normal file
116
ConstructionCompany/ConstructionCompanyView/FormWarehouseReport.Designer.cs
generated
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
namespace ConstructionCompanyView
|
||||||
|
{
|
||||||
|
partial class FormWarehouseReport
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.comboBoxMaterial = new System.Windows.Forms.ComboBox();
|
||||||
|
this.buttonShow = new System.Windows.Forms.Button();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.BackgroundColor = System.Drawing.Color.White;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(3, 26);
|
||||||
|
this.dataGridView.MultiSelect = false;
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowHeadersVisible = false;
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(489, 450);
|
||||||
|
this.dataGridView.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// comboBoxMaterial
|
||||||
|
//
|
||||||
|
this.comboBoxMaterial.FormattingEnabled = true;
|
||||||
|
this.comboBoxMaterial.Location = new System.Drawing.Point(498, 55);
|
||||||
|
this.comboBoxMaterial.Name = "comboBoxMaterial";
|
||||||
|
this.comboBoxMaterial.Size = new System.Drawing.Size(229, 28);
|
||||||
|
this.comboBoxMaterial.TabIndex = 12;
|
||||||
|
//
|
||||||
|
// buttonShow
|
||||||
|
//
|
||||||
|
this.buttonShow.Location = new System.Drawing.Point(498, 89);
|
||||||
|
this.buttonShow.Name = "buttonShow";
|
||||||
|
this.buttonShow.Size = new System.Drawing.Size(134, 29);
|
||||||
|
this.buttonShow.TabIndex = 13;
|
||||||
|
this.buttonShow.Text = "Отобразить";
|
||||||
|
this.buttonShow.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonShow.Click += new System.EventHandler(this.buttonShow_Click);
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(498, 26);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(78, 20);
|
||||||
|
this.label1.TabIndex = 14;
|
||||||
|
this.label1.Text = "Материал";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(68, 20);
|
||||||
|
this.label2.TabIndex = 15;
|
||||||
|
this.label2.Text = "Рабочие";
|
||||||
|
//
|
||||||
|
// FormWarehouseReport
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(743, 478);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.buttonShow);
|
||||||
|
this.Controls.Add(this.comboBoxMaterial);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormWarehouseReport";
|
||||||
|
this.Text = "FormWarehouseReport";
|
||||||
|
this.Load += new System.EventHandler(this.FormWarehouseReport_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private ComboBox comboBoxMaterial;
|
||||||
|
private Button buttonShow;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
using ConstructionCompanyContracts.BindingModels;
|
||||||
|
using ConstructionCompanyContracts.BusinessLogicContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ConstructionCompanyView
|
||||||
|
{
|
||||||
|
public partial class FormWarehouseReport : Form
|
||||||
|
{
|
||||||
|
private readonly IMaterialLogic _logic;
|
||||||
|
public FormWarehouseReport(IMaterialLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonShow_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxMaterial.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите материал!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new MaterialBindingModel
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(comboBoxMaterial.SelectedValue),
|
||||||
|
};
|
||||||
|
Stopwatch stopwatch = new Stopwatch();
|
||||||
|
stopwatch.Start();
|
||||||
|
var list = _logic.ReadEmployeesUsingMaterial(model);
|
||||||
|
stopwatch.Stop();
|
||||||
|
MessageBox.Show(stopwatch.ElapsedMilliseconds.ToString(), "Готово. Время:");
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
//dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["PositionId"].Visible = false;
|
||||||
|
dataGridView.Columns["EmployeeName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormWarehouseReport_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null).OrderBy(x => x.Id).ToList();
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
comboBoxMaterial.DisplayMember = "Id";
|
||||||
|
comboBoxMaterial.ValueMember = "Id";
|
||||||
|
comboBoxMaterial.DataSource = list;
|
||||||
|
comboBoxMaterial.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -65,6 +65,7 @@ namespace ConstructionCompanyView
|
|||||||
services.AddTransient<FormEmployee>();
|
services.AddTransient<FormEmployee>();
|
||||||
services.AddTransient<FormEmployeeOrders>();
|
services.AddTransient<FormEmployeeOrders>();
|
||||||
services.AddTransient<FormEmployeeOrder>();
|
services.AddTransient<FormEmployeeOrder>();
|
||||||
|
services.AddTransient<FormWarehouseReport>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user