107 lines
3.6 KiB
C#
107 lines
3.6 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Forms;
|
||
using DEM_Timofeev_prob.Models;
|
||
using Microsoft.EntityFrameworkCore;
|
||
|
||
namespace DEM_Timofeev_prob
|
||
{
|
||
public partial class Form_maneger : Form
|
||
{
|
||
DemDemContext context;
|
||
public Form_maneger()
|
||
{
|
||
InitializeComponent();
|
||
dataGridView1.DataError += (sender, e) => e.ThrowException = false;
|
||
}
|
||
|
||
protected override void OnLoad(EventArgs e)
|
||
{
|
||
base.OnLoad(e);
|
||
context = new DemDemContext();
|
||
context.Products.Include(x => x.IdTipeProductNavigation).Include(x => x.IdManufacturNavigation).Include(x => x.IdSuplierNavigation).Include(x => x.IdEdNavigation).Load();
|
||
context.Database.EnsureCreated();
|
||
bindingSource_product.DataSource = context.Products.Local.ToBindingList();
|
||
bindingSource_manufactur.DataSource = context.Manufacts.Local.ToBindingList();
|
||
bindingSource_ed.DataSource = context.Eds.Local.ToBindingList();
|
||
bindingSource_supplier.DataSource = context.Supliers.Local.ToBindingList();
|
||
bindingSource_tipe_product.DataSource = context.TipeProducts.Local.ToBindingList();
|
||
|
||
comboBox1.Items.AddRange(new string[]
|
||
{
|
||
"Все производители",
|
||
"а-я",
|
||
"я-а",
|
||
"цена а-я",
|
||
"цена я-а"
|
||
});
|
||
comboBox1.SelectedIndex = 0;
|
||
|
||
|
||
}
|
||
|
||
private void button3_Click(object sender, EventArgs e)
|
||
{
|
||
this.Hide();
|
||
Form1 ff = new Form1();
|
||
ff.Show();
|
||
}
|
||
|
||
public void maneger(string fio)
|
||
{
|
||
label3.Text = fio;
|
||
}
|
||
|
||
private void textBox1_TextChanged(object sender, EventArgs e)
|
||
{
|
||
string qwery = textBox1.Text.Trim();
|
||
if (string.IsNullOrEmpty(qwery))
|
||
{
|
||
bindingSource_product.DataSource = context.Products.Local.ToBindingList();
|
||
}
|
||
|
||
var result = context.Products.Local
|
||
.Where(x => x.Name.IndexOf(qwery, StringComparison.OrdinalIgnoreCase) >= 0 ||
|
||
x.ProductContent.IndexOf(qwery, StringComparison.OrdinalIgnoreCase) >= 0 ||
|
||
x.IdManufacturNavigation.Name.IndexOf(qwery, StringComparison.OrdinalIgnoreCase) >= 0)
|
||
.ToList();
|
||
bindingSource_product.DataSource = result;
|
||
}
|
||
|
||
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
var data = context.Products.Local.AsQueryable();
|
||
switch (comboBox1.SelectedIndex)
|
||
{
|
||
case 1:
|
||
data = data.OrderBy(x => x.Name);
|
||
break;
|
||
|
||
case 2:
|
||
data = data.OrderByDescending(x => x.Name);
|
||
break;
|
||
case 3:
|
||
data = data.OrderBy(x => x.PriceProduct);
|
||
break;
|
||
case 4:
|
||
data = data.OrderByDescending(x => x.PriceProduct);
|
||
break;
|
||
}
|
||
bindingSource_product.DataSource = data.ToList();
|
||
}
|
||
|
||
private void button1_Click(object sender, EventArgs e)
|
||
{
|
||
this.Hide();
|
||
form_order_maneger ff = new form_order_maneger();
|
||
ff.Show();
|
||
}
|
||
}
|
||
}
|