using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Collections.ObjectModel;
using SilverlightDataApp;
using System.Windows.Ria;
using System.Windows.Data;
using SilverlightDataApp.Web;

namespace SilverlightDataApp
{
	public partial class Registration : ChildWindow
	{
        //A new person is defined here.
        public RegTable newPerson;

        //SilverlightDataApp.Registered RegisteredUC = new SilverlightDataApp.Registered();

		public Registration()
		{
			// Required to initialize variables
			InitializeComponent();

            //New person's data is generated from the values which the database accepts.
            newPerson = new RegTable();
            //The current item of the DataForm is set to be a newPerson. 
            MyDataForm.CurrentItem = newPerson;
		}

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            //When the Submit button is clicked, the changes are saved locally
            this.MyDataForm.CommitItemEdit();
            //and the result is set to true, which is the caught in the MainPage, for the newPerson to get saved
            //to the database.
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            //If the Cancel button is clicked, the result is set to false, and the window is closed. 
            this.DialogResult = false;
        }    
	}
}