コード例 #1
0
        public Models.Patient GetPatientInfo(string firstName, string lastName)
        {
            string sql = String.Format("SELECT * FROM Patients WHERE FirstName = '{0}' AND LastName = '{1}'",
                firstName, lastName);

            SqlCommand command = new SqlCommand(sql, conn);
            conn.Open();

            SqlDataReader reader;
            try
            {
                reader = command.ExecuteReader();
            }
            catch (Exception e)
            {
                conn.Close();
                throw new FaultException(e.Message);
            }

            if (reader.HasRows)
            {
                reader.Read();

                Patient result = new Patient()
                {
                    HealthInsuranceNo = reader.GetString(0),
                    FirstName = reader.GetString(1),
                    LastName = reader.GetString(2),
                    PhoneNumber = reader.GetInt32(3),
                    Address = reader.GetString(4),
                    Email = reader.GetString(5)
                };

                reader.Close();
                conn.Close();
                return result;
            }
            else
                reader.Close();
                conn.Close();
                return null;
        }
コード例 #2
0
        public bool PatientRegistration(string healthInsuranceNo, string firstName, string lastName, int phoneNumber, string address, string email)
        {
            Patient p = new Patient()
            {
                HealthInsuranceNo = healthInsuranceNo,
                FirstName = firstName,
                LastName = lastName,
                PhoneNumber = phoneNumber,
                Address = address,
                Email = email
            };

            string sql = String.Format("INSERT INTO Patients VALUES('{0}', '{1}', '{2}', {3}, '{4}', '{5}')",
                p.HealthInsuranceNo, p.FirstName, p.LastName, p.PhoneNumber, p.Address, p.Email);
            SqlCommand command = new SqlCommand(sql, conn);
            conn.Open();

            int num;
            try
            {
                num = command.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception e)
            {
                conn.Close();
                throw new FaultException(e.Message);
            }

            if (num > 0)
                return true;
            else
                return false;
        }
コード例 #3
0
        public Models.Patient GetPatientInfo(string firstName, string lastName)
        {
            PatientData pData = (from p in db.PatientDatas
                                 where p.FirstName == firstName
                                 && p.LastName == lastName
                                 select p).FirstOrDefault();

            if (pData == null)
            {
                return null;
            }

            Patient pModel = new Patient()
            {
                HealthInsuranceNo = pData.HealthInsuranceNo,
                FirstName = pData.FirstName,
                LastName = pData.LastName,
                PhoneNumber = pData.PhoneNumber,
                Address = pData.Address,
                Email = pData.Email
            };

            return pModel;
        }