public override bool Equals(Object obj) { TestAddress p = obj as TestAddress; if ((object)p == null) { return(false); } if (this.address == p.address) { return(true); } if ((this.address == null) || (p.address == null)) { return(false); } if ((this.address.Appartment == p.address.Appartment) && (this.address.Building == p.address.Building) && (this.address.City == p.address.City) && (this.address.GeoData == p.address.GeoData) && (this.address.IdAddressType == p.address.IdAddressType) && (this.address.PostalCode == p.address.PostalCode) && (this.address.Street == p.address.Street) && (this.address.StringAddress == p.address.StringAddress)) { return(true); } else { this.FindMismatch(p); Global.errors3.Add("несовпадение TestAddress"); return(false); } }
private void FindMismatch(TestAddress b) { if (this.address.Appartment != b.address.Appartment) { Global.errors3.Add("Несовпадение Appartment TestAddress"); } if (this.address.Building != b.address.Building) { Global.errors3.Add("Несовпадение Building TestAddress"); } if (this.address.City != b.address.City) { Global.errors3.Add("Несовпадение City TestAddress"); } if (this.address.GeoData != b.address.GeoData) { Global.errors3.Add("Несовпадение GeoData TestAddress"); } if (this.address.IdAddressType != b.address.IdAddressType) { Global.errors3.Add("Несовпадение IdAddressType TestAddress"); } if (this.address.PostalCode != b.address.PostalCode) { Global.errors3.Add("Несовпадение PostalCode TestAddress"); } if (this.address.Street != b.address.Street) { Global.errors3.Add("Несовпадение Street TestAddress"); } if (this.address.StringAddress != b.address.StringAddress) { Global.errors3.Add("Несовпадение StringAddress TestAddress"); } }
static public List <TestAddress> BuildAdressesFromDataBaseData(string idPerson) { List <TestAddress> addresses = new List <TestAddress>(); using (SqlConnection connection = Global.GetSqlConnection()) { foreach (int i in Enum.GetValues(typeof(AddressId))) { string findIdAdresses = "SELECT TOP(1) * FROM mm_Person2Address WHERE IdAddress = (SELECT MAX(IdAddress) FROM mm_Person2Address WHERE IdPerson = '" + idPerson + "' AND IdAddressType = '" + i + "')"; SqlCommand IdAddresses = new SqlCommand(findIdAdresses, connection); using (SqlDataReader addressesIdReader = IdAddresses.ExecuteReader()) { while (addressesIdReader.Read()) { string id = (Convert.ToString(addressesIdReader["IdAddress"])); using (SqlConnection connection2 = Global.GetSqlConnection()) { string findIdAdresses2 = "SELECT TOP(1) * FROM Address WHERE IdAddress = '" + id + "'"; SqlCommand IdAddresses2 = new SqlCommand(findIdAdresses2, connection2); using (SqlDataReader addressesReader = IdAddresses2.ExecuteReader()) { while (addressesReader.Read()) { AddressDto address = new AddressDto(); if (addressesIdReader["IdAddressType"].ToString() != "") { address.IdAddressType = Convert.ToByte(addressesIdReader["IdAddressType"]); } if (addressesReader["StringAddress"].ToString() != "") { address.StringAddress = Convert.ToString(addressesReader["StringAddress"]); } if (addressesReader["IdKladrCity"].ToString() != "") { address.City = Convert.ToString(addressesReader["IdKladrCity"]); } if (addressesReader["IdKladrStreet"].ToString() != "") { address.Street = Convert.ToString(addressesReader["IdKladrStreet"]); } if (addressesReader["Building"].ToString() != "") { address.Building = Convert.ToString(addressesReader["Building"]); } if (addressesReader["Appartment"].ToString() != "") { address.Appartment = Convert.ToString(addressesReader["Appartment"]); } if (addressesReader["PostalCode"].ToString() != "") { address.PostalCode = Convert.ToInt32(addressesReader["PostalCode"]); } if (addressesReader["GeoData"].ToString() != "") { address.GeoData = Convert.ToString(addressesReader["GeoData"]); } TestAddress a = new TestAddress(address); addresses.Add(a); } } } } } } } if (addresses.Count != 0) { return(addresses); } else { return(null); } }
public static List<TestAddress> BuildAdressesFromDataBaseData(string idPerson) { List<TestAddress> addresses = new List<TestAddress>(); using (SqlConnection connection = Global.GetSqlConnection()) { foreach (int i in Enum.GetValues(typeof(AddressId))) { string findIdAdresses = "SELECT TOP(1) * FROM mm_Person2Address WHERE IdAddress = (SELECT MAX(IdAddress) FROM mm_Person2Address WHERE IdPerson = '" + idPerson + "' AND IdAddressType = '" + i + "')"; SqlCommand IdAddresses = new SqlCommand(findIdAdresses, connection); using (SqlDataReader addressesIdReader = IdAddresses.ExecuteReader()) { while (addressesIdReader.Read()) { string id = (Convert.ToString(addressesIdReader["IdAddress"])); using (SqlConnection connection2 = Global.GetSqlConnection()) { string findIdAdresses2 = "SELECT TOP(1) * FROM Address WHERE IdAddress = '" + id + "'"; SqlCommand IdAddresses2 = new SqlCommand(findIdAdresses2, connection2); using (SqlDataReader addressesReader = IdAddresses2.ExecuteReader()) { while (addressesReader.Read()) { AddressDto address = new AddressDto(); if (addressesIdReader["IdAddressType"].ToString() != "") address.IdAddressType = Convert.ToByte(addressesIdReader["IdAddressType"]); if (addressesReader["StringAddress"].ToString() != "") address.StringAddress = Convert.ToString(addressesReader["StringAddress"]); if (addressesReader["IdKladrCity"].ToString() != "") address.City = Convert.ToString(addressesReader["IdKladrCity"]); if (addressesReader["IdKladrStreet"].ToString() != "") address.Street = Convert.ToString(addressesReader["IdKladrStreet"]); if (addressesReader["Building"].ToString() != "") address.Building = Convert.ToString(addressesReader["Building"]); if (addressesReader["Appartment"].ToString() != "") address.Appartment = Convert.ToString(addressesReader["Appartment"]); if (addressesReader["PostalCode"].ToString() != "") address.PostalCode = Convert.ToInt32(addressesReader["PostalCode"]); if (addressesReader["GeoData"].ToString() != "") address.GeoData = Convert.ToString(addressesReader["GeoData"]); TestAddress a = new TestAddress(address); addresses.Add(a); } } } } } } } if (addresses.Count != 0) return addresses; else return null; }
private void FindMismatch(TestAddress b) { if (this.address.Appartment != b.address.Appartment) Global.errors3.Add("Несовпадение Appartment TestAddress"); if (this.address.Building != b.address.Building) Global.errors3.Add("Несовпадение Building TestAddress"); if (this.address.City != b.address.City) Global.errors3.Add("Несовпадение City TestAddress"); if (this.address.GeoData != b.address.GeoData) Global.errors3.Add("Несовпадение GeoData TestAddress"); if (this.address.IdAddressType != b.address.IdAddressType) Global.errors3.Add("Несовпадение IdAddressType TestAddress"); if (this.address.PostalCode != b.address.PostalCode) Global.errors3.Add("Несовпадение PostalCode TestAddress"); if (this.address.Street != b.address.Street) Global.errors3.Add("Несовпадение Street TestAddress"); if (this.address.StringAddress != b.address.StringAddress) Global.errors3.Add("Несовпадение StringAddress TestAddress"); }
static public TestPatient BuildPatientFromDataBaseData(string guid = null, string idlpu = null, string mis = null, string patientId = null) { if (patientId == null) { patientId = GetPatientId(guid, idlpu, mis); } else { string[] s = GetGUIDandIDLPUandIDMIS(patientId); guid = s[0]; idlpu = s[1]; mis = s[2]; } if (patientId != null) { using (SqlConnection connection = Global.GetSqlConnection()) { string findPatient = "SELECT TOP(1) * FROM Person, PatientAdditionalInfo WHERE Person.IdPerson = '" + patientId + "' AND Person.IdPerson = PatientAdditionalInfo.IdPerson"; SqlCommand person = new SqlCommand(findPatient, connection); using (SqlDataReader patientFromDataBase = person.ExecuteReader()) { while (patientFromDataBase.Read()) { PatientDto p = new PatientDto(); if (patientFromDataBase["FamilyName"].ToString() != "") { p.FamilyName = Convert.ToString(patientFromDataBase["FamilyName"]); } else { p.FamilyName = null; } if (patientFromDataBase["MiddleName"].ToString() != "") { p.MiddleName = Convert.ToString(patientFromDataBase["MiddleName"]); } else { p.MiddleName = null; } if (patientFromDataBase["GivenName"].ToString() != "") { p.GivenName = Convert.ToString(patientFromDataBase["GivenName"]); } else { p.GivenName = null; } p.BirthDate = Convert.ToDateTime(patientFromDataBase["BirthDate"]); p.Sex = Convert.ToByte(patientFromDataBase["IdSex"]); p.IsVip = Convert.ToBoolean(patientFromDataBase["IsVip"]); if (patientFromDataBase["IdSocialStatus"].ToString() != "") { p.SocialStatus = Convert.ToString(patientFromDataBase["IdSocialStatus"]); } else { p.SocialStatus = null; } if (patientFromDataBase["IdSocialGroup"].ToString() != "") { p.SocialGroup = Convert.ToByte(patientFromDataBase["IdSocialGroup"]); } else { p.SocialGroup = null; } if (patientFromDataBase["IdLivingAreaType"].ToString() != "") { p.IdLivingAreaType = Convert.ToByte(patientFromDataBase["IdLivingAreaType"]); } else { p.IdLivingAreaType = null; } if (patientFromDataBase["IdBloodType"].ToString() != "") { p.IdBloodType = Convert.ToByte(patientFromDataBase["IdBloodType"]); } else { p.IdBloodType = null; } if (patientFromDataBase["DeathTime"].ToString() != "") { p.DeathTime = Convert.ToDateTime(patientFromDataBase["DeathTime"]); } else { p.DeathTime = null; } p.IdPatientMIS = mis; p.IdGlobal = patientId; TestPatient patient = new TestPatient(guid, idlpu, p); patient.documents = TestDocument.BuildDocumentsFromDataBaseData(patientId); patient.addreses = TestAddress.BuildAdressesFromDataBaseData(patientId); patient.contacts = TestContact.BuildContactsFromDataBaseData(patientId); patient.job = TestJob.BuildTestJobFromDataBase(patientId); patient.privilege = TestPrivilege.BuildTestPrivilegeFromDataBase(patientId); patient.birthplace = TestBirthplace.BuildBirthplaceFromDataBaseData(patientId); return(patient); } } } } return(null); }