Example #1
0
        public void btn_carre_Click(object sender, EventArgs e)
        {
            try
            {
                if (monResultat == null)
                {
                    monResultat           = new Carre();
                    monResultat.Operande1 = decimal.Parse(temp);
                }
                else if (monResultat.Operande1.HasValue)
                {
                    monResultat.Operande2 = decimal.Parse(temp);
                    temp                  = monResultat.Calculer().ToString();
                    monResultat           = new Carre();
                    monResultat.Operande1 = decimal.Parse(temp);
                    zt_Write.Text         = temp;
                    zt_Write.Text         = temp;
                }

                zt_Write.Text     += "^";
                temp               = string.Empty;
                this.ActiveControl = null;
            }
            catch (FormatException)
            {
                MessageBox.Show("Mauvaise manipulation de votre part, vérifiez votre saisie");
                monResultat = null;
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("Opérations sans opérandes est impossible!");
                monResultat = null;
            }
        }
Example #2
0
 public void btn_racine_Click(object sender, EventArgs e)
 {
     try {
         if (monResultat == null)
         {
             monResultat           = new RacineCarre();
             monResultat.Operande1 = decimal.Parse(temp);
             btn_equal_Click(btn_equal, new EventArgs());
             zt_Write.Text = temp;
             zt_read.Text  = temp;
         }
         else if (monResultat.Operande1.HasValue)
         {
             temp                  = monResultat.Calculer().ToString();
             monResultat           = new RacineCarre();
             monResultat.Operande1 = decimal.Parse(temp);
             zt_Write.Text         = temp;
             zt_read.Text          = temp;
             btn_equal_Click(btn_equal, new EventArgs());
         }
         this.ActiveControl = null;
     }
     catch (ArgumentNullException)
     {
         MessageBox.Show("Racine carré de valeur null est impossible");
         monResultat = null;
     }
     catch (FormatException)
     {
         MessageBox.Show("Mauvaise manipulation de votre part, vérifiez votre saisie");
         monResultat = null;
     }
 }
Example #3
0
        public void btn_equal_Click(object sender, EventArgs e)
        {
            try
            {
                monResultat.Operande2 = decimal.Parse(temp);
                this.ActiveControl    = null;
                decimal var1 = monResultat.Calculer();
                zt_read.Text = var1.ToString();
                temp         = zt_read.Text;
                monResultat  = null;

                zt_Write.Text = temp;
                zt_read.Text  = temp;
            }
            catch (DivideByZeroException)
            {
                MessageBox.Show("Division par zero est impossible...");
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("Racine carré de valeur null est impossible");
            }
            catch (FormatException)
            {
                MessageBox.Show("Traitement sans valeur est impossible...");
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Mauvaise manipulation de votre part, double égal est impossible!");
            }
        }
Example #4
0
 public void btn_reset_Click(object sender, EventArgs e)
 {
     zt_Write.Text      = null;
     zt_read.Text       = null;
     this.ActiveControl = null;
     temp        = string.Empty;
     monResultat = null;
 }
Example #5
0
        public void btn_divise_Click(object sender, EventArgs e)
        {
            try
            {
                if (monResultat == null)
                {
                    monResultat           = new Diviser();
                    monResultat.Operande1 = decimal.Parse(temp);
                }
                else if (monResultat.Operande1.HasValue)
                {
                    monResultat.Operande2 = decimal.Parse(temp);
                    if (monResultat.Operande2 == 0)
                    {
                        MessageBox.Show("Division par zero est impossible");
                    }
                    else
                    {
                        temp                  = monResultat.Calculer().ToString();
                        monResultat           = new Diviser();
                        monResultat.Operande1 = decimal.Parse(temp);
                        zt_Write.Text         = temp;
                        zt_read.Text          = temp;
                    }
                }

                zt_Write.Text     += "/";
                temp               = string.Empty;
                this.ActiveControl = null;
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("Sans operandes l'operation est impossible");
                monResultat = null;
            }
            catch (FormatException)
            {
                MessageBox.Show("Mauvaise manipulation de votre part, vérifiez votre saisie");
                monResultat = null;
            }
        }
Example #6
0
 public void btn_reset_Click(object sender, EventArgs e)
 {
     zt_Write.Text = null;
     zt_read.Text = null;
     this.ActiveControl = null;
     temp = string.Empty;
     monResultat = null;
 }
Example #7
0
        public void btn_racine_Click(object sender, EventArgs e)
        {
            try {
                if (monResultat == null)
                {

                    monResultat = new RacineCarre();
                    monResultat.Operande1 = decimal.Parse(temp);
                    btn_equal_Click(btn_equal, new EventArgs());
                    zt_Write.Text = temp;
                    zt_read.Text = temp;

                }
                else if (monResultat.Operande1.HasValue)
                {
                    temp = monResultat.Calculer().ToString();
                    monResultat = new RacineCarre();
                    monResultat.Operande1 = decimal.Parse(temp);
                    zt_Write.Text = temp;
                    zt_read.Text = temp;
                    btn_equal_Click(btn_equal, new EventArgs());
                }
                this.ActiveControl = null;
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("Racine carré de valeur null est impossible");
                monResultat = null;
            }
            catch (FormatException)
            {
                MessageBox.Show("Mauvaise manipulation de votre part, vérifiez votre saisie");
                monResultat = null;
            }
        }
Example #8
0
        public void btn_multi_Click(object sender, EventArgs e)
        {
            try
            {
                if (monResultat == null)
                {
                    monResultat = new Multiplier();
                    monResultat.Operande1 = decimal.Parse(temp);
                }
                else if (monResultat.Operande1.HasValue)
                {
                    monResultat.Operande2 = decimal.Parse(temp);
                    temp = monResultat.Calculer().ToString();
                    monResultat = new Multiplier();
                    monResultat.Operande1 = decimal.Parse(temp);
                    zt_Write.Text = temp;
                    zt_read.Text = temp;
                }

                zt_Write.Text += "*";
                temp = string.Empty;
                this.ActiveControl = null;
            }
            catch(ArgumentNullException)
            {
                MessageBox.Show("Sans operandes l'operation est impossible");
                monResultat = null;
            }
            catch (FormatException)
            {
                MessageBox.Show("Mauvaise manipulation de votre part, vérifiez votre saisie");
                monResultat = null;
            }
        }
Example #9
0
        public void btn_equal_Click(object sender, EventArgs e)
        {
            try
            {
                monResultat.Operande2 = decimal.Parse(temp);
                this.ActiveControl = null;
                decimal var1 = monResultat.Calculer();
                zt_read.Text = var1.ToString();
                temp = zt_read.Text;
                monResultat = null;

                zt_Write.Text = temp;
                zt_read.Text = temp;
            }
            catch(DivideByZeroException)
            {
                MessageBox.Show("Division par zero est impossible...");
            }
            catch(ArgumentNullException)
            {
                MessageBox.Show("Racine carré de valeur null est impossible");
            }
            catch(FormatException)
            {
                MessageBox.Show("Traitement sans valeur est impossible...");
            }
            catch(NullReferenceException)
            {
                MessageBox.Show("Mauvaise manipulation de votre part, double égal est impossible!");
            }
        }