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 { //t_sys_country_code public partial class t_sys_country_codeDAL { public bool Exists(int c_code_id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select count(1) from [t_sys_country_code]"); strSql.Append(" where "); strSql.Append(" c_code_id = @c_code_id "); SqlParameter[] parameters = { new SqlParameter("@c_code_id", SqlDbType.Int,4) }; parameters[0].Value = c_code_id; return DbHelperSQL.Exists(strSql.ToString(),parameters); } /// /// 增加一条数据 /// public int Add(DSWeb.SoftMng.Model.t_sys_country_code model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into [t_sys_country_code]("); strSql.Append("c_country_name,c_country_ename,c_country_code,c_enterprise_codetype"); strSql.Append(") values ("); strSql.Append("@c_country_name,@c_country_ename,@c_country_code,@c_enterprise_codetype"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@c_country_name", SqlDbType.NVarChar,50) , new SqlParameter("@c_country_ename", SqlDbType.VarChar,50) , new SqlParameter("@c_country_code", SqlDbType.VarChar,50) , new SqlParameter("@c_enterprise_codetype", SqlDbType.VarChar,50) }; parameters[0].Value = model.c_country_name??(Object)DBNull.Value; parameters[1].Value = model.c_country_ename??(Object)DBNull.Value; parameters[2].Value = model.c_country_code??(Object)DBNull.Value; parameters[3].Value = model.c_enterprise_codetype??(Object)DBNull.Value; return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); } /// /// 更新一条数据 /// public int Update(DSWeb.SoftMng.Model.t_sys_country_code model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update [t_sys_country_code] set "); strSql.Append(" c_country_name = @c_country_name,"); strSql.Append(" c_country_ename = @c_country_ename,"); strSql.Append(" c_country_code = @c_country_code,"); strSql.Append(" c_enterprise_codetype = @c_enterprise_codetype"); strSql.Append(" where c_code_id=@c_code_id "); SqlParameter[] parameters = { new SqlParameter("@c_code_id", SqlDbType.Int,4) , new SqlParameter("@c_country_name", SqlDbType.NVarChar,50) , new SqlParameter("@c_country_ename", SqlDbType.VarChar,50) , new SqlParameter("@c_country_code", SqlDbType.VarChar,50) , new SqlParameter("@c_enterprise_codetype", SqlDbType.VarChar,50) }; parameters[0].Value = model.c_code_id; parameters[1].Value = model.c_country_name??(Object)DBNull.Value; parameters[2].Value = model.c_country_ename??(Object)DBNull.Value; parameters[3].Value = model.c_country_code??(Object)DBNull.Value; parameters[4].Value = model.c_enterprise_codetype??(Object)DBNull.Value; return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); } /// /// 删除一条数据 /// public int Delete(int c_code_id) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from [t_sys_country_code] "); strSql.Append(" where c_code_id=@c_code_id"); SqlParameter[] parameters = { new SqlParameter("@c_code_id", SqlDbType.Int,4) }; parameters[0].Value = c_code_id; return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters); } /// /// 批量删除一批数据 /// public int DeleteList(string c_code_idlist ) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from [t_sys_country_code] "); strSql.Append(" where ID in ("+c_code_idlist + ") "); return DbHelperSQL.ExecuteSql(strSql.ToString()); } /// /// 按条件批量删除 /// public int DeleteListWhere(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from [t_sys_country_code] "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } return DbHelperSQL.ExecuteSql(strSql.ToString()); } /// /// 得到一个对象实体 /// public DataSet GetModel(int c_code_id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select c_code_id, c_country_name, c_country_ename, c_country_code, c_enterprise_codetype "); strSql.Append(" from [t_sys_country_code] "); strSql.Append(" where c_code_id=@c_code_id"); SqlParameter[] parameters = { new SqlParameter("@c_code_id", SqlDbType.Int,4) }; parameters[0].Value = c_code_id; DSWeb.SoftMng.Model.t_sys_country_code model=new DSWeb.SoftMng.Model.t_sys_country_code(); return DbHelperSQL.Query(strSql.ToString(),parameters); } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append("select * "); strSql.Append(" FROM [t_sys_country_code] "); 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 [t_sys_country_code] "); 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 [t_sys_country_code] 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 [t_sys_country_code] "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } return DbHelperSQL.ExcuteScalarSQL(strSql.ToString()); } } }