Ejemplo n.º 1
0
        private void btnAddVideo_Click(object sender, EventArgs e)
        {
            VideoForm dlg = new VideoForm();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string qry = string.Format("INSERT INTO tblVideo (Name, Num, Company, Director," +
                    "Major, Genre) VALUES ('{0}',{1},'{2}','{3}','{4}','{5}');",
                    dlg.Name1, dlg.Num, dlg.Company, dlg.Director, dlg.Major, dlg.Genre);
                SqlCommand Com = new SqlCommand(qry, Con);
                Com.ExecuteNonQuery();
                RefreshVideo();
            }
        }
Ejemplo n.º 2
0
        private void btnEditVideo_Click(object sender, EventArgs e)
        {
            int Pk;

            if (lvVideo.SelectedItems.Count == 0)
            {
                MessageBox.Show("수정할 비디오를 먼저 선택하십시오.");
                return;
            }
            Pk = Convert.ToInt32(lvVideo.SelectedItems[0].SubItems[0].Text);

            VideoForm dlg = new VideoForm();

            SqlCommand Com = new SqlCommand("SELECT Name, Num, Company, Director, Major, Genre FROM " +
                "tblVideo WHERE Pk = " + Pk.ToString(), Con);
            SqlDataReader R = Com.ExecuteReader();
            R.Read();
            dlg.Name1 = R["Name"].ToString();
            dlg.Num = (int)R["Num"];
            dlg.Company = R["Company"].ToString();
            dlg.Director = R["Director"].ToString();
            dlg.Major = R["Major"].ToString();
            dlg.Genre = R["Genre"].ToString();
            R.Close();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string qry = string.Format("UPDATE tblVideo Set Name = '{0}', Num = {1}, Company = '{2}', " +
                    "Director = '{3}', Major = '{4}', Genre = '{5}' WHERE Pk = {6}",
                    dlg.Name1, dlg.Num, dlg.Company, dlg.Director, dlg.Major, dlg.Genre, Pk);
                Com = new SqlCommand(qry, Con);
                Com.ExecuteNonQuery();
                RefreshVideo();
            }
        }