Exemple #1
0
        protected void bt_CapNhat_Click(object sender, EventArgs e)
        {
            if (Session["NguoiDung"] == null)
            {
                Response.Redirect("/thanhvien/DangNhap.aspx");
                return;
            }

            CinemaLINQDataContext dt = new CinemaLINQDataContext();

            Button _sender      = (Button)sender;
            int    _maSuatChieu = int.Parse(_sender.CommandArgument);

            SuatChieu _suatChieuCapNhat = (from _sc in dt.SuatChieus
                                           where _sc.MaSuatChieu == _maSuatChieu
                                           select _sc).Single();

            TimeSpan _toQuery = TimeSpan.Parse(Session["CNLC-SuatChieuMoi"].ToString());

            DanhMucSuatChieu _scToUpdate = (from _dmsc in dt.DanhMucSuatChieus
                                            where _dmsc.ThoiGianBatDau.TimeOfDay == _toQuery
                                            select _dmsc).Single();

            _suatChieuCapNhat.MaDanhMucSuatChieu = _scToUpdate.MaDanhMucSuatChieu;
            dt.SubmitChanges();
            MyDataBind();
        }
        protected void btn_ThemSuat_Click(object sender, EventArgs e)
        {
            CinemaLINQDataContext dt = new CinemaLINQDataContext();

            var query = from dmsc in dt.DanhMucSuatChieus
                        where dmsc.ThoiGianBatDau.Hour == int.Parse(tb_Gio.Text) && dmsc.ThoiGianBatDau.Minute == int.Parse(tb_Phut.Text)
                        select dmsc;

            if (query.Count <DanhMucSuatChieu>() == 0)
            {
                DanhMucSuatChieu dmsc = new DanhMucSuatChieu();
                DateTime         time = new DateTime(1990, 1, 1);
                time = time.AddHours(int.Parse(tb_Gio.Text));
                time = time.AddMinutes(int.Parse(tb_Phut.Text));
                dmsc.ThoiGianBatDau = time;
                dmsc.TinhTrang      = true;
                dmsc.GiaDanhMuc     = int.Parse(tb_GiaDanhMucSuatMoi.Text);
                dt.DanhMucSuatChieus.InsertOnSubmit(dmsc);
                dt.SubmitChanges();
            }
        }