Example #1
0
        private void Dashboard_Load(object sender, EventArgs e)
        {
            //Get the name from the logged in user and display it in the corner
            lblName.Text = "Welcome, " + CurrentUser.Name + "!";

            //List of strings (departments in database)
            List <String> departmentsList = new List <String>();
            //List of strings (genders in database)
            List <String> gendersList = new List <String>();
            //Create a new database object to search from
            LibraryDB formInfo = new LibraryDB();

            //Retrieve list of departments from the library DB
            departmentsList = formInfo.getDepartments();
            //Retrieve list of genders from the library DB
            gendersList = formInfo.getGenders();

            //Fill the combo box with the list of departments
            cmbDepartment.DataSource = departmentsList;
            cmbGender.DataSource     = gendersList;

            //Only way to make the date time picker empty
            dtpDOB.CustomFormat = " ";
            //Maximum date it today
            dtpDOB.MaxDate = DateTime.Now;

            //List of strings (departments in database)
            List <String> languagesList = new List <String>();
            //List of strings (genders in database)
            List <String> categoriesList = new List <String>();

            //Retrieve list of departments from the library DB
            languagesList = formInfo.getLanguages();
            //Retrieve list of genders from the library DB
            categoriesList = formInfo.getCategories();

            //Fill the combo box with the list of departments
            cmbLang.DataSource     = languagesList;
            cmbCategory.DataSource = categoriesList;

            //Empty the combo boxes to give user a blank slate to search on
            cmbLang.SelectedIndex       = -1;
            cmbCategory.SelectedIndex   = -1;
            cmbDepartment.SelectedIndex = -1;
            cmbGender.SelectedIndex     = -1;

            //Only way to make the date time picker empty
            dtpPubYear.CustomFormat = " ";
            //Maximum date it today
            dtpPubYear.MaxDate = DateTime.Now;

            if (CurrentUser.IsAdmin == "False")
            {
                tabDashboard.TabPages.Remove(tabAdmin);
            }
        }
Example #2
0
        /// <summary>
        /// Refresh the form information
        /// </summary>
        private void RefreshForm()
        {
            //Create a database object to get the list of departments
            LibraryDB     dbInfo       = new LibraryDB();
            List <String> categoryList = new List <String>();
            List <String> languageList = new List <String>();
            List <String> bindingList  = new List <String>();

            //To store the new student ID calculated by database
            String newBookID = "";

            //Get the new student ID
            newBookID = dbInfo.getNewID("Book");
            //Set the textbox to display new student ID (Can't be modified by user)
            txtISBN.Text = newBookID;

            //Put the list of categories into a list
            categoryList = dbInfo.getCategories();
            //Put the list of languages into a list
            languageList = dbInfo.getLanguages();
            //Put the list of binding names into a list
            bindingList = dbInfo.getBindings();

            //Set the depart ment combo box datasource as the department list
            cmbCategory.DataSource = categoryList;
            cmbLang.DataSource     = languageList;
            cmbBinding.DataSource  = bindingList;

            //Makes it so there is no selected date when the user loads the form
            dtpPubYear.CustomFormat = " ";

            //Clear the name data (for when the user wants to enter another student
            txtTitle.Text = "";


            //Makes it so there is no selected option starting off
            cmbLang.SelectedIndex     = -1;
            cmbCategory.SelectedIndex = -1;
            cmbBinding.SelectedIndex  = -1;
            //This one is selected to the first option
            cmbFloorNo.SelectedIndex = 0;

            //Sets it so the maximum date is today. Technically no one can be born today and enter into the database, but its ok
            dtpPubYear.MaxDate = DateTime.Now;
        }