/// <summary> /// 更新数据 /// </summary> public bool Update(Module_Information model) { StringBuilder strSql = new StringBuilder(); strSql.Append("Update WebPlatForm_Module_Information set "); strSql.Append(" strURL = @strURL, "); strSql.Append(" strUrlDescription = @strUrlDescription, "); strSql.Append(" nsortid = @nsortid, "); strSql.Append(" _blank = @_blank, "); strSql.Append(" strIconCss = @strIconCss,"); strSql.Append(" nParentID = @nParentID,"); strSql.Append(" nEnable = @nEnable "); strSql.Append(" where nID = @nID "); SqlParameter[] parameters = { new SqlParameter("@nID", model.nID), new SqlParameter("@strURL", model.strURL), new SqlParameter("@strUrlDescription", model.strUrlDescription), new SqlParameter("@nsortid", model.nsortid), new SqlParameter("@_blank", model._blank), new SqlParameter("@nParentID", model.nParentID), new SqlParameter("@strIconCss", model.strIconCss), new SqlParameter("@nEnable", model.nEnable) }; return(SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.Text, strSql.ToString(), parameters) > 0); }
/// <summary> /// 读取DataRow数据到Model中 /// </summary> private void DataRowToModel(Module_Information model, DataRow dr) { model.nID = ObjectConvertClass.static_ext_int(dr["nID"]); model.strURL = ObjectConvertClass.static_ext_string(dr["strURL"]); model.strUrlDescription = ObjectConvertClass.static_ext_string(dr["strUrlDescription"]); model.nParentID = ObjectConvertClass.static_ext_int(dr["nParentID"]); model.nsortid = ObjectConvertClass.static_ext_int(dr["nsortid"]); model._blank = ObjectConvertClass.static_ext_int(dr["_blank"]); model.strIconCss = ObjectConvertClass.static_ext_string(dr["strIconCss"]); model.nEnable = ObjectConvertClass.static_ext_int(dr["nEnable"]); }
/// <summary> /// 检查数据是否存在 /// </summary> public bool Exists(Module_Information _Module_Information) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(*) from WebPlatForm_Module_Information where nID=@nID"); SqlParameter[] parameters = { new SqlParameter("nID", _Module_Information.nID) }; return(Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, CommandType.Text, strSql.ToString(), parameters)) > 0); }
/// <summary> /// 更新启用状态 /// </summary> public bool UpdateEnable(Module_Information model) { StringBuilder strSql = new StringBuilder(); strSql.Append("Update WebPlatForm_Module_Information set "); strSql.Append(" nEnable = @nEnable "); strSql.Append(" where nID = @nID "); SqlParameter[] parameters = { new SqlParameter("@nID", model.nID), new SqlParameter("@nEnable", model.nEnable) }; return(SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.Text, strSql.ToString(), parameters) > 0); }
/// <summary> /// 获得一个实体对象 /// </summary> public Module_Information GetModel(Module_InformationQueryCondition QueryCondition) { SqlParameter[] sqlParams; StringBuilder strSqlOption = new StringBuilder(); QueryCondition.OutPut(out strSqlOption, out sqlParams); StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * "); strSql.Append(" FROM WebPlatForm_Module_Information where 1=1 " + strSqlOption.ToString()); DataTable dt = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, strSql.ToString(), sqlParams).Tables[0]; Module_Information _Module_Information = null; if (dt.Rows.Count > 0) { _Module_Information = new Module_Information(); DataRowToModel(_Module_Information, dt.Rows[0]); } return(_Module_Information); }
/// <summary> /// 添加数据 /// </summary> public bool Add(Module_Information model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into WebPlatForm_Module_Information"); strSql.Append("(nID,strURL,strUrlDescription,nParentID,nsortid,_blank,strIconCss,nEnable)"); strSql.Append("values(@nID,@strURL,@strUrlDescription,@nParentID,@nsortid,@_blank,@strIconCss,@nEnable)"); SqlParameter[] parameters = { new SqlParameter("@nID", model.nID), new SqlParameter("@strURL", model.strURL), new SqlParameter("@strUrlDescription", model.strUrlDescription), new SqlParameter("@nParentID", model.nParentID), new SqlParameter("@nsortid", model.nsortid), new SqlParameter("@_blank", model._blank), new SqlParameter("@strIconCss", model.strIconCss), new SqlParameter("@nEnable", model.nEnable) }; return(SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.Text, strSql.ToString(), parameters) > 0); }
/// <summary> /// 获得数据List /// </summary> public Module_InformationList GetDataList(Module_InformationQueryCondition QueryCondition) { SqlParameter[] sqlParams; StringBuilder strSqlOption = new StringBuilder(); QueryCondition.OutPut(out strSqlOption, out sqlParams); StringBuilder strSql = new StringBuilder(); if (QueryCondition.page == 0) { strSql.Append("select * "); strSql.Append(" FROM WebPlatForm_Module_Information where 1=1 " + strSqlOption.ToString()); strSql.Append(QueryCondition.sort == "" ? " nID" : QueryCondition.sort); strSql.Append(QueryCondition.order == "" ? " desc" : " " + QueryCondition.order); } else { strSql.Append(@"select top " + QueryCondition.rows.ToString() + " * from WebPlatForm_Module_Information where 1 = 1 " + strSqlOption.ToString() + " and nID not in ( select top " + (QueryCondition.page - 1) * QueryCondition.rows + " nID from WebPlatForm_Module_Information where 1=1 " + strSqlOption.ToString()); strSql.Append(" order by "); strSql.Append(QueryCondition.sort == "" ? " nID" : QueryCondition.sort); strSql.Append(QueryCondition.order == "" ? " desc" : " " + QueryCondition.order); strSql.Append(") order by "); strSql.Append(QueryCondition.sort == "" ? " nID" : QueryCondition.sort); strSql.Append(QueryCondition.order == "" ? " desc" : " " + QueryCondition.order); } DataTable dt = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, strSql.ToString(), sqlParams).Tables[0]; Module_InformationList list = new Module_InformationList(); foreach (DataRow dr in dt.Rows) { Module_Information _Module_Information = new Module_Information(); DataRowToModel(_Module_Information, dr); list.Add(_Module_Information); } return(list); }