Esempio n. 1
0
        public void InsertMusic(MusicCD m)
        {
            try
            {
                if (baglanti.State == System.Data.ConnectionState.Closed)
                {
                    baglanti.Open();
                }
                SqlCommand cmd = new SqlCommand("Insert into Product (Name,Price) Values(@name,@price)", baglanti);
                cmd.Parameters.AddWithValue("@name", m.name);
                cmd.Parameters.AddWithValue("@price", m.price);
                cmd.ExecuteNonQuery();
                baglanti.Close();

                if (baglanti.State == System.Data.ConnectionState.Closed)
                {
                    baglanti.Open();
                }
                SqlCommand komut = new SqlCommand("Insert into MusicCD(MusicCD_ID,Singer,Type) Values((SELECT IDENT_CURRENT('Product')),@singer,@type)", baglanti);

                komut.Parameters.AddWithValue("@singer", m.singer);
                komut.Parameters.AddWithValue("@type", m.type);
                komut.ExecuteNonQuery();
                baglanti.Close();
                MessageBox.Show("Successfully Register !", "Success !", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch
            {
                MessageBox.Show("Registor is failed !", "Failed !", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                throw;
            }
        }
Esempio n. 2
0
        public void UpdateMusic(MusicCD oldMusic, MusicCD newMusic)
        {
            try
            {
                SqlConnection connect = new SqlConnection(@"Data Source=Your PC Name;Initial Catalog=Book_Store;Integrated Security=True");
                if (connect.State == System.Data.ConnectionState.Closed)
                {
                    connect.Open();
                }

                SqlCommand kmt = new SqlCommand("Update Product Set [Name] = '" + newMusic.name + "',[Price] = " + (newMusic.price) + " Where [Product_ID] = " + (oldMusic.ID) + " ", connect);
                kmt.ExecuteNonQuery();
                connect.Close();

                if (connect.State == System.Data.ConnectionState.Closed)
                {
                    connect.Open();
                }
                SqlCommand komut = new SqlCommand("Update MusicCD Set [Singer] = '" + (newMusic.Singer) + "',[Type] = '" + newMusic.Type + "' Where [MusicCD_ID] = " + (oldMusic.ID) + " ", connect);
                komut.ExecuteNonQuery();
                connect.Close();
                MessageBox.Show("Successfully Update !", "Success !", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch
            {
                MessageBox.Show("Updating is failed !", "Failed !", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Esempio n. 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            grpBxMagazine.Visible = false;
            GrpBxMusic.Visible    = true;
            GrpBxBook.Visible     = false;
            MusicCD m = new MusicCD();

            m.printProperties(dataGridView1);
        }
Esempio n. 4
0
        private void btnRemoveMusic_Click(object sender, EventArgs e)
        {
            MusicCD m = new MusicCD();

            m.ID = int.Parse(dataGridView1.CurrentRow.Cells["Product_ID"].Value.ToString());
            try
            {
                musicProvide.Delete_MusicCD(m.ID);
                m.printProperties(dataGridView1);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 5
0
 private void btnAddMusic_Click(object sender, EventArgs e)
 {
     if (txtMusicName.Text != "" && txtSinger.Text != "" && cmBxType.Text != "" && txtMusicPrice.Text != "")
     {
         GrpBxBook.Visible  = false;
         GrpBxMusic.Visible = true;
         MusicCD music = new MusicCD();
         music.name   = txtMusicName.Text;
         music.Singer = txtSinger.Text;
         music.price  = int.Parse(txtMusicPrice.Text);
         music.Type   = cmBxType.Text;
         music.InsertMusic(music);
         music.printProperties(dataGridView1);
     }
     else
     {
         MessageBox.Show("Please fill in the blank fields", "Warning !", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }