Esempio n. 1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (!Int32.TryParse(TBoxId.Text, out int idInt))
            {
                MessageBox.Show("ID non numérique !"); TBoxId.Focus(); return;
            }
            ;

            if (string.IsNullOrEmpty(TBoxNom.Text))
            {
                MessageBox.Show("Nom obligatoire !"); TBoxNom.Focus(); return;
            }
            ;

            if (string.IsNullOrEmpty(TBoxPrenom.Text))
            {
                MessageBox.Show("Prénom obligatoire !"); TBoxPrenom.Focus(); return;
            }
            ;

            if (!Int32.TryParse(TBoxAge.Text, out int ageInt))
            {
                MessageBox.Show("Age non numérique !"); TBoxAge.Focus(); return;
            }
            ;

            if (!Int32.TryParse(TBoxSalaire.Text, out int salaireInt))
            {
                MessageBox.Show("Salaire non numérique !"); TBoxSalaire.Focus(); return;
            }
            ;

            if (string.IsNullOrEmpty(TBoxEmail.Text))
            {
                MessageBox.Show("Email obligatoire !"); TBoxEmail.Focus(); return;
            }
            ;

            try
            {
                _societe.AddTravailleur(idInt, TBoxNom.Text, TBoxPrenom.Text, ageInt, TBoxEmail.Text, salaireInt);
            }
            catch (TravailleurExceptionValidationEmail exc)
            {
                MessageBox.Show(exc.Message);
                TBoxEmail.Focus();
                return;
            }
            catch (Exception)
            {
                throw;
            }

            this.Close();
        }
Esempio n. 2
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            //if (!Int32.TryParse(TBoxId.Text, out int idInt)) { MessageBox.Show("ID non numérique !"); TBoxId.Focus(); return; };

            if (string.IsNullOrEmpty(TBoxNom.Text))
            {
                MessageBox.Show("Nom obligatoire !"); TBoxNom.Focus(); return;
            }
            ;

            if (string.IsNullOrEmpty(TBoxPrenom.Text))
            {
                MessageBox.Show("Prénom obligatoire !"); TBoxPrenom.Focus(); return;
            }
            ;

            if (!Int32.TryParse(TBoxAge.Text, out int ageInt))
            {
                MessageBox.Show("Age non numérique !"); TBoxAge.Focus(); return;
            }
            ;

            if (!Int32.TryParse(TBoxNbrH.Text, out int nbrHInt))
            {
                MessageBox.Show("Nbr d'heures non numérique !"); TBoxNbrH.Focus(); return;
            }
            ;

            if (!Int32.TryParse(TBoxTauxH.Text, out int tauxHInt))
            {
                MessageBox.Show("Taux horaire non numérique !"); TBoxTauxH.Focus(); return;
            }
            ;

            if (string.IsNullOrEmpty(TBoxEmail.Text))
            {
                MessageBox.Show("Email obligatoire !"); TBoxEmail.Focus(); return;
            }
            ;

            try
            {
                if (string.IsNullOrEmpty(TBoxId.Text))
                {
                    TBoxId.Text = "0";
                }

                TBoxId.Text = _societe.AddTravailleur(Int32.Parse(TBoxId.Text), TBoxNom.Text, TBoxPrenom.Text, ageInt, TBoxEmail.Text, nbrHInt, tauxHInt).ToString();
            }
            catch (TravailleurExceptionValidationEmail exc)
            {
                MessageBox.Show(exc.Message);
                TBoxEmail.Focus();
                return;
            }
            catch (Exception)
            {
                throw;
            }

            //this.Close();
        }