예제 #1
0
        /*Precondition:
         Postcondition: Sets up and initialises everything needed */
        private void setup()
        {
            //Create DB and list to store stock in
            dbManager = new DatabaseManager();
            fileManager = new FileManager();
            allStock = new List<Stock>();
            currStock = null;

            //Setup datagridview column widths
            DataGridViewColumn column1 = dataGridView1.Columns[0];
            column1.Width = 50;
            DataGridViewColumn column2 = dataGridView1.Columns[1];
            column2.Width = 200;
            DataGridViewColumn column3 = dataGridView1.Columns[2];
            column3.Width = 300;
            DataGridViewColumn column4 = dataGridView1.Columns[3];
            column4.Width = 200;
            DataGridViewColumn column5 = dataGridView1.Columns[4];
            column5.Width = 60;
            DataGridViewColumn column6 = dataGridView1.Columns[5];
            column6.Width = 75;

            //Make the newstock table if it doesn't exist already
            dbManager.createNewStockTable();

            //Setup keypress handlers for when enter is pressed on textboxes
            boxSearchBookID.KeyPress += TextBox_KeyPress_Enter;
            boxSearchAuthor.KeyPress += TextBox_KeyPress_Enter;
            boxSearchTitle.KeyPress += TextBox_KeyPress_Enter;
            boxSearchSubject.KeyPress += TextBox_KeyPress_Enter;

            //Check to make sure storage location has been set for export files, if not then ask user to set it
            if (!fileManager.checkForStorageLocation())
            {
                FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
                folderBrowser.Description = "Select storage location";

                if (folderBrowser.ShowDialog() == DialogResult.OK)
                {
                    string path = folderBrowser.SelectedPath;

                    fileManager.setExportStorageLocationFile(folderBrowser.SelectedPath);
                }
            }

            //Give focus to bookID box
            boxSearchBookID.Select();
        }
예제 #2
0
        /*Precondition:
          Postcondition: Initializes everything needed and autofills date */
        private void setup()
        {
            dbManager = new DatabaseManager();
            newStockEntered = new List<Stock>();
            newStockAlreadyInDatabase = new List<bool>();
            tabPress = false;
            indexOfNewStock = 0;

            //Setup event handlers for when a texbox is entered
            boxQuantity.Enter += textbox_Enter;
            boxNote.Enter += textbox_Enter;
            boxAuthor.Enter += textbox_Enter;
            boxTitle.Enter += textbox_Enter;
            boxSubtitle.Enter += textbox_Enter;
            boxPublisher.Enter += textbox_Enter;
            boxComment.Enter += textbox_Enter;
            boxDescription.Enter += textbox_Enter;
            boxPrice.Enter += textbox_Enter;
            boxSubject.Enter += textbox_Enter;
            boxCatalogues.Enter += textbox_Enter;
            boxInitials.Enter += textbox_Enter;
            boxSales.Enter += textbox_Enter;
            boxBookID.Enter += textbox_Enter;
            boxDateEntered.Enter += textbox_Enter;

            //Give focus to author box
            boxAuthor.Select();

            //Get all of the stock that's in the newstock table
            newStockEntered = dbManager.getAllNewStock();

            //Check to see newstock wasn't 0
            if (newStockEntered.Count != 0)
            {
                //Set the index to the last entry
                indexOfNewStock = newStockEntered.Count - 1;

                //Get the last entry
                Stock currStock = newStockEntered[indexOfNewStock];

                //Load up last entry into textboxes
                loadStockIntoTextboxes(currStock);

                btnPrev.Enabled = true;

                //Track which entries came from the database already
                for (int i = 0; i < newStockEntered.Count; i++)
                {
                    newStockAlreadyInDatabase.Add(true);
                }
            }
        }