//constructor with parameters public Case( //string caseID, IndivAtRisk indiv, CareGiver careGiver, PersonOfInterest personOfInterest, SocialWorker socialWorker, CaseHistory caseHistory) { // caseID = _caseID; indiv = _indiv; careGiver = _careGiver; personOfInterest = _personOfInterest; socialWorker = _socialWorker; caseHistory = _caseHistory; }
//4)Once a case is chosen, this will load the data from the Persons table and data from the IndividualAtRisk table and loads it into the Care Giver tab on the //Case View form. public CareGiver RetrieveCareGiverData(int indivId) { var giver = new CareGiver(); sqlConnection1 = InitializeConnectionString(); using (sqlConnection1) { string data = "Select * from Persons, CareGiver, IndividualAtRisk where IndividualAtRisk.IndivId = '" + indivId + "' AND IndividualAtRisk.IndivId = CareGiver.IndivId AND Caregiver.PersonId = Persons.PersonId"; System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(data, sqlConnection1); sqlConnection1.Open(); using (SqlDataReader read = cmd.ExecuteReader()) { while (read.Read()) { giver.personId = read["PersonId"].ToString(); giver.lastName = read["Last_Name"].ToString(); giver.firstName = read["First_Name"].ToString(); giver.gender = read["Gender"].ToString(); giver.race = read["Race"].ToString(); giver.dob = read["DOB"].ToString(); giver.ssn = read["SSN"].ToString(); giver.milDependent = read["Military_Dependent"].ToString(); giver.churchConnection = read["Church_Connections"].ToString(); giver.streetAddress = read["Street_Address"].ToString(); giver.apartment = read["Apartment_Number"].ToString(); giver.city = read["City"].ToString(); giver.state = read["State"].ToString(); giver.zip = read["Zip_Code"].ToString(); giver.email = read["Email"].ToString(); giver.homePhone = read["Telephone_Home"].ToString(); giver.mobilePhone = read["Telephone_Mobile"].ToString(); giver.workPhone = read["Telephone_Work"].ToString(); giver.type = read["Person_Type"].ToString(); giver.relationship = read["Relationship"].ToString(); } } } sqlConnection1.Close(); return giver; }
//12)This will pull the individual id in the case so a care giver id can be created in the care giver table. public CareGiver CareIndivId() { var care = new CareGiver(); sqlConnection1 = InitializeConnectionString(); using (sqlConnection1) { string data = "Select IndivId, Last_Value(IndivId) Over (Partition By IndivId Order By IndivId) from IndividualAtRisk"; System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(data, sqlConnection1); sqlConnection1.Open(); using (SqlDataReader read = cmd.ExecuteReader()) { while (read.Read()) { care.indivId = read["IndivId"].ToString(); } } } sqlConnection1.Close(); return care; }