Beispiel #1
0
        public frmReturnInfo(Book issueBook, int studentID)
        {
            InitializeComponent();

            isbn = issueBook.Isbn.ToString();

            txtStudentID.Text = studentID.ToString();

            //Displays todays date
            dtpActualDate.Value = DateTime.Now;
            //Custom format
            dtpActualDate.CustomFormat = "yyyy-MM-dd";

            //Set the isbn code textbox
            txtISBN.Text = isbn;

            LibraryDB dateAndBorrow = new LibraryDB();

            List <String> dateAndBorrowNum = new List <string>();

            dateAndBorrowNum = dateAndBorrow.getReturnDateAndBorrowNum(Int32.Parse(isbn), studentID);


            //If there was no record found
            if (dateAndBorrowNum.Count == 0)
            {
                //Tell the user that the student has not taken this book out
                MessageBox.Show("Student #" + studentID + " has not taken out this book", "Wrong Student ID", MessageBoxButtons.OK, MessageBoxIcon.Error);


                //Goes through all the open forms and finds dashboard to show it again
                for (int i = 0; i < Application.OpenForms.Count; i++)
                {
                    if (Application.OpenForms[i].Name == "frmReturnIssueReturn")
                    {
                        Application.OpenForms[i].Show();
                    }
                }

                DelayClose();
            }
            else
            {
                //Get the borrower num
                borrowerNum = dateAndBorrowNum[1].ToString();
                //Set the return date
                dtpReturnDate.Text = dateAndBorrowNum[0].ToString();
            }

            //Custom format
            dtpReturnDate.CustomFormat = "yyyy-MM-dd";
        }