Beispiel #1
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            try
            {
                int  id   = Convert.ToInt32(lblID.Text);
                PHIM phim = Session.dbContxt.PHIMs.Where(x => x.ID == id).FirstOrDefault();

                Session.dbContxt.PHIMs.Remove(phim);
                Session.dbContxt.SaveChanges();

                MessageBox.Show("Xóa thành công");
                reloadData();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi đã xảy ra", ex.ToString());
            }
        }
Beispiel #2
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            try
            {
                int  id   = Convert.ToInt32(lblID.Text);
                PHIM phim = Session.dbContxt.PHIMs.Where(x => x.ID == id).FirstOrDefault();

                phim.Tenphim  = txtTenphim.Text;
                phim.Theloai  = txtTheloai.Text;
                phim.Thongtin = txtThongtin.Text;
                phim.Noidung  = txtNoidung.Text;

                Session.dbContxt.SaveChanges();

                MessageBox.Show("Sửa thành công");
                reloadData();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi đã xảy ra", ex.ToString());
            }
        }
Beispiel #3
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            try
            {
                PHIM phim = new PHIM();

                phim.Tenphim  = txtTenphim.Text;
                phim.Theloai  = txtTheloai.Text;
                phim.Thongtin = txtThongtin.Text;
                phim.Noidung  = txtNoidung.Text;

                Session.dbContxt.PHIMs.Add(phim);
                Session.dbContxt.SaveChanges();

                MessageBox.Show("Thêm thành công");
                reloadData();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi đã xảy ra", ex.ToString());
            }
        }