示例#1
0
        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;
            }
        }
示例#2
0
        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;
            }
        }