/// <summary> /// 获取记录 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static DataTable getDT(DC_ARMY_MEMBER_SW sw) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(" FROM DC_ARMY_MEMBER"); sb.AppendFormat(" WHERE 1=1"); if (string.IsNullOrEmpty(sw.DC_ARMY_MEMBER_ID) == false) { sb.AppendFormat(" AND DC_ARMY_MEMBER_ID = '{0}'", ClsSql.EncodeSql(sw.DC_ARMY_MEMBER_ID)); } if (string.IsNullOrEmpty(sw.DC_ARMY_ID) == false) { sb.AppendFormat(" AND DC_ARMY_ID = '{0}'", ClsSql.EncodeSql(sw.DC_ARMY_ID)); } if (string.IsNullOrEmpty(sw.MEMBERNAME) == false) { sb.AppendFormat(" AND MEMBERNAME like '%{0}%'", ClsSql.EncodeSql(sw.MEMBERNAME)); } if (string.IsNullOrEmpty(sw.SEX) == false) { sb.AppendFormat(" AND SEX = '{0}'", ClsSql.EncodeSql(sw.SEX)); } string sql = ""; sql = "SELECT DC_ARMY_MEMBER_ID, DC_ARMY_ID, MEMBERNAME, SEX, CONTACTS, BIRTH" + sb.ToString() + " order by MEMBERNAME"; DataSet ds = DataBaseClass.FullDataSet(sql); return(ds.Tables[0]); }
/// <summary> /// 获取列表 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static IEnumerable <DC_ARMY_MEMBER_Model> getModelList(DC_ARMY_MEMBER_SW sw) { var result = new List <DC_ARMY_MEMBER_Model>(); DataTable dt = BaseDT.DC_ARMY_MEMBER.getDT(sw);//列表 DataTable dtSex = BaseDT.T_SYS_DICT.getDT(new T_SYS_DICTSW { DICTFLAG = "性别" }); //性别 for (int i = 0; i < dt.Rows.Count; i++) { DC_ARMY_MEMBER_Model m = new DC_ARMY_MEMBER_Model(); m.DC_ARMY_MEMBER_ID = dt.Rows[i]["DC_ARMY_MEMBER_ID"].ToString(); m.DC_ARMY_ID = dt.Rows[i]["DC_ARMY_ID"].ToString(); m.MEMBERNAME = dt.Rows[i]["MEMBERNAME"].ToString(); m.SEX = dt.Rows[i]["SEX"].ToString(); m.SEXNAME = BaseDT.T_SYS_DICT.getName(dtSex, dt.Rows[i]["SEX"].ToString()); m.CONTACTS = dt.Rows[i]["CONTACTS"].ToString(); m.BIRTH = PublicClassLibrary.ClsSwitch.SwitDate(dt.Rows[i]["BIRTH"].ToString()); result.Add(m); } dt.Clear(); dt.Dispose(); return(result); }
/// <summary> /// 判断记录是否存在 /// </summary> /// <param name="sw">参见模型</param> /// <returns>true存在 false不存在</returns> public static bool isExists(DC_ARMY_MEMBER_SW sw) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("select 1 from DC_ARMY_MEMBER where 1=1"); if (string.IsNullOrEmpty(sw.DC_ARMY_MEMBER_ID) == false) { sb.AppendFormat(" where DC_ARMY_MEMBER_ID= '{0}'", ClsSql.EncodeSql(sw.DC_ARMY_MEMBER_ID)); } return(DataBaseClass.JudgeRecordExists(sb.ToString())); }
/// <summary> /// 根据查询条件获取某一条用户信息记录,用于修改、删除、用户登录验证 /// </summary> /// <param name="sw">参见模型</param> /// <returns>参见模型</returns> public static DC_ARMY_MEMBER_Model getModel(DC_ARMY_MEMBER_SW sw) { var result = new List <DC_ARMY_MEMBER_Model>(); DataTable dt = BaseDT.DC_ARMY_MEMBER.getDT(sw);//列表 DC_ARMY_MEMBER_Model m = new DC_ARMY_MEMBER_Model(); if (dt.Rows.Count > 0) { int i = 0; m.DC_ARMY_MEMBER_ID = dt.Rows[i]["DC_ARMY_MEMBER_ID"].ToString(); m.DC_ARMY_ID = dt.Rows[i]["DC_ARMY_ID"].ToString(); m.MEMBERNAME = dt.Rows[i]["MEMBERNAME"].ToString(); m.SEX = dt.Rows[i]["SEX"].ToString(); m.CONTACTS = dt.Rows[i]["CONTACTS"].ToString(); m.BIRTH = PublicClassLibrary.ClsSwitch.SwitDate(dt.Rows[i]["BIRTH"].ToString()); } dt.Clear(); dt.Dispose(); return(m); }
/// <summary> /// 获取分页列表 /// </summary> /// <param name="sw"></param> /// <param name="total"></param> /// <returns></returns> public static DataTable getDT(DC_ARMY_MEMBER_SW sw, out int total) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(" FROM DC_ARMY_MEMBER"); sb.AppendFormat(" WHERE 1=1"); if (string.IsNullOrEmpty(sw.DC_ARMY_MEMBER_ID) == false) { sb.AppendFormat(" AND DC_ARMY_MEMBER_ID = '{0}'", ClsSql.EncodeSql(sw.DC_ARMY_MEMBER_ID)); } if (string.IsNullOrEmpty(sw.DC_ARMY_ID) == false) { sb.AppendFormat(" AND DC_ARMY_ID = '{0}'", ClsSql.EncodeSql(sw.DC_ARMY_ID)); } if (string.IsNullOrEmpty(sw.MEMBERNAME) == false) { sb.AppendFormat(" AND MEMBERNAME like '%{0}%'", ClsSql.EncodeSql(sw.MEMBERNAME)); } if (string.IsNullOrEmpty(sw.SEX) == false) { sb.AppendFormat(" AND SEX = '{0}'", ClsSql.EncodeSql(sw.SEX)); } string sql = "SELECT DC_ARMY_MEMBER_ID, DC_ARMY_ID, MEMBERNAME, SEX, CONTACTS, BIRTH" + sb.ToString() + " order by MEMBERNAME"; string sqlC = "select count(1) " + sb.ToString(); total = int.Parse(DataBaseClass.ReturnSqlField(sqlC)); sw.curPage = PagerCls.getCurPage(new PagerSW { curPage = sw.curPage, pageSize = sw.pageSize, rowCount = total }); DataSet ds = DataBaseClass.FullDataSet(sql, (sw.curPage - 1) * sw.pageSize, sw.pageSize, "a"); return(ds.Tables[0]); }