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); } }
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); } }