Beispiel #1
0
        private void btnXoatheloai_Click(object sender, EventArgs e)
        {
            if (lvwTheloai.SelectedItems.Count == 0)
            {
                return;
            }
            DialogResult tb = MessageBox.Show("Bạn có thực sự muốn xóa Thể loại[" + lvwTheloai.SelectedItems[0].SubItems[1].Text + "] không!", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (tb == DialogResult.Cancel)
            {
                return;
            }
            string     matl = lvwTheloai.SelectedItems[0].Tag.ToString();
            tblTheloai dt   = new tblTheloai(matl);
            int        kq   = dt.xoaTheLoai();

            if (kq == 0)
            {
                MessageBox.Show("Bạn đã xóa Thể Loại[" + lvwTheloai.SelectedItems[0].SubItems[1].Text + "] thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Bạn chưa xóa được thể loại!)", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            lvwTheloai.Items.Clear();
            loadlai_listview();
        }
        private void btnDongy_Click(object sender, EventArgs e)
        {
            tblTheloai objtheloai;

            try
            {
                objtheloai = new tblTheloai(txtMatheloai.Text, txtTentheloai.Text);
            }
            catch (Exception ex)
            {
                string erro = ex.Message;
                MessageBox.Show(erro, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (erro.Contains("mã"))
                {
                    txtMatheloai.Focus();
                }
                else
                {
                    txtTentheloai.Focus();
                }
                return;
            }
            tblTheloai objTheloai = new tblTheloai(txtMatheloai.Text, txtTentheloai.Text);
            int        result     = objTheloai.capnhatTheLoai();

            if (result == 0)
            {
                MessageBox.Show("Cập nhật thành công [" + txtTentheloai.Text + "]!");
            }
            else
            {
                MessageBox.Show("Cập nhật thất bại");
            }
            this.DialogResult = DialogResult.OK;
        }
Beispiel #3
0
        private void lvwTheloai_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvwTheloai.SelectedItems.Count == 0)
            {
                return;
            }
            lvwBaihat_theloai.Items.Clear();
            DataTable dt;

            try
            {
                dt = new tblBaihat().getBaiHat_by_TheLoai(lvwTheloai.SelectedItems[0].Tag.ToString());

                foreach (DataRow dr in dt.Rows)
                {
                    ListViewItem li = lvwBaihat_theloai.Items.Add("");
                    li.SubItems.Add(dr["TenBaihat"].ToString());
                    DataTable dt1      = new tblCasi_Baihat().getCasi_BaiHat_by_mabaihat(dr["MaBaiHat"].ToString());
                    string    cac_casi = "";
                    foreach (DataRow r in dt1.Rows)
                    {
                        DataTable dtcasi = new tblCaSi().getCasi_by_macasi(r["MaCaSi"].ToString());
                        foreach (DataRow r1 in dtcasi.Rows)
                        {
                            cac_casi += r1["TenCaSi"].ToString() + ", ";
                        }
                    }
                    li.SubItems.Add(cac_casi + "...");
                    DataTable dtA = new tblTheloai().getTheLoai_by_ma(dr["MaTheLoai"].ToString());
                    DataRow   rr  = dtA.Rows[0];
                    li.SubItems.Add(rr["TenTheLoai"].ToString());
                    li.SubItems.Add(dr["LoiBaiHat"].ToString());
                    li.Tag = dr["MaBaiHat"];
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi không xác định");
                return;
            }
            STT(lvwBaihat_theloai);
        }
        private void btnDongy_Click(object sender, EventArgs e)
        {
            tblTheloai objTheLoai;

            try
            {
                objTheLoai = new tblTheloai(txtMatheloai.Text, txtTentheloai.Text);
            }
            catch (Exception ex)
            {
                string loi = ex.Message;
                MessageBox.Show(loi, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (loi.Contains("mã"))
                {
                    txtMatheloai.Focus();
                }
                else if (loi.Contains("tên"))
                {
                    txtTentheloai.Focus();
                }

                return;
            }
            tblTheloai tl     = new tblTheloai(txtMatheloai.Text, txtTentheloai.Text);
            int        resutl = tl.themTheLoai();

            if (resutl == 0)
            {
                MessageBox.Show("Thêm thành công thể loại [" + txtTentheloai.Text + "] với mã thể loại là [" + txtMatheloai.Text + "]");
            }
            else
            {
                MessageBox.Show("That bai");
            }
            this.DialogResult = DialogResult.OK;
        }