public ActionResult addTapMoi() { string txt = Request["idp"]; string link = Request["link"]; DBIO d = new DBIO(); List <cacTap> c = d.getvideo(txt); int tap = 0; if (c.Count == 0) { tap = 1; } else { foreach (var item in c) { tap = Int32.Parse(item.tap); } tap = tap + 1; } try { d.addTap(txt, tap, driveControl(link)); ViewBag.messeage = "Add success"; } catch { ViewBag.messeage = "Add Fail!!"; } Phim p = d.getFilm(txt); return(PartialView("DataPhim", p)); }
public bool UpdatePhim(PhimDTO p) { try { using (QLRPContext context = new QLRPContext()) { Phim pc = context.Phims.SingleOrDefault(px => px.MaPhim == p.MaPhim); if (pc != null) { if (Utils.ValidateRowversion(pc.RowVersion, p.RowVersion)) { pc.TenPhim = p.TenPhim; pc.TheLoai = p.TheLoai; pc.NgayKhoiChieu = p.NgayKhoiChieu; pc.NgaySua = DateTime.Now; pc.NguoiSua = CurrentUser.Username; context.SaveChanges(); return(true); } throw new Exception("Có ai đó đã update đối tượng này trước đó. Danh sách sẽ được load lại."); } throw new Exception("Phim này đã bị xóa bởi ai đó. Danh sách sẽ được load lại."); } } catch (DbUpdateConcurrencyException) { throw new Exception("Hiện tại, có ai đó cũng đang update đối tượng này. Danh sách sẽ được load lại."); } catch (Exception) { throw; } }
public ActionResult Create([Bind(Include = "maphim,matheloai,daodien,tenphim,ngaykhoichieu,ngayketthuc,mota,hinh,nhasanxuat,thoiluong,trailer")] Phim phim) { try { if (ModelState.IsValid) { //db.Phims.Add(phim); db.Database.SqlQuery <Phim> ("exec sp_addPhim {0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", phim.matheloai.ToString(), phim.daodien.ToString(), phim.tenphim.ToString(), phim.ngaykhoichieu, phim.ngayketthuc, phim.mota.ToString(), phim.hinh.ToString(), phim.nhasanxuat.ToString(), phim.thoiluong.ToString(), phim.trailer.ToString()).ToList(); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (EntityCommandExecutionException ex) { return(RedirectToAction("Index")); } ViewBag.matheloai = new SelectList(db.TheLoai, "matheloai", "tentheloai", phim.matheloai); return(View(phim)); }
public async Task <ResponseEntity> XoaPhim(int MaPhim) { bool ckbPhim = db.Phim.Any(n => n.MaPhim == MaPhim); if (!ckbPhim) { return(new ResponseEntity(StatusCodeConstants.BAD_REQUEST, "Mã phim không hợp lệ!", MessageConstant.BAD_REQUEST)); //return await tbl.TBLoi(ThongBaoLoi.Loi500, "Mã phim không hợp lệ!"); } bool ckbLichChieu = db.LichChieu.Any(n => n.MaPhim == MaPhim); if (ckbLichChieu) { return(new ResponseEntity(StatusCodeConstants.NOT_FOUND, "Phim đã xếp lịch chiếu không thể xóa!", MessageConstant.MESSAGE_ERROR_404)); //return await tbl.TBLoi(ThongBaoLoi.Loi500, "Phim đã xếp lịch chiếu không thể xóa"); } Phim p = db.Phim.SingleOrDefault(n => n.MaPhim == MaPhim); string hinhAnh = p.HinhAnh; db.Phim.Remove(p); db.SaveChanges(); var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/hinhanh", hinhAnh); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } return(new ResponseEntity(StatusCodeConstants.OK, "Xóa thành công!", MessageConstant.MESSAGE_SUCCESS_200)); //return Ok(); }
private void btnThem_Click(object sender, RoutedEventArgs e) { var phim = new Phim { Ten = txtTenPhim.Text, NgayKhoiChieu = DateTime.Parse(ngayKhoiChieu.Text), theloai = new TheLoai { TenTheLoai = txtTheLoai.Text }, ThoiLuong = int.Parse(txtThoiLuong.Text), NgonNgu = txtNgonNgu.Text, Rated = float.Parse(txtRated.Text) }; if (Phim.KiemTraInputHopLe(phim).Item1) { try { using (var context = new QlyRapPhimContext()) { context.Phims.Add(phim); context.SaveChanges(); MessageBox.Show(Phim.KiemTraInputHopLe(phim).Item2, "Success"); } } catch { // ....... } } else { MessageBox.Show(Phim.KiemTraInputHopLe(phim).Item2, "Error"); } }
//cap nhat Phim public void CapNhatPhim(Phim phim) { string query = ""; query = "Update [Phim] " + "Set [Phim].TuaDePhim = '" + phim.TuaDePhim + "'," + "[Phim].Poster = '" + phim.Poster + "'," + "[Phim].ThongTinDienVien = '" + phim.ThongTinDienVien + "'," + "[Phim].DaoDien = '" + phim.DaoDien + "'," + "[Phim].BienKich = '" + phim.BienKich + "'," + "[Phim].NgaySanXuat = '" + phim.NgaySanXuat + "'," + "[Phim].HangPhim = '" + phim.HangPhim + "'," + "[Phim].NoiDung = '" + phim.NoiDung + "'," + "[Phim].ThoiLuong = " + phim.ThoiLuong + "," + "[Phim].NgayCongChieu = '" + phim.NgayCongChieu + "'," + "[Phim].NgayKetThuc = '" + phim.NgayKetThuc + "'," + "[Phim].LoaiPhim = '" + phim.LoaiPhim + "'" + " Where [Phim].MaPhim = " + phim.MaPhim; tryq { this.editRow(query); } catch (OracleException ex) { throw ex; } }
public ActionResult ThemMoi(Phim p, HttpPostedFileBase fileUpload) { //Đưa dữ liệu vào dropdownlist ViewBag.MaP = new SelectList(db.TheLoais.ToList().OrderBy(n => n.TenTheLoai), "TenTheLoai"); if (fileUpload == null) { return(View()); } //Thêm vào cơ sở dữ liệu if (ModelState.IsValid) { //Lưu tên file var fileName = Path.GetFileName(fileUpload.FileName); var path = Path.Combine(Server.MapPath("~/Content/image"), fileName); //Kiểm tra hình ảnh đã tồn tại chưa if (System.IO.File.Exists(path)) { ViewBag.ThongBao = "Hình ảnh đã tồn tại"; } else { fileUpload.SaveAs(path); } p.TenAnh = fileUpload.FileName; db.Phims.Add(p); db.SaveChanges(); } return(View()); }
// GET: MovieInfo public ActionResult Index(int id) { Phim a = db.Database.SqlQuery <Phim>("exec sp_loadChiTietPhim {0}", id).First(); ViewData["ChiTietPhim"] = a; ViewData["TheLoai"] = db.Database.SqlQuery <TheLoai>("exec sp_loadTheLoai {0}", a.matheloai).First().tentheloai; List <IGrouping <DateTime, SuatChieu> > s = db.Database.SqlQuery <SuatChieu>("exec sp_loadSuatChieuTheoPhim {0}", id).GroupBy(k => k.ngaychieu).ToList(); ViewData["SuatChieu"] = s; List <DateTime> ngayChieu = db.Database.SqlQuery <DateTime>("exec sp_loadNgayChieuSuatChieuTheoPhim {0}", id).ToList(); List <Tuple <Tuple <DateTime, int>, List <TimeSpan> > > dsSC = new List <Tuple <Tuple <DateTime, int>, List <TimeSpan> > >(); //foreach(var nc in ngayChieu) //{ // int idsc = 0; // List<TimeSpan> dsGC = new List<TimeSpan>(); // bool flag = false; // foreach(var sc in s) // { // if (sc.ngaychieu.Equals(nc)) // { // dsGC.Add(sc.giochieu); // idsc = sc.masuatchieu; // flag = true; // } // if (flag) // dsSC.Add(new Tuple<Tuple<DateTime, int>, List<TimeSpan>>(new Tuple<DateTime, int>(nc, idsc), dsGC)); // } //} //ViewData["dsSC"] = dsSC; return(View()); }
public async Task <PhimViewModel> LayThongTinPhim(int maPhim) { Phim phim = null; using (var connection = new SqlConnection(connectionString)) { var p = new DynamicParameters(); p.Add("@KEYWORD", maPhim); phim = connection.QuerySingleOrDefault <Phim>("SELECT * FROM [dbo].[PHIM] WHERE MaPhim = " + maPhim, p, commandType: CommandType.Text); IEnumerable <BinhLuanViewModel> listBinhLuan = connection.Query <BinhLuanViewModel>("SELECT * FROM dbo.View_BINH_LUAN WHERE MaPhim = " + maPhim, commandType: CommandType.Text); //PhimViewModel phimVM = Mapper.Map<Phim, PhimViewModel>(phim); PhimViewModel phimVM = new PhimViewModel(); phimVM.TenPhim = phim.TenPhim; phimVM.BiDanh = phim.BiDanh; phimVM.DanhGia = phim.DanhGia; phimVM.HinhAnh = phim.HinhAnh; phimVM.MaPhim = phim.MaPhim; phimVM.MoTa = phim.MoTa; phimVM.Trailer = phim.Trailer; phimVM.NgayKhoiChieu = phim.NgayKhoiChieu.ToString("dd/MM/yyyy"); phimVM.DaoDien = phim.DaoDien; phimVM.DienVien = phim.DienVien; phimVM.DoTuoi = phim.DoTuoi; phimVM.DaXoa = phim.DaXoa; phimVM.KhoiChieu = phim.KhoiChieu; phimVM.SapChieu = phim.SapChieu; phimVM.ListBinhLuan = listBinhLuan; return(phimVM); } }
void MyDataBind() { if (Session["XLC-MaPhim"] == null) { return; } int _maPhim = int.Parse(Session["XLC-MaPhim"].ToString()); CinemaLINQDataContext dt = new CinemaLINQDataContext(); List <LichChieuPhim> _dsNgayChieu = (from _lc in dt.LichChieuPhims where _lc.NgayChieu >= DateTime.Now.Date && _lc.SuatChieus.Where(_sc => _sc.MaPhim == _maPhim).Count() > 0 orderby _lc.NgayChieu.Date ascending select _lc).ToList(); Phim _phim = (from _ph in dt.Phims where _ph.MaPhim == _maPhim select _ph).Single(); Label6.Text = _phim.TenPhim; dtl_dsNgayChieu.DataSource = _dsNgayChieu; dtl_dsNgayChieu.DataBind(); for (int i = 0; i < _dsNgayChieu.Count; i++) { ((LinkButton)dtl_dsNgayChieu.Items[i].FindControl("lbt_NgayChieu")).Text = _dsNgayChieu[i].NgayChieu.ToString("dd/MM/yyyy"); } }
public async Task <object> XoaPhim(int maPhim) { using (var connection = new SqlConnection(connectionString)) { var p = new DynamicParameters(); Phim phim = connection.QuerySingleOrDefault <Phim>("SELECT * FROM [dbo].[PHIM] WHERE MaPhim = " + maPhim, commandType: CommandType.Text); if (phim == null) { return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Mã phim không hợp lệ!")); } IEnumerable <LichChieu> lichChieuPhim = connection.Query <LichChieu>("SELECT * FROM [dbo].[LICHCHIEU] WHERE MaPhim = " + maPhim, commandType: CommandType.Text); if (lichChieuPhim.Count() > 0) { return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Phim đã xếp lịch chiếu không thể xóa!")); } var param = new DynamicParameters(); param.Add("@MAPHIM", maPhim); await connection.QueryAsync <Phim>("PHIM_DELETE", param, commandType : CommandType.StoredProcedure); string key = ""; IEnumerable <Phim> phimreturn = await this.LayDanhSachPhim(key); return(phimreturn); } }
private void btnThem_Click(object sender, EventArgs e) { if (btnThem.Text == "Thêm") { UnlockControl(); EmptyControl(); btnThem.Text = "Lưu"; btnSua.Enabled = false; btnXoa.Text = "Hủy"; } else { Phim item = new Phim(); item.TenPhim = txbTen.Text; item.MoTa = txbMoTa.Text; item.ThoiLuong = Convert.ToInt32(txbThoiLuong.Text); item.KhoiChieu = dtpKhoiChieu.Value; item.TheLoaiID = Convert.ToInt32(cboTheLoai.SelectedValue); if (new PhimDAO().AddPhim(item)) { MessageBox.Show("Thêm thành công"); } else { MessageBox.Show("Không thành công"); } LockControl(); loadPhim(); } }
private void LoadTTSuatChieu(Phim t) { List <SuatChieu> list = t.ListSC; PnFLow_SuatChieu.Controls.Clear(); for (int i = 0; i < list.Count; i++) { int ck = DangDienRa(list[i].Ngay, list[i].Thang, list[i].Nam); PnFLow_SuatChieu.Controls.Add(CreateSCDay(list[i].Ngay, list[i].Thang, list[i].Nam, t.MaPhim, ck)); FlowLayoutPanel SCLayout = CreateSCHourLayout(t.MaPhim, ck); int n = 0; for (int j = i; j < list.Count; j++) { ck = DangDienRa(list[j].Ngay, list[j].Thang, list[j].Nam, list[j].Gio, list[j].Phut, t.ThoiLuong); if (list[j].Ngay == list[i].Ngay && list[j].Thang == list[i].Thang && list[j].Nam == list[i].Nam) { SCLayout.Controls.Add(CreateSCHour(list[j].Gio, list[j].Phut, list[j].MaPhong, list[j].MaSuatChieu, ck)); n++; } else { break; } } i += n - 1; SCLayout.Size = new Size(226, 34 * ((n > 6) ? 3 : ((n > 3) ? 2 : 1))); PnFLow_SuatChieu.Controls.Add(SCLayout); } }
public List <Phim> HienThiTatCaPhim() { List <Phim> dsphim = new List <Phim>(); OpenConnected(); SqlCommand command = TaoCommand("Phim_Select_All"); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Phim phim = new Phim(); phim.MaPhim = reader.GetInt32(0); phim.TenPhimGoc = reader.GetString(1).Trim(); phim.TenPhim = reader.GetString(2).Trim(); phim.HinhAnh = reader.GetString(3).Trim(); phim.NoiDung = reader.GetString(4).Trim(); phim.NamPhatSong = reader.GetString(5).Trim(); phim.QuocGia = reader.GetString(6).Trim(); phim.TrangThai = reader.GetString(7).Trim(); phim.ThoiLuong = reader.GetInt32(8); phim.TheLoai = reader.GetString(9).Trim(); dsphim.Add(phim); } reader.Close(); return(dsphim); }
public async Task <ActionResult> XoaPhim(int MaPhim) { bool ckbPhim = db.Phim.Any(n => n.MaPhim == MaPhim); if (!ckbPhim) { return(await tbl.TBLoi(ThongBaoLoi.Loi500, "Mã phim không hợp lệ!")); } bool ckbLichChieu = db.LichChieu.Any(n => n.MaPhim == MaPhim); if (ckbLichChieu) { return(await tbl.TBLoi(ThongBaoLoi.Loi500, "Phim đã xếp lịch chiếu không thể xóa")); } Phim p = db.Phim.SingleOrDefault(n => n.MaPhim == MaPhim); string hinhAnh = p.HinhAnh; db.Phim.Remove(p); db.SaveChanges(); var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/hinhanh", hinhAnh); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } return(Ok("Xóa thành công !")); }
public Phim HienThiTheoMaPhim(Phim p) { OpenConnected(); SqlCommand command = TaoCommand("Phim_HienThiTheoMa"); command.Parameters.Add("@MaPhim", SqlDbType.Int).Value = p.MaPhim; SqlDataReader reader = command.ExecuteReader(); Phim phim = new Phim(); if (reader.Read()) { phim.MaPhim = reader.GetInt32(0); phim.TenPhimGoc = reader.GetString(1).Trim(); phim.TenPhim = reader.GetString(2).Trim(); phim.HinhAnh = reader.GetString(3).Trim(); phim.NoiDung = reader.GetString(4).Trim(); phim.NamPhatSong = reader.GetString(5).Trim(); phim.QuocGia = reader.GetString(6).Trim(); phim.TrangThai = reader.GetString(7).Trim(); phim.ThoiLuong = reader.GetInt32(8); phim.TheLoai = reader.GetString(9).Trim(); phim.DuongDan = reader.GetString(10).Trim(); } reader.Close(); return(phim); }
public string Sua(PhimBDO phim) { try { Phim tim = db.Phims.Where(x => x.PhimID == phim.PhimID).FirstOrDefault(); if (tim != null) { tim.Ten = phim.Ten; tim.DaoDien = phim.DaoDien; tim.DienVien = phim.DienVien; tim.DoDai = phim.DoDai; tim.GioiThieu = phim.GioiThieu; tim.HangPhim = phim.HangPhim; tim.NuocSanXuat = phim.NuocSanXuat; tim.Pdf = phim.PDF; tim.PhienBan = phim.PhienBan; tim.Poster = phim.Poster; tim.TheLoai = phim.TheLoai; tim.Trailer = phim.Trailer; db.SaveChanges(); return("Sửa thành công"); } else { return("Không có phim này"); } } catch { return("Có lỗi xảy ra"); } }
private void btnLuu_Click(object sender, EventArgs e) { phimcr = new PhimChieuRap(); PhimDB phimDB = new PhimDB(); Phim phim = new Phim(); DataRow row; try { for (int i = 0; i < listPhimChon.Items.Count; i++) { row = (listPhimChon.Items[i] as DataRowView).Row; phimcr.MaRap = (int)cboRapChieu.SelectedValue; //MessageBox.Show(row.Field<string>("MaPhim")); phimcr.MaPhim = Convert.ToInt16(row.Field<string>("MaPhim")); phim = phimDB.ThongTinPhim(phimcr.MaPhim); phimcr.NgayCongChieu = phim.NgayCongChieu; phimcr.NgayKetThuc = phim.NgayKetThuc; phimcrDB.ThemPhimChieuRap(phimcr); } } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } EmptyControl(); this.EnabledControl(true); }
public TopReviewModels BaiNhanXet2BaiNhanXetViewModels(BaiNhanXet topReview) { AccountBus acBus = new AccountBus(); ReviewFilmsBus bus = new ReviewFilmsBus(); ThanhVien temp = acBus.getMemberByUserId(topReview.MS_TaiKhoan); TopReviewModels result = new TopReviewModels(); result.UserName = temp.HoTen; result.postDate = (DateTime)topReview.NgayDang; result.content = topReview.NoiDung; result.totalRank = bus.getTotalRank(topReview.MaSo); result.title = topReview.TieuDe; result.MS_Phim = (int)topReview.MS_Phim; result.MS_ReView = (int)topReview.MaSo; FilmBus filmBus = new FilmBus(); Phim p = filmBus.getFilmByID(result.MS_Phim.ToString()); result.ulr_HinhAnh = p.HinhAnh; result.TenPhim = p.TenPhim; return(result); }
public string Them(PhimBDO phim) { try { Phim tim = db.Phims.Where(x => x.Ten == phim.Ten).FirstOrDefault(); if (tim == null) { Phim phimsethem = new Phim() { Ten = phim.Ten, DaoDien = phim.DaoDien, DienVien = phim.DienVien, DoDai = phim.DoDai, GioiThieu = phim.GioiThieu, HangPhim = phim.HangPhim, NuocSanXuat = phim.NuocSanXuat, Pdf = phim.PDF, PhienBan = phim.PhienBan, Poster = phim.Poster, TheLoai = phim.TheLoai, Trailer = phim.Trailer }; db.Phims.Add(phimsethem); db.SaveChanges(); return("Thêm thành công"); } else { return("Đã có phim này"); } } catch { return("Có lỗi xảy ra"); } }
public bool XoaPhim(int ma, string rv) { try { using (QLRPContext context = new QLRPContext()) { Phim pc = context.Phims.SingleOrDefault(px => px.MaPhim == ma); if (pc != null) { if (Utils.ValidateRowversion(pc.RowVersion, rv)) { context.Phims.Remove(pc); context.SaveChanges(); return(true); } throw new Exception("Có ai đó đã update đối tượng này trước đó. Danh sách sẽ được load lại."); } throw new Exception("Phim này đã bị xóa bởi ai đó. Danh sách sẽ được load lại."); } } catch (DbUpdateConcurrencyException) { throw new Exception("Hiện tại, có ai đó cũng đang update đối tượng này. Danh sách sẽ được load lại."); } catch (Exception) { throw; } }
private PhimViewModels Phim2PhimViewModels(Phim p, int?page = 1, string strSort = "ID", bool isASC = true) { PhimViewModels pvm = new PhimViewModels(); pvm.MaSo = p.MaSo; pvm.TenPhim = p.TenPhim; pvm.NoiDung = p.NoiDung; pvm.URL_Trailer = p.URL_Trailer; pvm.DiemDanhGia = p.DiemDanhGia; pvm.ThoiLuong = p.ThoiLuong; pvm.DienVien = p.DienVien; pvm.DaoDien = p.DaoDien; pvm.HinhAnh = p.HinhAnh; pvm.NgayPhatHanh = p.NgayPhatHanh; pvm.TheLoai = bus.getTypeOfFilm(p.MS_TheLoai); pvm.NuocSX = bus.getCountryOfFilm(p.MS_NuocSX); pvm.DiemDanhGiaTrungBinh = bus.calculateAvgRank(p.MaSo); pvm.LuotDanhGia = bus.countRateTimes(p.MaSo); pvm.Banner = p.AnhBanner; pvm.strSort = strSort; pvm.currentPage = (int)page; pvm.isASC = isASC; pvm.MS_TheLoai = (int)p.MS_TheLoai; pvm.MS_NuocSX = (int)p.MS_NuocSX; return(pvm); }
public ActionResult GetPhim() { string txt = Request["idp"]; DBIO d = new DBIO(); Phim p = d.getFilm(txt); return(PartialView("DataPhim", p)); }
public PhimViewModels getFilmByMaso(int ms_phim) { Phim p = bus.getFilmByMaso(ms_phim); PhimViewModels pvm = Phim2PhimViewModels(p); return(pvm); }
private void QuanLyMenu_Load(object sender, EventArgs e) { textBox1.Text = Phim.totalView(); textBox2.Text = Phim.numberphim(); textBox4.Text = BinhLuan.totalComment(); textBox5.Text = Account.totalAccount(); textBox6.Text = TinTuc.totalNew(); }
private void LoadThongTinPhim(CinemaLINQDataContext dt, Phim currentPhim) { FormView_Phim.DataSource = from phim in dt.Phims where phim.MaPhim == currentPhim.MaPhim select phim; FormView_Phim.DataBind(); }
public ActionResult phimdetail() { DBIO d = new DBIO(); string idp = Request["IDPForCm"]; Phim p = d.getFilm(idp); Session["idpForRm"] = idp; return(PartialView("detailphim", p)); }
private void CreateDatGheLayout(Phim t, SuatChieu s) { Button btn_huy = new Button(); Label lb_tp = new Label(); Button btn_dv = new Button(); Panel pn_dg = CreateDatGhePanel(t, s); // // Btn_Huy // btn_huy.BackColor = System.Drawing.Color.IndianRed; btn_huy.FlatStyle = System.Windows.Forms.FlatStyle.Flat; btn_huy.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); btn_huy.ForeColor = System.Drawing.Color.White; btn_huy.Location = new System.Drawing.Point(3, 3); btn_huy.Name = "Btn_Huy"; btn_huy.Size = new System.Drawing.Size(60, 46); btn_huy.TabIndex = 11; btn_huy.Text = "Hủy"; btn_huy.UseVisualStyleBackColor = false; btn_huy.Click += this.Btn_HuyClick; // // LabelTenPhim // lb_tp.BackColor = System.Drawing.Color.DarkCyan; lb_tp.Font = new System.Drawing.Font("Segoe UI", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); lb_tp.ForeColor = System.Drawing.Color.White; lb_tp.ImageAlign = System.Drawing.ContentAlignment.TopCenter; lb_tp.Location = new System.Drawing.Point(69, 0); lb_tp.Name = t.MaPhim; lb_tp.Size = new System.Drawing.Size(754, 52); lb_tp.TabIndex = 0; lb_tp.Text = t.TenPhim; lb_tp.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // Btn_DatVe // btn_dv.BackColor = System.Drawing.Color.MediumSeaGreen; btn_dv.FlatStyle = System.Windows.Forms.FlatStyle.Flat; btn_dv.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); btn_dv.ForeColor = System.Drawing.Color.White; btn_dv.Location = new System.Drawing.Point(829, 3); btn_dv.Name = "Btn_DatVe"; btn_dv.Size = new System.Drawing.Size(81, 46); btn_dv.TabIndex = 12; btn_dv.Text = "Đặt vé"; btn_dv.UseVisualStyleBackColor = false; btn_dv.Click += this.Btn_DatVeClick; // //add to frame // PnFlow_DatVe.Controls.Clear(); PnFlow_DatVe.Controls.Add(btn_huy); PnFlow_DatVe.Controls.Add(lb_tp); PnFlow_DatVe.Controls.Add(btn_dv); PnFlow_DatVe.Controls.Add(pn_dg); }
private void LoadTTPhimForEdit(Phim t) { Tbox_TenPhim_GrThemPhim.Text = t.TenPhim; Cbox_TrangThai_GrThemPhim.SelectedItem = t.TrangThai; Tbox_Mota_GrThemPhim.Text = t.MoTa; Num_ThoiLuong.Value = t.ThoiLuong; Btn_Save.Name = t.MaPhim; Picbox_Phim.Image = t.Hinh; }
internal PhimViewModels getFilmByID(string codeFilm) { Phim p = bus.getFilmByID(codeFilm); PhimViewModels pvm = Phim2PhimViewModels(p); return(pvm); }
public ActionResult AddNewFilm(HttpPostedFileBase file, HttpPostedFileBase banner, String reissue, String genre, String country, String content, PhimViewModels fvm) //String name, String rank, String actor, // String director, String duration, String reissue, String genre, String country, String content, String trailer) { String fileName = ""; if (file != null && file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Images/"), fileName); file.SaveAs(path); } else { fileName = "defaultAvatar.jpg"; } String fileNameBanner = ""; if (banner != null && banner.ContentLength > 0) { fileNameBanner = Path.GetFileName(banner.FileName); var path = Path.Combine(Server.MapPath("~/Images/"), fileNameBanner); banner.SaveAs(path); } else { fileNameBanner = "defaultBanner.jpg"; } Phim p = new Phim(); p.DiemDanhGia = fvm.DiemDanhGia; p.NoiDung = content; p.NgayPhatHanh = DateTime.ParseExact(reissue, "MM/dd/yyyy", null);; p.TenPhim = fvm.TenPhim; p.TinhTrang = true; p.ThoiLuong = fvm.ThoiLuong; p.DaoDien = fvm.DaoDien; p.DienVien = fvm.DienVien; if (genre != "") { p.MS_TheLoai = Int32.Parse(genre); } if (country != "") { p.MS_NuocSX = Int32.Parse(country); } p.URL_Trailer = fvm.URL_Trailer; p.HinhAnh = "/Images/" + fileName; p.AnhBanner = "/Images/" + fileNameBanner; FilmService filmsv = new FilmService(); TempData["CreateFilmResult"] = filmsv.addNewFilmd(p); return(RedirectToAction("CreateFilmResult")); }
public ActionResult ChinhSua(Phim p, HttpPostedFileBase fileUpload) { db.Phims.Add(p); //Thực hiện cập nhập trong model db.Entry(p).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("HienThiDS")); //return View(); }
private void btnLuu_Click(object sender, EventArgs e) { if (themmoi) //them Phim moi { try { phim = new Phim(); PutPhimData(phim); phimDB.ThemPhim(phim); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else //cap nhat Phim { Phim newPhim = new Phim(); newPhim.MaPhim = phim.MaPhim; this.PutPhimData(newPhim); // insert poster //FileStream filestream = new FileStream(posterLocation, FileMode.Open, FileAccess.Read); //byte[] bytePoster = new byte[filestream.Length]; //filestream.Read(bytePoster,0,bytePoster.Length); //filestream.Close(); //BinaryReader binaryreader = new BinaryReader(filestream); //poster = binaryreader.ReadBytes((int)filestream.Length); try { phimDB.CapNhatPhim(newPhim); } catch (Exception ex) { MessageBox.Show(ex.Message); ; } } this.DanhSachPhim(); this.EmptyControl(); this.EnableControlNhap(false); this.EnabledControl(true); }
private void grvPhim_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { int i = e.RowIndex; DataGridViewSelectedRowCollection rows = grvPhim.SelectedRows; foreach (DataGridViewRow row in rows) { DataRow myRow = (row.DataBoundItem as DataRowView).Row; int maPhim = myRow.Field<int>("MaPhim"); posterLocation = myRow.Field<string>("Poster"); //MessageBox.Show(posterLocation,"GridviewMouse!"); phim = phimDB.ThongTinPhim(maPhim); HienThiPhim(phim); } }
//hien thi Phim private void HienThiPhim(Phim phim) { string filepath = Application.StartupPath; if (phim!=null) { txtTuaDe.Text = phim.TuaDePhim; if (phim.Poster == "") { picPoster.Image = null; } else { picPoster.Image = Image.FromFile(filepath + phim.Poster); } txtDienVien.Text = phim.ThongTinDienVien; txtDaoDien.Text = phim.DaoDien; txtBienKich.Text = phim.BienKich; dtpNgaySanXuat.Text = phim.NgaySanXuat.ToString(); txtHangPhim.Text = phim.HangPhim; txtNoiDung.Text = phim.NoiDung; txtThoiLuong.Text = phim.ThoiLuong.ToString(); dtpNgayCongChieu.Text = phim.NgayCongChieu.ToString(); dtpNgayKetThuc.Text = phim.NgayKetThuc.ToString(); txtLoaiPhim.Text = phim.LoaiPhim; //poster //byte[] poster; //if (poster == null) //{ // picPoster.Image = null; //} //else //{ // MemoryStream ms = new MemoryStream(poster); // picPoster.Image = Image.FromStream(ms); //} } else { MessageBox.Show("Ko co Phim!"); } }
private void PutPhimData(Phim phim) { phim.TuaDePhim = txtTuaDe.Text; phim.Poster = posterLocation; phim.ThongTinDienVien = txtDienVien.Text; phim.DaoDien = txtDaoDien.Text; phim.BienKich = txtBienKich.Text; phim.NgaySanXuat = dtpNgaySanXuat.Value; phim.HangPhim = txtHangPhim.Text; phim.NoiDung = txtNoiDung.Text; phim.ThoiLuong =Convert.ToInt32(txtThoiLuong.Text); phim.NgayCongChieu = dtpNgayCongChieu.Value; phim.NgayKetThuc = dtpNgayKetThuc.Value; phim.LoaiPhim = txtLoaiPhim.Text; }
//them Phim moi //public void ThemPhim(Phim phim, byte[] poster) public void ThemPhim(Phim phim) { string query = ""; query = "Insert into Phim (TuaDePhim, Poster, ThongTinDienVien, DaoDien, BienKich, " + "NgaySanXuat, HangPhim, NoiDung, ThoiLuong, NgayCongChieu, " + "NgayKetThuc, LoaiPhim) " + "values ('" + phim.TuaDePhim + "','" + phim.Poster + "','" + phim.ThongTinDienVien + "','" + phim.DaoDien + "','" + phim.BienKich + "','" + phim.NgaySanXuat + "','" + phim.HangPhim + "','" + phim.NoiDung + "'," + phim.ThoiLuong + ",'" + phim.NgayCongChieu + "','" + phim.NgayKetThuc+ "','" + phim.LoaiPhim + "')"; try { this.addRow(query); } catch (OracleException ex) { throw ex; } }
//xoa Phim public void XoaPhim(Phim phim) { string query = ""; if (phim.MaPhim >0) { query = "Delete [Phim] " + " where [Phim].MaPhim = " + phim.MaPhim; try { this.deleteRow(query); } catch (OracleException ex) { throw ex; } } }
//thong tin Phim public Phim ThongTinPhim(int maPhim) { Phim phim = new Phim(); DataTable dsPhim = new DataTable(); string query = ""; if (maPhim>=0) { query = @"select [Phim].* from [Phim] where [Phim].MaPhim = " + maPhim; try { dsPhim = this.getRows(query); if (dsPhim.Rows.Count > 0) { DataRow row = dsPhim.Rows[0]; phim.MaPhim = (int)row[0]; phim.TuaDePhim = row[1].ToString(); //poster //byte[] bytePoster = (byte[])row[2]; //phim.Poster = this.byteArrayToImage(bytePoster); phim.Poster = row[2].ToString(); phim.ThongTinDienVien = row[3].ToString(); phim.DaoDien = row[4].ToString(); phim.BienKich = row[5].ToString(); phim.NgaySanXuat = (DateTime)row[6]; phim.HangPhim = row[7].ToString(); phim.NoiDung = row[8].ToString(); phim.ThoiLuong = (int)row[9]; phim.NgayCongChieu = (DateTime)row[10]; phim.NgayKetThuc = (DateTime)row[11]; phim.LoaiPhim = row[12].ToString(); return phim; } else { return phim; } } catch (OracleException ex) { throw ex; } } else { return phim; } }