Beispiel #1
0
        internal static void AddBook(string bookTitle, string pdfLocation, int categoryID,
                                     string publishDate, int pagesCount, int publisherID, string ISBN, string description, byte[] coverImage, object pdfDocument)
        {
            open();
            string     proceduer = "sp_AddBook";
            SqlCommand cmd       = new SqlCommand(proceduer, conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@title", bookTitle);
            cmd.Parameters.AddWithValue("@categoryID", categoryID);
            cmd.Parameters.AddWithValue("@publishDate", publishDate);
            cmd.Parameters.AddWithValue("@publisherID", publisherID);
            cmd.Parameters.AddWithValue("@pagesCount", pagesCount);
            cmd.Parameters.AddWithValue("@description", description);
            cmd.Parameters.AddWithValue("@location", pdfLocation);
            cmd.Parameters.AddWithValue("@isbn", ISBN);
            cmd.Parameters.AddWithValue("@coverPic", coverImage);
            cmd.ExecuteNonQuery();
            int bookID = GetLastBook("");

            PDFTools.InsertBookPages(bookID, pdfLocation, pagesCount);
            close();
        }
Beispiel #2
0
        private void FillPDFInfo()
        {
            document = PdfDocument.Load(pdfLocation);
            var          image = document.Render(0, 400, 400, true);
            MemoryStream ms    = new MemoryStream();

            image.Save(ms, ImageFormat.Jpeg);
            coverImage = ms.ToArray();

            string[] values = pdfLocation.Split('\\');
            string   title  = values[values.Length - 1];

            Dispatcher.Invoke(new Action(() =>
            {
                string isbn            = PDFTools.GetISBN(locationTB.Text);
                pagesCountTB.Text      = PDFTools.GetPagesCount(pdfLocation) + "";
                coverPicIE.Source      = LoadImage(coverImage);
                titleTB.Text           = title.TrimEnd(".pdf".ToCharArray());
                textBoxISBN.Text       = isbn;
                progressBar.Visibility = Visibility.Hidden;
                progressbarLBL.Content = "Done getting info.";
            }));
        }