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); } } } }