示例#1
0
        public MusicCD GetMusicCD(int id)
        {
            MusicCD       musicCD    = null;
            SqlConnection connection = new SqlConnection(ConnectionString);

            connection.Open();
            SqlCommand    command = new SqlCommand("select * from musicCD", connection);
            SqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                if (id == Convert.ToInt32(reader["id"]))
                {
                    MusicCDType type = MusicCD.getMusicCDType(reader["type"].ToString().Trim());
                    musicCD    = new MusicCD(reader["singer"].ToString().Trim(), type, reader["name"].ToString(), Convert.ToInt32(reader["id"]), Convert.ToDouble(reader["price"]), reader["demo"].ToString().Trim(), reader["picture"].ToString(), reader["issue"].ToString());
                    musicCD.Id = Convert.ToInt32(reader["id"]);
                    if (musicCD.Id > Product.Idcount)
                    {
                        Product.Idcount = musicCD.Id;
                    }
                }
            }
            connection.Close();
            return(musicCD);
        }
示例#2
0
        private void btnAddMusicCD_Click(object sender, EventArgs e)
        {
            ;
            MusicCDType type = MusicCD.getMusicCDType(cmbMusicType.SelectedItem.ToString());

            adminUser.addNewMusicCD(txtMusicSinger.Text, type, txtMusicName.Text, Product.Idcount, Convert.ToDouble(txtMusicPrice.Text.Trim()), txtMusicName.Text.Trim() + ".jpg", txtMusicIssue.Text);
            DataTable dataTable = new DataTable();

            DataTable             = data.datagrid(dataTable, "musicCD");
            dtgMusicCD.DataSource = DataTable;
        }