Пример #1
0
 public Boolean modifier(Materiel m, string refe)
 {
     try
     {
         string    reference = m.getReference();
         string    des       = m.getDescription();
         string    prix      = m.getPrix();
         string    quantite  = m.getQuantite();
         string    lien      = m.getLien();
         Fabricant fab       = m.getFabricant();
         Cassier   c         = m.getCassier();
         string    req       = string.Format("update Materiel set ref='" + reference + "', description='" + des + "' , prix='" + prix + "' , quantite='" + quantite + "' , lien='" + lien + "' , nomFab='" + fab.getNom() + "' , nomCasier='" + c.getNom() + "' where ref='" + refe + "'");
         cmd.Connection = cn;
         cn.Open();
         cmd.CommandText = req;
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (SqlException ex)
     {
         System.Console.WriteLine("error :" + ex.Message);
         return(false);
     }
     finally
     {
         cn.Close();
     }
 }
Пример #2
0
 public Boolean ModifierPa(Materiel m, string refe)
 {
     try
     {
         string    reference = m.getReference();
         string    des       = m.getDescription();
         string    prix      = m.getPrix();
         string    quantite  = m.getQuantite();
         string    lien      = m.getLien();
         Fabricant fab       = m.getFabricant();
         Cassier   c         = m.getCassier();
         cn.Open();
         cmd.Connection  = cn;
         cmd.CommandText = "update Materiel set ref= @reference, description = @des, prix = @prix, quantite = @quantite, lien = @lien, nomFab = @nomFab, nomCasier=@nomCasier  where ref=@refe";
         cmd.Parameters.Add(new SqlParameter("@reference", reference));
         cmd.Parameters.Add(new SqlParameter("@des", des));
         cmd.Parameters.Add(new SqlParameter("@prix", prix));
         cmd.Parameters.Add(new SqlParameter("@quantite", quantite));
         cmd.Parameters.Add(new SqlParameter("@lien", lien));
         cmd.Parameters.Add(new SqlParameter("@nomFab", fab.getNom()));
         cmd.Parameters.Add(new SqlParameter("@nomCasier", c.getNom()));
         cmd.Parameters.Add(new SqlParameter("@refe", refe));
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (SqlException ex)
     {
         Console.WriteLine("error :" + ex);
         return(false);
     }
     finally
     {
         cn.Close();
     }
 }
Пример #3
0
 public Boolean Ajout(Materiel m)
 {
     try
     {
         string    reference = m.getReference();
         string    des       = m.getDescription();
         string    prix      = m.getPrix();
         string    quantite  = m.getQuantite();
         string    lien      = m.getLien();
         Fabricant fab       = m.getFabricant();
         Cassier   c         = m.getCassier();
         string    req       = string.Format("insert into Materiel values ('" + reference + "','" + des + "','" + prix + "','" + quantite + "','" + lien + "','" + fab.getNom() + "','" + c.getNom() + "')");
         cmd.Connection = cn;
         cn.Open();
         cmd.CommandText = req;
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (SqlException ex)
     {
         Console.WriteLine("error :" + ex.Message);
         return(false);
     }
     finally
     {
         cn.Close();
     }
 }
Пример #4
0
 public Boolean AjouterP(Materiel m)
 {
     try
     {
         string    reference = m.getReference();
         string    des       = m.getDescription();
         string    prix      = m.getPrix();
         string    quantite  = m.getQuantite();
         string    lien      = m.getLien();
         Fabricant fab       = m.getFabricant();
         Cassier   c         = m.getCassier();
         cn.Open();
         cmd.Connection  = cn;
         cmd.CommandText = "insert into Materiel values (@reference,@des,@prix,@quantite,@lien,@fab,@casier)";
         cmd.Parameters.Add(new SqlParameter("@reference", reference));
         cmd.Parameters.Add(new SqlParameter("@des", des));
         cmd.Parameters.Add(new SqlParameter("@prix", prix));
         cmd.Parameters.Add(new SqlParameter("@quantite", quantite));
         cmd.Parameters.Add(new SqlParameter("@lien", lien));
         cmd.Parameters.Add(new SqlParameter("@fab", fab.getNom()));
         cmd.Parameters.Add(new SqlParameter("@casier", c.getNom()));
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (SqlException ex)
     {
         Console.WriteLine("error :" + ex);
         return(false);
     }
     finally
     {
         cn.Close();
     }
 }