public void DataPatchProgram(string versionNo) { if (versionNo == "1.0.20") // patch Nationality, Country, Place Of Birth { // Patch Nationality DBFilter m_empPersonalInfoFilter = new DBFilter(); m_empPersonalInfoFilter.add(new NullTerm("NOT EmpNationality")); DataTable m_table = m_empPersonalInfoFilter.loadData(dbConn, "SELECT DISTINCT EmpNationality FROM EmpPersonalInfo"); string m_decodedString; foreach (DataRow m_row in m_table.Rows) { m_decodedString = AppUtils.Decode(EEmpPersonalInfo.db.getField("EmpNationality"), m_row[0].ToString().Trim()); if (m_decodedString != "") { ENationality m_nationality = new ENationality(); if (m_decodedString.Length > 20) { m_nationality.NationalityCode = m_decodedString.Substring(0, 20); } else { m_nationality.NationalityCode = m_decodedString; } if (m_decodedString.Length > 100) { m_nationality.NationalityDesc = m_decodedString.Substring(0, 100); } else { m_nationality.NationalityDesc = m_decodedString; } ENationality.db.insert(dbConn, m_nationality); } } // patch Country Code m_empPersonalInfoFilter.add(new NullTerm("NOT EmpPassportIssuedCountry")); m_table = m_empPersonalInfoFilter.loadData(dbConn, "SELECT DISTINCT EmpPassportIssuedCountry FROM EmpPersonalInfo"); foreach (DataRow m_row in m_table.Rows) { m_decodedString = AppUtils.Decode(EEmpPersonalInfo.db.getField("EmpPassportIssuedCountry"), m_row[0].ToString().Trim()); if (m_decodedString != "") { EIssueCountry m_country = new EIssueCountry(); if (m_decodedString.Length > 20) { m_country.CountryCode = m_decodedString.Substring(0, 20); } else { m_country.CountryCode = m_decodedString; } if (m_decodedString.Length > 100) { m_country.CountryDesc = m_decodedString.Substring(0, 100); } else { m_country.CountryDesc = m_decodedString; } EIssueCountry.db.insert(dbConn, m_country); } } // patch Place of Birth m_empPersonalInfoFilter.add(new NullTerm("NOT EmpPlaceOfBirth")); m_table = m_empPersonalInfoFilter.loadData(dbConn, "SELECT DISTINCT EmpPlaceOfBirth FROM EmpPersonalInfo"); foreach (DataRow m_row in m_table.Rows) { m_decodedString = AppUtils.Decode(EEmpPersonalInfo.db.getField("EmpPlaceOfBirth"), m_row[0].ToString().Trim()); if (m_decodedString != "") { EPlaceOfBirth m_placeOfBirth = new EPlaceOfBirth(); if (m_decodedString.Length > 20) { m_placeOfBirth.PlaceOfBirthCode = m_decodedString.Substring(0, 20); } else { m_placeOfBirth.PlaceOfBirthCode = m_decodedString; } if (m_decodedString.Length > 100) { m_placeOfBirth.PlaceOfBirthDesc = m_decodedString.Substring(0, 100); } else { m_placeOfBirth.PlaceOfBirthDesc = m_decodedString; } EPlaceOfBirth.db.insert(dbConn, m_placeOfBirth); } } // patch EmpPersonalInfo foreach (EEmpPersonalInfo m_info in EEmpPersonalInfo.db.select(dbConn, new DBFilter())) { bool m_update = false; if (!string.IsNullOrEmpty(m_info.EmpPlaceOfBirth)) { DBFilter m_filter = new DBFilter(); m_filter.add(new Match("PlaceOfBirthCode", m_info.EmpPlaceOfBirth)); ArrayList m_list = EPlaceOfBirth.db.select(dbConn, m_filter); if (m_list.Count > 0) { m_info.EmpPlaceOfBirthID = ((EPlaceOfBirth)m_list[0]).PlaceOfBirthID; } m_update = true; } if (!string.IsNullOrEmpty(m_info.EmpPassportIssuedCountry)) { DBFilter m_filter = new DBFilter(); m_filter.add(new Match("CountryCode", m_info.EmpPassportIssuedCountry)); ArrayList m_list = EIssueCountry.db.select(dbConn, m_filter); if (m_list.Count > 0) { m_info.EmpPassportIssuedCountryID = ((EIssueCountry)m_list[0]).CountryID; } } if (!string.IsNullOrEmpty(m_info.EmpNationality)) { DBFilter m_filter = new DBFilter(); m_filter.add(new Match("NationalityCode", m_info.EmpNationality)); ArrayList m_list = ENationality.db.select(dbConn, m_filter); if (m_list.Count > 0) { m_info.EmpNationalityID = ((ENationality)m_list[0]).NationalityID; } } if (m_update == true) { EEmpPersonalInfo.db.update(dbConn, m_info); } } } }