Пример #1
0
        /// <summary>
        /// Créer la marque lorsque l'on clique sur le bouton valider
        /// </summary>
        /// <param name="Sender"></param>
        /// <param name="Event"></param>
        private void OkButton_Click(object Sender, EventArgs Event)
        {
            int IntRef;

            if (int.TryParse(RefTextBox.Text, out IntRef))
            {
                if (NameTextBox.Text != "")
                {
                    if (BrandDAO.GetBrandById(IntRef) == null)
                    {
                        Brand NewBrand = new Brand(IntRef, NameTextBox.Text);
                        BrandDAO.AddBrand(NewBrand);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Ref existe déjà", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Les champs doivent etre remplient", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Référence doit etre un chiffre", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        /// <summary>
        /// Créé une nouvelle marque à partir de son nom
        /// </summary>
        /// <param name="NameBrandToSet"></param>
        public Brand(String NameBrandToSet)
        {
            NameBrand = NameBrandToSet;
            RefBrand  = -1;

            int TestRef = -1;

            // Recherche d'un id inutilisé
            while (RefBrand == -1)
            {
                TestRef++;

                if (BrandDAO.GetBrandById(TestRef) == null)
                {
                    RefBrand = TestRef;
                }
            }
        }
Пример #3
0
        public Brand GetBrandById(int Id)
        {
            BrandDAO brandDAO = new BrandDAO();

            return(brandDAO.GetBrandById(Id));
        }