Ejemplo n.º 1
0
        //Constructor
        public BookStoreClass()
        {
            Book         = new BookClass();
            EmployeeList = new EmployeeListClass();

            currentBookFile     = new currentFile(currentBookFilePath);
            updatedBookFile     = new UpdatedFile(updatedBookFilePath);
            currentEmployeeFile = new currentFile(currentEmployeeFilePath);
            updatedEmployeeFile = new UpdatedFile(updatedEmployeeFilePath);
        }
Ejemplo n.º 2
0
        //This method takes the data from the text file and formats the data to the proper types required.
        //It splits the data at the asterisk and reads all the lines and does checks to validate that the proper data is
        //being inserted as well as the proper lengths of the ISBN number.
        public bool createBookObject(string b)
        {
            BookClass thisBook = this;

            string[] bookString = b.Split('*');

            hiddenISBN   = bookString[0].Trim();
            hiddenTitle  = bookString[1].Trim();
            hiddenAuthor = bookString[2].Trim();

            for (int i = 0; i < bookString.Length; i++)
            {
                bookString[i] = bookString[i].Trim();
            }

            //Checks to make sure the value inserted into the isbn text boxes is equal to the required length of the ISBN
            if (hiddenISBN.Length != Globals.BookStore.getFullISBNLength)
            {
                MessageBox.Show(bookString[0] + ": the ISBN number is not 6 digits.", "ERROR");
                return(false);
            }

            //Checks to make sure the title is not empty
            if (hiddenTitle == "")
            {
                MessageBox.Show(bookString[1] + ": there is no title for this book.");
                return(false);
            }

            //Checks to make sure the author is not empty
            if (hiddenAuthor == "")
            {
                MessageBox.Show(bookString[2] + ": there is no author for this book.");
            }

            //Converts the price to a decimal and gets rid of the dollar sign and any commas
            try
            {
                hiddenPrice = Convert.ToDecimal(bookString[3].Replace("$", "").Replace(",", ""));
            }
            catch
            {
                MessageBox.Show("Could not convert the price to a decimal", "ERROR");
                return(false);
            }

            //Converts the on hand number to an integer
            try
            {
                hiddenNumOnHand = Convert.ToInt32(bookString[4]);
            }
            catch
            {
                MessageBox.Show("Could not convert " + bookString[4] + " to an integer", "ERROR");
                return(false);
            }

            //Parses the date
            try
            {
                hiddenLastTransaction = DateTime.Parse(bookString[5]);
            }
            catch
            {
                MessageBox.Show("The date accessed is not in a valid date form.", "ERROR");
                return(false);
            }

            return(true);
        }