public MedicalCentreAdministrationForm()
        {
            InitializeComponent();
            // create new datatable access layer
            medicalCentreDB = new SqlDataTableAccessLayer();

            // create new dataset
            DataSet medicalCenterDataSet = new DataSet()
            {
                // must be name for backup purpose
                DataSetName = "MedicalCentreDataSet"
            };

            // title of the form
            Text = "Medical Centre: Administration Options";

            // set the connectionString from App.config
            string connectingString = medicalCentreDB.GetConnectionString("MedicalCentreManagementConnection");

            // open connection
            medicalCentreDB.OpenConnection(connectingString);

            // Register the event handler for database backup to xml
            buttonBackupDatabase.Click  += (s, e) => medicalCentreDB.BackupDataSetToXML(medicalCenterDataSet);
            buttonRestoreDatabase.Click += (s, e) => medicalCentreDB.RestoreDataSetFromBackup(medicalCenterDataSet);

            // Ensure that the connection to the db is closed
            this.FormClosing += (s, e) => medicalCentreDB.CloseConnection();
        }
예제 #2
0
        public StudentRegistrationAppForm()
        {
            InitializeComponent();

            // form display name

            Text = "Student Registration App";

            // get a new access layer and dataset

            registrationDB = new SqlDataTableAccessLayer();

            registrationDataSet = new DataSet()
            {
                // must be named for backup purposes

                DataSetName = "StudentRegistrationDataSet",
            };

            // YOUR CODE HERE
            // set the connectionString from App.config
            string connectingString = registrationDB.GetConnectionString("StudentRegistrationDB");

            registrationDB.OpenConnection(connectingString);

            // set the form title
            Text = "Student Registration App";

            // associate the datagridview controls with a database table
            // this also adds each table to the dataset

            // make sure Orders is added to database last or database restore will crash
            InitializeDataGridViewAndDataSet(dataGridViewDepartments, registrationDataSet, "Departments");
            InitializeDataGridViewAndDataSet(dataGridViewStudents, registrationDataSet, "Students");

            // DepartmentMajorCount is a view, do not add it to DataSet.Tables
            dataGridViewDepartmentMajorsCount.ReadOnly            = true;
            dataGridViewDepartmentMajorsCount.AllowUserToAddRows  = false;
            dataGridViewDepartmentMajorsCount.RowHeadersVisible   = false;
            dataGridViewDepartmentMajorsCount.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            dataGridViewDepartmentMajorsCount.DataSource          = registrationDB.GetDataTable("DepartmentMajorCount");

            // Add button event hanlder for database backup to xml
            buttonBackupDatabase.Click            += (s, e) => registrationDB.BackupDataSetToXML(registrationDataSet);
            buttonRestoreDatabaseFromBackup.Click += (s, e) => registrationDB.RestoreDataSetFromBackup(registrationDataSet);

            // Ensure that the connection to the db is closed
            this.FormClosing += (s, e) => registrationDB.CloseConnection();
        }
예제 #3
0
        public StudentRegistrationAppForm()
        {
            InitializeComponent();

            // form display name

            Text = "Student Registration App";

            // get a new access layer and dataset

            registrationDB = new SqlDataTableAccessLayer();

            registrationDataSet = new DataSet()
            {
                // must be named for backup purposes

                DataSetName = "StudentRegistrationDataSet",
            };

            //get the connection string from App.config and openconnection
            string connectionString = registrationDB.GetConnectionString("StudentRegistrationDB");

            registrationDB.OpenConnection(connectionString);

            InitializeDataGridViewAndDataSet(dataGridViewDepartments, registrationDataSet, "Departments");
            InitializeDataGridViewAndDataSet(dataGridViewStudents, registrationDataSet, "Students");

            //DepartmentMajorsCount is a view
            dataGridViewDepartmentMajorsCount.DataSource          = registrationDB.GetDataTable("DepartmentMajorsCount");
            dataGridViewDepartmentMajorsCount.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            dataGridViewDepartmentMajorsCount.ReadOnly            = true;
            dataGridViewDepartmentMajorsCount.AllowUserToAddRows  = false; //user unable to edit or add rows
            dataGridViewDepartmentMajorsCount.RowHeadersVisible   = false;

            //event handlers to backup and restore the database using DAL methods
            buttonBackupDatabase.Click            += (s, e) => registrationDB.BackupDataSetToXML(registrationDataSet);
            buttonRestoreDatabaseFromBackup.Click += (s, e) => registrationDB.RestoreDataSetFromBackup(registrationDataSet);


            this.FormClosing += (s, e) => registrationDB.CloseConnection();
        }
        public BackUpForm()
        {
            InitializeComponent();


            beautySalonDB = new SqlDataTableAccessLayer();

            beautySalonDataset = new DataSet()
            {
                DataSetName = "BeautySalonDataSet",
            };

            //get the connection
            string connectionString = beautySalonDB.GetConnectionString("BeautySalonConnection");

            beautySalonDB.OpenConnection(connectionString);

            // Load gridviews
            this.Load += BackUpForm_Load;

            buttonBackup.Click += (s, e) => beautySalonDB.BackupDataSetToXML(beautySalonDataset);

            this.FormClosing += (s, e) => beautySalonDB.CloseConnection();
        }