/// <summary> /// 碎言碎语 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button3_Click(object sender, EventArgs e) { SayModal saymodal = new SayModal(); SayDAO saydao = new SayDAO(); string txtconttext = TxtContText.InnerText; if (txtconttext == "") { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('内容不能为空');</script>"); return; } saymodal.SayCont = txtconttext; bool b = saydao.SayInsertrt(saymodal); if (b) { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert(' 碎言碎语插入成功');</script>"); TxtContText.InnerText = ""; } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert(' 碎言碎语插入失败');</script>"); } }
/// <summary> /// 插入岁言碎语 /// </summary> /// <param name="says"></param> /// <returns></returns> public bool SayInsertrt(SayModal says) { bool flag = false; string sql = "insert INTO say(sayCont) VALUES(@sayCont)"; SqlParameter[] par = { new SqlParameter("@sayCont", says.SayCont) }; int res = sqlhelper.ExecuteNonQuery(sql, CommandType.Text, par); if (res > 0) { flag = true; } return(flag); }