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

74 lines
2.2 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 GestionDeCommerceInfoClasseBDDNCouches;
using GestionDeCommerceInfoClasseBDDNCouches.DataLayer;
namespace Gestion_de_commerce_Informatique
{
public partial class ConfigurationStock : Form
{
BDDAccesArticle bddArticle;
public Article article;
bool Modif;
public ConfigurationStock(BDDAccesArticle bddArticle)
{
InitializeComponent();
this.bddArticle = bddArticle;
Modif = false;
}
public ConfigurationStock(Article article, BDDAccesArticle bddArticle)
{
InitializeComponent();
this.bddArticle = bddArticle;
this.article = article;
vtbDesignation.Text = article.Designation;
vtbPrixHTVA.Text = article.PrixHTVA.ToString();
vtbStock.Text = article.Stock.ToString();
btnConfirm.Text = "Mettre à jours";
Modif = true;
}
private void bunifuFlatButton1_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnConfirm_Click(object sender, EventArgs e)
{
int stock; float prixHTVA;
if (int.TryParse(vtbStock.Text, out stock) == true && float.TryParse(vtbPrixHTVA.Text, out prixHTVA))
{
if (Modif)
{
article.Designation = vtbDesignation.Text;
article.PrixHTVA = prixHTVA;
article.Stock = stock;
bddArticle.ModifArticle(article);
}
else
{
this.article = new Article(vtbDesignation.Text, prixHTVA, stock, true, true);
bddArticle.AjouterArticle(article);
}
this.Close();
}
else
{
MessageBox.Show("Prix Hors TVA ou Stock incorect");
}
}
}
}