예제 #1
0
        protected void btn_PhatSinh_Click(object sender, EventArgs e)
        {
            CinemaLINQDataContext dt = new CinemaLINQDataContext();

            for (int i = 0; i < int.Parse(cbb_ChonNgay.SelectedItem.Value); ++i)
            {
                var query = from _lichchieu in dt.LichChieuPhims
                                where _lichchieu.NgayChieu.CompareTo(DateTime.Today.AddDays(i + 1)) == 0
                                select _lichchieu;
                LichChieuPhim lichchieu = null;
                if (query.Count<LichChieuPhim>() == 0)
                {
                    lichchieu = new LichChieuPhim();
                    lichchieu.NgayChieu = DateTime.Today.AddDays(i + 1);
                    lichchieu.TinhTrang = true;
                    dt.LichChieuPhims.InsertOnSubmit(lichchieu);
                    dt.SubmitChanges();
                }
                else
                {
                    lichchieu = query.Single();
                }

                var dmSuatChieu = from _dmsc in dt.DanhMucSuatChieus
                                  where _dmsc.TinhTrang == true
                                  select _dmsc;
                foreach (DanhMucSuatChieu dmsc in dmSuatChieu)
                {
                    var suatchieu = from _suatchieu in dt.SuatChieus
                                    where _suatchieu.MaLichChieu == lichchieu.MaLichChieuPhim && _suatchieu.MaPhim == int.Parse(cbb_ChonPhim.SelectedItem.Value) && _suatchieu.MaPhong == int.Parse(cbb_Phong.SelectedItem.Value) && _suatchieu.MaDanhMucSuatChieu == dmsc.MaDanhMucSuatChieu
                                    select _suatchieu;
                    if (suatchieu.Count<SuatChieu>() == 0)
                    {
                        SuatChieu sc = new SuatChieu();
                        sc.MaLichChieu = lichchieu.MaLichChieuPhim;
                        sc.MaPhim = int.Parse(cbb_ChonPhim.SelectedItem.Value);
                        sc.MaPhong = int.Parse(cbb_Phong.SelectedItem.Value);
                        sc.MaDanhMucSuatChieu = dmsc.MaDanhMucSuatChieu;
                        sc.TinhTrang = false;
                        dt.SuatChieus.InsertOnSubmit(sc);
                        dt.SubmitChanges();
                    }
                }
            }
        }
예제 #2
0
 protected void btn_XacNhan_Click(object sender, EventArgs e)
 {
     CinemaLINQDataContext dt = new CinemaLINQDataContext();
     if (Session["DungDo"] != null && (bool)Session["DungDo"] == true)
         lb_ThongBao.Text = "Vẫn còn đụng độ trên lịch chiếu - Thêm mới thất bại";
     else
     {
         for (int i = 0; i < int.Parse(cbb_ChonNgay.SelectedItem.Value); ++i)
         {
             var query = from _lichchieu in dt.LichChieuPhims
                         where _lichchieu.NgayChieu.CompareTo(DateTime.Today.AddDays(i + 1)) == 0
                         select _lichchieu;
             LichChieuPhim lichchieu = null;
             if (query.Count<LichChieuPhim>() == 0)
             {
                 lichchieu = new LichChieuPhim();
                 lichchieu.NgayChieu = DateTime.Today.AddDays(i + 1);
                 lichchieu.TinhTrang = true;
                 dt.LichChieuPhims.InsertOnSubmit(lichchieu);
                 dt.SubmitChanges();
             }
             else
             {
                 lichchieu = query.Single();
             }
             var dsSuatChieu = from _suatchieu in dt.SuatChieus
                               where _suatchieu.MaLichChieu == lichchieu.MaLichChieuPhim && _suatchieu.MaPhim == int.Parse(cbb_ChonPhim.SelectedItem.Value) && _suatchieu.MaPhong == int.Parse(cbb_Phong.SelectedItem.Value) && _suatchieu.TinhTrang == false
                               select _suatchieu;
             foreach (SuatChieu _suatchieu in dsSuatChieu)
             {
                 _suatchieu.TinhTrang = true;
                 dt.SubmitChanges();
             }
             var dsSuatChieuTam = from _suatchieu in dt.SuatChieus
                                  where _suatchieu.TinhTrang == false
                                  select _suatchieu;
             dt.SuatChieus.DeleteAllOnSubmit(dsSuatChieuTam);
             dt.SubmitChanges();
         }
     }
 }
예제 #3
0
 partial void UpdateLichChieuPhim(LichChieuPhim instance);
예제 #4
0
 partial void DeleteLichChieuPhim(LichChieuPhim instance);
예제 #5
0
 partial void InsertLichChieuPhim(LichChieuPhim instance);