예제 #1
0
 private void btnRetour_Click(object sender, RoutedEventArgs e)
 {
     ProduitsController.reinitialiserOnglet();
     // Lorsqu'il clique sur Retour on veut :
     // Que le usercontrol Produit change d'onglet > direction : onglet rechercher.
     ProduitsController.RafraichirGrille(false);
     ProduitUserControl.TbcProduitPublic.SelectedIndex = 0;
 }
예제 #2
0
 private void txtRechercherProduit_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (txtRechercherProduit.Text.ToString() == "")
     {
         ProduitsController.Produits = new ObservableCollection <Produit>(HibernateProduitService.RetrieveAll());
     }
     else
     {
         ProduitsController.LiveFiltering(txtRechercherProduit.Text.ToString());
     }
     ProduitsController.RafraichirGrille(true);
 }
예제 #3
0
        //private Produit updateChampsProduit()
        //{
        //    Produit p = new Produit();
        //    //  ProduitsController.Produit.Code = txtCode.Text;
        //    p.Description = txtDescription.Text;
        //    p.Nom = txtNom.Text;
        //    p.Prix = Convert.ToDouble(txtPrix.Text);
        //    p.Quantite = Convert.ToDouble(txtQuantite.Text);
        //    p.Code = ProduitsController.GenererCodeProduit();

        //    return p;
        //    //ProduitsController.Produit.EstActif = true;
        //}

        private void btnEnregister_Click(object sender, RoutedEventArgs e)
        {
            // Commit
            Produit p         = ProduitsController.VerifierInactif();
            bool    EstSucces = false;

            if (EstModif)
            {
                if (ProduitsController.ValiderModif())
                {
                    if (p != null)
                    {
                        ProduitsController.DemanderSiModifAncienDelete(p, EstModif);
                    }
                    else
                    {
                        updateChampsProduit();
                        ProduitsController.UpdateProduit();
                        ProduitsController.SuccesModif();
                    }
                    EstSucces = true;
                }
            }
            else
            {
                if (ProduitsController.ValiderAjout())
                {
                    ProduitsController.Produit = new Produit(txtNom.Text, txtDescription.Text, Convert.ToDouble(txtPrix.Text), Convert.ToDouble(txtQuantite.Text), true);
                    // TODO: Modif
                    //ProduitsController.Produit.Code = ProduitsController.GenererCodeProduit();
                    if (p == null)
                    {
                        ProduitsController.AjoutProduit();
                        ProduitsController.SuccesAjout();
                        viderChamps();
                        EstSucces = true;
                    }
                    else
                    {
                        ProduitsController.DemanderSiModifAncienDelete(p, EstModif);
                    }
                }
            }
            if (EstSucces)
            {
                ProduitsController.RafraichirGrille(false);
            }
        }