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