/// <summary>
        /// Initializes a new instance of the <see cref="SimplePlaceExecuter"/> class.
        /// </summary>
        /// <param name="db">The database.</param>
        /// <param name="placeName">Name of the place.</param>
        /// <param name="artistName">Name of the artist.</param>
        public SimplePlaceExecuter(DataBaseConnector db, string placeName, string artistName)
        {
            this.conn = db;
            bool placePresent  = !placeName.Equals(string.Empty);
            bool artistPresent = !artistName.Equals(string.Empty);

            this.command = IKnowWhatIWantQuriesBank.GetPlaceQuery(this.conn.Connection, artistPresent, placePresent);
            if (placePresent)
            {
                command.Parameters["@placeName"].Value = "%" + placeName + "%";
            }
            if (artistPresent)
            {
                command.Parameters["@artistName"].Value = "%" + artistName + "%";
            }
        }
Example #2
0
 public bool SetQuery(string songName, string artistName, int fromYear, int toYear)
 {
     try
     {
         bool songNamePresent   = !songName.Equals(string.Empty);
         bool artistNamePresent = !artistName.Equals(string.Empty);
         this.command = IKnowWhatIWantQuriesBank.GetArtistQuery(artistNamePresent, songNamePresent, this.conn.Connection);
         if (songNamePresent)
         {
             command.Parameters["@songName"].Value = "%" + songName + "%";
         }
         if (artistNamePresent)
         {
             command.Parameters["@artistName"].Value = "%" + artistName + "%";
         }
         command.Parameters["@fromYear"].Value = fromYear;
         command.Parameters["@toYear"].Value   = toYear;
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }