Exemple #1
0
        static public TestPerson BuildPersonFromDataBaseData(string personId)
        {
            string mis = GetIDMIS(personId);

            if (personId != null)
            {
                using (SqlConnection connection = Global.GetSqlConnection())
                {
                    string     findPatient = "SELECT TOP(1) * FROM Person WHERE IdPerson = '" + personId + "'";
                    SqlCommand person      = new SqlCommand(findPatient, connection);
                    using (SqlDataReader personFromDataBase = person.ExecuteReader())
                    {
                        PersonWithIdentity p = new PersonWithIdentity();
                        while (personFromDataBase.Read())
                        {
                            if (personFromDataBase["BirthDate"].ToString() != "")
                            {
                                p.Birthdate = Convert.ToDateTime(personFromDataBase["BirthDate"]);
                            }
                            p.Sex = Convert.ToByte(personFromDataBase["IdSex"]);
                        }
                        p.IdPersonMis = mis;
                        TestPerson pers = new TestPerson(p);
                        pers.name      = TestHumanName.BuildHumanNameFromDataBaseData(personId);
                        pers.documents = TestIdentityDocument.BuildDocumentsFromDataBaseData(personId);
                        return(pers);
                    }
                }
            }
            return(null);
        }