Esempio n. 1
0
        protected void studentSubmitBtn_Click(object sender, EventArgs e)
        {
            BusinessLayer.Student newStudent = new BusinessLayer.Student();
            newStudent.stId = Convert.ToInt32(this.studentId.Text);
            // newStudent.stId = Convert.ToInt32(this.studentId2.Value);
            newStudent.stFirstName = this.studentFirstName.Text;
            newStudent.stLastName  = this.studentLastName.Text;
            // newStudent.stBirthDate = this.studentBirthDate.Text;
            if (!String.IsNullOrEmpty(this.studentBirthDate2.Value))
            {
                newStudent.stBirthDate = this.studentBirthDate2.Value;
            }
            newStudent.stGender = this.studentGender.Text;
            newStudent.stClass  = this.studentClass.Text;

            string result = DataAccessLayer.Tools.InsertStudent(newStudent);

            if (result.Equals("1"))
            {
                UserMessage.Text = "Database Error.";
            }
            else if (result.Equals("0"))
            {
                UserMessage.Text = "Registration Successful, Thank You.";
                cleanupForm();
            }
        }
Esempio n. 2
0
        protected void BorrowBtn_Click(object sender, EventArgs e)
        {
            BusinessLayer.Student borrowingStudent = new BusinessLayer.Student();
            borrowingStudent.stId = Convert.ToInt32(this.StudentDropDown.Text);

            BusinessLayer.Book requestedBook = new BusinessLayer.Book();
            requestedBook.bkId = Convert.ToInt32(this.BookDropDown.Text);

            string result = DataAccessLayer.Tools.BorrowBook(borrowingStudent, requestedBook);

            if (result.Equals("1"))
            {
                UserMessage.Text = "Database Error.";
            }
            else if (result.Equals("0"))
            {
                UserMessage.Text = "Book Successfully Borrowed, Thank You.";
            }
            else if (result.Equals("MaxBooksLimitReached"))
            {
                UserMessage.Text = "This student has already borrowed 3 books.";
            }
            else if (result.Equals("BookNotAvailable"))
            {
                UserMessage.Text = "This book is not available at the moment.";
            }
        }
        protected void ReturnBtn_Click(object sender, EventArgs e)
        {
            BusinessLayer.Student returningStudent = new BusinessLayer.Student();
            returningStudent.stId = Convert.ToInt32(this.StudentDropDown.Text);

            BusinessLayer.Book returnedBook = new BusinessLayer.Book();
            if (this.StudentBookDropDown.Text == "")
            {
                UserMessage.Text = "Please select a Book to return";
                return;
            }
            returnedBook.bkId = Convert.ToInt32(this.StudentBookDropDown.Text);

            string result = DataAccessLayer.Tools.ReturnBook(returningStudent, returnedBook);

            if (result.Equals("1"))
            {
                UserMessage.Text = "Database Error.";
            }
            else if (result.Equals("0"))
            {
                UserMessage.Text = "Book Successfully Returned, Thank You.";
                this.StudentBookDropDown.Items.Remove(this.StudentBookDropDown.SelectedItem);
                // this.StudentDropDown.ClearSelection();
            }
        }
        protected void GetBookBtn_Click(object sender, EventArgs e)
        {
            BusinessLayer.Student returningStudent = new BusinessLayer.Student();
            returningStudent.stId = Convert.ToInt32(this.StudentDropDown.Text);

            DataSet   ds = DataAccessLayer.Tools.GetStudentBooks(returningStudent);
            DataTable dt = ds.Tables[0];

            this.StudentBookDropDown.DataSource     = dt;
            this.StudentBookDropDown.DataTextField  = dt.Columns[1].ToString();
            this.StudentBookDropDown.DataValueField = dt.Columns[0].ToString();
            this.StudentBookDropDown.DataBind();
        }