コード例 #1
0
        private void ajouter()
        {
            int fa_code = 1;

            try
            {
                if (dataGridView1.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(numero_Facture) from facture";
                    connection.Open();
                    fa_code = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
                    connection.Close();
                }
                Form a = new AjouterFacture(Convert.ToString(fa_code), this, ac);
                a.Show();
                ac.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erreur", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
ファイル: Factures.cs プロジェクト: judaHa/dotNETApplications
 private void ajouter()
 {
     int fa_code=1;
     try
     {
         if (dataGridView1.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(numero_Facture) from facture";
             connection.Open();
             fa_code = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
             connection.Close();
         }
         Form a = new AjouterFacture(Convert.ToString(fa_code),this,ac);
         a.Show();
         ac.Enabled = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Erreur", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
     }
 }