Exemple #1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            List <string> list = new List <string>();

            dataGridView1.DataSource = null;

            string wherePart = CreateWherePart(ucatAlbum, "Album");

            if (wherePart != "'None'" && wherePart.Trim().Length > 0)
            {
                list.Add(wherePart);
            }

            wherePart = CreateWherePart(ucatArtists, "artist_Name");
            if (wherePart != "'None'" && wherePart.Trim().Length > 0)
            {
                list.Add(wherePart);
            }

            wherePart = CreateWherePart(ucatComment, "Comments");
            if (wherePart != "'None'" && wherePart.Trim().Length > 0)
            {
                list.Add(wherePart);
            }

            wherePart = CreateWherePart(ucatFileName, "File_Name");
            if (wherePart != "'None'" && wherePart.Trim().Length > 0)
            {
                list.Add(wherePart);
            }

            wherePart = CreateWherePart(ucatGenre, "Genre");
            if (wherePart != "'None'" && wherePart.Trim().Length > 0)
            {
                list.Add(wherePart);
            }

            wherePart = CreateWherePart(ucatTitle, "Song_Title");
            if (wherePart != "'None'" && wherePart.Trim().Length > 0)
            {
                list.Add(wherePart);
            }

            OperationResult op = new OperationResult();

            try
            {
                wherePart = MP3DBManager.BuildSearchWhereClause(list, rbAnd.Checked);


                MP3DBManager mdbmgr = new MP3DBManager();

                mdbmgr.SetDataStore(ddtbMp3DbFile.ItemText, ref op);
                Dictionary <string, string> parms = new Dictionary <string, string>();
                parms.Add("Where_Clause", wherePart);


                DataTable dt = mdbmgr.RunSqlScript(ref parms, SqlScriptEnum.GetMP3Data_EnterWhereClause, ref op);

                if (op.Success)
                {
                    dataGridView1.DataSource = dt;
                }
            }
            catch (Exception ex)
            {
                op.AddException(ex);
                rtbMessages.Text = op.GetAllErrorsAndExceptions("\n");
                return;
            }
        }
Exemple #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            dataGridView1.DataSource = null;
            rtbMessages.Text         = "";



            if (!MP3DBExists())
            {
                rtbMessages.Text = "Database file does not exists";
                return;
            }

            List <string> list = new List <string>();

            string wherePart = CreateWherePart(ftAlbum, "Album");

            if (wherePart.Trim().Length > 0)
            {
                list.Add(wherePart);
            }

            wherePart = CreateWherePart(ftArtist, "artist_Name");
            if (wherePart.Trim().Length > 0)
            {
                list.Add(wherePart);
            }

            wherePart = CreateWherePart(ftComment, "Comments");
            if (wherePart.Trim().Length > 0)
            {
                list.Add(wherePart);
            }

            wherePart = CreateWherePart(ftFileName, "File_Name");
            if (wherePart.Trim().Length > 0)
            {
                list.Add(wherePart);
            }

            wherePart = CreateWherePart(ftGenre, "Genre");
            if (wherePart.Trim().Length > 0)
            {
                list.Add(wherePart);
            }

            wherePart = CreateWherePart(ftTitle, "Song_Title");
            if (wherePart.Trim().Length > 0)
            {
                list.Add(wherePart);
            }

            OperationResult op = new OperationResult();

            try
            {
                wherePart = MP3DBManager.BuildSearchWhereClause(list, rbAnd.Checked);


                MP3DBManager mdbmgr = new MP3DBManager();

                mdbmgr.SetDataStore(ddtbMp3DbFile.ItemText, ref op);
                Dictionary <string, string> parms = new Dictionary <string, string>();
                parms.Add("Where_Clause", wherePart);


                DataTable dt = mdbmgr.RunSqlScript(ref parms, SqlScriptEnum.GetMP3Data_EnterWhereClause, ref op);

                if (op.Success)
                {
                    dataGridView1.DataSource = dt;
                    int count = 0;

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        count = dt.Rows.Count;
                    }
                    rtbMessages.Text = $"Search Results - {count}";
                }
                else
                {
                    rtbMessages.Text = op.GetAllErrorsAndExceptions("\n");
                    return;
                }
            }
            catch (Exception ex)
            {
                op.AddException(ex);
                rtbMessages.Text = op.GetAllErrorsAndExceptions("\n");
                return;
            }
        }