public Model.RotaryInformationJoinModel GetModelById(string Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from RotaryInformationJoin "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.NVarChar, 50) }; parameters[0].Value = Id; Model.RotaryInformationJoinModel model = new Model.RotaryInformationJoinModel(); DataSet ds = db.RunDataSet(strSql.ToString(), parameters, "tbName"); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public List <Model.RotaryInformationJoinModel> GetPagedList(string training_base_code, string dept_code, string teachers_name, string name, string sex, string high_education, string identity_type, string send_unit, string collaborative_unit, string training_time, string plan_training_time, string rotary_begin_time, string rotary_end_time, string outdept_status, int start, int end) { string sql = "select * from (select row_number() over(order by TrainingTime desc,RotaryBeginTime asc) as num,* from RotaryInformationJoin where TrainingBaseCode='" + training_base_code + "' and DeptCode='" + dept_code + "' and TeachersName='" + teachers_name + "'"; if (!string.IsNullOrEmpty(name)) { sql += "and Name = '" + name + "'"; } if (!string.IsNullOrEmpty(sex)) { sql += "and Sex = '" + sex + "'"; } if (!string.IsNullOrEmpty(high_education)) { sql += "and HighEducation = '" + high_education + "'"; } if (!string.IsNullOrEmpty(identity_type)) { sql += "and IdentityType = '" + identity_type + "'"; } if (!string.IsNullOrEmpty(send_unit)) { sql += "and SendUnit like '%" + send_unit + "%'"; } if (!string.IsNullOrEmpty(collaborative_unit)) { sql += "and CollaborativeUnit like '%" + collaborative_unit + "%'"; } if (!string.IsNullOrEmpty(training_time)) { sql += "and TrainingTime like '%" + training_time + "%'"; } if (!string.IsNullOrEmpty(plan_training_time)) { sql += "and PlanTrainingTime like '%" + plan_training_time + "%'"; } if (!string.IsNullOrEmpty(rotary_begin_time)) { sql += "and RotaryBeginTime = '" + rotary_begin_time + "'"; } if (!string.IsNullOrEmpty(rotary_end_time)) { sql += "and RotaryEndTime = '" + rotary_end_time + "'"; } if (!string.IsNullOrEmpty(outdept_status)) { sql += "and OutdeptStatus = '" + outdept_status + "'"; } sql += ")as t where t.num>=@start and t.num<=@end"; SqlParameter[] pars = { new SqlParameter("@start", SqlDbType.Int), new SqlParameter("@end", SqlDbType.Int) }; pars[0].Value = start; pars[1].Value = end; DataTable dt = db.RunDataTable(sql, pars); List <RotaryInformationJoinModel> list = null; if (dt.Rows.Count > 0) { list = new List <RotaryInformationJoinModel>(); Model.RotaryInformationJoinModel model = null;//声明实体对象 foreach (DataRow dr in dt.Rows) { model = new RotaryInformationJoinModel(); model = DataRowToModel(dr); list.Add(model); } } return(list); }