示例#1
0
        private void ajouterToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            AddSousFamille Add_Sous_Famille = new AddSousFamille();

            Add_Sous_Famille.ShowDialog(this);

            if (Add_Sous_Famille.DialogResult == DialogResult.OK)
            {
                listView_ShowBD_DataBinding();
                this.ToolStripStatusLabel.Text = "You have added a sub family!";
            }
        }
        public void AddSousFamille(String SousFamilleName, String FamilleName, AddSousFamille AddSousFamille)
        {
            if (MarquesDao.FindMarqueByMarqueName(SousFamilleName))
            {
                MessageBox.Show("This name has already been used by a Marque!", "ERROR");
                AddSousFamille.textBox_SousFamilleName.Text = "";
                return;
            }

            if (FamillesDao.FindFamilleByFamilleName(SousFamilleName))
            {
                MessageBox.Show("This name has already been used by a Famille!", "ERROR");
                AddSousFamille.textBox_SousFamilleName.Text = "";
                return;
            }

            if (SousFamillesDao.FindSousFamilleBySousFamilleName(SousFamilleName))
            {
                MessageBox.Show("SousFamille Already exsited!", "ERROR");
                AddSousFamille.textBox_SousFamilleName.Text = "";
                return;
            }
            else
            {
                if (!FamillesDao.FindFamilleByFamilleName(FamilleName))
                {
                    if (MessageBox.Show("Famille doesn't exsite! Do you want to add a new Famille?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        Familles NewFamille = new Familles(FamilleName);
                        NewFamille.RefFamille = FamillesDao.GetMaxRefFamille() + 1;
                        FamillesDao.AddFamille(NewFamille);
                        if (FamillesDao.FindFamilleByFamilleName(FamilleName))
                        {
                            MessageBox.Show("Add Famille succeed!");
                        }
                    }
                }
                SousFamilles SousFamille = new SousFamilles(SousFamilleName);
                Familles     Famille     = FamillesDao.FindFamillesByFamilleName(FamilleName);
                SousFamille.RefSousFamille = SousFamillesDao.GetMaxRefSousFamille() + 1;

                SousFamillesDao.AddSousFamille(SousFamille, Famille);

                if (SousFamillesDao.FindSousFamilleBySousFamilleName(SousFamilleName))
                {
                    MessageBox.Show("Add SousFamille succeed!");
                    AddSousFamille.Close();
                }
            }
        }
示例#3
0
        private string Add_SousFamille_ParentNode()
        {
            AddSousFamille AddSousFamille = new AddSousFamille()
            {
                StartPosition = FormStartPosition.CenterParent
            };

            AddSousFamille.label_Famille_Name.Text = TreeView.SelectedNode.Parent.Text;
            AddSousFamille.ShowDialog(this);

            if (AddSousFamille.textBox_SousFamilleName.Text != "")
            {
                SousFamilleNames.Add(AddSousFamille.textBox_SousFamilleName.Text);
            }

            return(AddSousFamille.textBox_SousFamilleName.Text);
        }
示例#4
0
        /// <summary>
        /// Add an article to the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_Add_Click(object sender, EventArgs e)
        {
            var RefArticle      = this.textBox_RefArticle.Text;
            var Description     = this.textBoxDescription.Text;
            var MarqueName      = this.comboBox_Marque.Text;
            var FamilleName     = this.comboBox_Famille.Text;
            var SousFamilleName = this.comboBox_SousFamille.Text;
            var PrixHT          = this.textBox_PrixHT.Text;
            var Quantite        = this.textBox_Quantite.Text;

            if (RefArticle == "")
            {
                MessageBox.Show("Please enter the RefArticle!", "ERROR");
            }

            else if (Description == "")
            {
                MessageBox.Show("Please enter the Description!", "ERROR");
            }

            else if (PrixHT == "")
            {
                MessageBox.Show("Please enter the Price!", "ERROR");
            }

            else if (Quantite == "")
            {
                MessageBox.Show("Please enter the Quantite!", "ERROR");
            }

            else if (MarqueName == "")
            {
                MessageBox.Show("Please enter the Marque Name!", "ERROR");
            }

            else if (FamilleName == "")
            {
                MessageBox.Show("Please enter the Famille Name!", "ERROR");
            }

            else if (SousFamilleName == "")
            {
                MessageBox.Show("Please enter the SousFamille Name!", "ERROR");
            }

            else if (RefArticle.Length >= 15)
            {
                MessageBox.Show("RefArticle is too long! The maximum length of the RefArticle is 15!");
            }

            else if (!float.TryParse(PrixHT, out var Prix))
            {
                MessageBox.Show("Please enter the right price!");
            }

            else if (!int.TryParse(Quantite, out var Number))
            {
                MessageBox.Show("Please enter the right quantity!");
            }

            else if (ArticleController.FindArticleByRefArticle(RefArticle))
            {
                MessageBox.Show("Article Already exsited!", "ERROR");
            }

            else
            {
                if (!SousFamilleController.FindSousFamilleBySousFamilleName(SousFamilleName))
                {
                    var Result = MessageBox.Show("SousFamille doesn't exsite! Do you want to add a new SousFamille?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (Result == DialogResult.OK)
                    {
                        AddSousFamille AddSousFamille = new AddSousFamille {
                            StartPosition = FormStartPosition.CenterParent
                        };
                        AddSousFamille.ShowDialog(this);
                    }
                    else
                    {
                        return;
                    }
                }
                if (!MarqueController.FindMarqueByMarqueName(MarqueName))
                {
                    var Result = MessageBox.Show("Marque doesn't exsite! Do you want to add a new Marque?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (Result == DialogResult.OK)
                    {
                        Marques NewMarque = new Marques(MarqueName);
                        NewMarque.RefMarque = MarqueDao.GetMaxRefMarque() + 1;
                        MarqueDao.AddMarque(NewMarque);
                    }
                    else
                    {
                        return;
                    }
                }

                SousFamilles SousFamille = SousFamilleController.FindSousFamillesBySousFamilleName(SousFamilleName);
                Marques      Marque      = MarqueController.FindMarquesByMarqueName(MarqueName);
                string       Price       = float.Parse(PrixHT).ToString();
                Price = Price.Replace(".", ",");
                Articles Article = new Articles(RefArticle, Description, FamilleController.FindFamillesByRefSousFamille(SousFamille.RefSousFamille), SousFamille, Marque, float.Parse(Price), int.Parse(Quantite));
                ArticleDao.AddArticle(Article);

                if (ArticleController.FindArticleByRefArticle(RefArticle))
                {
                    MessageBox.Show("Add Article succeed!");
                    this.Close();
                }
            }
        }
示例#5
0
        public void FindAndModifyArticle(String RefArticle, String Description, String MarqueName, String FamilleName, String SousFamilleName, String PrixHT, String Quantite, ModifyArticle Form)
        {
            if (Description == "")
            {
                MessageBox.Show("Please enter the Description!", "ERROR");
            }

            else if (MarqueName == "")
            {
                MessageBox.Show("Please enter the Marque Name!", "ERROR");
            }

            else if (FamilleName == "")
            {
                MessageBox.Show("Please enter the Famille Name!", "ERROR");
            }

            else if (SousFamilleName == "")
            {
                MessageBox.Show("Please enter the SousFamille Name!", "ERROR");
            }

            else if (PrixHT == "")
            {
                MessageBox.Show("Please enter the Price!", "ERROR");
            }

            else if (Quantite == "")
            {
                MessageBox.Show("Please enter the Quantite!", "ERROR");
            }

            else if (!PrixHT.Contains(","))
            {
                MessageBox.Show("In our software, you must enter a price with ',' instead of '.'. If you want to enter an integer, please enter like '5,0'.");
            }

            else if (!int.TryParse(Quantite, out var Number))
            {
                MessageBox.Show("Please enter the right quantity!");
            }

            else
            {
                if (!SousFamillesDao.FindSousFamilleBySousFamilleName(SousFamilleName))
                {
                    if (MessageBox.Show("SousFamille doesn't exsite! Do you want to add a new SousFamille?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        AddSousFamille AddSousFamille = new AddSousFamille {
                            StartPosition = FormStartPosition.CenterParent
                        };
                        AddSousFamille.ShowDialog(Form);
                    }
                    else
                    {
                        return;
                    }
                }
                if (!MarquesDao.FindMarqueByMarqueName(MarqueName))
                {
                    if (MessageBox.Show("Marque doesn't exsite! Do you want to add a new Marque?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        AddMarque AddMarque = new AddMarque {
                            StartPosition = FormStartPosition.CenterParent
                        };
                        AddMarque.ShowDialog(Form);
                    }
                    else
                    {
                        return;
                    }
                }

                SousFamilles SousFamille = SousFamillesDao.FindSousFamillesBySousFamilleName(SousFamilleName);
                Marques      Marque      = MarquesDao.FindMarquesByMarqueName(MarqueName);

                Articles Article = new Articles(RefArticle, Description, FamillesDao.FindFamillesByRefSousFamille(SousFamille.RefSousFamille), SousFamille, Marque, double.Parse(PrixHT), int.Parse(Quantite));

                if (!CompareArticles(ArticlesDao.FindArticlesByRefArticle(Article.RefArticle), Article))
                {
                    ArticlesDao.ModifyArticle(Article);
                    if (ArticlesDao.FindArticleByRefArticle(Article.RefArticle))
                    {
                        MessageBox.Show("Modify succeed!");
                        Form.Close();
                    }
                }
                else
                {
                    MessageBox.Show("The article can't be the same before and after modification!");
                    return;
                }
            }
        }
示例#6
0
        public void AddArticle(String RefArticle, String Description, String MarqueName, String FamilleName, String SousFamilleName, String PrixHT, String Quantite, Form Form)
        {
            if (RefArticle == "")
            {
                MessageBox.Show("Please enter the RefArticle!", "ERROR");
            }

            else if (Description == "")
            {
                MessageBox.Show("Please enter the Description!", "ERROR");
            }

            else if (PrixHT == "")
            {
                MessageBox.Show("Please enter the Price!", "ERROR");
            }

            else if (Quantite == "")
            {
                MessageBox.Show("Please enter the Quantite!", "ERROR");
            }

            else if (MarqueName == "")
            {
                MessageBox.Show("Please enter the Marque Name!", "ERROR");
            }

            else if (FamilleName == "")
            {
                MessageBox.Show("Please enter the Famille Name!", "ERROR");
            }

            else if (SousFamilleName == "")
            {
                MessageBox.Show("Please enter the SousFamille Name!", "ERROR");
            }

            else if (RefArticle.Length >= 15)
            {
                MessageBox.Show("RefArticle is too long! The maximum length of the RefArticle is 15!");
            }

            else if (!PrixHT.Contains(","))
            {
                MessageBox.Show("In our software, you must enter a price with ',' instead of '.'. If you want to enter an integer, please enter like '5,0'.");
            }

            //else if (!int.TryParse(PrixHT, out var Prix))
            //  MessageBox.Show("Please enter the right price!");

            else if (!int.TryParse(Quantite, out var Number))
            {
                MessageBox.Show("Please enter the right quantity!");
            }

            else if (FindArticleByRefArticle(RefArticle))
            {
                MessageBox.Show("Article Already exsited!", "ERROR");
            }

            else
            {
                if (!SousFamillesDao.FindSousFamilleBySousFamilleName(SousFamilleName))
                {
                    var Result = MessageBox.Show("SousFamille doesn't exsite! Do you want to add a new SousFamille?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (Result == DialogResult.OK)
                    {
                        AddSousFamille AddSousFamille = new AddSousFamille {
                            StartPosition = FormStartPosition.CenterParent
                        };
                        AddSousFamille.ShowDialog(Form);
                    }
                    else
                    {
                        return;
                    }
                }
                if (!MarquesDao.FindMarqueByMarqueName(MarqueName))
                {
                    var Result = MessageBox.Show("Marque doesn't exsite! Do you want to add a new Marque?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (Result == DialogResult.OK)
                    {
                        Marques NewMarque = new Marques(MarqueName);
                        NewMarque.RefMarque = MarquesDao.GetMaxRefMarque() + 1;
                        MarquesDao.AddMarque(NewMarque);
                    }
                    else
                    {
                        return;
                    }
                }

                SousFamilles SousFamille = SousFamillesDao.FindSousFamillesBySousFamilleName(SousFamilleName);
                Marques      Marque      = MarquesDao.FindMarquesByMarqueName(MarqueName);
                Articles     Article     = new Articles(RefArticle, Description, FamillesDao.FindFamillesByRefSousFamille(SousFamille.RefSousFamille), SousFamille, Marque, double.Parse(PrixHT), int.Parse(Quantite));
                ArticlesDao.AddArticle(Article);

                if (ArticlesDao.FindArticleByRefArticle(RefArticle))
                {
                    MessageBox.Show("Add Article succeed!");
                    Form.Close();
                }
            }
        }
        /// <summary>
        /// Modify an article of the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_Modify_Click(object sender, EventArgs e)
        {
            var Description     = this.textBox_Description.Text;
            var MarqueName      = this.comboBox_Marque.Text;
            var FamilleName     = this.comboBox_Famille.Text;
            var SousFamilleName = this.comboBox_SousFamille.Text;
            var PrixHT          = this.textBox_PrixHT.Text;
            var Quantite        = this.textBox_Quantite.Text;

            if (Description == "")
            {
                MessageBox.Show("Please enter the Description!", "ERROR");
            }

            else if (MarqueName == "")
            {
                MessageBox.Show("Please enter the Marque Name!", "ERROR");
            }

            else if (FamilleName == "")
            {
                MessageBox.Show("Please enter the Famille Name!", "ERROR");
            }

            else if (SousFamilleName == "")
            {
                MessageBox.Show("Please enter the SousFamille Name!", "ERROR");
            }

            else if (PrixHT == "")
            {
                MessageBox.Show("Please enter the Price!", "ERROR");
            }

            else if (Quantite == "")
            {
                MessageBox.Show("Please enter the Quantite!", "ERROR");
            }

            else if (!float.TryParse(PrixHT, out var Prix))
            {
                MessageBox.Show("Please enter the right price!");
            }

            else if (!int.TryParse(Quantite, out var Number))
            {
                MessageBox.Show("Please enter the right quantity!");
            }

            else
            {
                if (!SousFamilleController.FindSousFamilleBySousFamilleName(SousFamilleName))
                {
                    if (MessageBox.Show("SousFamille doesn't exsite! Do you want to add a new SousFamille?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        AddSousFamille AddSousFamille = new AddSousFamille {
                            StartPosition = FormStartPosition.CenterParent
                        };
                        AddSousFamille.ShowDialog(this);
                    }
                    else
                    {
                        return;
                    }
                }
                if (!MarqueController.FindMarqueByMarqueName(MarqueName))
                {
                    if (MessageBox.Show("Marque doesn't exsite! Do you want to add a new Marque?", "Confirm Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        AddMarque AddMarque = new AddMarque {
                            StartPosition = FormStartPosition.CenterParent
                        };
                        AddMarque.ShowDialog(this);
                    }
                    else
                    {
                        return;
                    }
                }

                SousFamilles SousFamille = SousFamilleController.FindSousFamillesBySousFamilleName(SousFamilleName);
                Marques      Marque      = MarqueController.FindMarquesByMarqueName(MarqueName);
                Articles     Article     = new Articles(this.label_ReferenceArticle.Text, Description, FamilleController.FindFamillesByRefSousFamille(SousFamille.RefSousFamille), SousFamille, Marque, float.Parse(PrixHT), int.Parse(Quantite));

                if (!ArticleController.CompareArticles(ArticleController.FindArticlesByRefArticle(Article.RefArticle), Article))
                {
                    ArticleDao.ModifyArticle(Article);
                    if (ArticleController.FindArticleByRefArticle(Article.RefArticle))
                    {
                        MessageBox.Show("Modify succeed!");
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("The article can't be the same before and after modification!");
                    return;
                }
            }
        }