public void ajouter()
        {
            int cma_code = 1;

            try
            {
                if (dgvCommAchat.Rows.Count != 0)
                {
                    string          MyConString = "SERVER=localhost;" + "DATABASE=gestioncommerciale;" + "UID=root;" + "PASSWORD=freedomity;";
                    MySqlConnection connection  = new MySqlConnection(MyConString);
                    MySqlCommand    cmd         = connection.CreateCommand();
                    cmd.CommandText = "select max(cma_code) from commandeachat";
                    connection.Open();
                    cma_code = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
                    connection.Close();
                }
                Form aca = new AjouterCommandeAchat(Convert.ToString(cma_code), this, ac);
                aca.Show();
                ac.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erreur", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }
 public void ajouter()
 {
     int cma_code = 1;
     try
     {
         if (dgvCommAchat.Rows.Count != 0)
         {
             string MyConString = "SERVER=localhost;" + "DATABASE=gestioncommerciale;" + "UID=root;" + "PASSWORD=freedomity;";
             MySqlConnection connection = new MySqlConnection(MyConString);
             MySqlCommand cmd = connection.CreateCommand();
             cmd.CommandText = "select max(cma_code) from commandeachat";
             connection.Open();
             cma_code = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
             connection.Close();
         }
         Form aca = new AjouterCommandeAchat(Convert.ToString(cma_code),this,ac);
         aca.Show();
         ac.Enabled = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Erreur", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
     }
 }