1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| OleDbCommand command = new OleDbCommand();
command.Connection = connection;
//Création et décalartion des paramètres
command.Parameters.Add(new OleDbParameter("@Quand", OleDbType.VarChar));
command.Parameters.Add(new OleDbParameter("@Qui", OleDbType.VarChar));
command.Parameters.Add(new OleDbParameter("@Quoi", OleDbType.VarChar));
command.Parameters.Add(new OleDbParameter("@Comment", OleDbType.VarChar));
command.Parameters.Add(new OleDbParameter("@Ou", OleDbType.VarChar));
command.Parameters.Add(new OleDbParameter("@Pb", OleDbType.LongVarChar));
command.Parameters.Add(new OleDbParameter("@Solutions", OleDbType.LongVarChar));
command.Parameters.Add(new OleDbParameter("@Telem", OleDbType.Boolean));
command.Parameters.Add(new OleDbParameter("@Axi", OleDbType.Boolean));
command.Parameters.Add(new OleDbParameter("@Statut", OleDbType.VarChar));
command.Parameters.Add(new OleDbParameter("@Resolule", OleDbType.Date));
command.Parameters.Add(new OleDbParameter("@Commentaires", OleDbType.LongVarChar));
//Attribution des valeurs aux paramètres
command.Parameters["@Quand"].Value = textBox1.Text;
command.Parameters["@Qui"].Value = comboBox2.Text;
command.Parameters["@Quoi"].Value = comboBox1.Text;
command.Parameters["@Comment"].Value = comboBox3.Text;
command.Parameters["@Ou"].Value = textBox2.Text;
command.Parameters["@Pb"].Value = textBox3.Text;
command.Parameters["@Solutions"].Value = textBox4.Text;
command.Parameters["@Telem"].Value = Convert.ToBoolean(checkBox1.Checked);
command.Parameters["@Axi"].Value = Convert.ToBoolean(checkBox2.Checked);
command.Parameters["@Statut"].Value = comboBox4.Text;
dateTimePicker1.CustomFormat = "dd/MM/yyyy";
dateTimePicker1.Format = DateTimePickerFormat.Custom;
command.Parameters["@Resolule"].Value = dateTimePicker1.Text;
command.Parameters["@Commentaires"].Value = textBox6.Text;
command.CommandText = "INSERT INTO hotline (Quand,Qui,Quoi,Comment,Ou,Pb,Solutions,Telem,Axi,Statut,Resolule,Commentaires) VALUES (@Quand,@Qui,@Quoi,@Comment,@Ou,@Pb,@Solutions,@Telem,@Axi,@Statut,@Resolule,@Commentaires)";
connection.Open();
command.ExecuteNonQuery();
connection.Close();
SystemSounds.Exclamation.Play();
MessageBox.Show("Appel ajouté à HOTLINE");
this.Hide();
}
catch (Exception ex)
{
MessageBox.Show("ERREUR" + ex);
} |
Partager