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