protected void Button2_Click(object sender, EventArgs e) { string Title = TextBox1.Text; string Body = TextBox3.Text; string Author = "推广部"; string Date = DateTime.Now.ToString("yyyy-MM-dd"); string ifadmin = "1"; string ifpass = "******"; if (TextBox1.Text != "" && TextBox3.Text != "") { if (FileUpload1.HasFile) { TitlePic = UPimage(570, 385); } else { TitlePic = "default.jpg"; // 默认图片 } nd.OpenSqlTransaction(); try { nd.insertNews(Title, Body, Author, Date, ID, TitlePic, ifadmin, ifpass); DataSet ds = nd.GetLastNews(); string NewsID = ds.Tables[0].Rows[0]["NewsID"].ToString(); getcheck(CheckBoxList1, NewsID); if (diytag.Value != "") { nd.insertTags(diytag.Value); DataSet sd = nd.GetLastTags(); nd.insertNewsTag(NewsID, sd.Tables[0].Rows[0]["TagID"].ToString()); } nd.Commit(); } catch { nd.RollBack(); Response.Write(Util.ShowMessage("文章提交失败!")); } TextBox1.Text = ""; TextBox3.Text = ""; Image1.ImageUrl = "../images/" + TitlePic; Response.Write(Util.ShowMessage("你的文章已经提交,请耐心等待管理员审核!")); } else { Response.Write("<script language=\"JavaScript\">alert(\"信息不完全!\")</script>"); } }