Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            ValidateAdherent();
            ValidateBudget();
            ValidateDate();
            ValidateFlux();
            ValidateMontant();
            ValidatePrelev();
            ValidateTypeflux();

            bool montant = textBox2.Text.All(char.IsDigit);

            if (String.IsNullOrEmpty(dateTimePicker1.Text) == true || String.IsNullOrEmpty(textBox1.Text) == true || String.IsNullOrEmpty(textBox2.Text) == true ||
                String.IsNullOrEmpty(comboBox1.Text) == true || String.IsNullOrEmpty(comboBox2.Text) == true ||
                String.IsNullOrEmpty(comboBox3.Text) == true || String.IsNullOrEmpty(etatPrelev.Text) == true || !montant)
            {
                MessageBox.Show("Veuillez remplir tous les champs");
            }
            else
            {
                string   dateInput           = dateTimePicker1.Text;
                string   libelle             = textBox1.Text;
                float    montantFlux         = float.Parse(textBox2.Text);
                var      parsedDateNaissance = DateTime.Parse(dateInput);
                int      idAdherent          = (int)comboBox1.SelectedValue;
                int      idTypeflux          = (int)comboBox2.SelectedValue;
                int      idBudget            = (int)comboBox3.SelectedValue;
                string   etatPrelevement     = etatPrelev.Text;
                DateTime thisDay             = DateTime.Today;
                Flux     unFlux = new Flux(libelle, parsedDateNaissance, montantFlux, idAdherent, idTypeflux, idBudget, etatPrelevement);
                GestionFlux.AjoutFlux(unFlux);
                this.Close();
            }
        }
        private void btnEnregistrer_Click(object sender, EventArgs e)
        {
            int montantFlux = 0;
            int idAdherent  = ' ';
            int idBudget    = ' ';

            if (txtLibelle.Text == " ")
            {
                MessageBox.Show("Erreur votre champ est vide." +
                                " Veuillez saisir un nom", "Erreur"
                                , MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (txtMontant.Text == " ")
            {
                MessageBox.Show("Erreur votre champ est vide. " +
                                "Veuillez saisir un montant", "Erreur"
                                , MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                montantFlux = (int)Int32.Parse(txtMontant.Text);
            }

            if (lstAdherent.SelectedIndex == ' ')
            {
                MessageBox.Show("Erreur votre champ est vide. " +
                                "Veuillez selectionner un adherent", "Erreur"
                                , MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                idAdherent = lstAdherent.SelectedIndex;
            }

            if (lstBudget.SelectedIndex == ' ')
            {
                MessageBox.Show("Erreur votre champ est vide. " +
                                "Veuillez selectionner un budget", "Erreur"
                                , MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                idBudget = lstBudget.SelectedIndex;
            }

            Flux unFlux = new Flux(txtLibelle.Text, montantFlux, idAdherent, idTypeFlux, idBudget);

            GestionFlux.AjoutFlux(unFlux);

            Form.ActiveForm.Close();
        }