private void ConvertToModel(IDataReader reader, Member_BaseInfo model) { if (reader["Id"] != DBNull.Value) model.Id = Convert.ToInt32(reader["Id"]); if (reader["AccountId"] != DBNull.Value) model.AccountId = Convert.ToInt32(reader["AccountId"]); if (reader["TeacherNo"] != DBNull.Value) model.TeacherNo = reader["TeacherNo"].ToString(); if (reader["GroupId"] != DBNull.Value) model.GroupId = Convert.ToInt32(reader["GroupId"]); if (reader["RealName"] != DBNull.Value) model.RealName = reader["RealName"].ToString(); if (reader["Mobile"] != DBNull.Value) model.Mobile = reader["Mobile"].ToString(); if (reader["Phone"] != DBNull.Value) model.Phone = reader["Phone"].ToString(); if (reader["Address"] != DBNull.Value) model.Address = reader["Address"].ToString(); if (reader["PostCode"] != DBNull.Value) model.PostCode = reader["PostCode"].ToString(); if (reader["CredentialsType"] != DBNull.Value) model.CredentialsType = Convert.ToInt32(reader["CredentialsType"]); if (reader["CredentialsNumber"] != DBNull.Value) model.CredentialsNumber = reader["CredentialsNumber"].ToString(); if (reader["Sex"] != DBNull.Value) model.Sex = Convert.ToInt32(reader["Sex"]); if (reader["Birthday"] != DBNull.Value) model.Birthday = Convert.ToDateTime(reader["Birthday"]); if (reader["Nation"] != DBNull.Value) model.Nation = Convert.ToInt32(reader["Nation"]); if (reader["PoliticalStatus"] != DBNull.Value) model.PoliticalStatus = Convert.ToInt32(reader["PoliticalStatus"]); if (reader["Delflag"] != DBNull.Value) model.Delflag = Convert.ToBoolean(reader["Delflag"]); if (reader["CreateDate"] != DBNull.Value) model.CreateDate = Convert.ToDateTime(reader["CreateDate"]); if (reader["RegionId"] != DBNull.Value) model.RegionId = Convert.ToInt32(reader["RegionId"]); if (reader["StudySection"] != DBNull.Value) model.StudySection = reader["StudySection"].ToString(); if (reader["Organid"] != DBNull.Value) model.Organid = Convert.ToInt32(reader["Organid"]); if (reader["Job"] != DBNull.Value) model.Job = Convert.ToInt32(reader["Job"]); if (reader["WorkRank"] != DBNull.Value) model.WorkRank = Convert.ToInt32(reader["WorkRank"]); if (reader["TeachDate"] != DBNull.Value) model.TeachDate = Convert.ToDateTime(reader["TeachDate"]); if (reader["TeachStudySection"] != DBNull.Value) model.TeachStudySection = reader["TeachStudySection"].ToString(); if (reader["TeachSubject"] != DBNull.Value) model.TeachSubject = reader["TeachSubject"].ToString(); if (reader["TeachGrade"] != DBNull.Value) model.TeachGrade = reader["TeachGrade"].ToString(); if (reader["TraningType"] != DBNull.Value) model.TraningType = Convert.ToInt32(reader["TraningType"]); if (reader["TraningObject"] != DBNull.Value) model.TraningObject = Convert.ToInt32(reader["TraningObject"]); if (reader["EduLevel"] != DBNull.Value) model.EduLevel = Convert.ToInt32(reader["EduLevel"]); if (reader["EduDegree"] != DBNull.Value) model.EduDegree = Convert.ToInt32(reader["EduDegree"]); if (reader["EduMajor"] != DBNull.Value) model.EduMajor = Convert.ToInt32(reader["EduMajor"]); if (reader["EduMajorOhter"] != DBNull.Value) model.EduMajorOhter = reader["EduMajorOhter"].ToString(); if (reader["GraduateSchool"] != DBNull.Value) model.GraduateSchool = reader["GraduateSchool"].ToString(); if (reader["GraduateTime"] != DBNull.Value) model.GraduateTime = Convert.ToDateTime(reader["GraduateTime"]); }
public Member_BaseInfo GetMemberInfoByAccountId(int accountId) { string sql = "select * from [dbo].[Member_BaseInfo] where [AccountId]=@AccountId and Delflag=0"; SqlParameter[] cmdParams = new SqlParameter[]{ new SqlParameter("@AccountId", SqlDbType.Int, 4) { Value = accountId } }; using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql, cmdParams)) { if (reader.Read()) { Member_BaseInfo model = new Member_BaseInfo(); ConvertToModel(reader, model); return model; } else { return null; } } }