Пример #1
0
        public void AddMarque(String MarqueName, AddMarque AddMarque)
        {
            if (FamillesDao.FindFamilleByFamilleName(MarqueName))
            {
                MessageBox.Show("This name has already been used by a Famille!", "ERROR");
                AddMarque.textBox_MarqueName.Text = "";
                return;
            }

            if (SousFamillesDao.FindSousFamilleBySousFamilleName(MarqueName))
            {
                MessageBox.Show("This name has already been used by a SousFamille!", "ERROR");
                AddMarque.textBox_MarqueName.Text = "";
                return;
            }

            if (MarquesDao.FindMarqueByMarqueName(MarqueName))
            {
                MessageBox.Show("Marque Already exsited!", "ERROR");
                AddMarque.textBox_MarqueName.Text = "";
                return;
            }
            else
            {
                Marques Marque = new Marques(MarqueName);
                Marque.RefMarque = MarquesDao.GetMaxRefMarque() + 1;
                MarquesDao.AddMarque(Marque);
                if (MarquesDao.FindMarqueByMarqueName(MarqueName))
                {
                    MessageBox.Show("Add Marque succeed!");
                    AddMarque.Close();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Add a marque to the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_Add_Click(object sender, EventArgs e)
        {
            var MarqueName = this.textBox_MarqueName.Text;

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

            if (MarqueName == "Familles")
            {
                MessageBox.Show("MarqueName can't be Familles!", "ERROR");
                this.textBox_MarqueName.Text = "";
                return;
            }

            if (MarqueName == "Marques")
            {
                MessageBox.Show("MarqueName can't be Marques!", "ERROR");
                this.textBox_MarqueName.Text = "";
                return;
            }

            if (MarqueName == "Familles")
            {
                MessageBox.Show("MarqueName can't be Familles!", "ERROR");
                this.textBox_MarqueName.Text = "";
                return;
            }

            if (MarqueName == "Tous les articles")
            {
                MessageBox.Show("MarqueName can't be Tous les articles!", "ERROR");
                this.textBox_MarqueName.Text = "";
                return;
            }

            if (FamilleController.FindFamilleByFamilleName(MarqueName))
            {
                MessageBox.Show("This name has already been used by a Famille!", "ERROR");
                this.textBox_MarqueName.Text = "";
                return;
            }

            if (SousFamilleController.FindSousFamilleBySousFamilleName(MarqueName))
            {
                MessageBox.Show("This name has already been used by a SousFamille!", "ERROR");
                this.textBox_MarqueName.Text = "";
                return;
            }

            if (MarqueController.FindMarqueByMarqueName(MarqueName))
            {
                MessageBox.Show("Marque Already exsited!", "ERROR");
                this.textBox_MarqueName.Text = "";
                return;
            }
            else
            {
                Marques Marque = new Marques(MarqueName);
                Marque.RefMarque = MarqueDao.GetMaxRefMarque() + 1;
                MarqueDao.AddMarque(Marque);
                if (MarqueController.FindMarqueByMarqueName(MarqueName))
                {
                    MessageBox.Show("Add Marque succeed!");
                    this.Close();
                }
            }
        }
Пример #3
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();
                }
            }
        }
Пример #4
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();
                }
            }
        }