Wpf音乐播放器
WPF开发的一个简单的播放器,用windows自带的mediaplay实现的一个简单的音乐播放器,可以添加和删除音乐菜单
C#学生管理系统 主要代码: (1)自定义函数类代码: public class LinkDataBase { private string strSQL; //与SQL Server 的连接字符串设置 //与数据库的连接 private string connectionString = "server = .;database=stu_Manage;uid=sa;pwd=123"; private static SqlConnection con = new SqlConnection("server = .;database=stu_Manage;uid=sa;pwd=123"); private SqlConnection myConnection; private DataSet ds = new DataSet(); private SqlDataAdapter da; public DataSet SelectDataBase(string tempStrSQL, string tempTableName) //根据输入的SQL语句检索数据库数据 { this.strSQL = tempStrSQL; this.myConnection = new SqlConnection(connectionString); this.da = new SqlDataAdapter(this.strSQL, this.myConnection); this.ds.Clear(); this.da.Fill(ds, tempTableName); //返回填充了数据的DataSet,其中数据表以tempTableName给出的字符串命名 return ds; } public DataTable SelectDataBase(string tempStrSQL) //检索数据库数据(传字符串直接操作数据库) { this.myConnection = new SqlConnection(connectionString); DataSet tempDataSet = new DataSet(); this.da = new SqlDataAdapter (tempStrSQL, this.myConnection); this.da.Fill(tempDataSet); return tempDataSet.Tables[0]; } public void deleteInfo(string strcmd)//删除信息 { SqlCommand cmd = new SqlCommand(strcmd, con); try { con.Open(); if (MessageBox.Show("确定要删除吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { cmd.ExecuteNonQuery(); MessageBox.Show("删除成功!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { con.Close(); } } public void addInfo(string strcmd)//定义添加信息事件 { try { con.Open(); SqlCommand cmd = new SqlCommand(strcmd, con); cmd.ExecuteNonQuery(); MessageBox.Show("添加成功"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } finally { con.Close(); } } public void updateInfo(string strcmd)//自定义更新信息方法 { try { con.Open(); SqlCommand cmd = new SqlCommand(strcmd, con); cmd.ExecuteNonQuery(); MessageBox.Show("修改成功"); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } } } . . . . . . . . . (2) > . . .