コード例 #1
0
        public static void DeleteBonCmd(Bon_Cmd facture)
        {
            SqlConnection sqlConnection = new SqlConnection(constr);

            sqlConnection.Open();
            String     command    = "DELETE FROM " + table + " WHERE Id=@id ;";
            SqlCommand sqlCommand = new SqlCommand(command, sqlConnection);

            using (sqlCommand)
            {
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.Parameters.AddWithValue("@id", facture.getId());
                sqlCommand.ExecuteNonQuery();
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
        }
コード例 #2
0
        public static void AddBonCmd(Bon_Cmd bon_Cmd)
        {
            SqlConnection sqlConnection = new SqlConnection(constr);

            sqlConnection.Open();
            String command = "INSERT INTO " + table + " VALUES(@Id , @num  ,@fournisseur " +
                             ",@produit ,@prix,@date, @pretID" +
                             ",@Demand);";
            SqlCommand sqlCommand = new SqlCommand(command, sqlConnection);

            using (sqlCommand)
            {
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.Parameters.AddWithValue("@Id", bon_Cmd.getId());
                sqlCommand.Parameters.AddWithValue("@num", bon_Cmd.getNum());
                sqlCommand.Parameters.AddWithValue("@date", bon_Cmd.getDate());
                sqlCommand.Parameters.AddWithValue("@fournisseur", bon_Cmd.GetFournisseur().Id);
                if (bon_Cmd.getprets_id() != 0)
                {
                    sqlCommand.Parameters.AddWithValue("@pretID", bon_Cmd.getprets_id());
                }
                else
                {
                    sqlCommand.Parameters.AddWithValue("pretID", DBNull.Value);
                }
                sqlCommand.Parameters.AddWithValue("@produit", bon_Cmd.getproduit());
                if (bon_Cmd.getdemand_id() != 0)
                {
                    sqlCommand.Parameters.AddWithValue("@Demand", bon_Cmd.getdemand_id());
                }
                else
                {
                    sqlCommand.Parameters.AddWithValue("@Demand", DBNull.Value);
                }
                sqlCommand.Parameters.AddWithValue("@prix", bon_Cmd.getPrix());
                sqlCommand.ExecuteNonQuery();
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
        }