Pop child object up to global.
Add DOB picker to form Add some starter code to save/update and create a new child. Update should be done since it doesn't touch guardians.
This commit is contained in:
parent
e8b9d3f50e
commit
2e501e5133
@ -18,6 +18,7 @@ namespace GreatHomeChildcare
|
||||
|
||||
//Global instance of the SqliteDataAccess object.
|
||||
SqliteDataAccess SqliteDataAccess = new SqliteDataAccess();
|
||||
Child child;
|
||||
|
||||
enum Gender
|
||||
{
|
||||
@ -61,7 +62,7 @@ namespace GreatHomeChildcare
|
||||
*/
|
||||
private void LoadChild(int child_id_in)
|
||||
{
|
||||
Child child = SqliteDataAccess.GetChildByID(child_id_in);
|
||||
child = SqliteDataAccess.GetChildByID(child_id_in);
|
||||
Gender genderOut;
|
||||
|
||||
// sanity check, though it shouldn't be needed...
|
||||
@ -79,6 +80,7 @@ namespace GreatHomeChildcare
|
||||
Enum.TryParse<Gender>(child.gender, out genderOut);
|
||||
genderComboBox.SelectedItem = genderOut;
|
||||
|
||||
dOBMonthCalendar.SelectionStart = DateTime.Parse(child.DOB);
|
||||
addressTextBox.Text = child.address;
|
||||
photoPictureBox.Image = (child.photo != null) ? ImageWrangler.ByteArrayToImage(child.photo) : Properties.Resources.child;
|
||||
LoadGuardiansForChild(child);
|
||||
@ -130,6 +132,38 @@ namespace GreatHomeChildcare
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Save and close");
|
||||
return;
|
||||
|
||||
//collect form and save to child object.
|
||||
child.id = (int)idNumericUpDown.Value;
|
||||
child.address = addressTextBox.Text;
|
||||
child.DOB = dOBMonthCalendar.SelectionStart.ToShortDateString();
|
||||
child.FirstName = firstNameTextBox.Text;
|
||||
child.gender = genderComboBox.Text;
|
||||
child.LastName = lastNameTextBox.Text;
|
||||
child.race = raceTextBox.Text;
|
||||
|
||||
if (photoPictureBox.Tag.ToString() == DEFAULT_PIC_TAG)
|
||||
child.photo = null;
|
||||
else
|
||||
child.photo = ImageWrangler.ImageToByteArray(photoPictureBox.Image);
|
||||
|
||||
if(child.id > 0) //Should be all that's needed.....
|
||||
{
|
||||
SqliteDataAccess.UpdateChild(child);
|
||||
MessageBox.Show("Child updated successfully! Data saved!");
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: write code to add child. >> bee-gee's "Stayin' alive" plays <<
|
||||
/* PB&J
|
||||
* Pop new window to add at least one guardian to the child, either existing or new.
|
||||
* Validate guardian exist in db upon return to this form.
|
||||
* if valid, then populate guardian table and update authorized_guardians
|
||||
* LAST THING: InsertNewStudent(child);
|
||||
*/
|
||||
}
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user