/// <summary> /// 更改留言狀態 /// </summary> /// <param name="query"></param> /// <returns></returns> public int UpVoteMessageStatus(VoteMessageQuery query) { int result = 0; StringBuilder sql = new StringBuilder(); query.Replace4MySQL(); try { sql.Append("set sql_safe_updates=0;"); sql.AppendFormat("update vote_message set message_status='{0}', update_time='{1}'", query.message_status,CommonFunction.DateTimeToString(query.update_time)); sql.AppendFormat(" ,update_user='******',ip='{1}' where message_id='{2}'; ", query.update_user,query.ip,query.message_id); sql.Append("set sql_safe_updates=1;"); result = _access.execCommand(sql.ToString()); } catch (Exception ex) { throw new Exception("VoteMessageDao.UpVoteMessageStatus-->" + ex.Message + sql.ToString(), ex); } return result; }
/// <summary> /// 新增活動留言 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddVoteMessage(VoteMessageQuery model) { StringBuilder sbSql = new StringBuilder(); model.Replace4MySQL(); sbSql.Append("insert into vote_message(article_id,create_time,create_user,update_time,update_user,ip,message_status,message_content)values("); sbSql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}');", model.article_id, CommonFunction.DateTimeToString(model.create_time), model.create_user, CommonFunction.DateTimeToString(model.update_time), model.update_user, model.ip, model.message_status, model.message_content); sbSql.Append("SELECT @@IDENTITY;"); try { DataTable _dt = _access.getDataTable(sbSql.ToString()); if (_dt.Rows.Count > 0) { return Convert.ToInt32(_dt.Rows[0][0]); } else { return 0; } } catch (Exception ex) { throw new Exception("VoteMessageDao-->AddVoteMessage-->" + ex.Message + sbSql.ToString(), ex); } }
/// <summary> /// 修改活動留言 /// </summary> /// <param name="model"></param> /// <returns></returns> public int UpdateVoteMessage(VoteMessageQuery model) { int result = 0; StringBuilder sbSql = new StringBuilder(); model.Replace4MySQL(); sbSql.Append("set sql_safe_updates=0;"); sbSql.AppendFormat("update vote_message set article_id='{0}',update_time='{1}',update_user='******'", model.article_id, CommonFunction.DateTimeToString(model.update_time), model.update_user); sbSql.AppendFormat(",message_content='{0}',ip='{1}' where message_id='{2}';", model.message_content,model.ip,model.message_id); sbSql.Append("set sql_safe_updates=1;"); try { result = _access.execCommand(sbSql.ToString()); } catch (Exception ex) { throw new Exception("VoteMessageDao-->UpdateVoteMessage-->" + ex.Message + sbSql.ToString(), ex); } return result; }