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

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