예제 #1
0
        public byte[] Get(int SID, int bytes)
        {
            allergyController    aCon = new allergyController();
            conditionController  cCon = new conditionController();
            medicationController mCon = new medicationController();

            List <Models.allergy>    allergies   = aCon.Get(SID);
            List <Models.condition>  conditions  = cCon.Get(SID);
            List <Models.medication> medications = mCon.Get(SID);

            string output = "";

            byte[] toBytes = Encoding.ASCII.GetBytes((SID.ToString() + "/").Replace(" ", ""));
            byte[] temp    = toBytes;
            foreach (Models.allergy e in allergies)
            {
                output = e.type + "/";
                temp   = toBytes.Concat(Encoding.ASCII.GetBytes(output.Replace(" ", ""))).ToArray();
                if (temp.Length <= bytes)
                {
                    toBytes = temp;
                }
            }
            foreach (Models.condition e in conditions)
            {
                output = e.type + "/";
                temp   = toBytes.Concat(Encoding.ASCII.GetBytes(output.Replace(" ", ""))).ToArray();
                if (temp.Length <= bytes)
                {
                    toBytes = temp;
                }
            }
            foreach (Models.medication e in medications)
            {
                output = e.type + "/";
                temp   = toBytes.Concat(Encoding.ASCII.GetBytes(output.Replace(" ", ""))).ToArray();
                if (temp.Length <= bytes)
                {
                    toBytes = temp;
                }
            }


            return(toBytes);
        }
예제 #2
0
        public Models.soldierComplete Get(int SID, string val)
        {
            Models.soldierComplete output = new Models.soldierComplete();

            string        conn           = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
            SqlConnection sqlConnection1 = new SqlConnection(conn);
            SqlCommand    cmd            = new SqlCommand();
            SqlDataReader reader;

            cmd.CommandText = "SELECT * FROM soldiers WHERE SID = " + SID;
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = sqlConnection1;
            sqlConnection1.Open();

            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                output.SID        = SID;
                output.firstName  = (string)reader["FirstName"];
                output.lastName   = (string)reader["LastName"];
                output.bloodType  = (string)reader["BloodType"];
                output.height     = (int)reader["Height"];
                output.weight     = (int)reader["Weight"];
                output.birthday   = (DateTime)reader["Birthday"];
                output.lastVisit  = (DateTime)reader["LastVisit"];
                output.rank       = (string)reader["Rank"];
                output.supervisor = (string)reader["Supervisor"];
                output.contact    = (string)reader["Contact"];
                output.photoLink  = (string)reader["PhotoLink"];
            }
            output.allergies    = "";
            output.conditions   = "";
            output.vaccinations = "";
            output.medications  = "";

            allergyController     aCon = new allergyController();
            conditionController   cCon = new conditionController();
            medicationController  mCon = new medicationController();
            vaccinationController vCon = new vaccinationController();

            List <Models.allergy>     allergies    = aCon.Get(SID);
            List <Models.condition>   conditions   = cCon.Get(SID);
            List <Models.medication>  medications  = mCon.Get(SID);
            List <Models.vaccination> vaccinations = vCon.Get(SID);

            foreach (Models.allergy e in allergies)
            {
                output.allergies += e.type + ", ";
            }
            if (output.allergies != "")
            {
                output.allergies = output.allergies.Substring(0, output.allergies.Length - 2);
            }

            foreach (Models.condition e in conditions)
            {
                output.conditions += e.type + ", ";
            }
            if (output.conditions != "")
            {
                output.conditions = output.conditions.Substring(0, output.conditions.Length - 2);
            }

            foreach (Models.vaccination e in vaccinations)
            {
                output.vaccinations += e.type + ", ";
            }
            if (output.vaccinations != "")
            {
                output.vaccinations = output.vaccinations.Substring(0, output.vaccinations.Length - 2);
            }

            foreach (Models.medication e in medications)
            {
                output.medications += e.type + ", ";
            }
            if (output.medications != "")
            {
                output.medications = output.medications.Substring(0, output.medications.Length - 2);
            }



            sqlConnection1.Close();
            return(output);
        }