Home >php教程 >php手册 >MyKTV project summary

MyKTV project summary

WBOY
WBOYOriginal
2016-07-06 13:30:362240browse

Project name: KTV song request system - Instructor Yuan Yuming finally completed my KTV project after more than a week. To be honest, I gained a lot from doing this project, and there were many difficulties. However, After many hardships, I finally came through. Not simple! This project is mainly divided into front and backend. The main functions implemented by the front desk are: song requests from singers, pinyin

                                                                                                                                                                    --Instructor Yuan Yuming

After more than a week, I finally completed my

KTV project. To be honest, I gained a lot from doing this project, and there were many difficulties. But after many hardships, I finally succeeded. It's coming. Not simple!

This project is mainly divided into front and backend. The main functions implemented by the front desk are: singer song request, pinyin song request, character number song request,

Genre selection, golden song ranking, some cut songs, duets, list of ordered songs, these are the main functions.

The main functions implemented in the background are: adding singers, adding songs, modifying song paths, and modifying singer picture paths.

First look at the front desk:

Frontend core class:

SqlHelper

class (responsible for connecting to the database):

KtvHelper

class (
 <span style="color: #008000;">//</span><span style="color: #008000;">连接字符串</span>
       <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> str = <span style="color: #800000;">"</span><span style="color: #800000;">Data Source=HYJ-PC;Initial Catalog=MyKTV;User ID=sa;pwd=123</span><span style="color: #800000;">"</span>;
directory where songs are saved; directory where singer pictures are saved)

Song class (song information and a switch to achieve song status(

Played
 <span style="color: #008000;">//</span><span style="color: #008000;">保存歌曲的目录</span>
       <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> songURL = <span style="color: #800000;">""</span><span style="color: #000000;">;
       </span><span style="color: #008000;">//</span><span style="color: #008000;">保存歌手图片的目录</span>
 <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> singer_photoURL = <span style="color: #800000;">""</span><span style="color: #000000;">;
FrmByValue类(窗体对象之间的传值)
  </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span><span style="color: #000000;"> frmsonglist frmsl;

       </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span><span style="color: #000000;"> FrmMain frM;

       </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> SelectedSong ss;

;Not played; Replay;Cut song)):

