/// <summary> /// Get the owner info /// </summary> private void GetOwnerInfo() { id = Convert.ToInt32(lstOwners.SelectedValue); string sql = $@"SELECT FirstName, COALESCE(MiddleName, '') AS MiddleName, LastName, DOB, DateOfRetirement, Retired FROM Owners WHERE OwnerID = {id};"; DataRow row = DatabaseHelper.GetDataRow(sql); txtFName.Text = row["FirstName"].ToString(); txtMName.Text = row["MiddleName"].ToString(); txtLName.Text = row["LastName"].ToString(); dtpDOB.Value = Convert.ToDateTime(row["DOB"]); UIMethods.PickDateTimePicker(dtpDateOfRetirement, row["DateOfRetirement"], false); chkRetired.Checked = Convert.ToBoolean(row["Retired"]); }
/// <summary> /// Load ownership record details /// </summary> private void LoadOwnershipDetails() { ownerID = Convert.ToInt32(cmbOwners.SelectedValue); originalDogID = Convert.ToInt32(lstOwnership.SelectedValue.ToString().Split(':')[1]); cmbDogs.SelectedValue = originalDogID; string sql = $@"SELECT Dogs.DogID AS ID, Dogs.[Name], StartOfOwnership, EndOfOwnership FROM DogOwnership LEFT JOIN Dogs ON Dogs.DogID = DogOwnership.DogID WHERE OwnerID = {ownerID} AND Dogs.DogID = {originalDogID} ORDER BY StartOfOwnership;"; DataRow dt = DatabaseHelper.GetDataRow(sql); UIMethods.PickDateTimePicker(dtpStartDate, dt["StartOfOwnership"]); UIMethods.PickDateTimePicker(dtpEndDate, dt["EndOfOwnership"], false); chkDoesEnd.Checked = dt["EndOfOwnership"] != DBNull.Value; }
/// <summary> /// Get the information on the selected dog /// </summary> private void GetDogDetails() { int id = Convert.ToInt32(lstDogs.SelectedValue); string sql = $"SELECT * FROM Dogs WHERE DogID = {id};"; DataRow row = DatabaseHelper.GetDataRow(sql); string name = row["Name"].ToString(); bool isMale = Convert.ToBoolean(row["Sex"]); double weight = Convert.ToDouble(row["Weight"]); double height = Convert.ToDouble(row["Height"]); DateTime dob = Convert.ToDateTime(row["DOB"]); UIMethods.PickDateTimePicker(dtpDateOfRetirement, row["DateOfRetirement"]); bool retired = Convert.ToBoolean(row["Retired"]); bool champion = Convert.ToBoolean(row["Champion"]); UIMethods.PickDateTimePicker(dtpChampionshipDate, row["DateOfChampionship"]); bool banned = Convert.ToBoolean(row["PermanentlyDisqualified"]); UIMethods.PickDateTimePicker(dtpDateBanned, row["DateOfDisqualification"]); int breedID = Convert.ToInt32(row["Breed"]); int ownerID = LoadFormData.GetCurrentOwnerOfDog(id); txtID.Text = id.ToString(); txtName.Text = name.ToString(); rdoMale.Checked = isMale; rdoFemale.Checked = !isMale; txtWeight.Text = weight.ToString("N1"); txtHeight.Text = height.ToString("N1"); dtpDateOfBirth.Value = dob; chkRetired.Checked = retired; chkChampion.Checked = champion; chkBanned.Checked = banned; cmbBreed.SelectedValue = breedID; cmbOwner.SelectedValue = ownerID; PopulateDogShows(); UIMethods.DisplayStatusMessage(((frmMDIParent)MdiParent).GetStatusLabel(), "Dog info loaded"); }
/// <summary> /// Get the information on the selected dog /// </summary> private void GetDogDetails() { int id = Convert.ToInt32(cmbDogToUpdate.SelectedValue); string sql = $"SELECT * FROM Dogs WHERE DogID = {id};"; DataRow row = DatabaseHelper.GetDataRow(sql); string name = row["Name"].ToString(); bool isMale = Convert.ToBoolean(row["Sex"]); decimal weight = Convert.ToDecimal(row["Weight"]); decimal height = Convert.ToDecimal(row["Height"]); DateTime dob = Convert.ToDateTime(row["DOB"]); UIMethods.PickDateTimePicker(dtpDateOfRetirement, row["DateOfRetirement"], false); bool retired = Convert.ToBoolean(row["Retired"]); bool champion = Convert.ToBoolean(row["Champion"]); UIMethods.PickDateTimePicker(dtpChampionshipDate, row["DateOfChampionship"], false); bool banned = Convert.ToBoolean(row["PermanentlyDisqualified"]); UIMethods.PickDateTimePicker(dtpDateBanned, row["DateOfDisqualification"], false); int breedID = Convert.ToInt32(row["Breed"]); txtName.Text = name.ToString(); rdoMale.Checked = isMale; rdoFemale.Checked = !isMale; nudWeight.Value = weight; nudHeight.Value = height; dtpDateOfBirth.Value = dob; chkRetired.Checked = retired; chkChampion.Checked = champion; chkBanned.Checked = banned; cmbBreed.SelectedValue = breedID; }
/// <summary> /// Load the info on the selected owner /// </summary> private void LoadOwnerDetails() { string sql = $@"SELECT FirstName, COALESCE(MiddleName, '') AS MiddleName, LastName, DOB, DateOfRetirement, Retired FROM Owners WHERE OwnerID = {currentID};"; DataRow row = DatabaseHelper.GetDataRow(sql); string fName = row["FirstName"].ToString(); string mName = row["MiddleName"].ToString(); string lName = row["LastName"].ToString(); DateTime dob = Convert.ToDateTime(row["DOB"]); UIMethods.PickDateTimePicker(dtDateOfRetirement, row["DateOfRetirement"]); bool retired = Convert.ToBoolean(row["Retired"]); txtFName.Text = fName; txtMName.Text = mName; txtLName.Text = lName; dtpDOB.Value = dob; chkRetired.Checked = retired; GetOwnership(); UIMethods.DisplayStatusMessage(((MDIParent)MdiParent).GetStatusLabel(), "Owner info loaded"); }