protected internal void BindData(Offender thisPerson) { PhoneNumbersRepeater.DataSource = thisPerson.PhoneNumbers; PhoneNumbersRepeater.DataBind(); AddressesRepeater.DataSource = thisPerson.Addresses; AddressesRepeater.DataBind(); GuardiansRepeater.DataSource = thisPerson.Guardians; GuardiansRepeater.DataBind(); CasesRepeater.DataSource = thisPerson.GetCases(); CasesRepeater.DataBind(); }
protected internal void LoadHeader(Offender thisPerson) { HeaderRelationship.Visible = false; HeaderPassword.Visible = false; HeaderUserType.Visible = false; HeaderOffenderNumber.Visible = true; PersonID.Text = thisPerson.PersonID.ToString(); FirstName.Text = thisPerson.FirstName.ToString(); LastName.Text = thisPerson.LastName.ToString(); DateOfBirth.Text = (thisPerson.DateOfBirth == default(DateTime) ? "" : thisPerson.DateOfBirth.ToString("MM/dd/yyyy")); Gender.Text = thisPerson.Gender.ToString(); Email.Text = thisPerson.Email.ToString(); Race.Text = thisPerson.Race.ToString(); OffenderNumber.Text = thisPerson.CourtID; MainContainer.Visible = true; GuardiansPanel.Visible = true; }
public static Offender Get(int personID) { string dsn = ConfigurationManager.ConnectionStrings["RJLouEntities"].ToString(); string sql = @" SELECT o.Person_ID, First_Name, Last_Name, Date_Of_Birth, Gender, Email, Race, Offender_Number FROM Offender o INNER JOIN Person p ON o.Person_ID = p.Person_ID WHERE o.Person_ID = @PersonID"; using (SqlConnection conn = new SqlConnection(dsn)) { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("PersonID", personID); SqlDataReader read = cmd.ExecuteReader(); if (read.Read()) { Offender result = new Offender() { PersonID = Convert.ToInt32(read["Person_ID"]), FirstName = read["First_Name"].ToString(), LastName = read["Last_Name"].ToString(), DateOfBirth = Convert.ToDateTime(read["Date_Of_Birth"]), Gender = read["Gender"].ToString(), Race = read["Race"].ToString(), Email = read["Email"].ToString(), CourtID = read["Offender_Number"].ToString() }; result.GetPhoneNumbers(); result.GetAddresses(); result.GetGuardians(); return result; } } return null; }
public static List<Offender> GetOffenders() { string dsn = ConfigurationManager.ConnectionStrings["RJLouEntities"].ToString(); string sql = @" SELECT o.Person_ID, First_Name, Last_Name, Date_Of_Birth, Gender, Email, Race, Offender_Number FROM Offender o INNER JOIN Person p ON o.Person_ID = p.Person_ID"; List<Offender> results = new List<Offender>(); using (SqlConnection conn = new SqlConnection(dsn)) { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.CommandType = CommandType.Text; SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { Offender newOffender = new Offender() { PersonID = Convert.ToInt32(read["Person_ID"]), FirstName = read["First_Name"].ToString(), LastName = read["Last_Name"].ToString(), DateOfBirth = Convert.ToDateTime(read["Date_Of_Birth"]), Gender = read["Gender"].ToString(), Race = read["Race"].ToString(), Email = read["Email"].ToString(), CourtID = read["Offender_Number"].ToString() }; newOffender.GetPhoneNumbers(); newOffender.GetAddresses(); newOffender.GetGuardians(); results.Add(newOffender); } } return results; }
internal void DeleteOffender(Offender offender) { string sql = @" DELETE FROM Case_File WHERE Case_ID = @CaseID AND Person_ID = @PersonID"; using (SqlConnection conn = new SqlConnection(Constants.DSN)) { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("CaseID", CaseID); cmd.Parameters.AddWithValue("PersonID", offender.PersonID); cmd.ExecuteNonQuery(); } }
internal void AddOffender(Offender offender) { string sql = @" INSERT INTO Case_File (Case_ID, Person_ID) VALUES (@CaseID, @PersonID)"; using (SqlConnection conn = new SqlConnection(Constants.DSN)) { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("CaseID", CaseID); cmd.Parameters.AddWithValue("PersonID", offender.PersonID); cmd.ExecuteNonQuery(); } }