private void ajouter() { int fr_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(idFournisseur) from fournisseur"; connection.Open(); fr_code = Convert.ToInt32(cmd.ExecuteScalar()) + 1; connection.Close(); } Form a = new AjouterFournisseur(Convert.ToString(fr_code), this); a.Show(); ac.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Erreur", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } }
private void ajouter() { int fr_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(idFournisseur) from fournisseur"; connection.Open(); fr_code = Convert.ToInt32(cmd.ExecuteScalar()) + 1; connection.Close(); } Form a = new AjouterFournisseur(Convert.ToString(fr_code),this); a.Show(); ac.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Erreur", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } }