protected void btnSubmit_Click(object sender, EventArgs e) { try { if (Label2.Text.Trim() == "") { Response.Write("<script>alert('照片不能为空!')</script>"); } else { ACG acg = new ACG(); acg.Pro_Title = txtTitle.Text.Trim(); acg.User_ID = 5; //news.AssID = 1; acg.Pro_Img = Label2.Text; acg.Pro_Content = Label1.Text; acg.Pro_Class = this.DropDownList2.SelectedItem.ToString(); switch (DropDownList3.SelectedItem.ToString()) { case "国家宝藏": acg.Tally_ID = 1; break; case "汉服": acg.Tally_ID = 2; break; case "青铜器": acg.Tally_ID = 3; break; case "瓷器": acg.Tally_ID = 4; break; case "金银器": acg.Tally_ID = 5; break; } acg.Pro_Time = DateTime.Now; int result = AcgService.Insert(acg); if (result >= 1) { txtContent.Text = ""; Label2.Text = "Img\\ACGImg\\"; Label1.Text = "video\\"; txtTitle.Text = ""; Response.Write("<script>alert('发布成功!')</script>"); } } } catch (Exception ex) { Response.Write("<script>alert('上传失败');</script> 原因是:" + ex); } }
////查找前6精华的Acg作品 //public DataTable tuiguang() //{ // string sql = "select top 6*from ACG,Recommend where ACG.Pro_ID=Recommend.Pro_ID and Recommend.AcgRecommend='是' order by Pro_Time desc"; // return DBHelper.GetFillData(sql); //} ////根据分类查找前五精华的Acg作品 //public DataTable acgjinghua(string Pro_Class) //{ // string sql = "select top 5*from ACG,Recommend where ACG.Pro_ID=Recommend.Pro_ID and Recommend.AcgRecommend='是' and ACG.Pro_Class=@Pro_Class order by Pro_Time desc"; // SqlParameter[] sp = new SqlParameter[] // { // new SqlParameter("@Pro_Class",Pro_Class) // }; // return DBHelper.GetFillData(sql, sp); //} //后台增加 public int Insert(ACG acg) { string sql = "insert into ACG (Pro_Title,Tally_ID,User_ID,Pro_Img,Pro_Content,Pro_Class,Pro_Time) values(@Pro_Title,@Tally_ID,@User_ID,@Pro_Img,@Pro_Content,@Pro_Class,@Pro_Time)"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@Pro_Title", acg.Pro_Title), new SqlParameter("@Tally_ID", acg.Tally_ID), new SqlParameter("@User_ID", acg.User_ID), new SqlParameter("@Pro_Img", acg.Pro_Img), new SqlParameter("@Pro_Content", acg.Pro_Content), new SqlParameter("@Pro_Class", acg.Pro_Class), new SqlParameter("@Pro_Time", acg.Pro_Time) }; return(DBHelper.GetExcuteNonQuery(sql, sp)); }
//用户发表ACG作品 public int addAcg(ACG acg) { string sql = "insert into ACG values(@User_ID, @Pro_Class, @Pro_Title, @Pro_Time, @Pro_Content, @Cull_Name, @Pro_Img)"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@User_ID", acg.User_ID), new SqlParameter("@Pro_Class", acg.Pro_Class), new SqlParameter("@Pro_Title", acg.Pro_Title), new SqlParameter("@Pro_Time", acg.Pro_Time), new SqlParameter("@Pro_Content", acg.Pro_Content), new SqlParameter("@Cull_Name", acg.Cull_Name), new SqlParameter("@Pro_Img", acg.Pro_Img) }; return(DBHelper.GetExcuteNonQuery(sql, sp)); }
protected void AddNews_Click(object sender, EventArgs e) { ACG acg = new ACG(); acg.Pro_Title = txtTitle.Text.Trim(); acg.User_ID = 5; //news.AssID = 1; acg.Pro_Img = Label2.Text; acg.Pro_Content = txtContent.Text; acg.Pro_Class = this.DropDownList2.SelectedItem.ToString(); switch (DropDownList3.SelectedItem.ToString()) { case "国家宝藏": acg.Tally_ID = 1; break; case "汉服": acg.Tally_ID = 2; break; case "青铜器": acg.Tally_ID = 3; break; case "瓷器": acg.Tally_ID = 4; break; case "金银器": acg.Tally_ID = 5; break; } acg.Pro_Time = DateTime.Now; int result = AcgService.Insert(acg); if (result >= 1) { txtContent.Text = ""; Label2.Text = "Img\\ACGImg\\"; txtTitle.Text = ""; Response.Write("<script>alert('发布成功!')</script>"); } }
//发表ACG创作 protected void AddNews_Click(object sender, EventArgs e) { ACG acg = new ACG(); acg.Pro_Title = txtTitle.Text.Trim(); acg.User_ID = int.Parse(Session["User_ID"].ToString()); //news.AssID = 1; acg.Pro_Img = "Img/ACGImg/" + FileUpload1.PostedFile.FileName; acg.Pro_Content = txtContent.Text.Trim(); acg.Pro_Class = this.DropDownList2.SelectedItem.ToString(); switch (DropDownList3.SelectedItem.ToString()) { case "国家宝藏": acg.Tally_ID = 1; break; case "汉服": acg.Tally_ID = 2; break; case "青铜器": acg.Tally_ID = 3; break; case "瓷器": acg.Tally_ID = 4; break; case "金银器": acg.Tally_ID = 5; break; } acg.Pro_Time = DateTime.Now; int result = AcgService.Insert(acg); if (result >= 1) { Response.Write("<script>alert('发布成功!')</script>"); } //user.User_Img = @"~/User_Img/" + ChangImg.PostedFile.FileName; }
//用户发表ACG作品 public static int addAcg(ACG acg) { return(iacg.addAcg(acg)); }
////根据分类查找前五精华的Acg作品 //public static DataTable acgjinghua(string Pro_Class) //{ // return iacg.acgjinghua(Pro_Class); //} ////查找前6精华的Acg作品 //public static DataTable tuiguang() //{ // return iacg.tuiguang(); //} //后台增加 public static int Insert(ACG acg) { return(iacg.Insert(acg)); }