예제 #1
0
파일: PrescDrug.cs 프로젝트: Maxwell20/PIMS
 public PrescDrug()
 {
     drug = new PIMS.Controller.Drug();
 }
예제 #2
0
 public PrescDrug()
 {
     drug = new PIMS.Controller.Drug();
 }
예제 #3
0
        /* 
         *This function gets the max value of the key from the relevant tables
         *and sets the value of the above indexes to those values.
         */
        public static void initValues()
        {
            string staffList = "SELECT max(Cast(staffID as int)) from Staff";
            SqlCommand staffCmd = new SqlCommand(staffList, cnn);
            cnn.Open();
            try
            {
                staffIndex = (int)staffCmd.ExecuteScalar();
            }
            catch
            {
                staffIndex = 9999;
            }


            string drugList = " SELECT * from drugs";
            SqlCommand cmd = new SqlCommand(drugList, cnn);
            SqlDataReader datardr = cmd.ExecuteReader();

            while (datardr.Read())
            {
                PIMS.Controller.Drug d = new PIMS.Controller.Drug();
                d.name = datardr.GetValue(0).ToString();
                d.cost = (int)datardr.GetValue(1);
                PIMS.Program.drugs.Add(d);
            }
            datardr.Close();
            string locList = " SELECT * from location";
            cmd = new SqlCommand(locList, cnn);
            datardr = cmd.ExecuteReader();
            while (datardr.Read())
            {
                HospLocation loc = new HospLocation();
                loc.bedNum = Convert.ToInt32(datardr.GetValue(0).ToString());
                loc.unit = datardr.GetValue(1).ToString();
                loc.floor = Convert.ToInt32(datardr.GetValue(2).ToString());
                loc.roomNum = Convert.ToInt32(datardr.GetValue(3).ToString());
                loc.occupancy = (int)datardr.GetValue(4);

                PIMS.Program.locations.Add(loc);
                Console.WriteLine(loc.unit);
            }
            datardr.Close();
            ////try
            ////{

            string genericStr = "select max(idNum) from ";
            string statsStr = genericStr + "patientStats";
            cmd = new SqlCommand(statsStr, cnn);
            try
            {
                statsIndex = (int)cmd.ExecuteScalar();
            }
            catch (Exception ex)
            {
                statsIndex = 9999;
            }

            string idString = "Select max(patientID) from patient";
            cmd = new SqlCommand(idString, cnn);
            try
            {
                patientIndex = (int)cmd.ExecuteScalar();
            }
            catch (Exception ex)
            {
                patientIndex = 9999;
            }


            string billStr = genericStr + "charges";
            cmd = new SqlCommand(billStr, cnn);
            try
            {
                billIndex = (int)cmd.ExecuteScalar();
            }
            catch (Exception ex)
            {
                billIndex = 9999;
            }


            string drugStr = "Select max(drugID) from prescriptions";
            cmd = new SqlCommand(drugStr, cnn);
            try
            {
                drugIndex = (int)cmd.ExecuteScalar();
            }
            catch (Exception ex)
            {
                drugIndex = 9999;
            }

            string procStr = genericStr + "ScheduledProcedures";
            cmd = new SqlCommand(procStr, cnn);
            procIndex = (int)cmd.ExecuteScalar();
            try
            {
                procIndex = (int)cmd.ExecuteScalar();
            }
            catch (Exception ex)
            {
                procIndex = 9999;
            }

            // cnn.Close();
            // MessageBox.Show("statIndex= " + statsIndex + "\ndrugIndex = " + drugIndex + "\nprocIndex = " + procIndex + "\nbillIndex = " + billIndex + "\npatIndex = " + patientIndex);
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("Cannot connect to Database.\nPlease try again");
            //    System.Environment.Exit(0);
            //}
        }