private void button2_Click(object sender, EventArgs e) { password = textBox4.Text; password2 = textBox5.Text; if (password == string.Empty || password2 == string.Empty) { MessageBox.Show("请输入密码", "提示"); return; } using (sqlAdapter sqladp = new sqlAdapter()) { password = MD5Create(password); string sql = "select ans from [user] where username = '******'"; string ans = sqladp.ExecuteScalar(sql) as string; if (ans == textBox3.Text) { sql = "update [user] set password='******' where username='******'"; sqladp.ExecuteScalar(sql); MessageBox.Show("修改密码成功!", "消息"); } else { MessageBox.Show("验证失败!", "消息"); } } }
private void button1_Click(object sender, EventArgs e) { using (sqlAdapter sqladp = new sqlAdapter()) { string sql = "update [user] set autho='" + comboBox2.Text + "' where username='******'"; sqladp.ExecuteScalar(sql); } MessageBox.Show("修改成功!", "消息"); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { comboBox2.Items.Clear(); using (sqlAdapter sqladp = new sqlAdapter()) { DataSet ds; sqladp.getDataSet("select autho from [user] where username='******'", out ds); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { comboBox2.Items.Add(ds.Tables[0].Rows[i][0]); } comboBox2.SelectedIndex = 0; } }
//private string modgcode2; //private string modscode2; //private string modacode2; //private string modtrack2; //private string adduser; public Form12() { InitializeComponent(); using (sqlAdapter sqladp = new sqlAdapter()) { DataSet ds2; sqladp.getDataSet("select distinct acode from [album]", out ds2); for (int i = 0; i < ds2.Tables[0].Rows.Count; i++) { comboBox2.Items.Add(ds2.Tables[0].Rows[i][0]); } comboBox2.SelectedIndex = 0; } }
//private string username; //private string autho; public Form10() { InitializeComponent(); using (sqlAdapter sqladp = new sqlAdapter()) { DataSet ds; sqladp.getDataSet("select distinct username from [user]", out ds); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { comboBox1.Items.Add(ds.Tables[0].Rows[i][0]); } comboBox1.SelectedIndex = 0; } }
private void button1_Click(object sender, EventArgs e) { DataPool.server = textBox1.Text; //Trace.WriteLine(DataPool.server); DataPool.conString = "Data Source=" + textBox1.Text + ";Initial Catalog=touhou music;User ID=thview"; try { sqlAdapter sqladp = new sqlAdapter(); sqladp.Dispose(); } catch { MessageBox.Show("连接失败!", "提示"); return; } MessageBox.Show("连接成功!", "提示"); }
private void button1_Click(object sender, EventArgs e) { userid = textBox1.Text; if (userid == string.Empty) { MessageBox.Show("请输入用户名", "提示"); return; } for (int i = 0; i < userid.Length; i++) { if (userid[i] == '\'') { MessageBox.Show("用户名不存在!", "提示信息"); return; } } using (sqlAdapter sqladp = new sqlAdapter()) { string sql = "select quest from [user] where username = '******'"; string quest = sqladp.ExecuteScalar(sql) as string; textBox2.Text = quest; } }
private void button1_Click(object sender, EventArgs e) { addoricode = textBox1.Text; addorigin = textBox2.Text.Replace("'", "''"); if (addoricode == string.Empty || addorigin == string.Empty) { MessageBox.Show("请输入数据", "提示"); return; } try { using (sqlAdapter sqladp = new sqlAdapter()) { string sql = "insert into [ori] values ('" + addoricode + "','" + addorigin + "')"; sqladp.ExecuteScalar(sql); } } catch (Exception) { MessageBox.Show("错误", "消息"); return; } MessageBox.Show("添加成功!","消息"); }
private void button3_Click(object sender, EventArgs e) { string sql; modaname2 = comboBox4.Text.Replace("'", "''"); modtime2 = comboBox5.Text; /* if (modaname2 != modaname) { connectSQL(); sql = "update [album] set aname='" + modaname2 + "' where acode='" + modacode + "'"; cmd = new SqlCommand(sql, conn); cmd.ExecuteScalar(); closeSQL(); MessageBox.Show("修改专辑名成功!", "消息"); } if (modtime2 != modtime) { connectSQL(); sql = "update [album] set time='" + modtime2 + "' where acode='" + modacode + "'"; cmd = new SqlCommand(sql, conn); cmd.ExecuteScalar(); closeSQL(); MessageBox.Show("修改首发展会成功!", "消息"); } connectSQL(); sql = "update [album] set cover='@cover' where acode='" + modacode + "'"; cmd = new SqlCommand(sql, conn); cmd.Parameters.Add("cover", SqlDbType.Image); cmd.Parameters["cover"].Value = imagebytes; cmd.ExecuteScalar(); closeSQL(); MessageBox.Show("修改专辑图片成功!", "消息"); */ using (sqlAdapter sqladp = new sqlAdapter()) { sql = "delete from [album] where acode='" + modacode + "'"; sqladp.ExecuteNonQuery(sql); sql = "insert into [album] values ('" + modacode + "','" + modaname2 + "','" + modtime2 + "',@cover)"; sqladp.setCommand(sql); sqladp.Command.Parameters.Add("cover", SqlDbType.Image); sqladp.Command.Parameters["cover"].Value = imagebytes; sqladp.Command.ExecuteNonQuery(); } MessageBox.Show("修改成功!", "消息"); }
private void button2_Click(object sender, EventArgs e) { // modacode2 = comboBox2.Text; // modtrack2 = comboBox6.Text; // modscode2 = modacode2 + modtrack2; // modgcode2 = comboBox1.Text; modgname2 = comboBox3.Text.Replace("'", "''"); if (modgname2 != modgname) { using (sqlAdapter sqladp = new sqlAdapter()) { sqladp.ExecuteNonQuery("update [group] set gname='" + modgname2 + "' where gcode='" + modgcode + "'"); } MessageBox.Show("修改社团名成功!", "消息"); } }
private void button1_Click(object sender, EventArgs e) { userid = textBox2.Text; password = textBox3.Text; password2 = textBox4.Text; if (password != password2) { MessageBox.Show("两次密码输入不一致!", "提示信息"); return; } if (userid == string.Empty) { MessageBox.Show("请输入用户名", "提示"); return; } if (userid.Contains("\'")) { MessageBox.Show("非法用户名!", "警告"); return; } if (password == string.Empty || password2==string.Empty) { MessageBox.Show("请输入密码", "提示"); return; } if (textBox5.Text == string.Empty || textBox6.Text == string.Empty) { MessageBox.Show("请输入找回密码必要的信息", "提示"); return; } password = MD5Create(password); //////////////////////////////////////////////////////////////// using (sqlAdapter sqladp = new sqlAdapter()) { string sql = "select username from [user] where username = '******'"; object obj = sqladp.ExecuteScalar(sql); //对数据库查询出的值进行判断 if (obj != null) { MessageBox.Show("用户名已存在!", "提示信息"); return; } else { sql = "insert into [user] values ('" + userid + "','" + password + "','3 ','" + textBox5.Text + "','" + textBox6.Text + "')"; sqladp.ExecuteScalar(sql); MessageBox.Show("注册成功!", "提示信息"); this.Dispose(); return; /*if (password == obj.ToString()) { //MessageBox.Show("登录成功", "提示"); DataPool.currentID = userid; DataPool.currentMD5Password = obj.ToString(); //this.Visible = false; this.Dispose(); } else MessageBox.Show("密码错误", "提示"); */ } } //////////////////////////////////////////////////////////////////// }
//private void connectSQL() //{ // conn = new SqlConnection(DataPool.conString); // conn.Open(); //} //private void closeSQL() //{ // conn.Close(); //} private void button1_Click(object sender, EventArgs e) { // pictureBox2.Image = null; tempgname = textBox1.Text.Replace("'", "''"); tempaname = textBox2.Text.Replace("'", "''"); tempsname = textBox3.Text.Replace("'", "''"); temparranger = textBox5.Text.Replace("'", "''"); templyric = textBox4.Text.Replace("'", "''"); tempvocal = textBox9.Text.Replace("'", "''"); tempstyle = textBox8.Text.Replace("'", "''"); temptime = textBox7.Text; temporigin = comboBox1.Text; sqlstr = "select [group].gname as 社团名,album.aname as 专辑名,[time] as 首发展会,track as 音轨号,sname as 曲目名,arranger as 编曲,lyric as 作词,vocal as 歌手,style as 风格,origin as 原曲,adduser as 添加人员 from album,gas,[group],ori,song where gas.gcode=[group].gcode and gas.acode=album.acode and gas.scode=song.scode and song.oricode=ori.oricode"; if (tempgname != string.Empty) sqlstr = sqlstr + " and [group].gname like '%" + tempgname + "%'"; if (tempaname != string.Empty) sqlstr = sqlstr + " and album.aname like '%" + tempaname + "%'"; if (tempsname != string.Empty) sqlstr = sqlstr + " and song.sname like '%" + tempsname + "%'"; if (temparranger != string.Empty) sqlstr = sqlstr + " and arranger like '%" + temparranger + "%'"; if (templyric != string.Empty) sqlstr = sqlstr + " and lyric like '%" + templyric + "%'"; if (tempvocal != string.Empty) sqlstr = sqlstr + " and vocal like '%" + tempvocal + "%'"; if (tempstyle != string.Empty) sqlstr = sqlstr + " and style like '%" + tempstyle + "%'"; if (temptime != string.Empty) sqlstr = sqlstr + " and time like '%" + temptime + "%'"; if (temporigin != string.Empty) sqlstr = sqlstr + " and origin='" + temporigin + "'"; DataSet ds1; using (sqlAdapter sqladp = new sqlAdapter()) { sqladp.getDataSet(sqlstr, out ds1, "detail"); } // Trace.WriteLine(ds.Tables[0].Rows.Count); dataGridView1.DataSource = ds1.Tables[0]; // for (int i = 0; i < ds.Tables[0].Rows.Count; i++) // { // dataGridView1. //comboBox1.Items.Add(ds.Tables[0].Rows[i][0]); // } // comboBox1.SelectedIndex = 0; /* byte[] imagebytes = null; connectSQL(); SqlCommand com = new SqlCommand("select cover from album where aname='"+tempaname+"'", conn); //" + tempaname + " SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { imagebytes = (byte[])dr.GetValue(0); } dr.Close(); com.Clone(); if (imagebytes != null) { MemoryStream ms = new MemoryStream(imagebytes); Bitmap bmpt = new Bitmap(ms); //Image image = Image.FromStream(ms, true); dr.Close(); closeSQL(); pictureBox2.Image = bmpt; }*/ }
private void button1_Click(object sender, EventArgs e) { userid = textBox1.Text; password = textBox2.Text; if (userid == string.Empty) { MessageBox.Show("请输入用户名", "提示"); return; } if(userid.Contains("\'")) { MessageBox.Show("用户名非法!", "提示"); return; } try { using (sqlAdapter sqladp = new sqlAdapter()) { string sql = "select password from [user] where username = '******'"; string obj = sqladp.ExecuteScalar(sql) as string; if (obj == null) // user from kamiro website //{ // using (sqlAdapter sqlKamiro = new sqlAdapter(DataPool.conkamiro)) // { // sql = "select password from [userTable] where userName = '******'"; // string kamiropass = sqlKamiro.ExecuteScalar(sql) as string; // if (psHd(password) == kamiropass) // { // DataPool.currentID = userid; // DataPool.currentMD5Password = obj; // //this.Visible = false; // MessageBox.Show("欢迎来自KCM的账号!", "消息"); // doRememberPasswd(); // this.Dispose(); // } // else MessageBox.Show("密码错误", "提示"); //} //} else // user of this program { if (psCt(password) == obj) { //MessageBox.Show("登录成功", "提示"); DataPool.currentID = userid; DataPool.currentMD5Password = obj; //this.Visible = false; doRememberPasswd(); this.Dispose(); } else MessageBox.Show("密码错误", "提示"); } } } catch (Exception ex) { MessageBox.Show("连接失败!", "提示"); Trace.Write(ex.StackTrace); return; } }
private void comboBox6_SelectedIndexChanged(object sender, EventArgs e) { comboBox7.Items.Clear(); comboBox8.Items.Clear(); comboBox10.Items.Clear(); comboBox11.Items.Clear(); comboBox12.Items.Clear(); comboBox9.Items.Clear(); modtrack = comboBox6.Text; modscode = modacode + modtrack; List<DataTable> dt; List<ComboBox> CB = new List<ComboBox>(6); CB.Add(comboBox7); CB.Add(comboBox8); CB.Add(comboBox9); CB.Add(comboBox10); CB.Add(comboBox11); CB.Add(comboBox12); DataSet modOrigin = new DataSet(); try { using (sqlAdapter sqladp = new sqlAdapter()) { sqladp.getDataSet("select origin from [ori],song where ori.oricode=song.oricode and scode='" + modscode + "'",out modOrigin); modorigin = modOrigin.Tables[0].Rows[0][0].ToString(); sqladp.getDataTables(out dt, "select lyric from [song] where scode='" + modscode + "'", "select sname from [song] where scode='" + modscode + "'", "select arranger from [song] where scode='" + modscode + "'", "select style from [song] where scode='" + modscode + "'", "select vocal from [song] where scode='" + modscode + "'", "select distinct origin from [ori]"); string sql = "select oricode from [ori] where origin = '" + modorigin + "'"; modoricode = sqladp.ExecuteScalar(sql) as string; } Program.fillIn(ref dt, ref CB); comboBox12.SelectedIndex = comboBox12.Items.IndexOf(modorigin); } catch(Exception) { MessageBox.Show("无此曲目", "提示"); } }
private void button2_Click(object sender, EventArgs e) { using (sqlAdapter sqladp = new sqlAdapter()) { string sql = "delete from [gas] where scode='" + modscode + "'"; sqladp.ExecuteScalar(sql); sql = "delete from [song] where scode='" + modscode + "'"; sqladp.ExecuteScalar(sql); sql = " select gcode from gas where gcode='" + modgcode + "'"; object obj = sqladp.ExecuteScalar(sql); if (obj == null) { sql = "delete from [group] where gcode='" + modgcode + "'"; sqladp.ExecuteScalar(sql); } sql = " select acode from gas where acode='" + modacode + "'"; object obj1 = sqladp.ExecuteScalar(sql); if (obj1 == null) { sql = "delete from [album] where acode='" + modacode + "'"; sqladp.ExecuteScalar(sql); } } MessageBox.Show("已删除", "提示"); this.Dispose(); }
private void button1_Click(object sender, EventArgs e) { if (comboBox2.Text == "" || comboBox4.Text == "" || comboBox6.Text == "" || comboBox3.Text == "" || comboBox8.Text == "" || comboBox9.Text == "") { MessageBox.Show("请填写完整带“*”的数据", "提示"); return; } //________________________________________________________________________________________________ addacode = comboBox2.Text; addaname = comboBox4.Text.Replace("'", "''"); addtime = comboBox5.Text; addgcode = addacode.Substring(0, 4); addtrack = comboBox6.Text; addscode = addacode + addtrack; addgname = comboBox3.Text.Replace("'", "''"); addorigin = comboBox12.Text; addsname = comboBox8.Text.Replace("'", "''"); addarranger = comboBox9.Text.Replace("'", "''"); addlyric = comboBox7.Text.Replace("'", "''"); addvocal = comboBox11.Text.Replace("'", "''"); addstyle = comboBox10.Text.Replace("'", "''"); using (sqlAdapter sqladp = new sqlAdapter()) { string sql = "select oricode from [ori] where origin = '" + addorigin + "'"; addoricode = sqladp.ExecuteScalar(sql) as string; if (addoricode == null) { MessageBox.Show("没有找到原曲!", "消息提示"); Form9 Form9 = new Form9(); Form9.ShowDialog(); return; } sql = "select acode from [album] where acode = '" + addacode + "'"; object obj = sqladp.ExecuteScalar(sql); if (obj == null) { sql = "insert into [album] values ('" + addacode + "','" + addaname + "','" + addtime + "',@cover)"; sqladp.setCommand(sql); sqladp.Command.Parameters.Add("cover", SqlDbType.Image); sqladp.Command.Parameters["cover"].Value = imagebytes; sqladp.Command.ExecuteNonQuery(); } sql = "select gcode from [group] where gcode = '" + addgcode + "'"; obj = sqladp.ExecuteScalar(sql); //对数据库查询出的值进行判断 if (obj == null) { sql = "insert into [group] values ('" + addgname + "','" + addgcode + "')"; sqladp.ExecuteScalar(sql); } try { sql = "insert into [song] values ('" + addsname + "','" + addtrack + "','" + addarranger + "','" + addlyric + "','" + addvocal + "','" + addoricode + "','" + addstyle + "','" + addscode + "','" + DataPool.currentID + "')"; sqladp.ExecuteScalar(sql); sql = "insert into [gas] values ('" + addgcode + "','" + addacode + "','" + addscode + "')"; sqladp.ExecuteScalar(sql); MessageBox.Show("提交成功!", "提示信息"); } catch (Exception) { MessageBox.Show("错误", "提示信息"); return; } } }
private void Form4_Load(object sender, EventArgs e) { // imagebytes = ImageToStream(".\\x.jpg"); // imagebytes[0] =0; imagebytes = new byte[1]; imagebytes[0] = 0; List<ComboBox> CB = new List<ComboBox>(11); List<DataTable> dt; CB.Add(comboBox2); CB.Add(comboBox3); CB.Add(comboBox4); CB.Add(comboBox5); CB.Add(comboBox6); CB.Add(comboBox7); CB.Add(comboBox8); CB.Add(comboBox9); CB.Add(comboBox10); CB.Add(comboBox11); CB.Add(comboBox12); using (sqlAdapter sqladp = new sqlAdapter()) { try { sqladp.getDataTables(out dt, "select distinct acode from [album]", "select distinct gname from [group]", "select distinct aname from [album]", "select distinct [time] from [album]", "select distinct track from [song]", "select distinct lyric from [song]", "select distinct sname from [song]", "select distinct arranger from [song]", "select distinct style from [song]", "select distinct vocal from [song]", "select distinct origin from [ori]"); Program.fillIn(ref dt, ref CB); } catch (System.Exception ex) { System.Diagnostics.Debug.Write(ex.Message); } } //comboBox2.SelectedIndex = 0; //for (int i = 0; i < ds3.Tables[0].Rows.Count; i++) //{ // comboBox3.Items.Add(ds3.Tables[0].Rows[i][0]); //} //comboBox3.SelectedIndex = 0; //for (int i = 0; i < ds4.Tables[0].Rows.Count; i++) //{ // comboBox4.Items.Add(ds4.Tables[0].Rows[i][0]); //} //comboBox4.SelectedIndex = 0; //for (int i = 0; i < ds5.Tables[0].Rows.Count; i++) //{ // comboBox5.Items.Add(ds5.Tables[0].Rows[i][0]); //} //comboBox5.SelectedIndex = 0; //for (int i = 0; i < ds6.Tables[0].Rows.Count; i++) //{ // comboBox6.Items.Add(ds6.Tables[0].Rows[i][0]); //} //comboBox6.SelectedIndex = 0; //for (int i = 0; i < ds7.Tables[0].Rows.Count; i++) //{ // comboBox7.Items.Add(ds7.Tables[0].Rows[i][0]); //} //comboBox7.SelectedIndex = 0; //for (int i = 0; i < ds8.Tables[0].Rows.Count; i++) //{ // comboBox8.Items.Add(ds8.Tables[0].Rows[i][0]); //} //comboBox8.SelectedIndex = 0; //for (int i = 0; i < ds9.Tables[0].Rows.Count; i++) //{ // comboBox9.Items.Add(ds9.Tables[0].Rows[i][0]); //} //comboBox9.SelectedIndex = 0; //for (int i = 0; i < ds10.Tables[0].Rows.Count; i++) //{ // comboBox10.Items.Add(ds10.Tables[0].Rows[i][0]); //} //comboBox10.SelectedIndex = 0; //for (int i = 0; i < ds11.Tables[0].Rows.Count; i++) //{ // comboBox11.Items.Add(ds11.Tables[0].Rows[i][0]); //} //comboBox11.SelectedIndex = 0; //for (int i = 0; i < ds12.Tables[0].Rows.Count; i++) //{ // comboBox12.Items.Add(ds12.Tables[0].Rows[i][0]); //} //comboBox12.SelectedIndex = 0; }
private void button4_Click(object sender, EventArgs e) { string autho; using (sqlAdapter sqladp = new sqlAdapter()) { string sql = "select autho from [user] where username = '******'"; autho = sqladp.ExecuteScalar(sql) as string; } if (autho == "1" || autho == "0") { Form12 Form12 = new Form12(); Form12.ShowDialog(); } else { MessageBox.Show("权限不足", "提示"); return; } }
private void button5_Click(object sender, EventArgs e) { userid = textBox1.Text; password = textBox2.Text; if (userid == string.Empty) { MessageBox.Show("请输入用户名", "提示"); return; } for (int i = 0; i < userid.Length; i++) { if (userid[i] == '\'') { MessageBox.Show("用户名不存在!", "提示"); return; } } using (sqlAdapter sqladp = new sqlAdapter()) { string sql = "select password from [user] where username = '******'"; object obj = sqladp.ExecuteScalar(sql); if (obj == null) { MessageBox.Show("用户名不存在!", "提示"); return; } else { if (psCt(password) == obj.ToString()) { DataPool.currentID = userid; DataPool.currentMD5Password = obj.ToString(); //this.Visible = false; sql = "select autho from [user] where username = '******'"; string autho = sqladp.ExecuteScalar(sql) as string; if (autho == "0") { Form10 Form10 = new Form10(); Form10.ShowDialog(); } else { MessageBox.Show("权限不足", "提示"); return; } } else { MessageBox.Show("密码错误", "提示"); } } } }
private void button4_Click(object sender, EventArgs e) { modlyric2 = comboBox7.Text.Replace("'", "''"); modsname2 = comboBox8.Text.Replace("'", "''"); modarranger2 = comboBox9.Text.Replace("'", "''"); modstyle2 = comboBox10.Text.Replace("'", "''"); modvocal2 = comboBox11.Text.Replace("'", "''"); modorigin2 = comboBox12.Text.Replace("'", "''"); if (modlyric2 != modlyric) { using (sqlAdapter sqladp = new sqlAdapter()) { sqladp.ExecuteScalar("update [song] set lyric='" + modlyric2 + "' where scode='" + modscode + "'"); } MessageBox.Show("修改作词成功!", "消息"); } if (modsname2 != modsname) { using (sqlAdapter sqladp = new sqlAdapter()) { sqladp.ExecuteScalar("update [song] set sname='" + modsname2 + "' where scode='" + modscode + "'"); } MessageBox.Show("修改歌曲名成功!", "消息"); } if (modarranger2 != modarranger) { using (sqlAdapter sqladp = new sqlAdapter()) { sqladp.ExecuteScalar("update [song] set arranger='" + modarranger2 + "' where scode='" + modscode + "'"); } MessageBox.Show("修改编曲成功!", "消息"); } if (modstyle2 != modstyle) { using (sqlAdapter sqladp = new sqlAdapter()) { sqladp.ExecuteScalar("update [song] set style='" + modstyle2 + "' where scode='" + modscode + "'"); } MessageBox.Show("修改曲风成功!", "消息"); } if (modvocal2 != modvocal) { using (sqlAdapter sqladp = new sqlAdapter()) { sqladp.ExecuteScalar("update [song] set vocal='" + modvocal2 + "' where scode='" + modscode + "'"); } MessageBox.Show("修改歌手成功!", "消息"); } using (sqlAdapter sqladp = new sqlAdapter()) { modoricode2 = sqladp.ExecuteScalar("select oricode from [ori] where origin = '" + modorigin2 + "'") as string; } if (modoricode2 != modoricode) { using (sqlAdapter sqladp = new sqlAdapter()) { sqladp.ExecuteScalar("update [song] set oricode='" + modoricode2 + "' where scode='" + modscode + "'"); } MessageBox.Show("修改原曲成功!", "消息"); } }
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { DataSet ds6 = new DataSet(); comboBox1.Items.Clear(); comboBox3.Items.Clear(); comboBox4.Items.Clear(); comboBox5.Items.Clear(); comboBox7.Items.Clear(); comboBox8.Items.Clear(); comboBox10.Items.Clear(); comboBox11.Items.Clear(); comboBox12.Items.Clear(); comboBox9.Items.Clear(); modacode = comboBox2.Text; modgcode = modacode.Substring(0, 4); List<DataTable> dt; List<ComboBox> CB = new List<ComboBox>(4); CB.Add(comboBox3); CB.Add(comboBox4); CB.Add(comboBox5); CB.Add(comboBox6); using (sqlAdapter sqladp = new sqlAdapter()) { try { sqladp.getDataTables(out dt,"select distinct gcode from [gas] where acode='" + modacode + "'"); for (int i = 0; i < dt[0].Rows.Count; i++) { comboBox1.Items.Add(dt[0].Rows[i][0]); } comboBox1.SelectedIndex = 0; modgcode = comboBox1.Text; sqladp.getDataTables(out dt, "select gname from [group] where gcode='" + modgcode + "'", "select aname from [album] where acode='" + modacode + "'", "select [time] from [album] where acode='" + modacode + "'", "select distinct track from [song],gas where gas.scode=song.scode and acode='" + modacode + "'"); comboBox6.Items.Clear(); Program.fillIn(ref dt, ref CB); modgcode = comboBox1.Text; modgname = comboBox3.Text; modaname = comboBox4.Text; modtime = comboBox5.Text; comboBox6.SelectedIndex = 0; } catch(Exception) { MessageBox.Show("无此曲目", "提示"); } } pictureBox1.Image = null; // byte[] imagebytes = null; using (sqlAdapter sqladp = new sqlAdapter()) { SqlDataReader dr; sqladp.getExecuteReader(out dr,"select cover from album where acode='" + modacode + "'"); while (dr.Read()) { imagebytes1 = (byte[])dr.GetValue(0); } dr.Close(); } if (imagebytes1 != null) { if (imagebytes1[0] == 0) { pictureBox1.Image = touhou_music.Properties.Resources.x; return; } MemoryStream ms = new MemoryStream(imagebytes1); Bitmap bmpt = new Bitmap(ms); //Image image = Image.FromStream(ms, true); //dr.Close(); //closeSQL(); pictureBox1.Image = bmpt; } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { pictureBox2.Image = null; int row = dataGridView1.CurrentCell.RowIndex; string nowalbum = dataGridView1.Rows[row].Cells[1].Value.ToString(); byte[] imagebytes = null; using (sqlAdapter sqladp = new sqlAdapter()) { //" + tempaname + " SqlDataReader dr; sqladp.getExecuteReader(out dr,"select cover from album where aname='" + nowalbum.Replace("'", "''") + "'"); while (dr.Read()) { imagebytes = (byte[])dr.GetValue(0); } dr.Close(); } if (imagebytes != null) { if (imagebytes[0] == 0) { pictureBox2.Image = touhou_music.Properties.Resources.x; return; } MemoryStream ms = new MemoryStream(imagebytes); Bitmap bmpt = new Bitmap(ms); //Image image = Image.FromStream(ms, true); //dr.Close(); //closeSQL(); pictureBox2.Image = bmpt; } }
private void Form2_Load(object sender, EventArgs e) { Form1 Form1 = new Form1(); Form1.ShowDialog(); if (!Form1.IsDisposed) return; //if (DataPool.currentID == "") // return; using (sqlAdapter sqladp = new sqlAdapter()) { string sql = "select count(scode) from gas "; int ssum = Convert.ToUInt16(sqladp.ExecuteScalar(sql)); toolStripStatusLabel1.Text = "目前歌曲数:" + ssum; sql = "select count(username) from [user] "; int peoplesum = Convert.ToUInt16(sqladp.ExecuteScalar(sql)); toolStripStatusLabel3.Text = "注册人数:" + peoplesum; sql = "select autho from [user] where username = '******'"; string autho = sqladp.ExecuteScalar(sql) as string; DataPool.currentAutho = autho; switch (autho) { case "3": 添加原曲ToolStripMenuItem.Enabled = false; 添加ToolStripMenuItem.Enabled = false; 删除ToolStripMenuItem.Enabled = false; 修改ToolStripMenuItem.Enabled = false; break; case "2": 删除ToolStripMenuItem.Enabled = false; 修改ToolStripMenuItem.Enabled = false; break; } DataSet ds; sqladp.getDataSet("SELECT origin FROM ori",out ds); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { comboBox1.Items.Add(ds.Tables[0].Rows[i][0]); } comboBox1.SelectedIndex = 0; } // clerkNameText.Text = "当前管理员 " + DataPool.currentID; // statusStrip1.Items.Insert(1, new ToolStripSeparator()); }
private void button1_Click(object sender, EventArgs e) { comboBox3.Items.Clear(); comboBox4.Items.Clear(); comboBox5.Items.Clear(); comboBox7.Items.Clear(); comboBox8.Items.Clear(); comboBox9.Items.Clear(); comboBox10.Items.Clear(); comboBox11.Items.Clear(); comboBox12.Items.Clear(); List<ComboBox> CB = new List<ComboBox>(9); List<DataTable> dt; CB.Add(comboBox3); CB.Add(comboBox4); CB.Add(comboBox5); CB.Add(comboBox7); CB.Add(comboBox8); CB.Add(comboBox9); CB.Add(comboBox10); CB.Add(comboBox11); CB.Add(comboBox12); modacode = comboBox2.Text; modtrack = comboBox6.Text; modscode = modacode + modtrack; modgcode = modacode.Substring(0, 4); using (sqlAdapter sqladp = new sqlAdapter()) { try { sqladp.getDataTables(out dt, "select gname from [group] where gcode='" + modgcode + "'", "select aname from [album] where acode='" + modacode + "'", "select [time] from [album] where acode='" + modacode + "'", "select lyric from [song] where scode='" + modscode + "'","select sname from [song] where scode='" + modscode + "'", "select arranger from [song] where scode='" + modscode + "'","select style from [song] where scode='" + modscode + "'", "select vocal from [song] where scode='" + modscode + "'", "select origin from [ori],song where ori.oricode=song.oricode and scode='" + modscode + "'"); for (int i = 0; i < dt.Count; i++) { try { for (int j = 0; j < dt[i].Rows.Count; j++) { CB[i].Items.Add(dt[i].Rows[j][0]); } CB.ElementAt(i).SelectedIndex = 0; } catch (System.Exception ex) { System.Diagnostics.Debug.Write(ex.Message); MessageBox.Show("无此曲目", "提示"); } } } catch (System.Exception ex) { System.Diagnostics.Debug.Write(ex.Message); } //modgname = comboBox3.Text; //modaname = comboBox4.Text; //modtime = comboBox5.Text; // modacode = comboBox2.Text; // modtrack = comboBox6.Text; } }