PlayList class (plays the core content of songs, functions

(
 <span   style="max-width:90%">//</span><span style="color: #008000;">定义一个枚举:歌曲播放状态</span>
   <span style="color: #0000ff;">public</span>  <span style="color: #0000ff;">enum</span><span style="color: #000000;"> SongPlayState
    {
        unplayed, played, newplayed, cut

    }
  </span><span style="color: #0000ff;">public</span>  <span style="color: #0000ff;">class</span><span style="color: #000000;"> Song
  {

      </span><span style="color: #0000ff;">public</span>  <span style="color: #0000ff;">string</span><span style="color: #000000;"> SongName
      {
          </span><span style="color: #0000ff;">get</span> { <span style="color: #0000ff;">return</span><span style="color: #000000;"> songName; }
          </span><span style="color: #0000ff;">set</span> { songName =<span style="color: #000000;"> value; }
      }
      </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">string</span><span style="color: #000000;"> SongURL
      {
          </span><span style="color: #0000ff;">get</span> { <span style="color: #0000ff;">return</span><span style="color: #000000;"> songURL; }
          </span><span style="color: #0000ff;">set</span> { songURL =<span style="color: #000000;"> value; }
      }

      </span><span style="color: #0000ff;">internal</span><span style="color: #000000;"> SongPlayState Playseat
      {
          </span><span style="color: #0000ff;">get</span> { <span style="color: #0000ff;">return</span><span style="color: #000000;"> playseat; }
          </span><span style="color: #0000ff;">set</span> { playseat =<span style="color: #000000;"> value; }
      }

      </span><span style="color: #0000ff;">PRivate</span> <span style="color: #0000ff;">string</span> songName;<span style="color: #008000;">//</span><span style="color: #008000;">歌曲名称字段</span>
      <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">string</span> songURL;<span style="color: #008000;">//</span><span style="color: #008000;">歌曲存放路径字段
      </span><span style="color: #008000;">//</span><span style="color: #008000;">让歌曲的播放状态默认为未播放;</span>
      <span style="color: #0000ff;">private</span> SongPlayState playseat =<span style="color: #000000;"> SongPlayState.unplayed;

      </span><span style="color: #008000;">//</span><span style="color: #008000;">把歌曲状态改为已播放</span>
      <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> SetSongPlayed()
      {
          </span><span style="color: #0000ff;">this</span>.playseat =<span style="color: #000000;"> SongPlayState.played;
      }
      </span><span style="color: #008000;">//</span><span style="color: #008000;">把歌曲状态改为重唱</span>
      <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> SetnewSong()
      {
          </span><span style="color: #0000ff;">this</span>.playseat =<span style="color: #000000;"> SongPlayState.newplayed;
      }
      </span><span style="color: #008000;">//</span><span style="color: #008000;">把歌曲状态改为一切歌</span>
      <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> Setcut()
      {
          </span><span style="color: #0000ff;">this</span>.playseat =<span style="color: #000000;"> SongPlayState.cut;
      }</span>

to implement playback, cut songs,Reprise)):

Code to implement form dragging (find the corresponding event and double-click):

Main interface: (
<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span><span style="color: #000000;"> PlayList
    {
       </span><span style="color: #008000;">//</span><span style="color: #008000;">定义一个数组,默认可以储存50首歌</span>
       <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Song[] songList=<span style="color: #0000ff;">new</span> Song[<span style="color: #800080;">50</span>];<span style="color: #008000;">//</span><span style="color: #008000;">歌曲播放列表数组</span>
       <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">int</span> songIndex;<span style="color: #008000;">//</span><span style="color: #008000;">当前播放的歌曲在数组的索引</span>



       <span style="color: #0000ff;">#region</span> 添加播放歌曲
       <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">bool</span><span style="color: #000000;"> AddSong(Song song)
       {
           </span><span style="color: #0000ff;">bool</span> happy = <span style="color: #0000ff;">false</span><span style="color: #000000;">;
           </span><span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">int</span> i = <span style="color: #800080;">0</span>; i < songList.Length; i++<span style="color: #000000;">)
           {
               </span><span style="color: #0000ff;">if</span> (songList[i] == <span style="color: #0000ff;">null</span><span style="color: #000000;">)
               {
                   songList[i] </span>=<span style="color: #000000;"> song;

                   happy </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
                   </span><span style="color: #0000ff;">break</span><span style="color: #000000;">;
               }
           }
           </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> happy;

       } 
       </span><span style="color: #0000ff;">#endregion</span>
    
       <span style="color: #0000ff;">#region</span> 当前播放的歌曲名称
         <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span><span style="color: #000000;"> PlayingSongName()
        { 
            </span><span style="color: #0000ff;">string</span> songName = <span style="color: #800000;">""</span>; <span style="color: #008000;">//</span><span style="color: #008000;"> 歌曲名称</span>
             <span style="color: #0000ff;">if</span>(songList.Length><span style="color: #000000;">songIndex)
             {
                 </span><span style="color: #0000ff;">if</span> (songList[songIndex] != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
                 {
                     songName </span>=<span style="color: #000000;"> songList[songIndex].SongName;
                 }
             }
           

            </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> songName;
        } 
       </span><span style="color: #0000ff;">#endregion</span>

       <span style="color: #0000ff;">#region</span> 获取当前播放的歌曲
         <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span><span style="color: #000000;"> Song GetPlayingSong()
         {
             </span><span style="color: #0000ff;">if</span>(songIndex<<span style="color: #000000;">songList.Length)
             {
                 </span><span style="color: #0000ff;">if</span> (songList[songIndex] != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
                 {
                     </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> songList[songIndex];
                 }
                 </span><span style="color: #0000ff;">else</span><span style="color: #000000;">
                 {
                     </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">;
                 }
             }
             </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">;
         } 
         </span><span style="color: #0000ff;">#endregion</span>

       <span style="color: #0000ff;">#region</span> 下一首要播放的歌曲名称
         <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span><span style="color: #000000;"> NextSongName()
         {
             </span><span style="color: #0000ff;">string</span> songName = <span style="color: #800000;">""</span>; <span style="color: #008000;">//</span><span style="color: #008000;"> 歌曲名称</span>
             <span style="color: #0000ff;">if</span>(songIndex<<span style="color: #000000;">songList.Length)
             {
                 </span><span style="color: #0000ff;">if</span> (songList.Length > songIndex + <span style="color: #800080;">1</span><span style="color: #000000;">)
                 {
                     </span><span style="color: #0000ff;">if</span> (songList[songIndex + <span style="color: #800080;">1</span>] != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
                     {
                         songName </span>= songList[songIndex + <span style="color: #800080;">1</span><span style="color: #000000;">].SongName;
                     }
                   
              
             }
           
           }
             </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> songName;
         } 
         </span><span style="color: #0000ff;">#endregion</span>

       <span style="color: #0000ff;">#region</span> 切歌:
         <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> CutSong()
         {
             </span><span style="color: #008000;">//</span><span style="color: #008000;">代表切歌的位置</span>
             <span style="color: #0000ff;">int</span> i =<span style="color: #000000;"> songIndex;  
            
             </span><span style="color: #0000ff;">if</span> (songList[i]!=<span style="color: #0000ff;">null</span><span style="color: #000000;">)
             {
                 songList[i].Setcut();
             }
             </span><span style="color: #0000ff;">while</span> (songList[i] != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
             {
                 songList[i] </span>= songList[i + <span style="color: #800080;">1</span><span style="color: #000000;">];
                 i</span>++<span style="color: #000000;">;

                 </span><span style="color: #008000;">//</span><span style="color: #008000;"> 如果到达数组最后一个元素,就将最后一个元素指向空</span>
                 <span style="color: #0000ff;">if</span> (i ==<span style="color: #000000;"> songList.Length)
                 {
                     songList[i] </span>= <span style="color: #0000ff;">null</span><span style="color: #000000;">;
                 }
             }
             </span><span style="color: #0000ff;">if</span> (songList[<span style="color: #800080;">0</span>] != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
             {
                 songList[</span><span style="color: #800080;">0</span>].Playseat =<span style="color: #000000;"> SongPlayState.played;
             }
         }
 
    </span><span style="color: #0000ff;">#endregion</span>

       <span style="color: #0000ff;">#region</span> 重放当前歌曲
         <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> PlayAgain()
         {
             </span><span style="color: #0000ff;">if</span> (songList[songIndex] != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
             {
                 songList[songIndex].SetnewSong();
             }
         } 
         </span><span style="color: #0000ff;">#endregion</span>

       <span style="color: #0000ff;">#region</span> 播放下一首
         <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> MoveOn()
         {
             </span><span style="color: #0000ff;">if</span>(songIndex<<span style="color: #000000;">songList.Length)
             {
                 </span><span style="color: #0000ff;">if</span> (songList[songIndex] != <span style="color: #0000ff;">null</span> && songList[songIndex].Playseat ==<span style="color: #000000;"> SongPlayState.newplayed)
                 {
                     songList[songIndex].SetSongPlayed();
                 }
                 </span><span style="color: #0000ff;">else</span><span style="color: #000000;">
                 {
                     songIndex</span>++<span style="color: #000000;">;
                 }
             }
            
         }        
         </span><span style="color: #0000ff;">#endregion</span><span style="color: #000000;">
  
   }</span>
FrmMain

)
<span style="color: #0000ff;">#region</span> 让窗体实现拖动
        <span style="color: #0000ff;">public</span> Point mouSEOffset;        <span style="color: #008000;">//</span><span style="color: #008000;">记录鼠标指针的坐标        </span>
        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">bool</span> isMouseDown = <span style="color: #0000ff;">false</span>; <span style="color: #008000;">//</span><span style="color: #008000;">记录鼠标按键是否按下   </span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> FrmMain_MouseDown(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, MouseEventArgs e)
        {
            </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> xOffset;
            </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> yOffset;
            </span><span style="color: #0000ff;">if</span> (e.Button ==<span style="color: #000000;"> MouseButtons.Left)
            {
                xOffset </span>= -e.X -<span style="color: #000000;"> SystemInformation.FrameBorderSize.Width;
                yOffset </span>= -e.Y - SystemInformation.CaptionHeight -<span style="color: #000000;"> SystemInformation.FrameBorderSize.Height;
                mouseOffset </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> Point(xOffset, yOffset);
                isMouseDown </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            }
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> FrmMain_MouseMove(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, MouseEventArgs e)
        {
            </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (isMouseDown)
            {
                Point mousePos </span>=<span style="color: #000000;"> Control.MousePosition;
                mousePos.Offset(mouseOffset.X </span>+ <span style="color: #800080;">5</span>, mouseOffset.Y + <span style="color: #800080;">30</span><span style="color: #000000;">);
                Location </span>=<span style="color: #000000;"> mousePos;
            }
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> FrmMain_MouseUp(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, MouseEventArgs e)
        {
            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 修改鼠标状态isMouseDown的值      
            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 确保只有鼠标左键按下并移动时,才移动窗体       </span>
            <span style="color: #0000ff;">if</span> (e.Button ==<span style="color: #000000;"> MouseButtons.Left)
            {
                isMouseDown </span>= <span style="color: #0000ff;">false</span><span style="color: #000000;">;
            }
        } 
        </span><span style="color: #0000ff;">#endregion</span>

Song star request song (

Frmbyswangetsong

):
 <span   style="max-width:90%">//</span><span style="color: #008000;">当前播放的歌曲</span>
        <span style="color: #0000ff;">public</span><span style="color: #000000;"> Song songname;

        </span><span style="color: #0000ff;">#region</span> 让窗体实现拖动
        <span style="color: #0000ff;">public</span> Point mouseOffset;        <span style="color: #008000;">//</span><span style="color: #008000;">记录鼠标指针的坐标        </span>
        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">bool</span> isMouseDown = <span style="color: #0000ff;">false</span>; <span style="color: #008000;">//</span><span style="color: #008000;">记录鼠标按键是否按下   </span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> FrmMain_MouseDown(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, MouseEventArgs e)
        {
            </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> xOffset;
            </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> yOffset;
            </span><span style="color: #0000ff;">if</span> (e.Button ==<span style="color: #000000;"> MouseButtons.Left)
            {
                xOffset </span>= -e.X -<span style="color: #000000;"> SystemInformation.FrameBorderSize.Width;
                yOffset </span>= -e.Y - SystemInformation.CaptionHeight -<span style="color: #000000;"> SystemInformation.FrameBorderSize.Height;
                mouseOffset </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> Point(xOffset, yOffset);
                isMouseDown </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            }
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> FrmMain_MouseMove(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, MouseEventArgs e)
        {
            </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (isMouseDown)
            {
                Point mousePos </span>=<span style="color: #000000;"> Control.MousePosition;
                mousePos.Offset(mouseOffset.X </span>+ <span style="color: #800080;">5</span>, mouseOffset.Y + <span style="color: #800080;">30</span><span style="color: #000000;">);
                Location </span>=<span style="color: #000000;"> mousePos;
            }
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> FrmMain_MouseUp(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, MouseEventArgs e)
        {
            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 修改鼠标状态isMouseDown的值      
            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 确保只有鼠标左键按下并移动时,才移动窗体       </span>
            <span style="color: #0000ff;">if</span> (e.Button ==<span style="color: #000000;"> MouseButtons.Left)
            {
                isMouseDown </span>= <span style="color: #0000ff;">false</span><span style="color: #000000;">;
            }
        } 
        </span><span style="color: #0000ff;">#endregion</span>

       <span style="color: #008000;">//</span><span style="color: #008000;"> 点击退出按钮触发的事件</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnexit_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            application.Exit();  
        } 

       </span><span style="color: #008000;">//</span><span style="color: #008000;"> Login事件</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> FrmMain_Load(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            
           
            </span><span style="color: #008000;">//</span><span style="color: #008000;">把整个窗体对象赋给FrmByValue的静态frM对象</span>
            FrmByValue.frM = <span style="color: #0000ff;">this</span><span style="color: #000000;">;
            </span><span style="color: #008000;">//</span><span style="color: #008000;">运行窗体时启动定时器</span>
            <span style="color: #0000ff;">this</span><span style="color: #000000;">.tilist_played.Start();

            </span><span style="color: #008000;">//</span><span style="color: #008000;">调用查询返回路径的方法,传入SQL语句
            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 歌曲路径</span>
            <span style="color: #0000ff;">string</span> sql = <span style="color: #800000;">"</span><span style="color: #800000;">select resource_path from Resource_path where resource_id=1</span><span style="color: #800000;">"</span><span style="color: #000000;">;
            KtvHelper.songURL </span>=<span style="color: #000000;"> song_path(sql);
            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 歌手图片路径</span>
            <span style="color: #0000ff;">string</span> sql1 = <span style="color: #800000;">"</span><span style="color: #800000;">select resource_path from Resource_path where resource_id=2</span><span style="color: #800000;">"</span><span style="color: #000000;">;
            KtvHelper.singer_photoURL </span>=<span style="color: #000000;"> song_path(sql1);


        } 
        
        </span><span style="color: #808080;">///</span> <span style="color: #808080;"><summary>
        <span style="color: #808080;">///</span><span style="color: #008000;"> 查询返回路径的方法
        </span><span style="color: #808080;">///</span> <span style="color: #808080;"></summary></span>
        <span style="color: #808080;">///</span> <span style="color: #808080;"><param name="sql"></span><span style="color: #008000;">传入sql语句</span><span style="color: #808080;"></param></span>
        <span style="color: #808080;">///</span> <span style="color: #808080;"><returns></span><span style="color: #008000;">根据传入的sql语句返回不同的路径(1.resource_id=1歌曲路径:resource_id=2歌手图片路径)</span><span style="color: #808080;"></returns></span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">string</span> song_path(<span style="color: #0000ff;">string</span><span style="color: #000000;"> sql)
        {
            SqlConnection con </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> SqlConnection(SqlHelper.str);
            SqlCommand cmd </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> SqlCommand(sql, con);
            </span><span style="color: #0000ff;">string</span> path = <span style="color: #800000;">""</span><span style="color: #000000;">;
            </span><span style="color: #0000ff;">try</span><span style="color: #000000;">
            {
                con.Open();
                SqlDataReader dr </span>=<span style="color: #000000;"> cmd.ExecuteReader();

                </span><span style="color: #0000ff;">if</span> (dr != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
                {
                    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (dr.HasRows)
                    {
                        </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (dr.Read())
                        {
                            path </span>= dr[<span style="color: #800000;">"</span><span style="color: #800000;">resource_path</span><span style="color: #800000;">"</span><span style="color: #000000;">].ToString();
                        }

                    }
                }
            }
            </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception)
            {


                MessageBox.Show(</span><span style="color: #800000;">"</span><span style="color: #800000;">网络异常!</span><span style="color: #800000;">"</span><span style="color: #000000;">);
            }
            </span><span style="color: #0000ff;">finally</span><span style="color: #000000;">
            {
                con.Close();
            }
            </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> path;
        }  
    
      </span><span style="color: #008000;">//</span><span style="color: #008000;">点击显示播放触发的事件</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnshow_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
        
      
         </span><span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">this</span>.Width == <span style="color: #800080;">567</span><span style="color: #000000;">)
         {
             </span><span style="color: #0000ff;">this</span>.Width = <span style="color: #0000ff;">this</span>.Width + <span style="color: #800080;">208</span><span style="color: #000000;">;
             btnshow.Text </span>= <span style="color: #800000;">"</span><span style="color: #800000;">隐 藏 播 放</span><span style="color: #800000;">"</span><span style="color: #000000;">;
         }
         </span><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">this</span>.Width > <span style="color: #800080;">567</span><span style="color: #000000;">)
         {
             </span><span style="color: #0000ff;">this</span>.Width = <span style="color: #800080;">567</span><span style="color: #000000;">;
             btnshow.Text </span>= <span style="color: #800000;">"</span><span style="color: #800000;">显 示 播 放</span><span style="color: #800000;">"</span><span style="color: #000000;">;
         }
          
        } 

       </span><span style="color: #008000;">//</span><span style="color: #008000;">已点歌曲窗体</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnopen_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            SelectedSong frm </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> SelectedSong();
            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.Hide();
            frm.Show();
        }

 
  
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 点击拼音点歌触发的事件</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnspell_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            frmbySongname frm </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> frmbySongname();
            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.Hide();
            frm.Show();
            
        } 
     
      </span><span style="color: #008000;">//</span><span style="color: #008000;">点击字数点歌触发的事件</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnnum_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            frmbyziSong frm </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> frmbyziSong();
            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.Hide();
            frm.Show();
        } 

        </span><span style="color: #008000;">//</span><span style="color: #008000;">点击类型点歌触发的事件</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btntype_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            frmbyTypesong frm </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> frmbyTypesong();
            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.Hide();
            frm.Show();
        }

        </span><span style="color: #008000;">//</span><span style="color: #008000;">定时扫描歌曲列表,显示当前播放歌曲的名称</span>
        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> ShowPlayingSongName()
        {
            txtopen.Text </span>=<span style="color: #000000;"> PlayList.PlayingSongName();
            txtnext.Text </span>=<span style="color: #000000;"> PlayList.NextSongName();
        }

       </span><span style="color: #008000;">//</span><span style="color: #008000;">播放歌曲的方法</span>
        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> PlaySong()
        {
            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 获取当前要播放的歌曲</span>
            <span style="color: #0000ff;">this</span>.songname =<span style="color: #000000;"> PlayList.GetPlayingSong();
          
          
            </span><span style="color: #0000ff;">if</span> (songname != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
            {
                </span><span style="color: #0000ff;">#region</span> 播放时显示歌曲图片
                <span style="color: #0000ff;">string</span> name =<span style="color: #000000;"> songname.SongName;
                </span><span style="color: #0000ff;">string</span> sql = <span style="color: #800000;">"</span><span style="color: #800000;">select singer_id from song_info where song_name ='</span><span style="color: #800000;">"</span> + name + <span style="color: #800000;">"</span><span style="color: #800000;">' </span><span style="color: #800000;">"</span><span style="color: #000000;">;
                SqlConnection con </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> SqlConnection(SqlHelper.str);
                con.Open();
                SqlCommand cmd </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> SqlCommand(sql, con);
                </span><span style="color: #0000ff;">int</span> singerid =<span style="color: #000000;"> Convert.ToInt32(cmd.ExecuteScalar());
                con.Close();
                </span><span style="color: #0000ff;">string</span> sql1 = <span style="color: #800000;">"</span><span style="color: #800000;">select singer_photo from singer_info where singer_id=</span><span style="color: #800000;">"</span> + singerid + <span style="color: #800000;">""</span><span style="color: #000000;">;
                SqlConnection con1 </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> SqlConnection(SqlHelper.str);
                con1.Open();
                SqlCommand cmd1 </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> SqlCommand(sql1, con1);
                </span><span style="color: #0000ff;">string</span> singer_photo =<span style="color: #000000;"> cmd1.ExecuteScalar().ToString();
                con1.Close();
                plist.Image </span>= Image.FromFile(KtvHelper.singer_photoURL +<span style="color: #000000;"> singer_photo); 
                </span><span style="color: #0000ff;">#endregion</span>
                <span style="color: #008000;">//</span><span style="color: #008000;"> 将当前歌曲播放状态设为已播放</span>
                <span style="color: #0000ff;">this</span><span style="color: #000000;">.songname.SetSongPlayed();
                
                </span><span style="color: #008000;">//</span><span style="color: #008000;"> 得到当前播放歌曲的路径</span>
                Playerlist.URL = KtvHelper.songURL +<span style="color: #000000;"> songname.SongURL;
               
            }
        } 
     
        </span><span style="color: #008000;">//</span><span style="color: #008000;">计时器控件的Tick事件</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> tilist_played_Tick(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
             ShowPlayingSongName();
            </span><span style="color: #0000ff;">if</span>(<span style="color: #0000ff;">this</span>.songname==<span style="color: #0000ff;">null</span><span style="color: #000000;">)
            {
                </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.PlaySong();
            }
            </span><span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">this</span>.Playerlist.playState ==<span style="color: #000000;"> WMPLib.WMPPlayState.wmppsStopped)
            {
                </span><span style="color: #0000ff;">this</span>.songname = <span style="color: #0000ff;">null</span><span style="color: #000000;">;
                PlayList.MoveOn();
            }
            </span><span style="color: #0000ff;">if</span>(<span style="color: #0000ff;">this</span>.songname!=<span style="color: #0000ff;">null</span>&&<span style="color: #0000ff;">this</span>.songname.Playseat==<span style="color: #000000;">SongPlayState.cut)
            {
                </span><span style="color: #0000ff;">this</span>.Playerlist.URL = <span style="color: #800000;">""</span><span style="color: #000000;">;
                </span><span style="color: #0000ff;">this</span>.songname = <span style="color: #0000ff;">null</span><span style="color: #000000;">;
            
            }
            </span><span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">this</span>.songname != <span style="color: #0000ff;">null</span> && <span style="color: #0000ff;">this</span>.songname.Playseat ==<span style="color: #000000;"> SongPlayState.newplayed)
            {
                </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.PlaySong();
            
            }
   
        }

        </span><span style="color: #008000;">//</span><span style="color: #008000;">点击切歌触发的事件</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnnextsong_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            </span><span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">this</span>.songname != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
            {
                PlayList.CutSong();
                
            }
            </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> 
            {
                MessageBox.Show(</span><span style="color: #800000;">"</span><span style="color: #800000;">亲!你还没有添加歌曲</span><span style="color: #800000;">"</span><span style="color: #000000;">);
                
            }
           
        }

        </span><span style="color: #008000;">//</span><span style="color: #008000;">点击重唱触发的事件</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnnew_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            </span><span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">this</span>.songname != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
            {
                PlayList.PlayAgain();
            }
            </span><span style="color: #0000ff;">else</span><span style="color: #000000;">
            {
                MessageBox.Show(</span><span style="color: #800000;">"</span><span style="color: #800000;">亲!你还没有添加歌曲</span><span style="color: #800000;">"</span><span style="color: #000000;">);

            }
           
        }

        </span><span style="color: #008000;">//</span><span style="color: #008000;">点击金曲排行触发的时间</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnorderby_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            frmsonglist frm </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> frmsonglist();
            frm.ph </span>= <span style="color: #800080;">1</span><span style="color: #000000;">;
            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.Hide();
            frm.Show();

        }
        </span><span style="color: #008000;">//</span><span style="color: #008000;">歌星点歌</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnswan_Click_1(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            Frmbyswangetsong frm </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> Frmbyswangetsong();
            frm.Show();
            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.Hide();
        }

        </span><span style="color: #008000;">//</span><span style="color: #008000;">当鼠标进入控件可见状态是触发的事件</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnswan_MouseEnter(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            ToolTip tp </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> ToolTip();
            tp.ShowAlways </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            tp.SetToolTip(btnswan,</span><span style="color: #800000;">"</span><span style="color: #800000;">歌星点歌</span><span style="color: #800000;">"</span><span style="color: #000000;">);

        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnspell_MouseEnter(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            ToolTip tp </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> ToolTip();
            tp.ShowAlways </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            tp.SetToolTip(btnspell, </span><span style="color: #800000;">"</span><span style="color: #800000;">拼音点歌</span><span style="color: #800000;">"</span><span style="color: #000000;">);
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnnum_MouseEnter(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            ToolTip tp </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> ToolTip();
            tp.ShowAlways </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            tp.SetToolTip(btnnum, </span><span style="color: #800000;">"</span><span style="color: #800000;">字数点歌</span><span style="color: #800000;">"</span><span style="color: #000000;">);
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btntype_MouseEnter(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
             ToolTip tp </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> ToolTip();
            tp.ShowAlways </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            tp.SetToolTip(btntype, </span><span style="color: #800000;">"</span><span style="color: #800000;">类型选择</span><span style="color: #800000;">"</span><span style="color: #000000;">);
            
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnorderby_MouseEnter(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            ToolTip tp </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> ToolTip();
            tp.ShowAlways </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            tp.SetToolTip(btnorderby, </span><span style="color: #800000;">"</span><span style="color: #800000;">金曲排行</span><span style="color: #800000;">"</span><span style="color: #000000;">);
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnnew_MouseEnter(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            ToolTip tp </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> ToolTip();
            tp.ShowAlways </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            tp.SetToolTip(btnnew, </span><span style="color: #800000;">"</span><span style="color: #800000;">重唱</span><span style="color: #800000;">"</span><span style="color: #000000;">); 
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnnextsong_MouseEnter(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            ToolTip tp </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> ToolTip();
            tp.ShowAlways </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            tp.SetToolTip(btnnextsong, </span><span style="color: #800000;">"</span><span style="color: #800000;">切歌</span><span style="color: #800000;">"</span><span style="color: #000000;">); 
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnopen_MouseEnter(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            ToolTip tp </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> ToolTip();
            tp.ShowAlways </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            tp.SetToolTip(btnopen, </span><span style="color: #800000;">"</span><span style="color: #800000;">已点</span><span style="color: #800000;">"</span><span style="color: #000000;">); 
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnfw_MouseEnter(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            ToolTip tp </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> ToolTip();
            tp.ShowAlways </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            tp.SetToolTip(btnfw, </span><span style="color: #800000;">"</span><span style="color: #800000;">服务</span><span style="color: #800000;">"</span><span style="color: #000000;">); 
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnexit_MouseEnter(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {

            ToolTip tp </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> ToolTip();
            tp.ShowAlways </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            tp.SetToolTip(btnexit, </span><span style="color: #800000;">"</span><span style="color: #800000;">退出</span><span style="color: #800000;">"</span><span style="color: #000000;">); 
        }

        </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnfw_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            MessageBox.Show(</span><span style="color: #800000;">"</span><span style="color: #800000;">正在呼叫服务...</span><span style="color: #800000;">"</span><span style="color: #000000;">);
        }</span>

 <span style="color: #008000;">//</span><span style="color: #008000;">Image Index</span>
        <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">int</span> index=<span style="color: #800080;">0</span><span style="color: #000000;">;
        </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">int</span> index_singer = <span style="color: #800080;">0</span><span style="color: #000000;">;

       </span><span style="color: #008000;">//</span><span style="color: #008000;">Load event</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> Frmbyswangetsong_Load(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            </span><span style="color: #008000;">//</span><span style="color: #008000;">When displaying the current form, let the second lvlisttwo and third lvlistthere controls not be displayed</span>
            lvlisttwo.Visible = <span style="color: #0000ff;">false</span><span style="color: #000000;">;
            lvlistthere.Visible </span>= <span style="color: #0000ff;">false</span><span style="color: #000000;">;


            </span><span style="color: #0000ff;">#region</span> Bind data to the first listview
            <span style="color: #008000;">//</span><span style="color: #008000;">Bind data and pictures to listview1</span>
            ListViewItem lv = <span style="color: #0000ff;">new</span> ListViewItem(<span style="color: #800000;">"</span><span style="color: #800000;">combination</span><span style="color: #800000;">"</span>, <span style="color: #800080;">0</span><span style="color: #000000;">);
            lv.Tag </span>= <span style="color: #800000;">"</span><span style="color: #800000;">combination</span><span style="color: #800000;">"</span><span style="color: #000000;">;
            ListViewItem lv1 </span>= <span style="color: #0000ff;">new</span> ListViewItem(<span style="color: #800000;">"</span><span style="color: #800000;">Female Singer</span><span style="color: #800000;">"</span>, <span style="color: #800080;">1</span><span style="color: #000000;">);
            lv1.Tag </span>= <span style="color: #800000;">"</span><span style="color: #800000;">Female</span><span style="color: #800000;">"</span><span style="color: #000000;">;
            ListViewItem lv2 </span>= <span style="color: #0000ff;">new</span> ListViewItem(<span style="color: #800000;">"</span><span style="color: #800000;">Male singer</span><span style="color: #800000;">"</span>, <span style="color: #800080;">2</span><span style="color: #000000;">);
            lv2.Tag </span>= <span style="color: #800000;">"</span><span style="color: #800000;">Male</span><span style="color: #800000;">"</span><span style="color: #000000;">;
            lvlistone.Items.Add(lv);
            lvlistone.Items.Add(lv1);
            lvlistone.Items.Add(lv2);
            </span><span style="color: #0000ff;">#endregion</span><span style="color: #000000;">

        }



       </span><span style="color: #008000;">//</span><span style="color: #008000;">Event triggered when clicking on the item in lvlistone</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> lvlistone_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            </span><span style="color: #008000;">//</span><span style="color: #008000;">If no item in the lvlistone control is selected, the second form will not be displayed.
            </span><span style="color: #008000;">//</span><span style="color: #008000;">Let the second appearing lvlisttwo and lvlistone be displayed at the same position</span>
            lvlisttwo.Location =<span style="color: #000000;"> lvlistone.Location;
            </span><span style="color: #008000;">//</span><span style="color: #008000;">If one item is selected, the second llvlisttwo will be displayed.
            </span><span style="color: #008000;">//</span><span style="color: #008000;">Let the second lvlisttwo display </span>
            lvlisttwo.Visible = <span style="color: #0000ff;">true</span><span style="color: #000000;">;
            </span><span style="color: #0000ff;">if</span> (lvlistone.SelectedItems[<span style="color: #800080;">0</span>] != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
            {
                </span><span style="color: #008000;">//</span><span style="color: #008000;">How to dynamically bind data to the second listview control</span>
<span style="color: #000000;"> lvlisttwoadd();
               
            }
           
        }</span><span style="color: #008000;">//</span><span style="color: #008000;">The method of dynamically binding data to the second listview control lvlisttwoadd();</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> lvlisttwoadd()
        {
            SqlConnection con </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> SqlConnection(SqlHelper.str);
            </span><span style="color: #0000ff;">string</span> sql = <span style="color: #800000;">"</span><span style="color: #800000;">select * from singer_type</span><span style="color: #800000;">"</span><span style="color: #000000;">;
            SqlCommand cmd </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> SqlCommand(sql, con);
            </span><span style="color: #0000ff;">try</span><span style="color: #000000;">
            {
                con.Open();
                SqlDataReader dr </span>=<span style="color: #000000;"> cmd.ExecuteReader();
                </span><span style="color: #0000ff;">if</span> (dr != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
                {
                    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (dr.HasRows)
                    {
                        </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (dr.Read())
                        {
                            </span><span style="color: #0000ff;">string</span> singertype_group = dr[<span style="color: #800000;">"</span><span style="color: #800000;">singertype_name</span><span style="color: #800000;">"</span><span style="color: #000000;">].ToString();
                            </span><span style="color: #0000ff;">int</span> id = Convert.ToInt32(dr[<span style="color: #800000;">"</span><span style="color: #800000;">singertype_id</span><span style="color: #800000;">"</span><span style="color: #000000;">]);
                            ListViewItem lv </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> ListViewItem();
                            lv.ImageIndex </span>= index <span style="color: #000000;">;
                            lv.Text </span>=<span style="color: #000000;"> singertype_group;
                            lv.Tag</span>=<span style="color: #000000;"> id;
                           </span><span style="color: #008000;">//</span><span style="color: #008000;"> MessageBox.Show(lvlisttwo.Tag.ToString());</span>
<span style="color: #000000;"> lvlisttwo.Items.Add(lv);
                        }
                    }
                }
            }
            </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception)
            {

                MessageBox.Show(</span><span style="color: #800000;">"</span><span style="color: #800000;">Network abnormality!</span><span style="color: #800000;">"</span><span style="color: #000000;">);
            }
            </span><span style="color: #0000ff;">finally</span><span style="color: #000000;">
            {
                con.Close();
            }
        }</span><span style="color: #008000;">//</span><span style="color: #008000;"> 03 Event triggered when clicking on the item in lvlisttwo </span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> lvlisttwo_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {

            lvlistthere.Items.Clear();
            </span><span style="color: #008000;">//</span><span style="color: #008000;">If no item in the lvlisttwo control is selected, the third form will not be displayed.
            </span><span style="color: #008000;">//</span><span style="color: #008000;">If an item is selected, the second llvlistthere will be displayed </span>
            <span style="color: #0000ff;">if</span> (lvlisttwo.SelectedItems[<span style="color: #800080;">0</span>] != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
            {
                lvlisttwo.Visible </span>= <span style="color: #0000ff;">false</span><span style="color: #000000;">;
                </span><span style="color: #008000;">//</span><span style="color: #008000;">Let the third lvlistthere and lvlistone appear in the same position</span>
                lvlistthere.Location =<span style="color: #000000;"> lvlistone.Location;
                </span><span style="color: #008000;">//</span><span style="color: #008000;">Let the third lvlistthere display </span>
                lvlistthere.Visible = <span style="color: #0000ff;">true</span><span style="color: #000000;">;
                </span><span style="color: #008000;">//</span><span style="color: #008000;">Get whether the first listview clicked by the user is a male singer, female singer or group</span>
                <span style="color: #0000ff;">string</span> singer_group = lvlistone.SelectedItems[<span style="color: #800080;">0</span><span style="color: #000000;">].Tag.ToString();
                </span><span style="color: #008000;">//</span><span style="color: #008000;">Get the id of which region the user clicks on the second listview</span>
                <span style="color: #0000ff;">int</span> cityid = Convert.ToInt32(lvlisttwo.SelectedItems[<span style="color: #800080;">0</span><span style="color: #000000;">].Tag);
                SqlConnection con </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> SqlConnection(SqlHelper.str);
                </span><span style="color: #0000ff;">string</span> sql = <span style="color: #800000;">"</span><span style="color: #800000;">select singer_name,singer_photo from singer_info where singer_sex ='</span><span style="color: #800000;">"</span> singer_group <span style="color: #800000;">"</span> <span style="color: #800000;">' and singertype_id=</span><span style="color: #800000;">"</span> cityid <span style="color: #800000;">"</span> <span style="color: #800000;">"</span><span style="color: #000000;">;
                SqlCommand cmd </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> SqlCommand(sql,con);
                </span><span style="color: #0000ff;">try</span><span style="color: #000000;">
                {
                    con.Open();
                  SqlDataReader dr</span>=<span style="color: #000000;"> cmd.ExecuteReader();
                    </span><span style="color: #0000ff;">if</span>(dr!=<span style="color: #0000ff;">null</span><span style="color: #000000;">)
                    {
                    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(dr.HasRows)
                    {
                        </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (dr.Read())
                        {
                            </span><span style="color: #008000;">//</span><span style="color: #008000;">Get the singer’s name and singer picture path</span>
                            <span style="color: #0000ff;">string</span> singer_name = dr[<span style="color: #800000;">"</span><span style="color: #800000;">singer_name</span><span style="color: #800000;">"</span><span style="color: #000000;">].ToString();
                            </span><span style="color: #0000ff;">string</span> singer_photo_url = dr[<span style="color: #800000;">"</span><span style="color: #800000;">singer_photo</span><span style="color: #800000;">"</span><span style="color: #000000;">].ToString();
                            </span><span style="color: #008000;">//</span><span style="color: #008000;">Joint path</span>
                            <span style="color: #0000ff;">string</span> URL = KtvHelper.singer_photoURL <span style="color: #000000;"> singer_photo_url;
                            imgsingerinfo .Images.Add(Image.FromFile(URL));
                            ListViewItem lv </span>= <span style="color: #0000ff;">new</span><span style="color: #000000;"> ListViewItem();
                            lv.Text </span>=<span style="color: #000000;"> singer_name;
                            lv.ImageIndex </span>=index_singer <span style="color: #000000;">;
                            lvlistthere.Items.Add(lv);

                        }
                    }
                    }

                }
                </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (Exception)
                {

                    MessageBox.Show(</span><span style="color: #800000;">"</span><span style="color: #800000;">Network abnormality!</span><span style="color: #800000;">"</span><span style="color: #000000;">);
                }
                </span><span style="color: #0000ff;">finally</span><span style="color: #000000;">
                {
                    con.Close();
                }
                
           
              }

        }
           
       </span><span style="color: #008000;">//</span><span style="color: #008000;">Events triggered by clicking the button on the main interface</span>
        <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> btnmain_Click(<span style="color: #0000ff;">object</span><span style="color: #000000;"> sender, EventArgs e)
        {
            FrmByValue.frM.Show();
            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.Close();
            
        }

       </span>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn