Professional Documents
Culture Documents
{
public SqlConnection cnx =new SqlConnection ();
public SqlCommand cmd=new SqlCommand ();
public SqlDataReader dr;
public DataTable dt = new DataTable ();
}
public void deconneter()
{
if (cnx.State == ConnectionState.Open)
{
cnx.Close();
}
}
}
}
public bool Ajouter()
{
if(nombre() == 0)
{
d.cmd.CommandText="insert into Employé values('"+textBox1.Text +
"','" + textBox2.Text+ "','" + textBox3.Text + "','" + textBox4.Text + "','" +
textBox5.Text + "','"+dateTimePicker1.Value +"')";
d.cmd.Connection=d.cnx;
d.cmd.ExecuteNonQuery();
return true;
}
return false;
}
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" ||
textBox4.Text == "" || textBox5.Text == ""|| textBox6.Text== "")
{
MessageBox.Show("remplir");
return;
}
if (Ajouter() == true)
{
MessageBox.Show("ajouter avec succes");
}
else
{
MessageBox.Show("existe deja");
}