GestionDeDommerceInformatique/Gestion de commerce Informa.../ConfigLSTArt.cs

74 lines
2.5 KiB
C#
Raw Normal View History

using GestionDeCommerceInfoClasseBDDNCouches.DataLayer;
using GestionDeCommerceInfoClasseBDDNCouches;
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;
namespace Gestion_de_commerce_Informatique
{
public partial class ConfigLSTArt : Form
{
BDDAccesArticle bddArticle = new BDDAccesArticle(Settings1.Default.ChaineDeConnection);
private DataTable dtArticle;
private DataTable dtLSTArt;
private BindingSource bsArticle;
private Panier.LSTArticle lstArt;
public ConfigLSTArt(DataTable dtLSTArt)
{
InitializeComponent();
bsArticle = new BindingSource();
this.dtLSTArt = dtLSTArt;
RemplirDVG();
}
private void txtBoxRecherche_KeyUp(object sender, EventArgs e)
{
string rowFilter = string.Format("[{0}] LIKE '%{1}%'", "NomArticle", txtBoxRecherche.text);//https://10tec.com/articles/datagridview-filter.aspx
dtArticle.DefaultView.RowFilter = rowFilter;
}
private void RemplirDVG(DataGridView dgv)
{
dtArticle = new DataTable();
dtArticle.Columns.Add(new DataColumn("idArt", System.Type.GetType("System.Int32")));
dtArticle.Columns.Add(new DataColumn("NomArticle", typeof(Article)));
dtArticle.Columns.Add("Valeur");
dtArticle.Columns.Add("Stock");
List<Article> larticles;
larticles = bddArticle.ListArticles();
foreach (Article Tmp in larticles)
dtArticle.Rows.Add(Tmp.ID, Tmp, $"{Math.Round(Tmp.PrixHTVA, 2)}€", Tmp.Stock);
bsArticle.DataSource = dtArticle;
dgv.DataSource = bsArticle;
}
public void RemplirDVG()
{
RemplirDVG(dgvArticle);
}
private void btnAnnuler_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnAddPanier_Click(object sender, EventArgs e)
{
int quant;
if (int.TryParse(vtbQuant.Text, out quant))
{
Article art = (Article)dgvArticle.SelectedRows[0].Cells["NomArticle"].Value;
Panier.LSTArticle lstart = new Panier.LSTArticle(art, quant);
dtLSTArt.Rows.Add(-1, lstart, $"{Math.Round(lstart.prixHTVAPC, 2)}€", lstart.quantitee, lstart.prixHTVATot);
}
}
}
}