/// <summary> /// 更新一条数据 /// </summary> public bool Update(PushTypeModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update YYHD.dbo.PushType set "); strSql.Append(" PushTypeId = @PushTypeId , "); strSql.Append(" PushTypeName = @PushTypeName "); strSql.Append(" where PushTypeId=@PushTypeId "); SqlParameter[] parameters = { new SqlParameter("@PushTypeId", SqlDbType.Int, 4), new SqlParameter("@PushTypeName", SqlDbType.VarChar, 50) }; parameters[0].Value = model.PushTypeId; parameters[1].Value = model.PushTypeName; 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 PushTypeModel GetModel(int PushTypeId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select PushTypeId, PushTypeName "); strSql.Append(" from YYHD.dbo.PushType "); strSql.Append(" where PushTypeId=@PushTypeId "); SqlParameter[] parameters = { new SqlParameter("@PushTypeId", SqlDbType.Int, 4) }; parameters[0].Value = PushTypeId; PushTypeModel model = new PushTypeModel(); DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["PushTypeId"].ToString() != "") { model.PushTypeId = int.Parse(ds.Tables[0].Rows[0]["PushTypeId"].ToString()); } model.PushTypeName = ds.Tables[0].Rows[0]["PushTypeName"].ToString(); return(model); } else { return(model); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(PushTypeModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into YYHD.dbo.PushType ("); strSql.Append("PushTypeId,PushTypeName"); strSql.Append(") values ("); strSql.Append("@PushTypeId,@PushTypeName"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@PushTypeId", SqlDbType.Int, 4), new SqlParameter("@PushTypeName", SqlDbType.VarChar, 50) }; parameters[0].Value = model.PushTypeId; parameters[1].Value = model.PushTypeName; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }