Example #1
0
 public void addBTN_Click(object sender, RoutedEventArgs e)
 {
     byte[] image = null;
     if (!string.IsNullOrWhiteSpace(nameTB.Text))
     {
         if (PicIE.Source != null)
         {
             string path = (PicIE.Source as BitmapImage).UriSource.OriginalString;
             image = Getimage(path);
         }
         else
         {
             Bitmap       bmap   = Properties.Resources.personIcon;
             MemoryStream stream = new MemoryStream();
             bmap.Save(stream, bmap.RawFormat);
             image = stream.ToArray();
         }
         DataBaseTools.AddPublisher(nameTB.Text, addressTB.Text, contactTB.Text, image, detailsTB.Text);
         System.Windows.Forms.MessageBox.Show("Publisher added");
         Close();
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("Enter Publisher Name");
     }
 }
Example #2
0
 private void searchTB_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(searchTB.Text) && table != "Data" && column != null)
     {
         string query;
         if (column != "ID")
         {
             query = "Select * from " + table + " Where " + column + " like N'%" + searchTB.Text + "%'";
         }
         else
         {
             query = "Select * from " + table + " Where " + column + " = " + searchTB.Text + " ";
         }
         DataBaseTools.open();
         SqlCommand cmd = new SqlCommand(query, DataBaseTools.conn);
         cmd.ExecuteNonQuery();
         SqlDataAdapter a = new SqlDataAdapter(cmd);
         DataTable      t = new DataTable();
         a.Fill(t);
         searchGrid.ItemsSource = t;
         DataBaseTools.close();
         matchesTB.Text = searchGrid.VisibleRowCount + "";
     }
     else
     {
         matchesTB.Text         = "";
         searchGrid.ItemsSource = null;
         searchGrid.Columns.Clear();
     }
 }
Example #3
0
 public void addBookFunc(int bookID, string bookTitle, string pdfLocation, int categoryID, string date, int pagesCount, int publisherID, string ISBN, string description, byte[] coverImage, PdfDocument document)
 {
     DataBaseTools.AddBook(bookTitle, pdfLocation, categoryID, date, pagesCount, publisherID, ISBN, description, coverImage, document);
     foreach (var item in AuthorsLB.Items)
     {
         string   line   = item.ToString();
         string[] values = line.Split(' ');
         foreach (string value in values)
         {
             try
             {
                 int authorID = int.Parse(value);
                 DataBaseTools.AddBookAuthor(bookID, authorID);
             }
             catch (Exception)
             {
             }
         }
     }
     Dispatcher.Invoke(new Action(() =>
     {
         progressBar.Visibility = Visibility.Hidden;
         progressbarLBL.Content = "Done.";
         System.Windows.Forms.MessageBox.Show("Book " + titleTB.Text + " Added", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         Close();
     }));
 }
Example #4
0
        private void customItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            int       pageId   = (int)searchGrid.GetFocusedRowCellValue("Page Number");
            string    title    = (string)searchGrid.GetFocusedRowCellValue("Title");
            string    location = DataBaseTools.GetPdfLocation(title);
            PDFViewer p        = new PDFViewer(location, pageId, searchTB.Text);

            p.Show();
            //System.Windows.Forms.MessageBox.Show("Menu Clicked !");
        }
Example #5
0
 private void GridControl_SelectedItemChanged(object sender, DevExpress.Xpf.Grid.SelectedItemChangedEventArgs e)
 {
     BookID = (int)booksGrid.GetFocusedRowCellValue("ID");
     try
     {
         coverPicIE.Source = LoadImage(DataBaseTools.GetCoverPic(BookID));
     }
     catch
     {
     }
 }
Example #6
0
        public static void InsertBookPages(int bookID, string path)
        {
            DataBaseTools.conn.Open();
            PdfReader reader   = new PdfReader(path);
            string    pagetext = "";

            for (int i = 1; i <= reader.NumberOfPages; i++)
            {
                pagetext = PdfTextExtractor.GetTextFromPage(reader, i);
                DataBaseTools.InsertBookPage(bookID, pagetext);
            }
            DataBaseTools.conn.Close();
            MessageBox.Show("Book " + bookID + " added with pages", "info", MessageBoxButtons.OK);
        }
