Exemplo n.º 1
0
 private void NewClasse()
 {
     try
     {
         cls = new ClasseCompte();
         ClearFields(1, 2);
         TxtIdClasse.Text        = cls.New("tClasse").ToString();
         BtnSaveClasse.Enabled   = true;
         BtnDeleteClasse.Enabled = false;
     }
     catch (InvalidOperationException ex)
     {
         MessageBox.Show("Une erreur est survenue pendant l'opération ! " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     catch (System.Data.SqlClient.SqlException ex)
     {
         MessageBox.Show("Une erreur est survenue pendant l'opération ! " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Une erreur est survenue pendant l'opération ! " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     finally
     {
         if (ImplementConnection.Instance.Conn != null)
         {
             if (ImplementConnection.Instance.Conn.State == System.Data.ConnectionState.Open)
             {
                 ImplementConnection.Instance.Conn.Close();
             }
         }
     }
 }
Exemplo n.º 2
0
        private void ControleClasse(bool save)
        {
            try
            {
                if (save)
                {
                    if (IsNotEmpty(1, 2))
                    {
                        cls = new ClasseCompte
                        {
                            Id             = Convert.ToInt32(TxtIdClasse.Text),
                            Designation    = TxtDesignClasse.Text,
                            Numero         = Convert.ToInt32(TxtNumClasse.Text),
                            RefCategClasse = _idRefCategClasse
                        };

                        cls.Save(cls);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(TxtIdClasse.Text))
                    {
                        cls = new ClasseCompte
                        {
                            Id             = Convert.ToInt32(TxtIdClasse.Text),
                            Designation    = TxtDesignClasse.Text,
                            Numero         = Convert.ToInt32(TxtNumClasse.Text),
                            RefCategClasse = _idRefCategClasse
                        };

                        cls.Delete(cls.Id);
                    }
                }

                LoadComboBox(2);
                LoadGridControle(2);
                ClearFields(1, 2);
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show("Une erreur est survenue pendant l'opération ! " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show("Une erreur est survenue pendant l'opération ! " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Une erreur est survenue pendant l'opération ! " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                if (ImplementConnection.Instance.Conn != null)
                {
                    if (ImplementConnection.Instance.Conn.State == System.Data.ConnectionState.Open)
                    {
                        ImplementConnection.Instance.Conn.Close();
                    }
                }
            }
        }