private void ComTeachName_SelectedIndexChanged(object sender, EventArgs e) { var box = sender as ComboBox; if (box == null) { return; } teach = box.SelectedItem as T_Teach; }
/// <summary> /// 查询教师ID、教师名、教师性别、教师出身日期 /// </summary> /// <param name="curIndex"></param> /// <param name="dataLength"></param> /// <param name="teachID"></param> /// <param name="teacherName"></param> /// <returns></returns> public List <T_Teach> GetTeches(int curIndex, int dataLength, string teachID, string teacherName) { SqlHelper hel = new SqlHelper(); string t_sql = "Select_TeachsPagration"; SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@curIndex", SqlDbType.Int) { Value = curIndex }, new SqlParameter("@dataLength", SqlDbType.Int) { Value = dataLength }, new SqlParameter("@teacherID", SqlDbType.VarChar) { Value = "%" + teachID + "%" }, new SqlParameter("@teacherName", SqlDbType.VarChar) { Value = "%" + teacherName + "%" } }; List <T_Teach> teaches = null; using (SqlDataReader reader = hel.ExecuteReader(t_sql, CommandType.StoredProcedure, pars)) { if (reader.HasRows) { teaches = new List <T_Teach>(); while (reader.Read()) { T_Teach teach = new T_Teach(); teach.TeachID = reader.GetInt32(0); teach.TeachName = reader.GetString(1); teach._sex = reader.GetBoolean(2); teach.BirthDay = reader.GetDateTime(3).ToString("yyyy-MM-dd"); teaches.Add(teach); } } } return(teaches); }