Example #1
0
        public ReportsAndBackupForm()
        {
            InitializeComponent();
            DataGridViewInitializeWithdrawal();
            DataGridViewInitializeDepositedBlood();
            DataGridViewInitializeAvailableBlood();

            bloodBankDB = new SqlDataAccessLayer();

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

                DataSetName = "BloodBankDataSet",
            };

            // get the connection string from App.config

            string connectionString = bloodBankDB.GetConnectionString("BloodBankConnection");

            bloodBankDB.OpenConnection(connectionString);
            // Initialise the DataGridViews and DataSets

            //InitializeDataGridViewAndDataSet(dataGridViewBloodDeposited, bloodBankDataSet, "BloodDeposit");
            //InitializeDataGridViewAndDataSet(dataGridViewBloodWithdrawal, bloodBankDataSet, "BloodWithdrawals");
            //InitializeDataGridViewAndDataSet(dataGridViewAvailableBlood, bloodBankDataSet, "BloodTypes");
            List <BloodWithdrawal> withdrawals = Controller <BloodBankEntities, BloodWithdrawal> .SetBindingList().ToList();

            List <Donor> donors = Controller <BloodBankEntities, Donor> .SetBindingList().ToList();

            // add button event handlers for database backup to xml
            buttonbackup.Click += (s, e) => bloodBankDB.BackupDataSetToXML(bloodBankDataSet);
            // buttonRestoreDatabaseFromBackup.Click += (s, e) => registrationDB.RestoreDataSetFromBackup(registrationDataSet);

            //close connection
            this.FormClosing += (s, e) => bloodBankDB.CloseConnection();
        }