Пример #1
0
        public bool updatePatient(int upadatetype, int id, int newvalue)
        {
            DatePatients  patients = new DatePatients();
            StringBuilder sbQuery  = new StringBuilder();

            switch (upadatetype)
            {
            case 1:    //Ventilator, needs to also add or get one ventilator from the  inventory
                sbQuery.AppendFormat("UPDATE dbo.Patient SET using_ventilator = {0} Where id = {1};", newvalue, id);
                break;

            case 2:     //Treatment
                sbQuery.AppendFormat("UPDATE dbo.Patient SET condition_id={0} Where id = {1};", newvalue, id);
                break;

            case 3:     //Symptoms
                sbQuery.AppendFormat("UPDATE dbo.Patient SET history_number={0} Where id = {1};", newvalue, id);
                break;
            }

            SqlDataReader data = connectionBD(sbQuery.ToString());

            data.Close();

            return(true);
        }
Пример #2
0
        public static DatePatients GetPatient(int history)
        {
            DatePatients patients = new DatePatients();

            StringBuilder sbQuery = new StringBuilder();

            sbQuery.Append("SELECT p.history_number, s.full_name, g.value as patient_gender, c.value as patient_condition, p.using_ventilator");
            sbQuery.Append(" FROM dbo.patient p JOIN dbo.users s on (s.id=p.user_id) JOIN dbo.conditions c on (c.id=p.condition_id) JOIN dbo.gender g on (s.gender_id=g.id)");
            sbQuery.AppendFormat(" WHERE p.history_number = {0}", history);


            string cnnString = "Server=tcp:nursehack.database.windows.net,1433;Initial Catalog=nursehackdb;Persist Security Info=False;User ID=alerico;Password=Albus19878712;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";

            try
            {
                SqlConnection connection = new SqlConnection(cnnString);
                SqlCommand    command    = new SqlCommand(sbQuery.ToString(), connection);
                connection.Open();
                SqlDataReader data = command.ExecuteReader();
                while (data.Read())
                {
                    patients.history_number    = Convert.ToInt32(data["history_number"]);
                    patients.full_name         = data["full_name"].ToString();
                    patients.patient_condition = data["patient_condition"].ToString();
                    patients.patient_gender    = data["patient_gender"].ToString();
                    patients.using_ventilator  = data["using_ventilator"].ToString();
                }

                data.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }



            return(patients);
        }
Пример #3
0
        public DatePatients GetPatient(int history)
        {
            DatePatients  patients = new DatePatients();
            StringBuilder sbQuery  = new StringBuilder();

            sbQuery.Append("SELECT p.history_number, s.full_name, g.value as patient_gender, c.value as patient_condition, p.using_ventilator");
            sbQuery.Append(" FROM dbo.patient p JOIN dbo.users s on (s.id=p.user_id) JOIN dbo.conditions c on (c.id=p.condition_id) JOIN dbo.gender g on (s.gender_id=g.id)");
            sbQuery.AppendFormat(" WHERE p.history_number = {0}", history);

            SqlDataReader data = connectionBD(sbQuery.ToString());

            while (data.Read())
            {
                patients.history_number    = Convert.ToInt32(data["history_number"]);
                patients.full_name         = data["full_name"].ToString();
                patients.patient_condition = data["patient_condition"].ToString();
                patients.patient_gender    = data["patient_gender"].ToString();
                patients.using_ventilator  = data["using_ventilator"].ToString();
            }

            data.Close();

            return(patients);
        }