/// <summary> /// 增加一条数据 /// </summary> public bool Add(TargetIdsModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into YYHD.dbo.TargetIds ("); strSql.Append("RongMsgLogId,TargetId,MsgStatus"); strSql.Append(") values ("); strSql.Append("@RongMsgLogId,@TargetId,@MsgStatus"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@RongMsgLogId", SqlDbType.Decimal, 9), new SqlParameter("@TargetId", SqlDbType.VarChar, 50), new SqlParameter("@MsgStatus", SqlDbType.Int, 4) }; parameters[0].Value = model.RongMsgLogId; parameters[1].Value = model.TargetId; parameters[2].Value = model.MsgStatus; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }
/// <summary> /// 得到一个对象实体 /// </summary> public TargetIdsModel GetModel(decimal RongMsgLogId, string TargetId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select RongMsgLogId, TargetId, MsgStatus "); strSql.Append(" from YYHD.dbo.TargetIds "); strSql.Append(" where RongMsgLogId=@RongMsgLogId and TargetId=@TargetId "); SqlParameter[] parameters = { new SqlParameter("@RongMsgLogId", SqlDbType.Decimal, 9), new SqlParameter("@TargetId", SqlDbType.VarChar, 50) }; parameters[0].Value = RongMsgLogId; parameters[1].Value = TargetId; TargetIdsModel model = new TargetIdsModel(); DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["RongMsgLogId"].ToString() != "") { model.RongMsgLogId = decimal.Parse(ds.Tables[0].Rows[0]["RongMsgLogId"].ToString()); } model.TargetId = ds.Tables[0].Rows[0]["TargetId"].ToString(); if (ds.Tables[0].Rows[0]["MsgStatus"].ToString() != "") { model.MsgStatus = int.Parse(ds.Tables[0].Rows[0]["MsgStatus"].ToString()); } return(model); } else { return(model); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(TargetIdsModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update YYHD.dbo.TargetIds set "); strSql.Append(" RongMsgLogId = @RongMsgLogId , "); strSql.Append(" TargetId = @TargetId , "); strSql.Append(" MsgStatus = @MsgStatus "); strSql.Append(" where RongMsgLogId=@RongMsgLogId and TargetId=@TargetId "); SqlParameter[] parameters = { new SqlParameter("@RongMsgLogId", SqlDbType.Decimal, 9), new SqlParameter("@TargetId", SqlDbType.VarChar, 50), new SqlParameter("@MsgStatus", SqlDbType.Int, 4) }; parameters[0].Value = model.RongMsgLogId; parameters[1].Value = model.TargetId; parameters[2].Value = model.MsgStatus; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }