Ejemplo n.º 1
0
        private void openLectureBtn_Click(object sender, EventArgs e)
        {
            readerPdf rd = new readerPdf();

            try
            {
                MySqlDataAdapter ad;
                MySqlConnection  con = new MySqlConnection();
                con.ConnectionString = login.dbConnection;
                string       bookdetail = "select * from lecture where lecture_id = '" + lect_id + "'";
                MySqlCommand com        = new MySqlCommand(bookdetail, con);

                try
                {
                    con.Open();
                    if (Lcheck == true)
                    {
                        // MySqlDataReader reader;
                        ad = new MySqlDataAdapter(com);
                        // reader = com.ExecuteReader();
                        DataTable table = new DataTable();
                        ad.Fill(table);
                        try
                        {
                            byte[] book = (byte[])table.Rows[0][2];

                            //wrinting a Pdf File
                            using (Stream file = File.Create("C:/Users/" + currentComputerUserName + "/AppData/Roaming/UdoRead/Lectures/Lecture.pdf"))
                            {
                                file.Write(book, 0, book.Length);
                            }

                            //opening the pdf file
                            rd.axAcroPDF1.src = "C:/Users/" + currentComputerUserName + "/AppData/Roaming/UdoRead/Lectures/Lecture.pdf";
                            rd.Show();
                        }
                        catch
                        {
                        }

                        ad.Dispose();
                    }
                    else
                    {
                        MessageBox.Show("Please Select Lecture to View");
                    }
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                con.Close();
            }
            catch
            {
                MessageBox.Show("No book selected..!", "Alert", MessageBoxButtons.OK);
            }
        }
Ejemplo n.º 2
0
        private void viewBtn_Click(object sender, EventArgs e)
        {
            var       button = sender as BunifuFlatButton;
            readerPdf rd     = new readerPdf();


            MySqlConnection con = new MySqlConnection();

            con.ConnectionString = login.dbConnection;
            string          bookdetail = "select item from sentitems where item_id = '" + button.Name + "'";
            MySqlCommand    com        = new MySqlCommand(bookdetail, con);
            DataTable       table      = new DataTable();
            MySqlDataReader reader;

            try
            {
                con.Open();
                reader = com.ExecuteReader();
                table.Load(reader);
                reader.Close();

                byte[] book = (byte[])table.Rows[0][0];

                //wrinting a Pdf File C:/Users/"+currentComputerUserName+"/AppData/Roaming/UdoRead/Videos/
                using (Stream file = File.Create("C:/Users/" + computerUserName + "/AppData/Roaming/UdoRead/Books/book.pdf"))
                {
                    file.Write(book, 0, book.Length);
                }

                //opening the pdf file
                rd.axAcroPDF1.src = "C:/Users/" + computerUserName + "/AppData/Roaming/UdoRead/Books/book.pdf";
                rd.Show();
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            con.Close();
        }