Exemplo n.º 1
0
 /// <summary>
 /// A constructor, creates an object of the
 /// BookLenderForm class, and initiates it's instance
 /// variables with argument values. It has
 /// two parameters. The controls in the GUI is initiated.
 /// </summary>
 /// <param name="titleText">titleText as a string</param>
 /// <param name="savedBookLender">savedBookLender as a BookLender object</param>
 public BookLenderForm(string titleText, BookLender savedBookLender)
 {
     InitializeComponent();
     bookLender = savedBookLender;
     InitializeGUI(titleText);
     // The GUI is filled with data from saved BookLender object
     FillSavedDataToGUI(savedBookLender);
 }
Exemplo n.º 2
0
 /// <summary>
 /// The method fills all the textboxes in the GUI with data
 /// from a saved book lender object.
 /// </summary>
 /// <param name="savedBookLender">savedBookLender as a BookLender object</param>
 private void FillSavedDataToGUI(BookLender savedBookLender)
 {
     // Is the book lender object not null ?
     if (savedBookLender != null)
     {
         tbx_FirstName.Text      = savedBookLender.FirstName;
         tbx_LastName.Text       = savedBookLender.LastName;
         tbx_MobilePhoneNbr.Text = savedBookLender.MyPhone.MobilePhoneNbr;
         tbx_HomePhoneNbr.Text   = savedBookLender.MyPhone.HomePhoneNbr;
         tbx_PrivateEmail.Text   = savedBookLender.MyEmail.PersonalEmail;
         tbx_WorkEmail.Text      = savedBookLender.MyEmail.WorkEmail;
         tbx_Street.Text         = savedBookLender.MyAddress.Street;
         tbx_ZipCode.Text        = savedBookLender.MyAddress.ZipCode;
         tbx_City.Text           = savedBookLender.MyAddress.City;
     }
 }
        /// <summary>
        /// This method changes book lender data in the instance variable
        /// bookLenderList at a specific index, If it's successful the
        /// method returns true, else false.
        /// </summary>
        /// <param name="index">An interger as index</param>
        /// <param name="newBookLender">newBookLender as a BookLender object</param>
        /// <returns>A boolean value</returns>
        public bool ChangeBookLender(int index, BookLender newBookLender)
        {
            bool changeOk = false;

            // Is object is not null and index within range of list?
            if (ValidateIndex(index) && (newBookLender != null))
            {
                // Deletes old object
                bookLenderList[index] = null;
                // Assigns changed object at index in list
                bookLenderList[index] = newBookLender;
                // Change successful
                changeOk = true;
            }
            // Returns true or false
            return(changeOk);
        }
        /// <summary>
        /// The method adds a bookLender to the instance variable
        /// bookLenderList. If the add is successful method
        ///  return true, else false.
        /// </summary>
        /// <param name="bookLender">bookLender as a BookLender object</param>
        /// <returns>A boolean value</returns>
        public bool AddBookLender(BookLender bookLender)
        {
            bool addOk = false;

            // Is the object not null?
            if (bookLender != null)
            {
                // The book lender gets an ID
                bookLender.LenderID = GetNewId;
                // The book lender is added to the list
                bookLenderList.Add(bookLender);
                // The add is successful
                addOk = true;
            }
            // Returns true or false
            return(addOk);
        }
Exemplo n.º 5
0
 /// <summary>
 /// A constructor, creates an object of the
 /// BookLenderForm class, and initiates it's instance
 /// variables with argument values. It has
 /// one parameter. The controls in the GUI is initiated.
 /// </summary>
 /// <param name="titleText">titleText as a string</param>
 public BookLenderForm(string titleText)
 {
     InitializeComponent();
     bookLender = new BookLender();
     InitializeGUI(titleText);
 }