/// <summary> /// 通过作品类别ID获取作品类别 /// </summary> /// <param name="worksTypeId">作品类别ID</param> /// <returns></returns> public static WorksType GetWorksTypeById(string worksTypeId) { long lWorksTypeId = long.Parse(worksTypeId); WorksType worksTypeEntity = db.WorksType.SingleOrDefault(w => w.WorksTypeID == lWorksTypeId); return(worksTypeEntity); }
//void btnSubmit_Click(object sender, EventArgs e) //{ // int score = int.Parse(HiddenField1.Value); // List<CSWorksExpertUser> dt = GetDSWorksComments; // CSWorksExpertUser dr = new CSWorksExpertUser(); // dr.WorksID = WorksID; // dr.UserID = DAL.Common.LoginID; // dr.Flag = 1; // dr.Score = score; // dr.Comments = txtComments.Text; // dr.Created = DateTime.Now; // try // { // long resultID = DAL.Works.InsertWorksComments(dr); // if (resultID > 0) // { // ViewState["dsWorksComments"] = null; // FillComments(); // Session["IsSubmit"] = true; // Response.Redirect("OnshowWorksSubmit.aspx"); // } // } // catch // { // Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "<script defer>alert('点评失败');</script>"); // } //} #endregion #region 方法 /// <summary> /// 根据作品类别ID获取类别名称 /// </summary> /// <param name="typeId"></param> /// <returns></returns> private string GetWorksTypeName(int typeId) { WorksType dr = WorksType.GetTypeById(typeId); if (dr != null) { return(dr.TypeName); } else { return(""); } }
/// <summary> /// 生成列表页面 /// </summary> /// <param name="worksList">作品列表数据源</param> /// <param name="pageSize">每页条目数</param> /// <param name="pageNum">当前页数</param> private void GenericList(List <CSMyWorks> worksList, long pageSize, long pageNum) { long worksCount = worksList.Count; if (worksCount > pageSize) { if (0 == pageNum)//最后一页 { pageSize = worksCount - pageSize * (pageNum - 1); } worksList = worksList.Skip((int)(pageSize * (pageNum - 1))).Take((int)pageSize).ToList(); } if (worksList.Count > 0) { HtmlContainerControl ulControl = new HtmlGenericControl("ul"); foreach (var works in worksList) { HtmlContainerControl liControl = new HtmlGenericControl("li"); StringBuilder liBuilder = new StringBuilder(); //填充作品信息 liBuilder.AppendLine("<a class='cbp-vm-image' href='WorksShow.aspx?wid=" + works.WorksID + "' target='_blank' title='" + works.WorksName + "'><img src='images/works.png'></a>"); liBuilder.AppendLine("<h3 class='cbp-vm-title'><a href='WorksShow.aspx?wid=" + works.WorksID + "' target='_blank'>" + works.WorksName + "</a></h3>"); if (works.PeriodID != null) { Periods period = Bll.WorksBll.GetPeriodsById(works.PeriodID.ToString()).FirstOrDefault(); if (period?.CourseID != null) { liBuilder.AppendLine("<div class='cbp-vm-price'>" + period.PeriodTitle + "</div>"); //作品所属期次 string courseId = period.CourseID.ToString(); Course course = Bll.WorksBll.GetCourseById(courseId).FirstOrDefault(); if (course != null) { string courseUrl = SPContext.Current.Site.RootWeb.Url + course.Url; liBuilder.AppendLine("<div class='cbp-vm-price'><a href='" + courseUrl + "' target='_blank'>" + course.CourseName + "</a></div>"); //作品所属网站 } } } if (works.WorksTypeID != null) { WorksType worksType = Bll.WorksBll.GetWorksTypeById(works.WorksTypeID.ToString()); liBuilder.AppendLine("<div class='cbp-vm-price'>" + worksType.WorksTypeName + "</div>"); //作品类别 } liBuilder.AppendLine("<div class='cbp-vm-price'>" + $"{works.Created:d}" + "</div>"); string desc = Common.Common.NoHtml(works.DesignIdeas); if (desc.Length > 45) { desc = desc.Substring(0, 45) + "..."; } liBuilder.AppendLine("<br/><div class='cbp-vm-details'><a href='WorksShow.aspx?wid=" + works.WorksID + "' target='_blank'>" + desc + "</a></div> ");//作品介绍 liControl.Controls.Add(new LiteralControl(liBuilder.ToString())); //liBuilder.AppendLine("</li>"); ulControl.Controls.Add(liControl); } //liBuilder.AppendLine("</ul>"); worksListDiv.Controls.Clear(); worksListDiv.Controls.Add(ulControl); } //worksListDiv.InnerHtml = liBuilder.ToString(); }
/// <summary> /// 初始化作品信息显示控件 /// </summary> /// <param name="userId">当前用户ID</param> /// <param name="worksId">当前作品ID</param> private void InitControl(long userId, long worksId) { if (worksId != 0) { //getall Works works = Bll.WorksBll.GetWorksSubmitById(worksId.ToString()); LbWorksName.Text = works.WorksName; LbWorksCode.Text = works.WorksCode; LbInstallationGuide.Text = works.InstallationGuide; LbComment.Text = works.Comment; LbSubmitProfile.Text = works.SubmitProfile; //LblDemoUrl.Text = works.DemoURL; //WorksType worksType=proxy. DivDesignIdeas.Controls.Clear(); DivDesignIdeas.InnerText = works.DesignIdeas; DivKeyPoints.InnerText = works.KeyPoints; DivScore.InnerText = works.Score.ToString(); if (works.WorksTypeID != null) { WorksType worksType = Bll.WorksBll.GetWorksTypeById(works.WorksTypeID.ToString()); LbWorksType.Text = worksType.WorksTypeName.ToString(); } //作品附件 ShowDocuments(worksId); //ShowMedias(proxy, worksId, 3); ShowMedias(worksId, 4); ShowImages(worksId); ShowOthers(worksId); getReadandFavData(worksId); //上下文导航 List <Works> worksList = Bll.WorksBll.GetWorks(); int currentIndex = worksList.FindIndex(w => w.WorksID == worksId); //string worksNavhtml = ""; if (currentIndex == 0)//第一条 { LeftLayer.InnerHtml = "<a class='nvWorksLnk' href='WorksShow.aspx?wid=" + worksList[worksList.Count - 1].WorksID + "' title='上一作品:" + worksList[worksList.Count - 1].WorksName + "'><img src='images//Prev.png' alt=''/></a>"; RightLayer.InnerHtml = "<a class='nvWorksLnk' href='WorksShow.aspx?wid=" + worksList[currentIndex + 1].WorksID + "' title='下一作品:" + worksList[currentIndex + 1].WorksName + "'><img src='images/Next.png' alt=''/></a>"; lnkPre.Text = "上一作品:" + worksList[worksList.Count - 1].WorksName; lnkPre.NavigateUrl = "WorksShow.aspx?wid=" + worksList[worksList.Count - 1].WorksID; lnkNext.Text = "下一作品:" + worksList[currentIndex + 1].WorksName; lnkNext.NavigateUrl = "WorksShow.aspx?wid=" + worksList[currentIndex + 1].WorksID; } else if (currentIndex == worksList.Count - 1)// { LeftLayer.InnerHtml = "<a class='nvWorksLnk' href='WorksShow.aspx?wid=" + worksList[currentIndex - 1].WorksID + "' title='上一作品:" + worksList[currentIndex - 1].WorksName + "'><img src='images/Prev.png' alt=''/></a>"; RightLayer.InnerHtml = "<a class='nvWorksLnk' href='WorksShow.aspx?wid=" + worksList[0].WorksID + "' title='下一作品:" + worksList[0].WorksName + "'><img src='images/Next.png' alt=''/></a>"; lnkPre.Text = "上一作品:" + worksList[currentIndex - 1].WorksName; lnkPre.NavigateUrl = "WorksShow.aspx?wid=" + worksList[currentIndex - 1].WorksID; lnkNext.Text = "下一作品:" + worksList[0].WorksName; lnkNext.NavigateUrl = "WorksShow.aspx?wid=" + worksList[0].WorksID; } else// { LeftLayer.InnerHtml = "<a class='nvWorksLnk' href='WorksShow.aspx?wid=" + worksList[currentIndex - 1].WorksID + "' title='上一作品:" + worksList[currentIndex - 1].WorksName + "'><img src='images/Prev.png' alt=''/></a>"; RightLayer.InnerHtml = "<a class='nvWorksLnk' href='WorksShow.aspx?wid=" + worksList[currentIndex + 1].WorksID + "' title='下一作品:" + worksList[currentIndex + 1].WorksName + "'><img src='images/Next.png' alt=''/></a>"; lnkPre.Text = "上一作品:" + worksList[currentIndex - 1].WorksName; lnkPre.NavigateUrl = "WorksShow.aspx?wid=" + worksList[currentIndex - 1].WorksID; lnkNext.Text = "下一作品:" + worksList[currentIndex + 1].WorksName; lnkNext.NavigateUrl = "WorksShow.aspx?wid=" + worksList[currentIndex + 1].WorksID; } //WorksNavDiv.InnerHtml = worksNavhtml; //if (em.WorksTypeID != null) //{ // LbWorksType.Text = GetWorksTypeName((int)em.WorksTypeID); //} } if (userId != 0) { Favorites favWorks = Bll.UserBll.GetUserFavorites(userId.ToString()).FirstOrDefault(f => f.DomainID == 5 & f.ItemID == worksId); if (favWorks != null) { BtnFav.Visible = false; BtnUnFav.Visible = true; } else { BtnFav.Visible = true; BtnUnFav.Visible = false; } } else { LeftLayer.Visible = false; RightLayer.Visible = false; } }