Ejemplo n.º 1
0
        //Afficher un article dans le fourmulaire nouvelle commande
        public static void Afficher(NouvelleCommande frm)
        {
            GridViewRow myRow = frm.GridArticles.SelectedRow;

            frm.TxtNum.Text  = myRow.Cells[1].Text;
            frm.TxtNom.Text  = myRow.Cells[2].Text;
            frm.TxtPrix.Text = myRow.Cells[5].Text;
        }
Ejemplo n.º 2
0
        //Initialiser la commande
        public static void InitialiserCommande(NouvelleCommande frm)
        {
            Commande commande = new Commande();

            //commande.LigneCommandes = new List<LigneCommande>();
            frm.Session["commande"] = commande;
            //frm.GridViewCommande.DataSource = commande.LigneCommandes;
            //frm.GridViewCommande.DataBind();
        }
Ejemplo n.º 3
0
        //Ajouter un article à la commande
        public static void Ajouter(NouvelleCommande frm)
        {
            try
            {
                int      numArticle = int.Parse(frm.TxtNum.Text);
                double   prix       = double.Parse(frm.TxtPrix.Text);
                int      quantite   = int.Parse(frm.TxtQuantite.Text);
                Commande cmd        = frm.Session["commande"] as Commande;

                LigneCommande ligne = RechercherLigneCommande(numArticle, cmd.LigneCommandes);
                if (ligne == null)
                {
                    ligne = new LigneCommande
                    {
                        numArticle = numArticle,
                        quantite   = quantite,
                        prix       = prix
                    };
                    cmd.LigneCommandes.Add(ligne);
                    cmd.montant        += prix * quantite;
                    frm.TxtMontant.Text = cmd.montant.ToString();
                }
                else
                {
                    ligne.quantite     += quantite;
                    cmd.montant        += prix * quantite;
                    frm.TxtMontant.Text = cmd.montant.ToString();
                }
                frm.GridViewCommande.DataSource = cmd.LigneCommandes;
                frm.GridViewCommande.DataBind();

                frm.TxtNum.Text                 = "";
                frm.TxtNom.Text                 = "";
                frm.TxtPrix.Text                = "";
                frm.TxtQuantite.Text            = "";
                frm.BtnAjouter.Enabled          = false;
                frm.BtnEnregistrer.Enabled      = true;
                frm.LblResultatTxtQuantite.Text = "";
            }
            catch (Exception e)
            {
                frm.LblResultatTxtQuantite.Text = "Champ obligatoire en nombre";
            }
        }
Ejemplo n.º 4
0
        //Enregistrer une commande
        public static void EnregisterCommande(NouvelleCommande frm)
        {
            //L'utilisateur en cours
            Utilisateur utilisateur = frm.Session["utilisateur"] as Utilisateur;

            //Mon fammeux objet commande
            Commande cmd = frm.Session["commande"] as Commande;

            //Recuperer le fournisseur
            Fournisseur fournisseur = GestionFournisseur.Rechercher(frm.CmbFournisseur.SelectedValue);

            //Completion de l'objet commande
            cmd.numFournisseur = fournisseur.numFournisseur;
            cmd.dateCommande   = DateTime.Now;
            try
            {
                cmd.nomUtilisateur = utilisateur.nomUtilisateur;

                using (var sim = new SIM_Context())
                {
                    //Sauvegarde de la commande
                    cmd = sim.Commandes.Add(cmd);
                    int result = sim.SaveChanges();

                    //Affichage numero commande
                    frm.TxtNumCommande.Text = cmd.numCommande.ToString();

                    //Mise à jour du grid
                    frm.GridViewCommande.DataSource = cmd.LigneCommandes;
                    frm.GridViewCommande.DataBind();

                    frm.BtnEnregistrer.Enabled = false;
                    frm.Session.Remove("commande");
                    frm.LblResultatEnregistrer.Text = "Nouvelle commande enregistré avec succes!";
                    //Message de confirmation : La commande a été sauvegardée avec succes
                }
            }
            catch (Exception)
            {
                frm.LblResultatEnregistrer.Text = "Vous êtes pas authentifié";
            }
            //cmd.Fournisseur = fournisseur;
        }
Ejemplo n.º 5
0
 //Lister articles dans le fenetre de commande
 public static void ListerArticles(NouvelleCommande frm)
 {
     if (!frm.TxtArticle.Text.Equals(""))
     {
         if ((frm.GridArticles.DataSource = Rechercher(frm.TxtArticle.Text, false)) != null)
         {
             frm.GridArticles.DataBind();
             frm.BtnAjouter.Enabled = true;
             frm.LblResultatRechercherArticle.Text = "";
         }
         else
         {
             frm.LblResultatRechercherArticle.Text = "Rien trouvé!";
         }
     }
     else
     {
         frm.LblResultatRechercherArticle.Text = "Champ vide!";
     }
 }
Ejemplo n.º 6
0
        //Supprimer une ligne de commande
        public static void supprimmerLigne(NouvelleCommande frm, int numArticle)
        {
            Commande cmd = frm.Session["commande"] as Commande;

            LigneCommande ligne = RechercherLigneCommande(numArticle, cmd.LigneCommandes);

            if (ligne != null)
            {
                //Mise à jour du montant dans la fenetre
                cmd.montant        -= ligne.prix * ligne.quantite;
                frm.TxtMontant.Text = cmd.montant.ToString();

                //Suppression de la ligne
                cmd.LigneCommandes.Remove(ligne);

                //Mise à jour du grid
                frm.GridViewCommande.DataSource = cmd.LigneCommandes;
                frm.GridViewCommande.DataBind();
            }
            else
            {
                //Erreur systeme grave!!!!!!  à ne pas traiter dans la page
            }
        }
 //Methode chargeant le fournisseur dans le DropDownList
 public static void ChargerFourniseur(NouvelleCommande frm)
 {
     frm.CmbFournisseur.DataSource    = GestionFournisseur.Rechercher();
     frm.CmbFournisseur.DataTextField = "nom";
     frm.CmbFournisseur.DataBind();
 }
        //Affichage des infos d'un fournisseur selectionne
        public static void AfficherInfosFournisseur(NouvelleCommande frm)
        {
            Fournisseur f = Rechercher(frm.CmbFournisseur.SelectedValue);

            frm.TxtInfoFournisseur.Text = "Nom :" + f.nom + "\n" + "Adresse :" + f.adresse + "\n" + "Telephone :" + f.telephone;
        }