Exemplo n.º 1
0
        //Constructeur

        /// <summary>
        /// Controller pour le menu ajouter de la fenetre principale
        /// </summary>
        /// <param name="Form"> fenetre principale </param>
        /// <param name="Type"> nom du bouton </param>
        public MenuAjouterController(FormMain Form, string Type)
        {
            this.Form = Form;
            this.Type = Type;

            if (Type.Equals("article"))
            {
                AjouterArticle AjouterA = new AjouterArticle(Form, Form.GetPathToSave());
                AjouterA.StartPosition = FormStartPosition.CenterParent;
                AjouterA.ShowDialog(Form);
            }
            else if (Type.Equals("marque"))
            {
                AjouterMarque AjouterM = new AjouterMarque(Form, Form.GetPathToSave());
                AjouterM.StartPosition = FormStartPosition.CenterParent;
                AjouterM.ShowDialog(Form);
            }
            else if (Type.Equals("famille"))
            {
                AjouterFamille AjouterF = new AjouterFamille(Form, Form.GetPathToSave());
                AjouterF.StartPosition = FormStartPosition.CenterParent;
                AjouterF.ShowDialog(Form);
            }
            else if (Type.Equals("sous famille"))
            {
                AjouterSousFamille AjouterSf = new AjouterSousFamille(Form, Form.GetPathToSave());
                AjouterSf.StartPosition = FormStartPosition.CenterParent;
                AjouterSf.ShowDialog(Form);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handler pour un click dans le menu contextuel.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            ListViewController Controller = new ListViewController(this.listView1, PathToSave);

            switch (e.ClickedItem.Text)
            {
            case "Ajouter":
                if (this.listView1.SelectedItems.Count > 0)
                {
                    switch (this.listView1.SelectedItems[0].Tag)
                    {
                    case Articles a:
                        AjouterArticle AjouterA = new AjouterArticle(this, PathToSave);
                        AjouterA.StartPosition = FormStartPosition.CenterParent;
                        AjouterA.ShowDialog(this);
                        break;

                    case Familles f:
                        AjouterFamille AjouterF = new AjouterFamille(this, PathToSave);
                        AjouterF.StartPosition = FormStartPosition.CenterParent;
                        AjouterF.ShowDialog(this);
                        break;

                    case SousFamilles sf:
                        AjouterSousFamille AjouterSf = new AjouterSousFamille(this, PathToSave);
                        AjouterSf.StartPosition = FormStartPosition.CenterParent;
                        AjouterSf.ShowDialog(this);
                        break;

                    case Marques m:
                        AjouterMarque AjouterM = new AjouterMarque(this, PathToSave);
                        AjouterM.StartPosition = FormStartPosition.CenterParent;
                        AjouterM.ShowDialog(this);
                        break;

                    default:
                        break;
                    }
                }
                break;

            case "Modifier":
                if (this.listView1.SelectedItems.Count > 0)
                {
                    switch (this.listView1.SelectedItems[0].Tag)
                    {
                    case Articles a:
                        ModifierArticle ModifierA = new ModifierArticle(this, PathToSave);
                        ModifierA.StartPosition = FormStartPosition.CenterParent;
                        ModifierA.ShowDialog(this);
                        break;

                    case Familles f:
                        ModifierFamille ModifierF = new ModifierFamille(this, PathToSave);
                        ModifierF.StartPosition = FormStartPosition.CenterParent;
                        ModifierF.ShowDialog(this);
                        break;

                    case SousFamilles sf:
                        ModifierSousFamille ModifierSf = new ModifierSousFamille(this, PathToSave);
                        ModifierSf.StartPosition = FormStartPosition.CenterParent;
                        ModifierSf.ShowDialog(this);
                        break;

                    case Marques m:
                        ModifierMarque ModifierM = new ModifierMarque(this, PathToSave);
                        ModifierM.StartPosition = FormStartPosition.CenterParent;
                        ModifierM.ShowDialog(this);
                        break;

                    default:
                        break;
                    }
                }
                break;

            case "Supprimer":
                Controller.DeleteSelectedItem(this.treeView1.SelectedNode, this);
                InitializeTreeView TreeConstruct = new InitializeTreeView(this.treeView1);
                TreeConstruct.ConstructTree(PathToSave);
                break;

            default:
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Constructeur du bouton ajouter des fenêtres d'ajout. Le String TypeModifier permet d'effectuer un traitement différent en fonction du type d'objet à ajouter
        /// </summary>
        /// <param name="PathBdd"> Le chemin vers la base de données </param>
        /// <param name="AjouterForm"> Le formulaire d'ajout </param>
        /// <param name="TypeAjouter"> Le String qui permet de déterminer quelles opérations faire </param>
        public AddButtonController(String PathBdd, Form AjouterForm, String TypeAjouter)
        {
            ToolStatusStripController TSSController;

            if (TypeAjouter.Equals("Marques"))
            {
                AjouterMarque Form = (AjouterMarque)AjouterForm;

                MarquesDAO MarquesD   = new MarquesDAO(PathBdd);
                String     NouveauNom = Form.GetTextBox().Text;

                Marques Marque = new Marques(NouveauNom);
                MarquesD.AjouterMarque(Marque);

                InitializeTreeView TreeViewInit = new InitializeTreeView(Form.GetFormMain().GetTreeView());
                TreeViewInit.ConstructTree(PathBdd);

                ListViewController ListViewInit = new ListViewController(Form.GetFormMain().GetListView(), PathBdd);
                ListViewInit.LoadListView(Form.GetFormMain().GetTreeView().SelectedNode);

                //maj du status strip
                TSSController = new ToolStatusStripController(Form.GetFormMain().GetToolStatusStrip("Marques"));
                TSSController.ChangeNumber(MarquesD.CountAllMarques());
            }

            if (TypeAjouter.Equals("Familles"))
            {
                AjouterFamille Form = (AjouterFamille)AjouterForm;

                FamillesDAO FamillesD  = new FamillesDAO(PathBdd);
                String      NouveauNom = Form.GetTextBox().Text;

                Familles Famille = new Familles(NouveauNom);
                FamillesD.AjouterFamille(Famille);

                InitializeTreeView TreeViewInit = new InitializeTreeView(Form.GetFormMain().GetTreeView());
                TreeViewInit.ConstructTree(PathBdd);

                ListViewController ListViewInit = new ListViewController(Form.GetFormMain().GetListView(), PathBdd);
                ListViewInit.LoadListView(Form.GetFormMain().GetTreeView().SelectedNode);

                //maj du status strip
                TSSController = new ToolStatusStripController(Form.GetFormMain().GetToolStatusStrip("Familles"));
                TSSController.ChangeNumber(FamillesD.CountAllFamilles());
            }

            if (TypeAjouter.Equals("SousFamilles"))
            {
                AjouterSousFamille Form = (AjouterSousFamille)AjouterForm;

                SousFamillesDAO SousFamillesD = new SousFamillesDAO(PathBdd);
                String          NouveauNom    = Form.GetTextBox().Text;

                SousFamilles SousFamille = new SousFamilles(((Familles)Form.GetComboBox().SelectedItem).GetRefFamille(), NouveauNom);
                SousFamillesD.AjouterSousFamille(SousFamille);

                InitializeTreeView TreeViewInit = new InitializeTreeView(Form.GetFormMain().GetTreeView());
                TreeViewInit.ConstructTree(PathBdd);

                ListViewController ListViewInit = new ListViewController(Form.GetFormMain().GetListView(), PathBdd);
                ListViewInit.LoadListView(Form.GetFormMain().GetTreeView().SelectedNode);

                //maj du status strip
                TSSController = new ToolStatusStripController(Form.GetFormMain().GetToolStatusStrip("SousFamilles"));
                TSSController.ChangeNumber(SousFamillesD.CountAllSousFamilles());
            }

            if (TypeAjouter.Equals("Articles"))
            {
                AjouterArticle Form = (AjouterArticle)AjouterForm;

                ArticlesDAO     ArticlesD     = new ArticlesDAO(PathBdd);
                SousFamillesDAO SousFamillesD = new SousFamillesDAO(PathBdd);

                Random        aleatoire  = new Random();
                int           Nombre     = aleatoire.Next(9999999);
                String        RefArticle = "F" + Nombre;
                List <String> Refs       = ArticlesD.GetAllArticlesRef();
                while (Refs.Contains(RefArticle))
                {
                    Nombre     = aleatoire.Next(9999999);
                    RefArticle = "F" + Nombre;
                }

                String Description    = Form.GetTextBox().Text;
                int    RefSousFamille = ((SousFamilles)Form.GetComboBoxSousFamille().SelectedItem).GetRefSousFamille();
                int    RefMarque      = ((Marques)Form.GetComboBoxMarque().SelectedItem).GetRefMarque();
                float  PrixHT         = (float)Form.GetNumericUpDownPrix().Value;
                int    Quantite       = (int)Form.GetNumericUpDown().Value;

                Articles Article = new Articles(RefArticle, Description, RefSousFamille, RefMarque, PrixHT, Quantite);

                ArticlesD.AjouterArticle(Article);

                InitializeTreeView TreeViewInit = new InitializeTreeView(Form.GetFormMain().GetTreeView());
                TreeViewInit.ConstructTree(PathBdd);

                ListViewController ListViewInit = new ListViewController(Form.GetFormMain().GetListView(), PathBdd);
                ListViewInit.LoadListView(Form.GetFormMain().GetTreeView().SelectedNode);

                //maj du status strip
                TSSController = new ToolStatusStripController(Form.GetFormMain().GetToolStatusStrip("Article"));
                TSSController.ChangeNumber(ArticlesD.CountAllArticles());
            }
        }