Exemple #1
0
        internal List <bookReserveDetails> getBookReservedDetailsFromStudentID(string student_ID)
        {
            bookReserveDetails        bookReserveDetails = new bookReserveDetails();
            List <bookReserveDetails> list = new List <bookReserveDetails>();
            CommonFunctions           cf   = new CommonFunctions();

            student_ID = "%" + student_ID + "%";
            string     sql = "";
            SqlCommand cmd = new SqlCommand();

            sql = "select BRD.studentID, BRD.bookCode, BD.bookTitle, BRD.reservedDate, BRD.releseBeforeDate From bookReserveDetails BRD, bookCodeDetails BCD,bookDetails BD where BRD.bookCode=BCD.bookCode AND BCD.bookID=BD.bookID AND BRD.studentID Like @student_ID";
            SqlConnection con = new SqlConnection(db_connection_string);

            cmd.Parameters.AddWithValue("@student_ID", student_ID);
            cmd.CommandText = sql;
            cmd.Connection  = con;
            con.Open();
            SqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                bookReserveDetails c = new bookReserveDetails();
                c.bookCode               = rdr["bookCode"].ToString();
                c.bookTitle              = rdr["bookTitle"].ToString();
                c.reservedDate           = DateTime.Parse(rdr["reservedDate"].ToString());
                c.releseBeforeDate       = DateTime.Parse(rdr["releseBeforeDate"].ToString());
                c.reservedDateString     = String.Format("{0:yyyy - MM - dd}", c.reservedDate);
                c.releseBeforeDateString = String.Format("{0:yyyy - MM - dd}", c.releseBeforeDate);
                c.studentID              = rdr["studentID"].ToString();
                list.Add(c);
            }
            con.Close();
            return(list);
        }
Exemple #2
0
        internal ReturnData deleteReservedBook(bookReserveDetails bookReserveDetails)
        {
            ReturnData rd = new ReturnData();

            SqlConnection con = new SqlConnection(db_connection_string);
            string        sql = "";

            sql = "Delete from bookReserveDetails where bookCode=@bookCode AND studentID=@studentID";

            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@bookCode", bookReserveDetails.bookCode);
            cmd.Parameters.AddWithValue("@studentID", bookReserveDetails.studentID);
            int count = 0;

            con.Open();
            try
            {
                count = (int)cmd.ExecuteNonQuery();
            }
            catch (Exception Ex)
            {
                rd.status  = 0;
                rd.message = Ex.Message;
            }
            con.Close();

            if (count > 0)
            {
                rd.status  = 1;
                rd.message = "OK";
            }
            return(rd);
        }
Exemple #3
0
        internal ReturnData validateIssueingBook(bookIssuingDetails bookIssuingDetails)
        {
            ReturnData rd            = new ReturnData();
            ReturnData isBookIDValid = new BookCodeDetails().validateBookID(bookIssuingDetails.bookID);

            if (isBookIDValid.status == 1)
            {
                ReturnData isStudent = new studentDetails().validateStudentID(bookIssuingDetails.studentID);
                if (isStudent.status == 1)
                {
                    ReturnData isStudentEligibleToBorrowBook = studentBookRecodeCount(bookIssuingDetails.studentID);
                    if (isStudentEligibleToBorrowBook.status == 1)
                    {
                        ReturnData isBookAlreadyBorrowed = new BookCodeDetails().isBookAlreadyBorrowed(bookIssuingDetails.bookID);
                        if (isBookAlreadyBorrowed.status == 1)
                        {
                            ReturnData isBookNotReserved = new bookReserveDetails().isBookNotReserved(bookIssuingDetails.bookID);
                            if (isBookNotReserved.status == 1)
                            {
                                addBookIssuingDetails();
                                rd.message = "OK";
                            }
                            else
                            {
                                ReturnData isBookReservedByThisStudent = new bookReserveDetails().isBookReservedByThisStudent(bookIssuingDetails.studentID, bookIssuingDetails.bookID);
                                if (isBookReservedByThisStudent.status == 1)
                                {
                                    addBookIssuingDetails();
                                    rd.message = "OK";
                                }
                                else
                                {
                                    rd.message = "This Book Already Reserved";
                                }
                            }
                        }
                        else
                        {
                            rd.message = "Check the BookCode.";
                        }
                    }
                    else
                    {
                        rd.message = "Student Has borrowed 2 Books";
                    }
                }
                else
                {
                    rd.message = "Student ID is not Valid";
                }
            }
            else
            {
                rd.message = "Book ID is not Valid";
            }

            return(rd);
        }
Exemple #4
0
        internal ReturnData ReserveBook(bookReserveDetails bookReserveDetails)
        {
            ReturnData    rd  = new ReturnData();
            SqlConnection con = new SqlConnection(db_connection_string);
            string        sql = "";

            sql = "select bookCode from bookCodeDetails where bookID=@bookID and Borrowed='0' and Active='1' and reserved='0'";

            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@bookID", bookReserveDetails.bookID);
            con.Open();
            SqlDataReader rdr = cmd.ExecuteReader();

            if (rdr.HasRows)
            {
                rdr.Read();
                bookCode = rdr["bookCode"].ToString();
                rd       = checkCountOfBooksReserved(bookReserveDetails.studentID);
                if (rd.status > 0)
                {
                    rd = changeReserveStatus(bookCode);
                    if (rd.status > 0)
                    {
                        rd = insertReserveDetails(bookReserveDetails.bookCode, bookReserveDetails.studentID);
                    }
                }
            }
            else
            {
                rd.message = "No Book to Reserve";
                rd.status  = 0;
            }
            con.Close();
            return(rd);
        }