示例#1
0
        /// <summary>
        /// registers the data in the per_details table
        /// </summary>
        /// <param name="details">object</param>
        /// <returns>object</returns>
        public static int RegisterDetails(PerDetails details)
        {
            SqlConnection connection = pchrDB.GetConnection();

            try
            {
                connection.Open();
                //insert string
                string insertStatement =
                    "INSERT INTO PER_DETAILS_TBL " +
                    "(PATIENT_ID, BLOOD_TYPE, ORGAN_DONOR, HIV_STATUS, HEIGHT_INCHES, WEIGHT_LBS) " +
                    "VALUES (@PatientID, @Type, @Donor, @Status, @Hight, @Weight) ";

                SqlCommand insertCommmand = new SqlCommand(insertStatement, connection);
                // adds data to the per_details table
                insertCommmand.Parameters.AddWithValue("@PatientID", details.IDNumber);
                insertCommmand.Parameters.AddWithValue("@Type", details.Type);
                insertCommmand.Parameters.AddWithValue("@Donor", Convert.ToBoolean(details.Donor));
                insertCommmand.Parameters.AddWithValue("@Status", Convert.ToInt32(details.Hiv));
                insertCommmand.Parameters.AddWithValue("@Hight", Convert.ToInt32(details.Hight));
                insertCommmand.Parameters.AddWithValue("@Weight", Convert.ToInt32(details.Weight));

                insertCommmand.ExecuteNonQuery();
                return(details.IDNumber);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }
示例#2
0
        /// <summary>
        /// updates the data in the per_details table
        /// </summary>
        /// <param name="oldDetails">old object</param>
        /// <param name="newDetails">new object</param>
        public static void UpdateDetails(PerDetails oldDetails,
                                         PerDetails newDetails)
        {
            SqlConnection connection = pchrDB.GetConnection();

            try
            {
                connection.Open();
                // update string
                string updateStatement =
                    "UPDATE PER_DETAILS_TBL SET " +
                    "BLOOD_TYPE = @NewType, " +
                    "ORGAN_DONOR = @NewDonor, " +
                    "HIV_STATUS = @NewStatus, " +
                    "HEIGHT_INCHES = @NewHeight, " +
                    "WEIGHT_LBS = @NewWeight " +
                    "WHERE PATIENT_ID = @oldPatientID " +
                    "AND BLOOD_TYPE = @oldType " +
                    "AND ORGAN_DONOR = @oldDonor " +
                    "AND HIV_STATUS = @oldStatus " +
                    "AND HEIGHT_INCHES = @oldHeight " +
                    "AND WEIGHT_LBS = @oldWeight ";

                SqlCommand updateCommand =
                    new SqlCommand(updateStatement, connection);
                // updates data in the per_details table
                updateCommand.Parameters.AddWithValue("@NewType",
                                                      newDetails.Type);
                updateCommand.Parameters.AddWithValue("@NewDonor",
                                                      newDetails.Donor);
                updateCommand.Parameters.AddWithValue("@NewStatus",
                                                      newDetails.Hiv);
                updateCommand.Parameters.AddWithValue("@NewHeight",
                                                      newDetails.Hight);
                updateCommand.Parameters.AddWithValue("@NewWeight",
                                                      newDetails.Weight);
                updateCommand.Parameters.AddWithValue("@oldPatientID",
                                                      oldDetails.IDNumber);
                updateCommand.Parameters.AddWithValue("@oldType",
                                                      oldDetails.Type);
                updateCommand.Parameters.AddWithValue("@oldDonor",
                                                      oldDetails.Donor);
                updateCommand.Parameters.AddWithValue("@oldStatus",
                                                      oldDetails.Hiv);
                updateCommand.Parameters.AddWithValue("@oldHeight",
                                                      oldDetails.Hight);
                updateCommand.Parameters.AddWithValue("@oldWeight",
                                                      oldDetails.Weight);

                updateCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }
示例#3
0
        /// <summary>
        /// gets the data in the per_details table
        /// </summary>
        /// <param name="idNumber">patient id</param>
        /// <returns></returns>
        public static PerDetails GetDetails(int idNumber)
        {
            SqlConnection connection = pchrDB.GetConnection();
            // select string
            string selectStatement
                = "SELECT PATIENT_ID, BLOOD_TYPE, ORGAN_DONOR, HIV_STATUS, HEIGHT_INCHES, WEIGHT_LBS "
                  + "FROM PER_DETAILS_TBL "
                  + "WHERE PATIENT_ID = @ID ";
            SqlCommand selectCommand =
                new SqlCommand(selectStatement, connection);

            selectCommand.Parameters.AddWithValue("@ID", idNumber);
            try
            {
                connection.Open();
                SqlDataReader custReader =
                    selectCommand.ExecuteReader(CommandBehavior.SingleRow);
                if (custReader.Read())
                {
                    PerDetails details = new PerDetails();
                    //reads data from the per_details table
                    details.IDNumber = Convert.ToInt32(custReader["PATIENT_ID"]);
                    details.Type     = custReader["BLOOD_TYPE"].ToString();
                    details.Donor    = custReader["ORGAN_DONOR"].ToString();
                    details.Hiv      = Convert.ToInt32(custReader["HIV_STATUS"]);
                    details.Hight    = Convert.ToInt32(custReader["HEIGHT_INCHES"]);
                    details.Weight   = Convert.ToInt32(custReader["WEIGHT_LBS"]);

                    return(details);
                }
                else
                {
                    return(null);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }
示例#4
0
        /// <summary>
        /// registers the information into the person,primary care, and per_details tables
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void registerButton_Click(object sender, EventArgs e)
        {
            Person person = new Person();

            //construct object and set its values equal to the text boxs
            if (Validator.IsPresent(userNameBox) == true)
            {
                person.UserName = userNameBox.Text;
            }
            else
            {
                Validator.Title = "Username";
            }
            if (Validator.IsPresent(passwordBox) == true)
            {
                person.Password = passwordBox.Text;
            }
            else
            {
                Validator.Title = "Password";
            }
            if (Validator.IsPresent(confirmBox) == true)
            {
                person.CnfrmPass = confirmBox.Text;
            }
            else
            {
                Validator.Title = "Confirmation";
            }
            if (Validator.IsPresent(idBox) == true)
            {
                if (Validator.IsInt32(idBox))
                {
                    person.IdNumber = Convert.ToInt32(idBox.Text);
                }
                else
                {
                    Validator.Title = "Identity Number";
                }
            }
            else
            {
                Validator.Title = "Identity Number";
            }

            if (Validator.IsPresent(initialsBox) == true)
            {
                person.Initials = initialsBox.Text;
            }
            else
            {
                Validator.Title = "Initials";
            }
            if (Validator.IsPresent(firstNameBox) == true)
            {
                person.LastName = firstNameBox.Text;
            }
            else
            {
                Validator.Title = "First Name";
            }
            if (Validator.IsPresent(lastNameBox) == true)
            {
                person.FirstName = lastNameBox.Text;
            }
            else
            {
                Validator.Title = "Last Name";
            }

            person.Date = dateTimePicker1.Text;

            if (Validator.IsComboPresent(titleComboBox) == true)
            {
                person.Title = titleComboBox.Text;
            }
            else
            {
                Validator.Title = "Title";
            }
            if (Validator.IsPresent(idBox) == true)
            {
                if (Validator.IsInt32(idBox))
                {
                    person.PrimaryID = Convert.ToInt32(primaryCareBox.Text);
                }
                else
                {
                    Validator.Title = "Primary CareID";
                }
            }
            else
            {
                Validator.Title = "Primary CareID";
            }

            if (maleButton.Checked == true)
            {
                person.Gender = "male";
            }
            else if (femaleButton.Checked == true)
            {
                person.Gender = "female";
            }
            //setting variables that arent yet manipulated by the user blank instead of null
            person.WorkPhone             = " ";
            person.Fax                   = " ";
            person.Email                 = " ";
            person.ContactName           = " ";
            person.ContactRelation       = " ";
            person.ContactAddress        = " ";
            person.ContactState          = " ";
            person.ContactCity           = " ";
            person.ContactZip            = " ";
            person.ContactPhone          = " ";
            person.ContactMobile         = " ";
            person.ContactWork           = " ";
            person.ContactFax            = " ";
            person.ContactEmail          = " ";
            person.CareProviderFirst     = " ";
            person.CareProviderLast      = " ";
            person.CareProviderMobile    = " ";
            person.CareProviderWork      = " ";
            person.CareProviderSpecialty = " ";

            //clears the list and then adds new info
            string path = System.Environment.GetFolderPath(
                System.Environment.SpecialFolder.Personal);
            string filename = Path.Combine(path, "Persons.xml");

            if (File.Exists(filename))
            {
                PersonDB.GetPersons().Clear();
                PersonDB.GetPersons();
                PersonDB.persons.Add(person);
            }
            else
            {
                PersonDB.persons.Add(person);
            }
            //PersonDB.GetPersons().Clear();
            //PersonDB.GetPersons();
            //PersonDB.persons.Add(person);



            if (person.Password != person.CnfrmPass)
            {
                MessageBox.Show("Passwords do not match");
            }

            else
            {
                PersonDB.SavePersons(PersonDB.persons);
            }



            //creats an object and sets its values so they are not null
            PerDetails details = new PerDetails();

            details.IDNumber = person.IdNumber;
            details.Type     = " ";
            details.Donor    = "false";
            details.Hiv      = 2;
            details.Hight    = 0;
            details.Weight   = 0;
            try
            {
                PersonDB.RegisterPerson(person);
                PerDetailsDB.RegisterDetails(details);
                PersonDB.RegisterCareProvider(person);
                Form newForm2 = new Form2();
                newForm2.Show();
                this.Close();
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Cannot insert duplicate key in object"))
                {
                    MessageBox.Show("That identification number is already in use, please choose another.");
                }
                else if (ex.Message.Contains("Cannot insert duplicate key in object 'dbo.PRIMARY_CARE_TBL'."))
                {
                    MessageBox.Show("That Primary care ID is already in use, please choose another.");
                }
            }
        }