Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            /*string filePath = @"DSTL.txt";
             * String[] lines; ;
             * lstTheLoaiBH.Items.Clear();
             *
             * if (System.IO.File.Exists(filePath))
             * {
             *  lines = System.IO.File.ReadAllLines(filePath);
             *  for (int i = 0; i < lines.Length; i++)
             *  {
             *      lstTheLoaiBH.Items.Add(lines[i]);
             *  }
             * }*/
            lstTheLoaiBH.DisplayMember = "TenTL";
            lstTheLoaiBH.ValueMember   = "MaTL";
            lstTheLoaiBH.DataSource    = KetNoiCSDL.LayBang("select * from TheLoai1");


            /*foreach (DataRow dr in KetNoiCSDL.LayBang("select * from TheLoai1").Rows)
             *  lstTheLoaiBH.Items.Add(dr);
             * lstTheLoaiBH.Items.Clear();*/
            /*foreach (TheLoai t in frmThongTin.DSTheLoai)
             * {
             *  lstTheLoaiBH.Items.Add(t);
             * }*/
        }
Exemple #2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            bool check = false;

            /*TheLoai t = new TheLoai();
             * t.MaTL = txtMaTL.Text;
             * t.TenTL = txtTenTL.Text;
             */
            if (txtMaTL.Text == "")
            {
                MessageBox.Show("Mã thể loại trống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (txtTenTL.Text == "")
            {
                MessageBox.Show("Tên thể loại trống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DataRowView t2 = (DataRowView)lstTheLoaiBH.SelectedItem;

            if (txtMaTL.Text == t2.Row["MaTL"].ToString())
            {
                check = true;
            }
            if (check == true)
            {
                MessageBox.Show("Mã thể loại tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtTenTL.Text.ToLower() == t2.Row["TenTL"].ToString().ToLower())
            {
                check = true;
            }
            if (check == true)
            {
                MessageBox.Show("Tên thể loại tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //frmThongTin.DSTheLoai.Add(t);

            KetNoiCSDL.ThayDoiDL("insert into TheLoai1 values ('" + txtMaTL.Text.Trim() + "','" + txtTenTL.Text.Trim() + "')");

            /*using (TextWriter sw = new StreamWriter(@"DSTL.txt", true))
             * {
             *  foreach (TheLoai s in frmThongTin.DSTheLoai)
             *  {
             *      sw.WriteLine(t);
             *  }
             * }*/
            ShowTheLoai();
            XoaManHinh();
            CheckChanged = true;
        }
Exemple #3
0
        void ShowBaiHat()
        {
            /*lstDanhSachBH.Items.Clear();
             * foreach (BaiHat m in DSBaiHat)
             * {
             *  lstDanhSachBH.Items.Add(m);
             * }*/

            lstDanhSachBH.DisplayMember = "TenBH";
            lstDanhSachBH.ValueMember   = "MaBH";
            lstDanhSachBH.DataSource    = KetNoiCSDL.LayBang("select * from BaiHat");
        }
Exemple #4
0
        private void ShowTheLoai()
        {
            /* cboTheLoai.Items.Clear();
             * foreach (TheLoai t in DSTheLoai)
             * {
             *   cboTheLoai.Items.Add(t);
             * }     */

            cboTheLoai.DisplayMember = "TenTL";
            cboTheLoai.ValueMember   = "MaTL";
            cboTheLoai.DataSource    = KetNoiCSDL.LayBang("select * from TheLoai1");
        }
Exemple #5
0
        void ShowTheLoai()
        {
            //lstTheLoaiBH.Items.Clear();

            /* foreach (TheLoai t in frmThongTin.DSTheLoai)
             * {
             *   lstTheLoaiBH.Items.Add(t);
             * }        */
            lstTheLoaiBH.DisplayMember = "TenTL";
            lstTheLoaiBH.ValueMember   = "MaTL";
            lstTheLoaiBH.DataSource    = KetNoiCSDL.LayBang("select * from TheLoai1");
        }
Exemple #6
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (lstTheLoaiBH.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn thể loại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DataRowView  t   = (DataRowView)lstTheLoaiBH.SelectedItem;
            DialogResult ret = MessageBox.Show(
                "Bạn muốn xóa [ " + t.Row["TenTL"] + "]?",
                "Hỏi", MessageBoxButtons.YesNo,
                MessageBoxIcon.Question);

            if (ret == DialogResult.Yes)
            {
                CheckChanged = true;
                //frmThongTin.DSTheLoai.Remove(t);
                //lstTheLoaiBH.Items.Remove(t);
                KetNoiCSDL.ThayDoiDL("delete from TheLoai1 where TenTl = '" + txtTenTL.Text + "' ");
                KetNoiCSDL.ThayDoiDL("delete from BaiHat where TenTl = '" + txtTenTL.Text + "' ");
                ShowTheLoai();
                MessageBox.Show("Bạn đã xóa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            XoaManHinh();

            /*if (lstTheLoaiBH.SelectedIndex == -1)
             * {
             *  MessageBox.Show("Bạn chưa chọn thể loại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             *  return;
             * }
             *
             * TheLoai t = lstTheLoaiBH.SelectedItem as TheLoai;
             * DialogResult ret = MessageBox.Show(
             *  "Bạn muốn xóa [ " + t.TenTL + "]?",
             *  "Hỏi", MessageBoxButtons.YesNo,
             *  MessageBoxIcon.Question);
             * if (ret == DialogResult.Yes)
             * {
             *  CheckChanged = true;
             *  frmThongTin.DSTheLoai.Remove(t);
             *  lstTheLoaiBH.Items.Remove(t);
             * }
             * XoaManHinh();
             */
        }
Exemple #7
0
        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            if (txtTimKiem.Text != "")
            {
                lstDanhSachBH.DisplayMember = "TenBH";
                lstDanhSachBH.ValueMember   = "MaBH";
                lstDanhSachBH.DataSource    = KetNoiCSDL.LayBang("select * from BaiHat where TenBH Like '%" + txtTimKiem.Text + "%'");
                if (lstDanhSachBH.Items.Count == 0)
                {
                    MessageBox.Show("Bài hát không tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtTimKiem.Text = "";
                    txtTimKiem.Focus();
                    return;
                }

                /*int count = 0;
                 * List<BaiHat> DanhSachTam = new List<BaiHat>();
                 * foreach (BaiHat m1 in DSBaiHat)
                 * {
                 *  if (txtTimKiem.Text.ToLower() == m1.TenBH.ToLower())
                 *  {
                 *      DanhSachTam.Add(m1);
                 *      count++;
                 *  }
                 * }
                 * if(count == 0)
                 * {
                 *  MessageBox.Show("Bài hát không tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 *  lstDanhSachBH.Items.Clear();
                 *  txtTimKiem.Focus();
                 *  return;
                 * }
                 * lstDanhSachBH.Items.Clear();
                 * foreach (BaiHat m in DanhSachTam)
                 * {
                 *      lstDanhSachBH.Items.Add(m);
                 * }*/
            }
            else
            {
                MessageBox.Show("Bạn chưa nhập thông tin tìm kiếm!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }
Exemple #8
0
        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            if (txtTimKiem.Text != "")
            {
                lstTheLoaiBH.DisplayMember = "TenTL";
                lstTheLoaiBH.ValueMember   = "MaTL";
                lstTheLoaiBH.DataSource    = KetNoiCSDL.LayBang("select * from TheLoai1 where TenTL Like '%" + txtTimKiem.Text + "%'");
                if (lstTheLoaiBH.Items.Count == 0)
                {
                    MessageBox.Show("Thể loại không tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtTimKiem.Text = "";
                    txtTimKiem.Focus();
                    return;
                }

                /* int count = 0;
                 * List<TheLoai> DanhSachTam = new List<TheLoai>();
                 * foreach (TheLoai t1 in frmThongTin.DSTheLoai)
                 * {
                 *   if (txtTimKiem.Text.ToLower() == t1.TenTL.ToLower())
                 *   {
                 *       DanhSachTam.Add(t1);
                 *       count++;
                 *   }
                 * }
                 * if (count == 0)
                 * {
                 *   MessageBox.Show("Thể loại không tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 *   lstTheLoaiBH.Items.Clear();
                 *   txtTimKiem.Focus();
                 *   return;
                 * }
                 * lstTheLoaiBH.Items.Clear();
                 * foreach (TheLoai t in DanhSachTam)
                 * {
                 *   lstTheLoaiBH.Items.Add(t);
                 * }*/
            }
            else
            {
                MessageBox.Show("Bạn chưa nhập thông tin tìm kiếm!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }
Exemple #9
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (lstDanhSachBH.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn chưa chọn bài hát!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            DataRowView  m   = (DataRowView)lstDanhSachBH.SelectedItem;
            DialogResult ret = MessageBox.Show(
                "Bạn muốn xóa [" + m.Row["TenTL"].ToString() + "]?",
                "Hỏi",
                MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (ret == DialogResult.Yes)
            {
                //DSBaiHat.Remove(m);
                KetNoiCSDL.ThayDoiDL("delete from BaiHat where TenBH = '" + txtTenBH.Text + "' and MaBH = '" + txtMaBH.Text + "'");
                ShowBaiHat();
                MessageBox.Show("Bạn đã xóa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            XoaManHinh();

            /*if (lstDanhSachBH.SelectedIndex == -1)
             * {
             *  MessageBox.Show("Bạn chưa chọn bài hát!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             *  return;
             * }
             * BaiHat m = lstDanhSachBH.SelectedItem as BaiHat;
             * DialogResult ret = MessageBox.Show(
             *  "Bạn muốn xóa [" + m.TenBH + "]?",
             *  "Hỏi",
             *  MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             * if (ret == DialogResult.Yes)
             * {
             *  DSBaiHat.Remove(m);
             *  ShowBaiHat();
             * }
             * XoaManHinh();*/
        }
Exemple #10
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            /*lstDanhSachBH.Items.Clear();
             * foreach (BaiHat m in DSBaiHat)
             * {
             *  lstDanhSachBH.Items.Add(m);
             * }*/

            /*string filePath = @"DSBH.txt";
             * string[] lines;
             * lstDanhSachBH.Items.Clear();
             * if (System.IO.File.Exists(filePath))
             * {
             *  lines = System.IO.File.ReadAllLines(filePath);
             *  for (int i = 0; i < lines.Length; i++)
             *  {
             *      lstDanhSachBH.Items.Add(lines[i]);
             *  }
             * }*/
            lstDanhSachBH.DisplayMember = "TenBH";
            lstDanhSachBH.ValueMember   = "MaBH";
            lstDanhSachBH.DataSource    = KetNoiCSDL.LayBang("select * from BaiHat");
        }
Exemple #11
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            bool check = false;

            if (cboTheLoai.SelectedIndex == -1)
            {
                MessageBox.Show("Thể loại không tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtMaBH.Text == "" || txtTenBH.Text == "" || txtTacGia.Text == "" || txtQuocGia.Text == "")
            {
                MessageBox.Show("Bạn chưa điền đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            /*TheLoai t = cboTheLoai.SelectedItem as TheLoai;
             * BaiHat m = new BaiHat();
             * m.MaBH = txtMaBH.Text;
             * m.TenBH = txtTenBH.Text;
             * m.TacGia = txtTacGia.Text;
             * m.QuocGia = txtQuocGia.Text;
             * m.NamPhatHanh = dtpNPH.Value;*/

            DataRowView m = (DataRowView)lstDanhSachBH.SelectedItem;

            if (txtMaBH.Text == m.Row["MaBH"].ToString())
            {
                check = true;
            }
            if (check == true)
            {
                DialogResult ret = MessageBox.Show("Mã bài hát tồn tại!\nBạn có muốn cập nhật bài hát?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (ret == DialogResult.Yes)
                {
                    KetNoiCSDL.ThayDoiDL("update BaiHat set TenTL ='" + cboTheLoai.GetItemText(cboTheLoai.SelectedItem).Trim() + "', TenBH = '" + txtTenBH.Text.Trim() + "', TacGia = '" + txtTacGia.Text.Trim() + "', QuocGia = '" + txtQuocGia.Text.Trim() + "', NamPhatHanh = '" + dtpNPH.Value.ToString("MM/dd/yyyy").Trim() + "', LinkBH = '" + txtDuongDan.Text.Trim() + "' where MaBH = '" + txtMaBH.Text.Trim() + "'");
                    ShowBaiHat();
                    MessageBox.Show("Cập nhật thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                XoaManHinh();
                return;
            }
            else
            {
                //t.addBH(m);
                //DSBaiHat.Add(m);

                KetNoiCSDL.ThayDoiDL("insert into BaiHat( MaBH, TenBH, TenTL, TacGia, QuocGia, NamPhatHanh, LinkBH) values ('" + txtMaBH.Text.Trim() + "','" + txtTenBH.Text.Trim() + "' ,'" + cboTheLoai.GetItemText(cboTheLoai.SelectedItem).Trim() + "','" + txtTacGia.Text.Trim() + "','" + txtQuocGia.Text.Trim() + "','" + dtpNPH.Value.ToString("MM/dd/yyyy").Trim() + "','" + txtDuongDan.Text.Trim() + "')");
                ShowBaiHat();
                XoaManHinh();
            }

            /*int i = 0;
             * bool check = false;
             *
             * if (cboTheLoai.SelectedIndex == -1)
             * {
             *  MessageBox.Show("Thể loại không tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             *  return;
             * }
             * if (txtMaBH.Text == "" || txtTenBH.Text == "" || txtTacGia.Text == "" || txtQuocGia.Text == "")
             * {
             *  MessageBox.Show("Bạn chưa điền đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             *  return;
             * }
             * TheLoai t = cboTheLoai.SelectedItem as TheLoai;
             * BaiHat m = new BaiHat();
             * m.MaBH = txtMaBH.Text;
             * m.TenBH = txtTenBH.Text;
             * m.TacGia = txtTacGia.Text;
             * m.QuocGia = txtQuocGia.Text;
             * m.NamPhatHanh = dtpNPH.Value;
             *
             * foreach (BaiHat m1 in DSBaiHat)
             * {
             *  if (m.MaBH == m1.MaBH)
             *      check = true;
             * }
             * if (check == true)
             * {
             *  MessageBox.Show("Mã bài hát tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             *  return;
             * }
             * else
             * {
             *
             *  t.addBH(m);
             *  DSBaiHat.Add(m);
             *  DataRowView cb = (DataRowView)cboTheLoai.SelectedItem;
             *  KetNoiCSDL.ThayDoiDL("insert into BaiHat values ('" + txtMaBH.Text.Trim() + "','" + txtTenBH.Text.Trim() + "'),'" + cb + "','" + txtTacGia.Text.Trim() + "','" + txtQuocGia.Text.Trim() + "','" + dtpNPH.Value + "'");
             *
             *  ShowBaiHat();
             *  XoaManHinh();
             * }*/
        }