コード例 #1
0
 public Marques FindMarquesByMarqueName(string MarqueName)
 {
     return(MarquesDao.FindMarquesByMarqueName(MarqueName));
 }
コード例 #2
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;
                }
            }
        }