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(); } } } }
protected void btn_ThayDoi_Click(object sender, EventArgs e) { CinemaLINQDataContext dt = new CinemaLINQDataContext(); var suatchieu = from _suatchieu in dt.SuatChieus where _suatchieu.MaSuatChieu == int.Parse(((LinkButton)sender).CommandArgument) select _suatchieu; dt.SuatChieus.DeleteAllOnSubmit(suatchieu); dt.SubmitChanges(); }
protected void btn_CapNhatGia_Click(object sender, EventArgs e) { CinemaLINQDataContext dt = new CinemaLINQDataContext(); var query = (from dmsc in dt.DanhMucSuatChieus where dmsc.MaDanhMucSuatChieu == int.Parse(((LinkButton)sender).CommandArgument) select dmsc).Single(); var giaMoi = int.Parse(((TextBox)dl_SuatChieuHienTai.Items[int.Parse(((LinkButton)sender).CommandName)].FindControl("tb_GiaDanhMuc")).Text); query.GiaDanhMuc = giaMoi; dt.SubmitChanges(); }
//protected void btn_Sua_Click(object sender, EventArgs e) //{ // Button btn = (Button)sender; // //((TextBox)dl_SuatChieuHienTai.Items[int.Parse(btn.CommandName)].FindControl("tb_ThoiGian")).ReadOnly = false; // CinemaLINQDataContext dt = new CinemaLINQDataContext(); // DateTime time = new DateTime(); // for (int i = 0; i < 96; ++i) // { // DanhMucSuatChieu dmsc = new DanhMucSuatChieu(); // dmsc.ThoiGianBatDau = time.AddMinutes(i * 15); // dmsc.TinhTrang = false; // dmsc.GiaDanhMuc = 90000; // dt.DanhMucSuatChieus.InsertOnSubmit(dmsc); // } // dt.SubmitChanges(); //} protected void btn_ThayDoi_Click(object sender, EventArgs e) { CinemaLINQDataContext dt = new CinemaLINQDataContext(); var query = (from dmsc in dt.DanhMucSuatChieus where dmsc.MaDanhMucSuatChieu == int.Parse(((LinkButton)sender).CommandArgument) select dmsc).Single(); query.TinhTrang = !query.TinhTrang; dt.SubmitChanges(); }
protected void btn_ThemPhongMoi_Click(object sender, EventArgs e) { CinemaLINQDataContext dt = new CinemaLINQDataContext(); PhongChieuPhim phong = (PhongChieuPhim)Session["Phong"]; if (phong == null) Response.Redirect("/admin/default.aspx"); var __phong = (from _phong in dt.PhongChieuPhims where _phong.MaPhongChieuPhim == phong.MaPhongChieuPhim select _phong).Single(); __phong.TinhTrang = true; dt.SubmitChanges(); var dsGhe = from _ghe in dt.Ghes where _ghe.MaPhongChieuPhim == __phong.MaPhongChieuPhim select _ghe; foreach (Ghe _ghe in dsGhe) { _ghe.TinhTrang = 1; } dt.SubmitChanges(); var dsGheTam = from _ghe in dt.Ghes where _ghe.TinhTrang == -1 select _ghe; dt.Ghes.DeleteAllOnSubmit(dsGheTam); dt.SubmitChanges(); var dsPhongTam = from _phong in dt.PhongChieuPhims where _phong.TinhTrang == false select _phong; dt.PhongChieuPhims.DeleteAllOnSubmit(dsPhongTam); dt.SubmitChanges(); Session["Phong"] = null; Response.Redirect("/admin/ThemPhongThanhCong.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { try { CinemaLINQDataContext dt = new CinemaLINQDataContext(); int maxMaPhim = -1; try { maxMaPhim = (from film in dt.Phims select film.MaPhim).Max(); } catch { maxMaPhim = 1; } string posterFileName = (maxMaPhim + 1).ToString() + Th_AnhPhim.FileName.Substring(Th_AnhPhim.FileName.Length - 4); string posterName = "/phim/poster/" + posterFileName; Th_AnhPhim.SaveAs(Server.MapPath("/phim/poster/") + posterFileName); string trailerFileName = (maxMaPhim + 1).ToString() + Th_Trailer.FileName.Substring(Th_Trailer.FileName.Length - 4); string trailerName = "/phim/trailer/" + trailerFileName; Th_Trailer.SaveAs(Server.MapPath("/phim/trailer/") + trailerFileName); Phim phim = new Phim(); phim.TenPhim = Th_TenPhim.Text; phim.TheLoai = int.Parse(DropDownList1.SelectedItem.Value); phim.DaoDien = Th_DaoDien.Text; phim.DienVienThamGia = Th_DienVien.Text; phim.NoiDung = Th_NoiDung.Text; phim.NgonNgu = Th_NgonNgu.Text; phim.ThoiLuong = int.Parse(Th_ThoiLuong.Text); phim.DiemDanhGia = 0; phim.TinhTrang = true; phim.AnhPhim = posterName; phim.TrailerPhim = trailerName; phim.LoaiPhim = int.Parse(DropDownList2.SelectedItem.Value); dt.Phims.InsertOnSubmit(phim); dt.SubmitChanges(); Session["SelectedFilmID"] = phim.MaPhim; Response.Redirect("ThemPhimThanhCong.aspx"); } catch { } }
protected void btn_Chuyen_Click(object sender, EventArgs e) { CinemaLINQDataContext dt = new CinemaLINQDataContext(); if (Session["Phong"] == null) Response.Redirect("/admin/default.aspx"); Ghe ghe = dt.Ghes.Where(_ghe => _ghe.MaGhe == int.Parse(((ImageButton)sender).CommandArgument)).Select(_ghe => _ghe).Single(); if (ghe.MaDanhMucGhe == dt.DanhMucGhes.Where(dmg => dmg.TenDanhMucGhe.CompareTo("Thường") == 0).Select(dmg => dmg.MaDanhMucGhe).Single()) { ghe.MaDanhMucGhe = dt.DanhMucGhes.Where(dmg => dmg.TenDanhMucGhe.CompareTo("Vip") == 0).Select(dmg => dmg.MaDanhMucGhe).Single(); } else { ghe.MaDanhMucGhe = dt.DanhMucGhes.Where(dmg => dmg.TenDanhMucGhe.CompareTo("Thường") == 0).Select(dmg => dmg.MaDanhMucGhe).Single(); } dt.SubmitChanges(); }
protected void btn_Chuyen_Click(object sender, EventArgs e) { CinemaLINQDataContext dt = new CinemaLINQDataContext(); var phong = (from _phong in dt.PhongChieuPhims where _phong.MaPhongChieuPhim == int.Parse(cbb_Phong.SelectedItem.Value) select _phong).Single(); Ghe ghe = dt.Ghes.Where(_ghe => _ghe.MaGhe == int.Parse(((ImageButton)sender).CommandArgument)).Select(_ghe => _ghe).Single(); if (ghe.MaDanhMucGhe == dt.DanhMucGhes.Where(dmg => dmg.TenDanhMucGhe.CompareTo("Thường") == 0).Select(dmg => dmg.MaDanhMucGhe).Single()) { ghe.MaDanhMucGhe = dt.DanhMucGhes.Where(dmg => dmg.TenDanhMucGhe.CompareTo("Vip") == 0).Select(dmg => dmg.MaDanhMucGhe).Single(); } else { ghe.MaDanhMucGhe = dt.DanhMucGhes.Where(dmg => dmg.TenDanhMucGhe.CompareTo("Thường") == 0).Select(dmg => dmg.MaDanhMucGhe).Single(); } dt.SubmitChanges(); }
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(); } }
protected void Xl_CapNhatThayDoi_Click(object sender, EventArgs e) { CinemaLINQDataContext dt = new CinemaLINQDataContext(); var query = (from phim in dt.Phims where phim.MaPhim == ((Phim)Session["CurrentPhim"]).MaPhim select phim).Single(); query.TenPhim = Th_TenPhim.Text; query.NoiDung = Th_NoiDung.Text; query.TheLoai = int.Parse(DropDownList1.SelectedItem.Value); query.LoaiPhim = int.Parse(DropDownList2.SelectedItem.Value); query.ThoiLuong = int.Parse(Th_ThoiLuong.Text); query.DienVienThamGia = Th_DienVien.Text; query.DaoDien = Th_DaoDien.Text; query.NgonNgu = Th_NgonNgu.Text; if (Th_AnhPhim.FileName != null && Th_AnhPhim.FileName.Trim().Length != 0) { string posterFileName = query.MaPhim.ToString() + Th_AnhPhim.FileName.Substring(Th_AnhPhim.FileName.Length - 4); string posterName = "/phim/poster/" + posterFileName; Th_AnhPhim.SaveAs(Server.MapPath("/phim/poster/") + posterFileName); query.AnhPhim = posterName; } if (Th_Trailer.FileName != null && Th_Trailer.FileName.Trim().Length != 0) { string trailerFileName = query.MaPhim.ToString() + Th_Trailer.FileName.Substring(Th_Trailer.FileName.Length - 4); string trailerName = "/phim/trailer/" + trailerFileName; Th_Trailer.SaveAs(Server.MapPath("/phim/trailer/") + trailerFileName); query.TrailerPhim = trailerName; } dt.SubmitChanges(); Session["CurrentPhim"] = query; Response.Redirect("default.aspx"); }
protected void Xl_XemSoDoGhe_Click(object sender, EventArgs e) { int soHang = int.Parse(tb_SoHangGhe.Text); int soGheTrenHang = int.Parse(tb_SoGheTrenHang.Text); CinemaLINQDataContext dt = new CinemaLINQDataContext(); PhongChieuPhim phong = new PhongChieuPhim(); phong.MaRapChieuPhim = int.Parse(cbb_RapPhim.SelectedItem.Value); phong.TenPhongChieuPhim = tb_TenPhong.Text; phong.TongSoLuongGhe = soGheTrenHang * soHang; phong.TinhTrang = false; phong.SoHang = soHang; phong.SoGheTrenHang = soGheTrenHang; dt.PhongChieuPhims.InsertOnSubmit(phong); dt.SubmitChanges(); for (int i = 0; i < soHang; ++i) { for (int j = 0; j < soGheTrenHang; ++j) { Ghe ghe = new Ghe(); ghe.MaPhongChieuPhim = phong.MaPhongChieuPhim; ghe.TenGhe = "Ghe"; ghe.MaDanhMucGhe = dt.DanhMucGhes.Where(dmg => dmg.TenDanhMucGhe.CompareTo("Thường") == 0).Select(dmg => dmg.MaDanhMucGhe).Single(); ghe.Hang = i; ghe.SoThuTu = j; ghe.TinhTrang = -1; dt.Ghes.InsertOnSubmit(ghe); dt.SubmitChanges(); } } Session["Phong"] = (PhongChieuPhim)phong; }
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(); } } }
protected void Xl_ChoDiem_Click(object sender, EventArgs e) { CinemaLINQDataContext dt = new CinemaLINQDataContext(); ChamDiem cd = new ChamDiem(); cd.MaPhim = ((Phim)Session["CurrentPhim"]).MaPhim; cd.SoDiem = int.Parse(Th_DiemCuaBan.SelectedItem.Value); cd.MaNguoiDung = ((NguoiDung)Session["NguoiDung"]).MaNguoiDung; dt.ChamDiems.InsertOnSubmit(cd); dt.SubmitChanges(); var query = (from phim in dt.Phims where phim.MaPhim == ((Phim)Session["CurrentPhim"]).MaPhim select phim).Single(); var query1 = from cd_ in dt.ChamDiems where cd_.MaPhim == ((Phim)Session["CurrentPhim"]).MaPhim select cd_.SoDiem; query.DiemDanhGia = (float)query1.Sum() / (float)query1.Count(); dt.SubmitChanges(); KiemTraQuyenBinhLuan(dt); LoadThongTinPhim(dt, ((Phim)Session["CurrentPhim"])); }
protected void Xl_Xoa_Click(object sender, EventArgs e) { CinemaLINQDataContext dt = new CinemaLINQDataContext(); var query = (from binhLuan in dt.BinhLuans where binhLuan.MaBinhLuan == int.Parse(((Button)sender).CommandArgument) select binhLuan).Single(); query.TinhTrang = dt.DanhMucTinhTrangBinhLuans.Where(ttbl => ttbl.TenTinhTrang.CompareTo("Đã xóa") == 0).Select(ttbl => ttbl.MaTinhTrang).Single(); ; dt.SubmitChanges(); }
protected void Xl_ThemBinhLuan_Click(object sender, EventArgs e) { try { CinemaLINQDataContext dt = new CinemaLINQDataContext(); BinhLuan bl = new BinhLuan(); bl.MaPhim = ((Phim)Session["CurrentPhim"]).MaPhim; bl.NoiDungBinhLuan = Th_BinhLuanMoi.Text; bl.MaNguoiDung = ((NguoiDung)Session["NguoiDung"]).MaNguoiDung; bl.TinhTrang = dt.DanhMucTinhTrangBinhLuans.Where(ttbl => ttbl.TenTinhTrang.CompareTo("Bình thường")==0).Select(ttbl => ttbl.MaTinhTrang).Single(); bl.ThoiGianBinhLuan = DateTime.Now; dt.BinhLuans.InsertOnSubmit(bl); dt.SubmitChanges(); Th_BinhLuanMoi.Text = ""; //Response.Redirect("/phim/chitietphim.aspx"); } catch { //Response.Redirect("/phim/chitietphim.aspx"); } }
protected void Xl_Sua_Click(object sender, EventArgs e) { CinemaLINQDataContext dt = new CinemaLINQDataContext(); var query = (from binhLuan in dt.BinhLuans where binhLuan.MaBinhLuan == int.Parse(((Button)sender).CommandArgument) select binhLuan).Single(); query.NoiDungBinhLuan = ((TextBox)DataList1.Items[int.Parse(((Button)sender).CommandName)].FindControl("Th_NoiDungBinhLuan")).Text; dt.SubmitChanges(); }