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 { //tSysEnumValue public partial class tSysEnumValueDAL { public bool Exists(decimal EnumTypeID,string EnumValueID,string EnumValueName) { StringBuilder strSql=new StringBuilder(); strSql.Append("select count(1) from [tSysEnumValue]"); strSql.Append(" where "); strSql.Append(" EnumTypeID = @EnumTypeID and "); strSql.Append(" EnumValueID = @EnumValueID and "); strSql.Append(" EnumValueName = @EnumValueName "); SqlParameter[] parameters = { new SqlParameter("@EnumTypeID", SqlDbType.Decimal,5), new SqlParameter("@EnumValueID", SqlDbType.VarChar,50), new SqlParameter("@EnumValueName", SqlDbType.VarChar,80) }; parameters[0].Value = EnumTypeID; parameters[1].Value = EnumValueID; parameters[2].Value = EnumValueName; return DbHelperSQL.Exists(strSql.ToString(),parameters); } /// /// 增加一条数据 /// public int Add(DSWeb.SoftMng.Model.tSysEnumValue model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into [tSysEnumValue]("); strSql.Append("LangID,EnumTypeID,EnumValueID,EnumValueName,IsDefault,DispIndex,VerNo,EnumValueName_2"); strSql.Append(") values ("); strSql.Append("@LangID,@EnumTypeID,@EnumValueID,@EnumValueName,@IsDefault,@DispIndex,@VerNo,@EnumValueName_2"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@LangID", SqlDbType.Decimal,5) , new SqlParameter("@EnumTypeID", SqlDbType.Decimal,5) , new SqlParameter("@EnumValueID", SqlDbType.VarChar,50) , new SqlParameter("@EnumValueName", SqlDbType.VarChar,80) , new SqlParameter("@IsDefault", SqlDbType.VarChar,1) , new SqlParameter("@DispIndex", SqlDbType.Decimal,5) , new SqlParameter("@VerNo", SqlDbType.VarChar,20) , new SqlParameter("@EnumValueName_2", SqlDbType.VarChar,50) }; parameters[0].Value = model.LangID; parameters[1].Value = model.EnumTypeID; parameters[2].Value = model.EnumValueID??(Object)DBNull.Value; parameters[3].Value = model.EnumValueName??(Object)DBNull.Value; parameters[4].Value = model.IsDefault??(Object)DBNull.Value; parameters[5].Value = model.DispIndex; parameters[6].Value = model.VerNo??(Object)DBNull.Value; parameters[7].Value = model.EnumValueName_2??(Object)DBNull.Value; return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); } /// /// 更新一条数据 /// public int Update(DSWeb.SoftMng.Model.tSysEnumValue model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update [tSysEnumValue] set "); strSql.Append(" LangID = @LangID,"); strSql.Append(" EnumTypeID = @EnumTypeID,"); strSql.Append(" EnumValueID = @EnumValueID,"); strSql.Append(" EnumValueName = @EnumValueName,"); strSql.Append(" IsDefault = @IsDefault,"); strSql.Append(" DispIndex = @DispIndex,"); strSql.Append(" VerNo = @VerNo,"); strSql.Append(" EnumValueName_2 = @EnumValueName_2"); strSql.Append(" where EnumTypeID=@EnumTypeID and EnumValueID=@EnumValueID and EnumValueName=@EnumValueName "); SqlParameter[] parameters = { new SqlParameter("@LangID", SqlDbType.Decimal,5) , new SqlParameter("@EnumTypeID", SqlDbType.Decimal,5) , new SqlParameter("@EnumValueID", SqlDbType.VarChar,50) , new SqlParameter("@EnumValueName", SqlDbType.VarChar,80) , new SqlParameter("@IsDefault", SqlDbType.VarChar,1) , new SqlParameter("@DispIndex", SqlDbType.Decimal,5) , new SqlParameter("@VerNo", SqlDbType.VarChar,20) , new SqlParameter("@EnumValueName_2", SqlDbType.VarChar,50) }; parameters[0].Value = model.LangID; parameters[1].Value = model.EnumTypeID; parameters[2].Value = model.EnumValueID??(Object)DBNull.Value; parameters[3].Value = model.EnumValueName??(Object)DBNull.Value; parameters[4].Value = model.IsDefault??(Object)DBNull.Value; parameters[5].Value = model.DispIndex; parameters[6].Value = model.VerNo??(Object)DBNull.Value; parameters[7].Value = model.EnumValueName_2??(Object)DBNull.Value; return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); } /// /// 删除一条数据 /// public int Delete(decimal EnumTypeID,string EnumValueID,string EnumValueName) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from [tSysEnumValue] "); strSql.Append(" where EnumTypeID=@EnumTypeID and EnumValueID=@EnumValueID and EnumValueName=@EnumValueName "); SqlParameter[] parameters = { new SqlParameter("@EnumTypeID", SqlDbType.Decimal,5), new SqlParameter("@EnumValueID", SqlDbType.VarChar,50), new SqlParameter("@EnumValueName", SqlDbType.VarChar,80) }; parameters[0].Value = EnumTypeID; parameters[1].Value = EnumValueID; parameters[2].Value = EnumValueName; return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); } /// /// 按条件批量删除 /// public int DeleteListWhere(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from [tSysEnumValue] "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } return DbHelperSQL.ExecuteSql(strSql.ToString()); } /// /// 得到一个对象实体 /// public DataSet GetModel(decimal EnumTypeID,string EnumValueID,string EnumValueName) { StringBuilder strSql=new StringBuilder(); strSql.Append("select LangID, EnumTypeID, EnumValueID, EnumValueName, IsDefault, DispIndex, VerNo, EnumValueName_2 "); strSql.Append(" from [tSysEnumValue] "); strSql.Append(" where EnumTypeID=@EnumTypeID and EnumValueID=@EnumValueID and EnumValueName=@EnumValueName "); SqlParameter[] parameters = { new SqlParameter("@EnumTypeID", SqlDbType.Decimal,5), new SqlParameter("@EnumValueID", SqlDbType.VarChar,50), new SqlParameter("@EnumValueName", SqlDbType.VarChar,80) }; parameters[0].Value = EnumTypeID; parameters[1].Value = EnumValueID; parameters[2].Value = EnumValueName; DSWeb.SoftMng.Model.tSysEnumValue model=new DSWeb.SoftMng.Model.tSysEnumValue(); return DbHelperSQL.Query(strSql.ToString(),parameters); } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append("select * "); strSql.Append(" FROM [tSysEnumValue] "); 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 [tSysEnumValue] "); 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 [tSysEnumValue] 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 [tSysEnumValue] "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } return DbHelperSQL.ExcuteScalarSQL(strSql.ToString()); } } }