コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UserModel user = (UserModel)Session["user"];

            if (user == null)
            {
                Server.Transfer("LoginPage.aspx");
            }
            Label6.Text = user.name;

            VideoDao          video_dao = Factory.Get(new VideoDao());
            List <VideoModel> list      = (List <VideoModel>)video_dao.GetBy("where video_id='" + (Session["video"] as VideoModel).video_id + "'");
            var title   = (Session["video"] as VideoModel).title;
            var des     = (Session["video"] as VideoModel).des;
            var yes     = list[0].yes;
            var no      = list[0].no;
            var collect = list[0].collect;

            Label1.Text = title;
            UserDAO user_dao = Factory.Get(new UserDAO());

            Label2.Text = "上传者:" + ((List <UserModel>)user_dao.GetBy("where id='" + (Session["video"] as VideoModel).user_id + "'"))[0].name + "<br>" + des;
            Label3.Text = "赞:" + yes;
            Label4.Text = "收藏:" + collect;
            Label5.Text = "踩:" + no;

            NoDAO          nodao   = Factory.Get(new NoDAO());
            List <NoModel> no_list = (List <NoModel>)nodao.GetBy("where video_id='" + (Session["video"] as VideoModel).video_id + "' and user_id='" + (Session["user"] as UserModel).id + "'");

            CollectDAO          collect_dao  = Factory.Get(new CollectDAO());
            List <CollectModel> collect_list = (List <CollectModel>)collect_dao.GetBy("where video_id='" + (Session["video"] as VideoModel).video_id + "' and user_id='" + (Session["user"] as UserModel).id + "'");

            YesDAO          dao      = Factory.Get(new YesDAO());
            List <YesModel> yes_list = (List <YesModel>)dao.GetBy("where video_id='" + (Session["video"] as VideoModel).video_id + "' and user_id='" + (Session["user"] as UserModel).id + "'");

            if (yes_list.Count > 0)
            {
                Button2.ForeColor = System.Drawing.ColorTranslator.FromHtml("#1763e9");
            }
            if (no_list.Count > 0)
            {
                Button4.ForeColor = System.Drawing.ColorTranslator.FromHtml("#1763e9");
            }
            if (collect_list.Count > 0)
            {
                Button3.ForeColor = System.Drawing.ColorTranslator.FromHtml("#1763e9");
            }
            UpdateComment();

            if ((Session["user"] as UserModel).type == "manager")
            {
                tougao.Visible   = false;
                shoucang.Visible = false;
                return1.Visible  = true;
            }

            else
            {
                tougao.Visible   = true;
                shoucang.Visible = true;
                return1.Visible  = false;
            }
        }
コード例 #2
0
        protected void ShowVideoImage()
        {
            CollectDAO          collect_dao = Factory.Get(new CollectDAO());
            List <CollectModel> collect     = (List <CollectModel>)collect_dao.GetBy("where user_id='" + (Session["user"] as UserModel).id + "'");
            VideoDao            dao         = Factory.Get(new VideoDao());
            List <VideoModel>   list        = new List <VideoModel>();

            foreach (var item in collect)
            {
                List <VideoModel> m = (List <VideoModel>)dao.GetBy("where video_id='" + item.video_id + "'");
                list.Add(m[0]);
            }


            foreach (VideoModel model in list)
            {
                System.Windows.Forms.ListViewItem item1 = new System.Windows.Forms.ListViewItem();
                //之前是直接用Images.FromFile(string Path)从文件夹中读取,删除时没法删除
                //改从文件流中读取图片,关闭窗口时可以删除文件

                string image_path = "VideoIcon/" + model.video_id.Split('.')[0] + ".jpg";

                ImageButton button = new ImageButton();
                button.Height   = 100;
                button.Width    = 160;
                button.ImageUrl = image_path;
                Label title_user = new Label();
                button.Click   += (object sender, ImageClickEventArgs e) => { Session["video"] = model; Response.Redirect("VideoPage.aspx"); };
                title_user.Text = model.title + "<br>上传者:" + model.user_id;


                if (Table1.Rows.Count == 0)
                {
                    _last_row = new TableRow();
                    Table1.Rows.Add(_last_row);
                }

                if (_last_row.Cells.Count < 2)
                {
                    TableCell cell = new TableCell();
                    cell.Controls.Add(button);
                    TableCell cell4 = new TableCell();
                    cell4.Controls.Add(title_user);


                    _last_row.Cells.Add(cell);
                    _last_row.Cells.Add(cell4);



                    cell.HorizontalAlign = HorizontalAlign.Center;
                }
                else
                {
                    _last_row = new TableRow();
                    TableCell cell = new TableCell();


                    TableCell cell4 = new TableCell();
                    cell4.Controls.Add(title_user);

                    cell.Controls.Add(button);
                    _last_row.Cells.Add(cell);
                    _last_row.Cells.Add(cell4);


                    Table1.Rows.Add(_last_row);

                    cell.HorizontalAlign = HorizontalAlign.Center;
                }
            }
        }