예제 #1
0
        internal ReturnData validateIssueingBook(bookIssuingDetails bookIssuingDetails)
        {
            ReturnData rd        = new ReturnData();
            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)
                    {
                        addBookIssuingDetails();
                    }
                    else
                    {
                        rd.message = "Check the BookCode.";
                    }
                }
                else
                {
                    rd.message = "Student Has borrowed 2 Books";
                }
            }
            else
            {
                rd.message = "Student ID is not Valid";
            }
            return(rd);
        }
예제 #2
0
        internal List <BookCodeDetails> getBookCodeDetailsFromBookID(string bookID)
        {
            BookCodeDetails        book = new BookCodeDetails();
            List <BookCodeDetails> list = new List <BookCodeDetails>();
            string     sql = "";
            SqlCommand cmd = new SqlCommand();

            sql = "select * from bookCodeDetails where bookID=@bookID and Borrowed=0";
            SqlConnection con = new SqlConnection(db_connection_string);

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

            while (rdr.Read())
            {
                BookCodeDetails c = new BookCodeDetails();
                c.bookCode = rdr["bookCode"].ToString();
                c.Active   = bool.Parse(rdr["Active"].ToString());
                list.Add(c);
            }
            con.Close();
            return(list);
        }
예제 #3
0
        internal List <BookCodeDetails> getBookCode()
        {
            SqlCommand cmd = new SqlCommand();

            List <BookCodeDetails> list = new List <BookCodeDetails>();

            SqlConnection con = new SqlConnection(db_connection_string);
            string        sql = "select * from bookCodeDetails where Borrowed='False'";

            cmd.CommandText = sql;
            cmd.Connection  = con;

            con.Open();
            SqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                BookCodeDetails s = new BookCodeDetails();
                s.bookCode = Convert.ToString(rdr["bookCode"]);
                list.Add(s);
            }
            con.Close();

            return(list);
        }
예제 #4
0
        public ReturnData addBookIssuingDetails()
        {
            ReturnData rd = new ReturnData();

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

            sql = "insert into bookIssuingDetails (bookCode,studentID,issueDate,returnDate) values (@bookID,@studentID,@issueDate,@returnDate) ";

            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@bookID", this.bookID);
            cmd.Parameters.AddWithValue("@studentID", this.studentID);
            cmd.Parameters.AddWithValue("@issueDate", this.issueDate);
            cmd.Parameters.AddWithValue("@returnDate", this.returnDate);

            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";
                BookCodeDetails bookCodeDetails = new BookCodeDetails();
                bookCodeDetails.updateBorrowedStatus(bookID);
                // rd.para1 = temp_invoice_id;
            }

            return(rd);
        }
예제 #5
0
        internal ReturnData extendTheBook(bookIssuingDetails bookIssuing)
        {
            ReturnData rd = new ReturnData();

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

            sql = "update bookIssuingDetails set returnDate=@returnDate where bookCode=@bookID";

            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@bookID", bookIssuing.bookID);
            cmd.Parameters.AddWithValue("@returnDate", getBookReturnDate());

            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";
                BookCodeDetails bookCodeDetails = new BookCodeDetails();
                bookCodeDetails.updateBorrowedStatus(bookID);
                // rd.para1 = temp_invoice_id;
            }

            return(rd);
        }
예제 #6
0
        public ReturnData addBookDetails()
        {
            ReturnData rd             = new ReturnData();
            string     isBookAvailabe = getBookIDFromISBNCode(isbnCode);

            if (isBookAvailabe == "")
            {
                SqlConnection con = new SqlConnection(db_connection_string);
                string        sql = "";

                sql = "insert into bookDetails (isbnCode,author,bookTitle,bookCategory,publisher,bookURL,bookImage,bookPDF,bookExternalURL,price,qty,bookDescription) values (@isbnCode,@author,@bookTitle,@bookCategory,@publisher,@bookURL,@bookImage,@bookPDF,@bookExternalURL,@price,@qty,@bookDescription) ";

                SqlCommand cmd = new SqlCommand(sql, con);
                //byte[] imageData = File.ReadAllBytes(this.imageofBook);
                cmd.Parameters.AddWithValue("@bookTitle", this.bookTitle);
                cmd.Parameters.AddWithValue("@isbnCode", this.isbnCode);
                cmd.Parameters.AddWithValue("@bookCategory", this.bookCategory);
                cmd.Parameters.AddWithValue("@author", this.author);
                cmd.Parameters.AddWithValue("@publisher", this.publisher);
                cmd.Parameters.AddWithValue("@price", this.price);
                cmd.Parameters.AddWithValue("@bookURL", this.bookURL);
                cmd.Parameters.AddWithValue("@bookImage", this.bookImage);
                cmd.Parameters.AddWithValue("@bookPDF", this.bookPDF);
                cmd.Parameters.AddWithValue("@bookExternalURL", this.bookExternalURL);
                cmd.Parameters.AddWithValue("@qty", this.qty);
                cmd.Parameters.AddWithValue("@bookDescription", this.bookDescription);

                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)
                {
                    string          bookID          = getBookIDFromISBNCode(isbnCode);
                    string          bookCode        = this.bookCategory.Substring(0, 4);
                    int             bookQty         = int.Parse(this.qty);
                    BookCodeDetails bookCodeDetails = new BookCodeDetails();
                    bookCodeDetails.addBookCode(bookID, bookCode, bookQty);
                    rd.status  = 1;
                    rd.message = "OK";
                    // rd.para1 = temp_invoice_id;
                }
            }
            else
            {
                string          bookID          = getBookIDFromISBNCode(isbnCode);
                string          bookCode        = this.bookCategory.Substring(0, 4);
                int             bookQty         = int.Parse(this.qty);
                BookCodeDetails bookCodeDetails = new BookCodeDetails();
                bookCodeDetails.addBookCode(bookID, bookCode, bookQty);
                rd.status  = 1;
                rd.message = "OK";
            }
            return(rd);
        }