using System; using System.Text; using System.Data.SqlClient; using System.Collections.Generic; using System.Data; using DSWeb.SoftMng.DBUtility; // ReSharper disable once CheckNamespace namespace DSWeb.SoftMng.DAL { //user_authority_info public partial class user_authority_infoDAL { public bool Exists(string GID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select count(1) from user_authority_info"); strSql.Append(" where "); strSql.Append(" GID = @GID "); SqlParameter[] parameters = { new SqlParameter("@GID", SqlDbType.VarChar,36) }; parameters[0].Value = GID; return DbHelperSQL.Exists(strSql.ToString(),parameters); } /// /// 增加一条数据 /// public int Add(DSWeb.SoftMng.Model.user_authority_info model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into user_authority_info("); strSql.Append("GID,NAME,DESCRIPTION,MODULEURL,ISALL,ISCOMPANY,ISDEPT,ISPERSON,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,ISDELETE"); strSql.Append(") values ("); strSql.Append("@GID,@NAME,@DESCRIPTION,@MODULEURL,@ISALL,@ISCOMPANY,@ISDEPT,@ISPERSON,@CREATEUSER,@CREATETIME,@MODIFIEDUSER,@MODIFIEDTIME,@ISDELETE"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@GID", SqlDbType.VarChar,36) , new SqlParameter("@NAME", SqlDbType.VarChar,50) , new SqlParameter("@DESCRIPTION", SqlDbType.VarChar,50) , new SqlParameter("@MODULEURL", SqlDbType.VarChar,50) , new SqlParameter("@ISALL", SqlDbType.Bit,1) , new SqlParameter("@ISCOMPANY", SqlDbType.Bit,1) , new SqlParameter("@ISDEPT", SqlDbType.Bit,1) , new SqlParameter("@ISPERSON", SqlDbType.Bit,1) , new SqlParameter("@CREATEUSER", SqlDbType.VarChar,36) , new SqlParameter("@CREATETIME", SqlDbType.DateTime) , new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) , new SqlParameter("@MODIFIEDTIME", SqlDbType.DateTime) , new SqlParameter("@ISDELETE", SqlDbType.Bit,1) }; parameters[0].Value = model.GID??(Object)DBNull.Value; parameters[1].Value = model.NAME??(Object)DBNull.Value; parameters[2].Value = model.DESCRIPTION??(Object)DBNull.Value; parameters[3].Value = model.MODULEURL??(Object)DBNull.Value; parameters[4].Value = model.ISALL??(Object)DBNull.Value; parameters[5].Value = model.ISCOMPANY??(Object)DBNull.Value; parameters[6].Value = model.ISDEPT??(Object)DBNull.Value; parameters[7].Value = model.ISPERSON??(Object)DBNull.Value; parameters[8].Value = model.CREATEUSER??(Object)DBNull.Value; parameters[9].Value = model.CREATETIME??(Object)DBNull.Value; parameters[10].Value = model.MODIFIEDUSER??(Object)DBNull.Value; parameters[11].Value = model.MODIFIEDTIME??(Object)DBNull.Value; parameters[12].Value = model.ISDELETE??(Object)DBNull.Value; return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); } /// /// 更新一条数据 /// public int Update(DSWeb.SoftMng.Model.user_authority_info model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update user_authority_info set "); strSql.Append(" GID = @GID,"); strSql.Append(" NAME = @NAME,"); strSql.Append(" DESCRIPTION = @DESCRIPTION,"); strSql.Append(" MODULEURL = @MODULEURL,"); strSql.Append(" ISALL = @ISALL,"); strSql.Append(" ISCOMPANY = @ISCOMPANY,"); strSql.Append(" ISDEPT = @ISDEPT,"); strSql.Append(" ISPERSON = @ISPERSON,"); strSql.Append(" CREATEUSER = @CREATEUSER,"); strSql.Append(" CREATETIME = @CREATETIME,"); strSql.Append(" MODIFIEDUSER = @MODIFIEDUSER,"); strSql.Append(" MODIFIEDTIME = @MODIFIEDTIME,"); strSql.Append(" ISDELETE = @ISDELETE"); strSql.Append(" where GID=@GID "); SqlParameter[] parameters = { new SqlParameter("@GID", SqlDbType.VarChar,36) , new SqlParameter("@NAME", SqlDbType.VarChar,50) , new SqlParameter("@DESCRIPTION", SqlDbType.VarChar,50) , new SqlParameter("@MODULEURL", SqlDbType.VarChar,50) , new SqlParameter("@ISALL", SqlDbType.Bit,1) , new SqlParameter("@ISCOMPANY", SqlDbType.Bit,1) , new SqlParameter("@ISDEPT", SqlDbType.Bit,1) , new SqlParameter("@ISPERSON", SqlDbType.Bit,1) , new SqlParameter("@CREATEUSER", SqlDbType.VarChar,36) , new SqlParameter("@CREATETIME", SqlDbType.DateTime) , new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) , new SqlParameter("@MODIFIEDTIME", SqlDbType.DateTime) , new SqlParameter("@ISDELETE", SqlDbType.Bit,1) }; parameters[0].Value = model.GID??(Object)DBNull.Value; parameters[1].Value = model.NAME??(Object)DBNull.Value; parameters[2].Value = model.DESCRIPTION??(Object)DBNull.Value; parameters[3].Value = model.MODULEURL??(Object)DBNull.Value; parameters[4].Value = model.ISALL??(Object)DBNull.Value; parameters[5].Value = model.ISCOMPANY??(Object)DBNull.Value; parameters[6].Value = model.ISDEPT??(Object)DBNull.Value; parameters[7].Value = model.ISPERSON??(Object)DBNull.Value; parameters[8].Value = model.CREATEUSER??(Object)DBNull.Value; parameters[9].Value = model.CREATETIME??(Object)DBNull.Value; parameters[10].Value = model.MODIFIEDUSER??(Object)DBNull.Value; parameters[11].Value = model.MODIFIEDTIME??(Object)DBNull.Value; parameters[12].Value = model.ISDELETE??(Object)DBNull.Value; return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); } /// /// 删除一条数据 /// public int Delete(string GID) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from user_authority_info "); strSql.Append(" where GID=@GID "); SqlParameter[] parameters = { new SqlParameter("@GID", SqlDbType.VarChar,36) }; parameters[0].Value = GID; return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); } /// /// 按条件批量删除 /// public int DeleteListWhere(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from user_authority_info "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } return DbHelperSQL.ExecuteSql(strSql.ToString()); } /// /// 得到一个对象实体 /// public DataSet GetModel(string GID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select GID, NAME, DESCRIPTION, MODULEURL, ISALL, ISCOMPANY, ISDEPT, ISPERSON, CREATEUSER, CREATETIME, MODIFIEDUSER, MODIFIEDTIME, ISDELETE "); strSql.Append(" from user_authority_info "); strSql.Append(" where GID=@GID "); SqlParameter[] parameters = { new SqlParameter("@GID", SqlDbType.VarChar,36) }; parameters[0].Value = GID; DSWeb.SoftMng.Model.user_authority_info model=new DSWeb.SoftMng.Model.user_authority_info(); return DbHelperSQL.Query(strSql.ToString(),parameters); } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append("select * "); strSql.Append(" FROM user_authority_info "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } return DbHelperSQL.Query(strSql.ToString()); } /// /// 获得前几行数据 /// public DataSet GetList(int Top,string strWhere,string filedOrder) { StringBuilder strSql=new StringBuilder(); strSql.Append("select "); if(Top>0) { strSql.Append(" top "+Top.ToString()); } strSql.Append(" * "); strSql.Append(" FROM user_authority_info "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } strSql.Append(" order by " + filedOrder); return DbHelperSQL.Query(strSql.ToString()); } /// /// 分页获取数据列表 /// public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex) { //动软代码 StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT * FROM ( "); strSql.Append(" SELECT ROW_NUMBER() OVER ("); if (!string.IsNullOrEmpty(orderby.Trim())) strSql.Append("order by T." + orderby); strSql.Append(")AS Row, T.* from user_authority_info T "); if (!string.IsNullOrEmpty(strWhere.Trim())) { strSql.Append(" WHERE " + strWhere); } strSql.Append(" ) TT"); strSql.AppendFormat(" WHERE TT.Row > {0} and TT.Row <= {1}", startIndex, endIndex); //公共代码 return DbHelperSQL.Query(strSql.ToString()); } /// /// 获取记录总数 /// public int GetRecordCount(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append("select count(1) FROM user_authority_info "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } return DbHelperSQL.ExcuteScalarSQL(strSql.ToString()); } } }