Esempio n. 1
0
        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
            {

            }
        }
 partial void DeletePhim(Phim instance);
 partial void UpdatePhim(Phim instance);
 partial void InsertPhim(Phim instance);
		private void detach_Phims(Phim entity)
		{
			this.SendPropertyChanging();
			entity.DanhMucTheLoaiPhim = null;
		}
		private void attach_Phims(Phim entity)
		{
			this.SendPropertyChanging();
			entity.DanhMucLoaiPhim = this;
		}
Esempio n. 7
0
 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();
 }