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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
//Méthode Ajouter
public Boolean ajouter()
{
//Déclaration de la variable SqlCommand
try
{
sqlconnection maConnexionSQLsrv;
sqlcommand myCommand;
string maRequete, ConnexionSQL;
maRequete = "insert into CLIENT values ('" & codeclt & "', '" & code_type_clt & "', " & nomconcerne & ", " & prenomconcerne & "," & & ", " & raisonsocial_clt & ", '" & adresseclt & "', '" & emailclt & "')";
//Exécution de la requète Ajouter
myCommand.Connection.Open();
int var = myCommand.ExecuteNonQuery();
if (var != 0)
{
return true;
}
}
catch (Exception r)
{
Console.WriteLine("L'erreur suivante a été rencontrée :" + r.Message);
return false;
}
}
//methode modifier
public Boolean modifier()
{
//Déclaration de la variable SqlCommand
string strConnexion = "Data Source=localhost; Integrated Security=SSPI;" + "Initial Catalog= facturation2";
try
{
//Affectation des paramètres de la variable SqlCommand
SqlConnection maConnexionSQLsrv;
SqlCommand myCommand;
string maRequete, ConnexionSQL;
maRequete = "UPDATE CLIENT SET [code_type_client]='" & code_type_clt & "', [nom_conc]='" & nomconcerne & "' ,[prenom_conc]='" & prenomconcerne & "',[raison_social]='" & raisonsocial_clt & "', [tel]= '" & telclt & "', [adresse]= '" & adresseclt & "', [Email]= '" & emailclt & "' WHERE [cod_clt] = '" & codeclt & "'";
//Exécution de la requète Modifier
myCommand.Connection.Open();
int var = myCommand.ExecuteNonQuery();
if (var != 0)
{
return true;
}
}
catch (Exception r)
{
Console.WriteLine("L'erreur suivante a été rencontrée :" + r.Message);
return false;
}
}
//méthode supprimer
public Boolean supprimer()
{
//Déclaration de la variable SqlCommand
string strConnexion = "Data Source=localhost; Integrated Security=SSPI;" + "Initial Catalog=aa";
try
{
string requete = "Delete from CLIENT where [cod_clt] = '" & codeclt & "'";
SqlCommand sqlcommand = new SqlCommand(requete, new SqlConnection(strConnexion));
sqlcommand.Connection.Open();
int confirm = sqlcommand.ExecuteNonQuery();
if (confirm != 0)
{ return true; }
}
catch (Exception r)
{
Console.WriteLine("L'erreur suivante a été rencontrée :" + r.Message);
return false;
} |
Partager