Beispiel #1
0
        private void btnFiltrer_Click(object sender, EventArgs e)
        {
            ProduitServiceWCFClient service = new ProduitServiceWCFClient();

            if (comboBoxFiltrage.SelectedIndex == -1)
            {
                MessageBox.Show("Veuillez séléctionner le type de filtrage",
                                "Attention", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (comboBoxFiltrage.SelectedIndex == 3)
            {
                dataGridProduits.DataSource = service.findDestockedProduts();
            }
            else if (comboBoxFiltrage.SelectedIndex == 2)
            {
                dataGridProduits.DataSource = service.findProductsNotAvaible();
            }
            else if (comboBoxFiltrage.SelectedIndex == 1)
            {
                dataGridProduits.DataSource = service.findAvaibleProducts();
            }
            else
            {
                ShowProducts();
            }
        }
Beispiel #2
0
        public void btnAjouter_Click(object sender, EventArgs e)
        {
            if (textBoxNom.Text == "" || imageLocation == "" || textBoxPrix.Text == "" ||
                comboBoxFournisseur.SelectedIndex == -1)
            {
                MessageBox.Show("Veuillez remplir tout les champ", "Attention",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                ProduitServiceWCFClient service = new ProduitServiceWCFClient();
                if (imageLocation != null)
                {
                    FileInfo fi = new FileInfo(imageLocation);
                    //While executing the application, the current directory will be the bin folder
                    string path = "../../images/" + textBoxNom.Text.Trim() + fi.Extension;
                    p.image = path;
                    if (File.Exists(p.image))
                    {
                        File.Delete(path);
                        File.Copy(imageLocation, path);
                    }
                    else
                    {
                        File.Copy(imageLocation, path);
                    }
                }
                else
                {
                    p.image = service.find(p.id_produit).image;
                }

                p.nom            = textBoxNom.Text.Trim();
                p.id_fournisseur = service.findFournisseurByName
                                       (comboBoxFournisseur.SelectedItem.ToString()).id_fournisseur;
                p.prix_vente      = decimal.Parse(textBoxPrix.Text);
                p.date_ajout      = DateTime.Now;
                p.date_expiration = dateTimePickerExpiration.Value;
                if (p.id_produit == 0)
                {
                    p.quantite = 0;
                    service.add(p);
                    MessageBox.Show("Le produit est ajouté à la base de donnée",
                                    "Confirmation d'ajout", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Clear();
                    this.Close();
                }
                else
                {
                    p.quantite = int.Parse(textBoxQuantite.Text);
                    service.edit(p);
                    MessageBox.Show("Le produit est modifié",
                                    "Confirmation de modification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                this.principalForm.ShowProducts();
            }
        }
Beispiel #3
0
        private void loadComboboxFournisseurs(AjouterProduit p)
        {
            ProduitServiceWCFClient service      = new ProduitServiceWCFClient();
            List <Fournisseur>      Fournisseurs = new List <Fournisseur>(service.findAllFournisseur());

            foreach (Fournisseur f in Fournisseurs)
            {
                p.comboBoxFournisseur.Items.Add(f.nom);
            }
        }
Beispiel #4
0
        private void cherch_Click(object sender, EventArgs e)
        {
            DashboardServiceWCFClient d  = new DashboardServiceWCFClient();
            ProduitServiceWCFClient   pr = new ProduitServiceWCFClient();
            var l = new[]
            {
                new { mn = 1, m = "Janvier" },
                new { mn = 2, m = "Février" },
                new { mn = 3, m = "Mars" },
                new { mn = 4, m = "Avril" },
                new { mn = 5, m = "Mai" },
                new { mn = 6, m = "Juin" },
                new { mn = 7, m = "Juillet" },
                new { mn = 8, m = "Aout" },
                new { mn = 9, m = "Septembre" },
                new { mn = 10, m = "Octobre" },
                new { mn = 11, m = "Novembre" },
                new { mn = 12, m = "Décembre" },
            }.ToList();

            foreach (var item in l)
            {
                if (comboBox1.Text == item.m)
                {
                    int n = d.nb_venteByMonth(item.mn, Convert.ToInt32(comboBoxYears.Text));
                    if (n != 0)
                    {
                        foreach (var c in chart_nb_vente.Series)
                        {
                            c.Points.Clear();
                        }

                        foreach (var v in pr.findAll())
                        {
                            chart_nb_vente.Series["ventes"].Points.AddXY(d.name_prod(Convert.ToInt32(v.id_produit)), d.q_v_m(Convert.ToInt32(v.id_produit), item.mn, Convert.ToInt32(comboBoxYears.Text)));
                        }


                        int g = d.gain_month(item.mn, Convert.ToInt32(comboBoxYears.Text));

                        int p = d.perte_mois(item.mn, Convert.ToInt32(comboBoxYears.Text));
                        nb.Text    = Convert.ToString(n);
                        gain.Text  = Convert.ToString(g);
                        perte.Text = Convert.ToString(p);
                    }
                    else
                    {
                        MessageBox.Show("Aucun vente  n'a été effectuer en ce mois!!");
                    }
                }
            }
        }
Beispiel #5
0
        private void buttonAjouter_Click(object sender, EventArgs e)
        {
            int x = 1;

            try
            { int nb = Convert.ToInt32(textBoxQtVendu.Text); }
            catch (Exception exp0)
            {
                MessageBox.Show("Veuillez saisir une quantité valide ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                x = 0;
            }
            if (x == 1)
            {
                if (Convert.ToInt32(textBoxQtRestante.Text) < Convert.ToInt32(textBoxQtVendu.Text))

                {
                    MessageBox.Show("La quantité que vous avez saisi est supérieure à celle du stock \n " +
                                    "veuillez entrer une quantité valide", "Error", MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
                }

                else
                {
                    VenteService.Vente vente = new VenteService.Vente();
                    vente.date_ajout     = DateTime.Now;
                    vente.quantite_vendu = Convert.ToInt32(textBoxQtVendu.Text);
                    ProduitService.Produit produit = (ProduitService.Produit)comboBox_prod.SelectedItem;
                    vente.id_produit = produit.id_produit;
                    VenteService.add(vente);

                    int Qt = Convert.ToInt32(textBoxQtRestante.Text) - Convert.ToInt32(textBoxQtVendu.Text);
                    VenteService.updateQuantity(Qt, produit.id_produit);

                    MessageBox.Show("Le Produit " + produit.nom + " a été Vendu .", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    btnCancel.PerformClick();
                    VenteServiceWCFClient ven = new VenteServiceWCFClient();
                    dataGridViewVente.DataSource = ven.listeVente();

                    comboBox_prod.Items.Clear();
                    ProduitServiceWCFClient       serviceproduit = new ProduitServiceWCFClient();
                    List <ProduitService.Produit> produits       = new List <ProduitService.Produit>(serviceproduit.findAvaibleProducts());
                    foreach (ProduitService.Produit p in produits)
                    {
                        comboBox_prod.Items.Add(p);
                    }
                    comboBox_prod.DisplayMember = "nom";
                    comboBox_prod.ValueMember   = "id_produit";
                }
            }
        }
Beispiel #6
0
 private void btnSupprimer_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Vous etes sûr de vouloir supprimer ce produit ?",
                         "Confirmation de suppression", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         ProduitServiceWCFClient service = new ProduitServiceWCFClient();
         service.delete(int.Parse(selectedRow.Cells[0].Value.ToString()));
         if (File.Exists(selectedRow.Cells[5].Value.ToString()))
         {
             File.Delete(selectedRow.Cells[5].Value.ToString());
         }
         MessageBox.Show("Le produit est supprimé");
         ShowProducts();
     }
 }
Beispiel #7
0
        private void btnJour_Click(object sender, EventArgs e)
        {
            chart_nb_vente.Visible = true;
            nb.Visible             = true;
            gain.Visible           = true;
            perte.Visible          = true;
            des.Visible            = true;
            label1.Visible         = true;
            label2.Visible         = true;
            label3.Visible         = true;
            label5.Visible         = true;
            //String date = dateTimePicker1.Value.ToShortDateString();

            DashboardServiceWCFClient d     = new DashboardServiceWCFClient();
            ProduitServiceWCFClient   pr    = new ProduitServiceWCFClient();
            VenteServiceWCFClient     vente = new VenteServiceWCFClient();
            int v = vente.nbVente(dateTimePicker1.Value.Date);

            if (v != 0)
            {
                int n = d.nb_ventes(dateTimePicker1.Value.Date);

                int g = d.gain_tout(dateTimePicker1.Value.Date);

                int p = d.perte(dateTimePicker1.Value.Date);
                int a = d.nbr_achat(dateTimePicker1.Value.Date);
                nb.Text    = Convert.ToString(n);
                gain.Text  = Convert.ToString(g);
                perte.Text = Convert.ToString(p);
                achat.Text = Convert.ToString(a);
                List <VenteService.Vente> l = new List <VenteService.Vente>();
                d.findnow(dateTimePicker1.Value.Date);

                foreach (var item in chart_nb_vente.Series)
                {
                    item.Points.Clear();
                }

                foreach (var item in pr.findAll())
                {
                    chart_nb_vente.Series["ventes"].Points.AddXY(d.name_prod(Convert.ToInt32(item.id_produit)), d.qu(Convert.ToInt32(item.id_produit), dateTimePicker1.Value.Date));
                }
            }
            else
            {
                MessageBox.Show("Aucun vente  n'a été effectuer en cette date!!");
            }
        }
Beispiel #8
0
        private void btnValider_Click(object sender, EventArgs e)
        {
            if (comboBox_prod.Text != "")
            {
                textBoxQtVendu.Enabled = true;
                ProduitServiceWCFClient serviceproduit = new ProduitServiceWCFClient();
                ProduitService.Produit  produit        = (ProduitService.Produit)comboBox_prod.SelectedItem;

                textBoxQtRestante.Text = Convert.ToString(produit.quantite);
                textBoxPrixVente.Text  = Convert.ToString(produit.prix_vente);
            }
            else
            {
                MessageBox.Show("Veuillez Choisir un Produit !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #9
0
        private void Ventes_Load(object sender, EventArgs e)
        {
            dataGridViewVente.AutoGenerateColumns = false;

            VenteServiceWCFClient vente = new VenteServiceWCFClient();

            dataGridViewVente.DataSource = vente.listeVente();


            ProduitServiceWCFClient       serviceproduit = new ProduitServiceWCFClient();
            List <ProduitService.Produit> produits       = new List <ProduitService.Produit>(serviceproduit.findAvaibleProducts());

            foreach (ProduitService.Produit p in produits)
            {
                comboBox_prod.Items.Add(p);
            }
            comboBox_prod.DisplayMember = "nom";
            comboBox_prod.ValueMember   = "id_produit";
        }
Beispiel #10
0
        private void btnModifier_Click(object sender, EventArgs e)
        {
            AjouterProduit ap = new AjouterProduit(int.Parse(selectedRow.Cells["id_produit"].Value.ToString()), this);

            ap.Text = "Modifier produit";
            ap.btnAjouterProduit.Text = "Modifier";
            loadComboboxFournisseurs(ap);
            ap.Show();
            ap.textBoxNom.Text = selectedRow.Cells["nom"].Value.ToString();
            ProduitServiceWCFClient service = new ProduitServiceWCFClient();

            ap.comboBoxFournisseur.SelectedItem = service.findProductsById(int.Parse(selectedRow.Cells["id_fournisseur"].Value.ToString())).nom.ToString();
            ap.textBoxPrix.Text = selectedRow.Cells["prix_vente"].Value.ToString();
            if (selectedRow.Cells["quantite"].Value == null)
            {
                ap.textBoxQuantite.Text = "0";
            }
            else
            {
                ap.textBoxQuantite.Text = selectedRow.Cells["quantite"].Value.ToString();
            }
            ap.dateTimePickerExpiration.Value = DateTime.Parse(selectedRow.Cells["date_expiration"].Value.ToString());
            ap.pictureBox.ImageLocation       = selectedRow.Cells["image"].Value.ToString();
        }
Beispiel #11
0
        private void btnAfficher_Click(object sender, EventArgs e)
        {
            AjouterProduit ap = new AjouterProduit(0, this);

            ap.Text = "Afficher produit";
            ap.Controls.Remove(ap.btnUpload);
            ap.Controls.Remove(ap.btnAjouterFournisseur);
            ap.Controls.Remove(ap.btnAjouterProduit);
            ap.btnUpload.Dispose();
            ap.btnAjouterFournisseur.Dispose();
            ap.btnAjouterProduit.Dispose();

            ap.textBoxNom.Text = selectedRow.Cells["nom"].Value.ToString();
            ProduitServiceWCFClient service = new ProduitServiceWCFClient();

            ap.comboBoxFournisseur.Items.Add(service.findProductsById(int.Parse(selectedRow.Cells["id_fournisseur"].Value.ToString())).nom.ToString());
            ap.comboBoxFournisseur.SelectedIndex = 0;
            ap.textBoxNom.Enabled  = false;
            ap.textBoxPrix.Enabled = false;
            ap.dateTimePickerExpiration.Enabled = false;
            ap.textBoxQuantite.Enabled          = false;
            ap.comboBoxFournisseur.Enabled      = false;

            ap.textBoxPrix.Text = selectedRow.Cells["prix_vente"].Value.ToString();
            if (selectedRow.Cells["quantite"].Value == null)
            {
                ap.textBoxQuantite.Text = "0";
            }
            else
            {
                ap.textBoxQuantite.Text = selectedRow.Cells["quantite"].Value.ToString();
            }
            ap.dateTimePickerExpiration.Value = DateTime.Parse(selectedRow.Cells["date_expiration"].Value.ToString());
            ap.pictureBox.ImageLocation       = selectedRow.Cells["image"].Value.ToString();
            ap.Show();
        }
Beispiel #12
0
        private void btnRechercher_Click(object sender, EventArgs e)
        {
            ProduitServiceWCFClient service = new ProduitServiceWCFClient();

            dataGridProduits.DataSource = service.findProductsByName(textBoxRecherche.Text);
        }
Beispiel #13
0
        public void ShowProducts()
        {
            ProduitServiceWCFClient service = new ProduitServiceWCFClient();

            dataGridProduits.DataSource = service.findAll();
        }