public Contract GetContractByID(int contractID) { using (var connection = new OleDbConnection(ConfigManagement.AccessConStr)) { string sqlText = string.Format(@"select ContractID, PeopleID, ContractrType, IsFirstContract, ContractNum, StartDate, EndDate, ProbationEndDate from {0} where ContractID=@ContractID", _ContractTableName); var paras = new OleDbParameter[1]; paras[0] = new OleDbParameter("ContractID", contractID); var reader = new OLESqlHelper().GetReader(sqlText, connection, paras); if (reader.Read()) { int i = 0; var contract = new Contract(); contract.ContractID = reader.GetInt32(i++); contract.PeopleID = reader.GetInt32(i++); contract.ContractrType = (int)reader.GetInt32(i++); contract.IsFirstContract = (bool)reader.GetBoolean(i++); contract.ContractNum = reader.GetString(i++); contract.StartDate = reader.IsDBNull(i) ? new Nullable<DateTime>() : reader.GetDateTime(i++); contract.EndDate = reader.IsDBNull(i) ? new Nullable<DateTime>() : reader.GetDateTime(i++); contract.ProbationEndDate = reader.IsDBNull(i) ? new Nullable<DateTime>() : reader.GetDateTime(i++); return contract; } else { return null; } } }
public PeopleBasicInfo GetPeopleBasicInfoByID(int peopleID) { using (var connection = new OleDbConnection(ConfigManagement.AccessConStr)) { string sqlText = string.Format(@"select PeopleID, PeopleName,Gender,DateOfBirth,Age,IDCardNum,IsMarried,PoliticalStatus, Nation,HouseholdRegisterAddress,HouseholdRegisterType,HouseholdRegisterPostCode,CurrentAddress,PhoneNum,CurrentAddressPostCode, EducationGrade,GraduationSchool,Profession,EmergencyContactPerson,EmergencyContactPersonPhone,EmergencyContactPersonRelation ,WorkerNum from {0} where PeopleID=@peopleID", _peopleTableName); var paras = new OleDbParameter[1]; paras[0] = new OleDbParameter("peopleID", peopleID); var reader = new OLESqlHelper().GetReader(sqlText, connection, paras); if (reader.Read()) { int i = 0; var people = new PeopleBasicInfo(); people.PeopleID = reader.GetInt32(i++); people.PeopleName = reader.GetString(i++); people.Gender = reader.GetString(i++); if (!reader.IsDBNull(i)) { people.DateOfBirth = reader.GetDateTime(i++); } else { i++; } people.Age = reader.GetInt32(i++); people.IDCardNum = reader.GetString(i++); people.IsMarried = reader.GetBoolean(i++); people.PoliticalStatus = reader.GetString(i++); people.Nation = reader.GetString(i++); people.HouseholdRegisterAddress = reader.GetString(i++); people.HouseholdRegisterType = reader.GetString(i++); people.HouseholdRegisterPostCode = reader.GetString(i++); people.CurrentAddress = reader.GetString(i++); people.PhoneNum = reader.GetString(i++); people.CurrentAddressPostCode = reader.GetString(i++); people.EducationGrade = reader.GetString(i++); people.GraduationSchool = reader.GetString(i++); people.Profession = reader.GetString(i++); people.EmergencyContactPerson = reader.GetString(i++); people.EmergencyContactPersonPhone = reader.GetString(i++); people.EmergencyContactPersonRelation = reader.GetString(i++); people.WorkerNum = reader.GetString(i++); return people; } else { return null; } } }
public PeopleBasicInfo GetPeopleWorkInfoByID(int peopleID) { using (var connection = new OleDbConnection(ConfigManagement.AccessConStr)) { string sqlText = string.Format(@"select PeopleID,JoinCompanyDate,LengthOfService,Department,Title,TitleState, LeftCompanyDate,LeftCompanyReason,SpecialSkill,WageCardNumber,WageCardAddress, IsCallInArchives,ArchivesNum,ArchiveCallInDate,ArchiveCallOutDate from {0} where PeopleID=@peopleID", _peopleTableName); var paras = new OleDbParameter[1]; paras[0] = new OleDbParameter("peopleID", peopleID); var reader = new OLESqlHelper().GetReader(sqlText, connection, paras); if (reader.Read()) { int i = 0; var people = new PeopleBasicInfo(); people.PeopleID = reader.GetInt32(i++); if (!reader.IsDBNull(i)) { people.JoinCompanyDate = reader.GetDateTime(i++); } else { i++; } people.LengthOfService = reader.GetFloat(i++); people.Department = reader.IsDBNull(i) ? "" : reader.GetString(i++); people.Title = reader.IsDBNull(i) ? "" : reader.GetString(i++); people.TitleState = reader.IsDBNull(i) ? "" : reader.GetString(i++); people.LeftCompanyDate = reader.IsDBNull(i) ? new Nullable<DateTime>() : reader.GetDateTime(i++); people.LeftCompanyReason = reader.IsDBNull(i) ? "" : reader.GetString(i++); people.SpecialSkill = reader.IsDBNull(i) ? "" : reader.GetString(i++); people.WageCardNumber = reader.IsDBNull(i) ? "" : reader.GetString(i++); people.WageCardAddress = reader.IsDBNull(i) ? "" : reader.GetString(i++); people.IsCallInArchives = reader.IsDBNull(i) ? false : reader.GetBoolean(i++); people.ArchivesNum = reader.IsDBNull(i) ? "" : reader.GetString(i++); people.ArchiveCallInDate = reader.IsDBNull(i) ? new Nullable<DateTime>() : reader.GetDateTime(i++); people.ArchiveCallOutDate = reader.IsDBNull(i) ? new Nullable<DateTime>() : reader.GetDateTime(i++); return people; } else { return null; } } }