protected void btnComments_Click(object sender, EventArgs e) { if (Session["user_name"] != null) { if (Page.IsValid) { travel_record_comt comt = new travel_record_comt();//新建查询对象 comt.user_id = int.Parse(Session["user_id"].ToString()); comt.trrecord_id = int.Parse(Request.QueryString["id"]); comt.comt_cont = txtComments.Text; comt.comt_time = DateTime.Now; int result = Travel_record_comtManager.InsertTravel_record_comt(comt); if (result >= 1) { ScriptManager.RegisterClientScriptBlock(updatecomment, this.GetType(), "click", "alert('评论成功!')", true); BindTravelComment(); txtComments.Text = ""; } else { ScriptManager.RegisterClientScriptBlock(updatecomment, this.GetType(), "click", "alert('评论失败!')", true); } } } else { ScriptManager.RegisterClientScriptBlock(updatecomment, this.GetType(), "click", "alert('您必须先登录才能评论!')", true); ScriptManager.RegisterStartupScript(updatecomment, updatecomment.GetType(), "updateScript", "window.location.href='login1.aspx'", true); } }
public int InsertTravel_record_comt(travel_record_comt travel_Record_Comt) { string sql = "insert into travel_record_comt values(@user_id,@trrecord_id,@comt_cont,@comt_time)"; SqlParameter[] sp = { new SqlParameter("@user_id", travel_Record_Comt.user_id), new SqlParameter("@trrecord_id", travel_Record_Comt.trrecord_id), new SqlParameter("@comt_cont", travel_Record_Comt.comt_cont), new SqlParameter("@comt_time", travel_Record_Comt.comt_time) }; return(DBHelper.GetExcuteNonQuery(sql, sp)); }
public static int InsertTravel_record_comt(travel_record_comt travel_Record_Comt) { return(itravel_Record_Comt.InsertTravel_record_comt(travel_Record_Comt)); }