c#实现KTV点歌系统

下面通过图文并茂的方式给大家分享C#实现KTV点歌系统。

public enum SongPlayState
 {
  //未播放,播放,重播,切歌
  unplayed, played, again, cut
 }
 public class Song
 {
  public string SongName { get; set; }//歌曲名称
  public string SongURL { get; set; }//歌曲路径
  public SongPlayState playState = SongPlayState.unplayed;//默认未播放
  internal SongPlayState PlayState { get; set; }
  //状态为已播
  public void SetSongPlayed()
  {
  this.PlayState = SongPlayState.played;
  }
  //重唱
  public void SetPlayAgain()
  {
  this.playState = SongPlayState.again;
  }
  //切歌
  public void SetSongCut()
  {
  this.playState = SongPlayState.cut;
  }

PlayList类中实现切歌 重唱 下一首 等.....

 public class PlayList
 {
  //定义一个长度为、 的歌曲数组,默认存储 首歌曲
  public static Song[] SongList = new Song[ ];
  public static int SongIndex = ;//当前播放的歌曲在数组中的索引
  //点播一首歌曲,其实是将歌曲对象添加到歌曲数组中
  public static bool AddSong(Song song)
  {
  bool success = false;//记录添加歌曲是否成功
  for (int i = ; i < SongList.Length; i++)
  {
   //找到数组中第一个为null的位置
   if (SongList[i] == null)
   {
   SongList[i] = song;
   success = true;
   break;
   }
  }
  return success;
  }
  //获取当前播放的歌曲::既然是获取当前播放的歌曲,返回值肯定是Song类型
  public static Song GetPlaySong()
  {
  if (SongList[SongIndex] != null)
  {
   return SongList[SongIndex];
  }
  else
  {
   return null;
  }
  }
  /// <summary>
  /// 播放下一首
  /// </summary>
  public static void MoveOn()
  {
  if (SongList[SongIndex] != null && SongList[SongIndex].PlayState == SongPlayState.again)
  {
   SongList[SongIndex].SetSongPlayed();
  }
  else
  {
   SongIndex++;
  }
  }
  /// <summary>
  /// 当前播放的歌曲名称
  /// </summary>
  /// <returns>歌曲名称</returns>
  public static string PlayingSongName()
  {
  string songName = ""; // 歌曲名称
  if (SongList[SongIndex] != null)
  {
   songName = SongList[SongIndex].SongName;
  }
   return songName;
  }
  /// <summary>
  /// 下一首要播放的歌曲名称
  /// </summary>
  /// <returns>歌曲名称</returns>
  public static string NextSongName()
  {
  string songName = ""; // 歌曲名称
  if (SongList[SongIndex + ] != null)
  {
   songName = SongList[SongIndex + ].SongName;
  }
   return songName;
  }
  //重放当前歌曲
  public static void PlayAgain()
  {
  if (SongList[SongIndex] != null)
  {
   SongList[SongIndex].SetPlayAgain();
  }
  }
  //切歌
  public static void CutSong(int index)
  {
  int i;//循环变量,代表切歌的位置
  if (index == - )//循环变量,代表切割的位置
  {
   i = SongIndex;
  }
  else
  {
   i = index;//从切歌的位置开始,将歌曲逐个向前移一个位置
  }
  SongList[i].SetSongCut();
  while (SongList[i] != null)
  {
   SongList[i] = SongList[i + ];
   i++;
   //如果达到数组最后一个元素,就将最后一个元素指向空
   if (i == SongList.Length)
   {
   SongList[i] = null;
   }
  }
  }
 }

实现歌手点歌

 public FrmMain frmMain;
  string connectionStr = "server=.;database=MyKTV;uid=sa";
  DBHelp db = new DBHelp();
  private SqlConnection con;
  //首先要查出数据库中的图片路径和歌曲路径
  private void FrmCountry_Load(object sender, EventArgs e)
  {
   con = new SqlConnection(connectionStr);
  con.Open();
  string sql = "select resource_path from resource_path where resource_id= ";
   string sqlsongpath = "select resource_path from resource_path where resource_id= ";
  SqlCommand cmd = new SqlCommand(sql,con);
   SqlCommand cmd = new SqlCommand(sqlsongpath, con);
  KtvUnit.ImagePath = cmd.ExecuteScalar().ToString();
  KtvUnit.SongPath = cmd .ExecuteScalar().ToString();
  con.Close();
  }
  //点击歌手男女或组合时
  private void LvOne_Click(object sender, EventArgs e)
  {
   LoadSingerArea();
  }
  public string singer_type { get; set; }
  private void LoadSingerArea()
  {
  if (this.LvOne.SelectedItems[ ] != null)
  {
   LvOne.Visible = false;
   LvTwo.Location = LvOne.Location;
   LvTwo.Dock = DockStyle.Fill;
   LvTwo.Visible = true;
   this.singer_type=Convert.ToString(LvOne.SelectedItems[ ].Text);
  }
   con = new SqlConnection(connectionStr);
  string sql = "select singertype_id,singertype_name from singer_type";
  SqlCommand cmd = new SqlCommand(sql, con);
  SqlDataReader dr;
  try
  {
   con.Open();
   LvTwo.Items.Clear();
   dr = cmd.ExecuteReader();
   if (dr.HasRows)
   {
   int index = ;
   while (dr.Read())
   {
    ListViewItem lvItem = new ListViewItem();
    int typeid = Convert.ToInt (dr["singertype_id"]);
    string typename = Convert.ToString(dr["singertype_name"]);
    lvItem.Text = typename;
    lvItem.Tag = typeid;
    lvItem.ImageIndex = index;
    LvTwo.Items.Add(lvItem);
    index++;
   }
   }
   dr.Close();
  }
  catch (Exception ex)
  {
   MessageBox.Show("系统出现异常" + ex.Message);
  }
  finally
  {
   con.Close();
  }
  }
  public string singertype_id { get; set; }
  /// <summary>
  /// 点击地区类型时
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
  private void LvTwo_Click(object sender, EventArgs e)
  {
  if (this.LvTwo.SelectedItems[ ] != null)
  {
   LvTwo.Visible = false;
   Lvthree.Location = LvTwo.Location;
   Lvthree.Dock = DockStyle.Fill;
   Lvthree.Visible = true;
   this.singertype_id = Convert.ToString(LvTwo.SelectedItems[ ].Tag);
  }
  string result = singer_type;
  if (result != "组合")
  {
   result = singer_type == "女歌手" ? "女" : "男";
  }
  con = new SqlConnection(connectionStr);
  string sql =string.Format( "select singer_id,singer_name,singer_photo_url from singer_info where singertype_id={ } and singer_Sex='{ }'",singertype_id,result);
  SqlCommand cmd = new SqlCommand(sql, con);
  SqlDataReader dr;
  try
  {
   con.Open();
   int index = ;
   Lvthree.Items.Clear();
   imageList .Images.Clear();
   dr = cmd.ExecuteReader();
   if (dr.HasRows)
   {
   while (dr.Read())
   {
    string photoURL =KtvUnit.ImagePath + Convert.ToString(dr["singer_photo_url"]);
    //先给ImageList填充图片
    imageList .Images.Add(Image.FromFile(photoURL));
    ListViewItem lvItem = new ListViewItem();
    lvItem.Text = Convert.ToString(dr["singer_name"]);
    lvItem.Tag = Convert.ToString(dr["singer_id"]);
    lvItem.ImageIndex = index;
    Lvthree.Items.Add(lvItem);
    index++;
   }
   }
   dr.Close();
  }
  catch (Exception ex)
  {
   MessageBox.Show("系统出现异常" + ex.Message);
  }
  finally
  {
   con.Close();
  }
  }
  public void SongList()
  {
  //读取数据库,读出该歌手的所有歌曲
   StringBuilder sb = new StringBuilder();
  //拼接SQL语句
  sb.AppendFormat("select song_id,song_name,song_url,singer_name from song_info,singer_info where singer_name='{ }' and song_info.singer_id={ }", Lvthree.SelectedItems[ ].Text, Convert.ToInt (Lvthree.SelectedItems[ ].Tag));
  FrmSongList songList = new FrmSongList();
   songList.Sql = sb.ToString();
  songList.Previous = KtvClient.PrevioisForm.Singer;//指定返回的窗体是按歌手点歌
  songList.ShowDialog();
  this.Close();
  }
  private void Lvthree_Click(object sender, EventArgs e)
  {
  SongList();
  }
  private void tsSingerMain_Click(object sender, EventArgs e)
  {
  FrmMain main = new FrmMain();
  main.Show();
  this.Hide();
  }
  private void tsSingerBack_Click(object sender, EventArgs e)
  {
  if (this.LvOne.Visible==true)
  {
   FrmMain man = new FrmMain();
   man.Show();
   this.Hide();
  }
  else if (this.LvTwo.Visible==true)
  {
   this.LvTwo.Visible = false;
   this.LvOne.Visible = true;
  }
  else if (this.Lvthree.Visible==true)
  {
   this.Lvthree.Visible = false;
   this.LvTwo.Visible = true;
  }
  }
  private void tsSingerCut_Click(object sender, EventArgs e)
  {
  PlayList.CutSong(- );
  }
  private void tsSingerAgain_Click(object sender, EventArgs e)
  {
  PlayList.PlayAgain();
  }
  private void tsSingerYidian_Click(object sender, EventArgs e)
  {
  FrmPlayList frm = new FrmPlayList();
  frm.Show();
  }

拼音点歌

 public FrmMain frmMain;
  [DllImportAttribute("user .dll")]
  private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
  DBHelp db = new DBHelp();
  string connectionStr = "server=.;database=MyKTV;uid=sa";
  private void FrmPinYin_Load(object sender, EventArgs e)
  {
  AnimateWindow(this.Handle, , FrmMain.AW_SLIDE + FrmMain.AW_VER_POSITIVE);
  SqlConnection con = new SqlConnection(connectionStr);
  con.Open();
  db.connection();
  string sqlsongpath = "select resource_path from resource_path where resource_id= ";
  SqlCommand cmd = new SqlCommand(sqlsongpath, con);
  KtvUnit.SongPath = cmd.ExecuteScalar().ToString();
  }
  private void btnSearch_Click(object sender, EventArgs e)
  {
  string PinYin = this.txtPinYin.Text;
  //判断是否是中文 还是拼音
  if (!Regex.IsMatch(this.txtPinYin.Text, @"^[\u e -\u fa ]+$"))
  {
   StringBuilder PY = new StringBuilder(PinYin);
   for (int i = ; i <= PY.Length; i++)
   {
   PY.Insert(i, "%");
   i++;
   }
   string sql = string.Format("SELECT song_name,singer_name FROM dbo.singer_info, dbo.song_info WHERE dbo.singer_info.singer_id=dbo.song_info.singer_id AND song_ab LIKE '{ }'", PY);
   this.dgvPinYinInfo.DataSource = db.dataTable(sql,"PY");
  }
  else
  {
   StringBuilder ZW = new StringBuilder(PinYin);
   for (int i = ; i < ZW.Length; i++)
   {
   ZW.Insert(i,"%");
   i++;
   }
   string sql = string.Format("SELECT song_name,singer_name FROM dbo.singer_info, dbo.song_info WHERE dbo.singer_info.singer_id=dbo.song_info.singer_id AND song_name LIKE '{ }'", ZW);
   this.dgvPinYinInfo.DataSource = db.dataTable(sql, "PY");
  }
  }
  private void dgvPinYinInfo_DoubleClick(object sender, EventArgs e)
  {
  string songname = this.dgvPinYinInfo.SelectedRows[ ].Cells["song_name"].Value.ToString();
  DBHelp db = new DBHelp();
  db.connection();
  string sql = string.Format("SELECT song_name,singer_name,song_url,song_photo_url FROM dbo.song_info,dbo.singer_info where dbo.singer_info.singer_id=dbo.song_info.singer_id and song_name='{ }'",songname);
   SqlDataReader reader = db.ExecuteReaders(sql.ToString());
   Song song;
  if (reader.Read())
  {
   song = new Song();
   song.SongName = reader["song_name"].ToString();
   song.SongURL = KtvUnit.SongPath+reader["song_url"].ToString();
   PlayList.AddSong(song);
  }
  reader.Close();
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "a";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "b";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "c";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "d";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "e";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "f";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "g";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "h";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "i";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "j";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "k";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "l";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "m";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "n";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "o";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "p";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "q";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "r";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "s";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "t";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "u";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "v";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "w";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "x";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "y";
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  textBox .Text = textBox .Text + "z";
  }
  private void FrmPinYin_FormClosing(object sender, FormClosingEventArgs e)
  {
  AnimateWindow(this.Handle, , FrmMain.AW_SLIDE + FrmMain.AW_VER_POSITIVE);
  }
  public void Binder()
  {
  string PinYin = this.textBox .Text;
  StringBuilder PY = new StringBuilder(PinYin);
   for (int i = ; i <= PY.Length; i++)
  {
   PY.Insert(i, "%");
   i++;
  }
  string sql = string.Format("SELECT song_name,singer_name FROM dbo.singer_info, dbo.song_info WHERE dbo.singer_info.singer_id=dbo.song_info.singer_id AND song_ab LIKE '{ }'", PY);
  DataSet ds = db.dataSet(sql, "PY");
  if (ds.Tables["PY"]!=null)
  {
   ds.Tables["PY"].Clear();
  }
  this.dgvPinYinInfo.DataSource = db.dataTable(sql, "PY");
  }
  private void pictureBox _Click(object sender, EventArgs e)
  {
  string text = textBox .Text;
  int index = text.Length - ;
  if (index >= )
  {
   textBox .Text = text.Remove(index);
  }
  }
  private void textBox _TextChanged(object sender, EventArgs e)
  {
  if (textBox .Text!=string.Empty)
  {
   Binder();
   this.dgvPinYinInfo.AutoGenerateColumns = false;
  }
  else
  {
   this.dgvPinYinInfo.DataSource=null;
  }
  }
  private void tsPYMain_Click(object sender, EventArgs e)
  {
  FrmMain main = new FrmMain();
  main.Show();
  this.Hide();
  }
  private void txPYAgain_Click(object sender, EventArgs e)
  {
  FrmMain main = new FrmMain();
  main.Playsong();
  }
  Song song = new Song();
  private void tsPYCut_Click(object sender, EventArgs e)
  {
  song.playState = SongPlayState.cut;
  }
  private void tsPYYidian_Click(object sender, EventArgs e)
  {
  FrmPlayList list = new FrmPlayList();
  list.Show();
  }
  private void tsPYBack_Click(object sender, EventArgs e)
  {
  Application.Exit();
  } 

类型点歌

 public FrmMain frmMain;
  string connectionStr = "server=.;database=MyKTV;uid=sa";
  DBHelp db = new DBHelp();
  private SqlConnection con;
  private void FrmSongType_Load(object sender, EventArgs e)
  {
  con = new SqlConnection(connectionStr);
  con.Open();
  string sql = "select resource_path from resource_path where resource_id= ";
  string sqlsongpath = "select resource_path from resource_path where resource_id= ";
  SqlCommand cmd = new SqlCommand(sqlsongpath,con);
  KtvUnit.SongPath = cmd .ExecuteScalar().ToString();
  SqlCommand cmd = new SqlCommand(sql, con);
  KtvUnit.ImagePath = cmd.ExecuteScalar().ToString();
  con.Close();
   con = new SqlConnection(connectionStr);
  string sql = string.Format("select songtype_id,songtype_name,songtype_URL from song_type");
  SqlCommand cmd = new SqlCommand(sql , con);
  SqlDataReader dr;
  try
  {
   con.Open();
   int index = ;
   lvSongType.Items.Clear();
   imageList .Images.Clear();
   dr = cmd .ExecuteReader();
   if (dr.HasRows)
   {
   while (dr.Read())
   {
    string photoURL = KtvUnit.ImagePath + Convert.ToString(dr["songtype_URL"]);
    //先给ImageList填充图片
    imageList .Images.Add(Image.FromFile(photoURL));
    ListViewItem lvItem = new ListViewItem();
    lvItem.Text = Convert.ToString(dr["songtype_name"]);
    lvItem.Tag = Convert.ToString(dr["songtype_id"]);
    lvItem.ImageIndex = index;
    lvSongType.Items.Add(lvItem);
    index++;
   }
   }
   dr.Close();
  }
  catch (Exception ex)
  {
   MessageBox.Show("系统出现异常" + ex.Message);
  }
  finally
  {
   con.Close();
  }
  }
  private void LoadSongType()
  {
  //读取数据库,读出该歌曲类型的所有歌曲
   StringBuilder sb = new StringBuilder();
  //拼接SQL语句
  sb.AppendFormat("select song_info.song_name,singer_info.singer_name,song_info.song_url from singer_info,song_info where song_info.singer_id=singer_info.singer_id and song_info.songtype_id={ }", Convert.ToInt (lvSongType.SelectedItems[ ].Tag));
  FrmSongList songList = new FrmSongList();
   songList.Sql = sb.ToString();
  songList.Previous = KtvClient.PrevioisForm.SongType;//指定返回的窗体是按歌曲类型点歌
  songList.ShowDialog();
  this.Close();
  }
  private void lvSongType_Click(object sender, EventArgs e)
  {
  LoadSongType();
  }
  private void tsTYSingerMain_Click(object sender, EventArgs e)
  {
  FrmMain main = new FrmMain();
  main.Show();
  this.Hide();
  }
  private void tsTYSingerAgain_Click(object sender, EventArgs e)
  {
  FrmMain main = new FrmMain();
  main.Playsong();
  }
  Song song = new Song();
  private void tsTYSingerCut_Click(object sender, EventArgs e)
  {
  song.playState = SongPlayState.cut;
  }
  private void tsTYSingerYidian_Click(object sender, EventArgs e)
  {
  FrmPlayList list = new FrmPlayList();
  list.Show();
  }
  private void tsTYSingerBack_Click(object sender, EventArgs e)
  {
  FrmMain main = new FrmMain();
  main.Show();
  this.Hide();
  }

金榜排行

public FrmMain frmMain;
  DBHelp db = new DBHelp();
  string connectionStr = "server=.;database=MyKTV;uid=sa";
  private void FrmJB_Load(object sender, EventArgs e)
  {
  SqlConnection con = new SqlConnection(connectionStr);
  con.Open();
  db.connection();
  string sql = "SELECT song_name,song_play_count FROM dbo.song_info ORDER BY song_play_count DESC";
  string sqlsongpath = "select resource_path from resource_path where resource_id= ";
  SqlCommand cmd = new SqlCommand(sqlsongpath, con);
  KtvUnit.SongPath = cmd.ExecuteScalar().ToString();
  DataSet ds = db.dataSet(sql,"Count");
  this.dgvSongList.DataSource = ds.Tables["Count"].DefaultView;
  }
  private void dgvSongList_Click(object sender, EventArgs e)
  {
  DBHelp db = new DBHelp();
  if (dgvSongList.SelectedRows[ ]!=null)
  {
   string songname = this.dgvSongList.SelectedRows[ ].Cells["SongName"].Value.ToString();
   db.connection();
   string sql = string.Format("SELECT song_name,singer_name,song_url,song_photo_url FROM dbo.song_info,dbo.singer_info where dbo.singer_info.singer_id=dbo.song_info.singer_id and song_name='{ }'", songname);
   SqlDataReader reader = db.ExecuteReaders(sql.ToString());
   Song song;
   if (reader.Read())
   {
   song = new Song();
   song.SongName = reader["song_name"].ToString();
   song.SongURL = KtvUnit.SongPath + reader["song_url"].ToString();
   PlayList.AddSong(song);
   }
   reader.Close();
  }
  else
  {
   MessageBox.Show("空");
  }
  }
 

数字点歌

 public FrmMain frmMain;
  string connectionStr = "server=.;database=MyKTV;uid=sa";
  DBHelp db = new DBHelp();
  private SqlConnection con;
  private void FrmNumber_Load(object sender, EventArgs e)
  {
  con = new SqlConnection(connectionStr);
  con.Open();
  string sqlsongpath = "select resource_path from resource_path where resource_id= ";
  SqlCommand cmd = new SqlCommand(sqlsongpath, con);
  KtvUnit.SongPath = cmd.ExecuteScalar().ToString();
  con.Close();
  for (int i = ; i <= ; i++)
  {
   for (int j = ; j <= ; j++)
   {
   Label label = new Label();
   label.ForeColor = Color.Red;
   label.BackColor = Color.Pink;
   label.Font=new System.Drawing.Font("华文彩云", );
   label.TextAlign = ContentAlignment.MiddleCenter;
   label.Click += label_Click;
   this.MouseMove += FrmNumber_MouseMove;
   label.MouseHover += label_MouseHover;
   label.Size = new System.Drawing.Size( , );
   label.Text = j.ToString();
   if (i > )
   {
    label.Text = (j + i + ).ToString();
   }
   if (i > )
   {
    label.Text = (j + i + ).ToString();
   }
   if (i > )
   {
    label.Text = (j + i + ).ToString();
   }
   label.Location = new Point( + * j, + * i);
   this.Controls.Add(label);
   }
  }
  }

已点列表

 private void FrmPlayList_Load(object sender, EventArgs e)
  {
  SongList();
  }
  public void SongList()
  {
  lvSong.Items.Clear();
  for (int i = ; i < PlayList.SongList.Length; i++)
  {
   if (PlayList.SongList[i]!=null)
   {
   ListViewItem item = new ListViewItem();
   item.Text = PlayList.SongList[i].SongName;
   item.Tag = i;
   string playstate = PlayList.SongList[i].PlayState == SongPlayState.unplayed ? "未播放" : "已播";
   item.SubItems.Add(playstate);
   lvSong.Items.Add(item);
   }
  }
  }
  private void btnClose_Click(object sender, EventArgs e)
  {
  this.Close();
  }

以上就是C#实现KTV点歌系统的全部代码,希望大家喜欢。

(0)

相关推荐

  • C#之IO读写文件方法封装代码

    具体不做详细介绍了,直接上代码 /// <summary> /// 功能:FileStream文件流读取文件 /// </summary> /// <param name="filePath">参数:文件路径</param> /// <returns>返回值:StreamReader对象</returns> public static StreamReader ReadFileByFs(string filePat

  • readme.txt之弹出免费点歌病毒的清除方法

    病毒名称:Trojan.Delf.rsd <瑞星><MACFEE.卡巴不报> MD5   216a3783443fc9c46fe4d32aa13c390f 运行后病毒样本,自动复制副本到%SYSTEMroot%目录下 %SYSTEMroot%\flashplay.dll %SYSTEMroot%\ge_1237.exe X:\flashplay.dll X:\readme.txt.exe X:\autorun.inf X指非系统盘符 %systemroot%是环境变量, autor

  • 如何使用C#操作幻灯片

    记得老师讲课的时候,经常会用PPT遥控翻页笔来遥控幻灯片来给我们讲课,当时觉得非常有趣,由于这段时间接触了VSTO相关的开发,了解到了Office的相关产品都公开了一些API来让我们对Office产品进行二次开发,这时候我就想,能不能用PowerPoint公开的对象来制作一个遥控幻灯片的程序呢?在本专题就向大家介绍下这个小工具的实现思路和效果. 实现思路 1.既然要实现的程序是遥控幻灯片,这样我们就需要先获得幻灯片应用程序的,在PowerPoint对象模型中,Microsoft.Office.I

  • 如何使用C#读写锁ReaderWriterLockSlim

    读写锁的概念很简单,允许多个线程同时获取读锁,但同一时间只允许一个线程获得写锁,因此也称作共享-独占锁.在C#中,推荐使用ReaderWriterLockSlim类来完成读写锁的功能. 某些场合下,对一个对象的读取次数远远大于修改次数,如果只是简单的用lock方式加锁,则会影响读取的效率.而如果采用读写锁,则多个线程可以同时读取该对象,只有等到对象被写入锁占用的时候,才会阻塞. 简单的说,当某个线程进入读取模式时,此时其他线程依然能进入读取模式,假设此时一个线程要进入写入模式,那么他不得不被阻塞

  • PHP实现网上点歌(二)

    midif2.php <? $d=dir("./dir");     //得到dir目录对象 $i="0"; while($entry=$d->read()){ $i=$i+1; if($i>2){           //大于2的目的是去掉当前目录的".",和表示前一个目录的".."     $wq[]=$entry;  //把目录明细放入$wq数组中     } } $d->close();    

  • 局域网内建基于CS模式的点歌台

    小马所在寝室中,只有他的电脑配有音箱,其余几位兄弟的只配备了耳麦,小马经常大音量播放歌曲很让兄弟们眼馋,他们多次跑到小马的电脑上来播放喜欢的歌曲,让小马玩游戏的时间大为减少.小马碍于情面不好多说,由于同宿舍的兄弟的电脑都在一个局域网内,他决定搭建一个网内点歌台,好让兄弟们在自己电脑上能点歌而不占用小马宝贵的游戏时间.小马搭建点歌台所用的工具是"思思音乐点播系统",使用这个基于C/S模式的软件非常方便. 软件名称:思思音乐点播系统软件版本:1.0软件大小:174KB软件性质:共享软件应用

  • c#实现KTV点歌系统

    下面通过图文并茂的方式给大家分享C#实现KTV点歌系统. public enum SongPlayState { //未播放,播放,重播,切歌 unplayed, played, again, cut } public class Song { public string SongName { get; set; }//歌曲名称 public string SongURL { get; set; }//歌曲路径 public SongPlayState playState = SongPlayS

  • vmware12中安装 RedHat RHEL7.2系统的详细步骤(图文)

    本文介绍了vmware12中安装 RedHat RHEL7.2系统的详细步骤(图文),分享给大家,具体如下: 一.开始安装 1)新建虚拟机 RHEL7.2 2)成功引导系统--开机出现此画面 Install Red Hat EnterpriseLinux 7.2 安装RHLE7.2 操作系统 Test this edia & install RedHat Enterprise Linux 7.2 测试安装文件并安装RHLE7.2 操作系统 Troubleshooting 修复故障 3)选择第一项

  • Mac系统下MySql下载MySQL5.7及详细安装图解

    一.在浏览器当中输入以下地址 https://dev.mysql.com/downloads/mysql/ 二.进入以下界面:直接点击下面位置 ,选择跳过登录 点过这后直接下载. 三.下载完成后, 直接双击打开,弹出以下界面,再继续点击即可 下面 一直点继续,和正学安装其它软件一样 四.启动MySQL 安装完毕后,到设置当中查看以下选项,如果里面有MySQL说明已经安装成功 点击后, 启动MySQL 五.修改数据库密码 启动完成后,打开终端 aliasmysql=/usr/local/mysql

  • Mac OS系统下mysql 5.7.20安装教程图文详解

    Mac OS X 下 TAR.GZ 方式安装 MySQL 5.7 与 MySQL 5.6 相比, 5.7 版本在安装时有两处不同: 1:初始化方式改变, 从scripts/mysql_install_db --user=mysql初始化方式变成了bin/mysqld --initialize --user=mysql方式; 2: 初始密码生成改变, 5.6 的版本在 tar gz 方式初始化完成后默认 root 密码为空, 5.7 版本在初始化完成后会生成一个临时的 root 密码: 一.在浏览

  • 秒杀系统Web层设计的实现方法

    秒杀系统Web层设计的实现方法 一.Restful接口设计 使用资源+名词的方式来为url链接命名.例如: 访问详情页的链接可以是: seckill/{seckillId}/detail 二.SpringMVC配置 1.首先要在web.xml中配置中央控制器. <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&q

  • 在windows 64位操作系统上运行32位的vbscript的方法

    今天在2008 r2 64位的服务器系统上,运行vbs文件的时候如下提示 --------------------------- Windows Script Host --------------------------- 脚本: C:\Users\Administrator\Desktop\vbs_cf.vbs 行: 10 字符: 1 错误: 未找到提供程序.该程序可能未正确安装. 代码: 800A0E7A 源: ADODB.Connection 在2003上运行正常的程序,为什么在08上不

  • Coldfusion MX广告轮换系统制作教程

    wait 蓝色理想CF里面没有提供象ASP里那样的广告组件,但是这并不能说明就不能做出功能强大的广告系统,这里我放上一个简单的广告轮换系统,也是我CCF论坛里面用的.功能,有显示次数和点击次数.在这基础上扩展比较容易,可以分类显示,下面的代码只是显示 大广告条.只是想抛砖引玉,大家举一反三,就能做出功能更加强大的广告系统出来. <!--- 判断是否有地址传递 ---> <CFIF NOT IsDefined("URL.ADID")> <!--- 默认为显示

  • SQL Server 移动系统数据库

    说到这个问题,基本上有人就会想到三个问题: 1,什么是系统数据? 2,为什么要移动系统数据库? 3,移动系统数据库我们可以用附加和分离,为什么还要单独拿出来说呢? 对于这三个问题我一个一个讲吧,也算是自己做个笔记. 1,什么是系统数据? 所谓系统数据库就是我们在装SQL Server之后,系统自带的数据库(这样的回答是不是很白痴^_^). 如果你装SQL Server2005或2008在打开一个SQL实例后,就会看到一个数据库--->系统数据库文件夹,里边就是系统自带的数据库,如图: 对于每一个

  • access中显示MSysObjects系统表的设置方法

    默认access的系统表MSysObjects等是不显示的,需要手动设置access显示MSysObjects等系统表. 设置方法如下: 1. 打开Access 2. 点击"工具"菜单,选择"选项" 3. 在"视图"页上,将"系统对象"勾上 4. 点击"确定"按钮保存设置 5. 点击"工具"菜单,选择"安全"中的"用户与组权限" 6. 选择&quo

随机推荐