Example #7
0
 private void addBTN_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(nameTB.Text))
     {
         string catName = nameTB.Text;
         DataBaseTools.AddCategory(catName, descriptionTB.Text);
         System.Windows.Forms.MessageBox.Show("Category added");
         Close();
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("Enter Category Name");
     }
 }
Example #8
0
 public AddBook()
 {
     InitializeComponent();
     fillCategories();
     FillAuthors();
     FillPublishers();
     progressbarLBL.Visibility = Visibility.Hidden;
     progressBar.Visibility    = Visibility.Hidden;
     try{ DataBaseTools.conn.Open(); }
     catch (Exception) {}
     BookIDTB.Text = (DataBaseTools.GetLastBook("") + 1) + "";
     try { DataBaseTools.conn.Close(); }
     catch (Exception) { }
 }
Example #9
0
 private void saveBTN_Click(object sender, RoutedEventArgs e)
 {
     using (FolderBrowserDialog folderDialog = new FolderBrowserDialog())
     {
         if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             Dispatcher.Invoke(new Action(() =>
             {
                 byte[] book  = DataBaseTools.GetPDFFile(BookID);
                 string title = booksGrid.GetFocusedRowCellValue("Title").ToString();
                 File.WriteAllBytes(folderDialog.SelectedPath + "\\" + title + ".pdf", book);
             }));
         }
     }
 }
Example #10
0
        public static void InsertBookPages(int bookID, string path, int pagesCount)
        {
            string    pagetext          = "";
            string    picturesText      = "";
            PdfReader reader            = new PdfReader(path);
            RandomAccessFileOrArray raf = new RandomAccessFileOrArray(path);

            for (int pageID = 1; pageID <= pagesCount; pageID++)
            {
                pagetext     = ConvertArabic(PdfTextExtractor.GetTextFromPage(reader, pageID));
                picturesText = GetPictureText(pageID, reader, raf);
                DataBaseTools.InsertBookPage(bookID, pagetext, picturesText);
            }
            raf.Close();
            reader.Close();
        }
Example #11
0
        private void searchBTN_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string searchFor = searchTB.Text;
            string query     = @"select b.Title ,d.pageid [Page Number] , d.text [Text] 
                                from books b inner join Data d 
                                on b.ID = d.BookID
                                where d.Text like N'%" + searchFor + @"%'
                                union 
                                select b.Title ,pd.pageid [Page Number] , 'Image : ' + pd.text [Text] 
                                from books b inner join PicturesData pd
                                on b.ID = pd.BookID
                                where pd.text like N'%" + searchFor + "%' order by b.Title";

            DataBaseTools.open();
            ExecuteAndFill(query);
        }
Example #12
0
 private void ExecuteCommand(SqlCommand cmd)
 {
     cmd.ExecuteNonQuery();
     Dispatcher.Invoke(new Action(() =>
     {
         SqlDataAdapter a = new SqlDataAdapter(cmd);
         DataTable t      = new DataTable();
         a.Fill(t);
         searchGrid.ItemsSource = t;
         searchGrid.GroupBy("Title");
         searchGrid.GroupBy("Page Number");
         Dispatcher.Invoke(new Action(() => {
             searchGrid.FindRowByValue("Text", searchTB.Text);
         }));
         DataBaseTools.close();
         matchesTB.Text          = searchGrid.VisibleRowCount + "";
         progressbar1.Visibility = System.Windows.Visibility.Hidden;
     }));
 }
Example #13
0
 private void addtoList_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         int    authorID = (int)authorsCB.SelectedValue;
         string name     = DataBaseTools.GetAuthorName(authorID);
         foreach (var item in AuthorsLB.Items)
         {
             if (authorID + " " + name == (string)item)
             {
                 return;
             }
         }
         AuthorsLB.Items.Add(authorID + " " + name);
     }
     catch (Exception)
     {
     }
 }