Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ContentTextDto ctext = new ContentTextDto();

            ctext.BookID      = Convert.ToInt64(cmbBook.SelectedValue.ToString());
            ctext.ChapterID   = Convert.ToInt64(cmbChapter.SelectedValue.ToString());
            ctext.Content     = rtxtContent.Text;
            ctext.CreatedBy   = MDIParent._UserMasterID;
            ctext.CreatedDate = DateTime.Now;
            ctext.ModifyedBy  = MDIParent._UserMasterID;
            ctext.ModifyDate  = DateTime.Now;
            ctext.Remarks     = rtxtRemarksForText.Text;

            if (ContentTextDao.Insert(ctext))
            {
                MessageBox.Show(Constant.NOTIFICATION_SUCCESS_DATA_SAVING, Constant.NOTIFICATION_CAPTION_SAVE, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                // ini();
            }
            else
            {
                MessageBox.Show(Constant.DBErrorMsg, Constant.NOTIFICATION_ERROR_DATA_SAVING, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }



            //under cn

            if (txtBrowesAudio.Text.Trim() != string.Empty)
            {
                ContentAudioDto caudio = new ContentAudioDto();
                caudio.BookID      = Convert.ToInt64(cmbBook.SelectedValue.ToString());
                caudio.ChapterID   = Convert.ToInt64(cmbChapter.SelectedValue.ToString());
                caudio.Content     = buffAudioData;
                caudio.CreatedBy   = MDIParent._UserMasterID;
                caudio.CreatedDate = DateTime.Now;
                caudio.ModifyedBy  = MDIParent._UserMasterID;
                caudio.ModifyDate  = DateTime.Now;
                ctext.Remarks      = rtxtRemarksForAudio.Text;
                if (ContentAudioDao.Insert(caudio))
                {
                    MessageBox.Show(Constant.NOTIFICATION_SUCCESS_DATA_SAVING, Constant.NOTIFICATION_CAPTION_SAVE, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    ini();
                }
                else
                {
                    MessageBox.Show(Constant.DBErrorMsg, Constant.NOTIFICATION_ERROR_DATA_SAVING, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            rtxtContent.Text         = string.Empty;
            cmbBook.SelectedIndex    = 0;
            cmbChapter.SelectedIndex = 0;
            tbcUpload.SelectedIndex  = 0;
        }
Exemplo n.º 2
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            if (filePath != string.Empty)
            {
                try
                {
                    PdfReader reder = new PdfReader(filePath);



                    for (int page = 1; page <= reder.NumberOfPages; page++)
                    {
                        ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.LocationTextExtractionStrategy();
                        string s = PdfTextExtractor.GetTextFromPage(reder, page, its);
                        s = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(s)));

                        ChapterDto chapter = new ChapterDto();
                        chapter.ChapterName = "Page " + page;
                        chapter.BookID      = Convert.ToInt64(cmbBook.SelectedValue.ToString());
                        chapter.CreatedBy   = MDIParent._UserMasterID;
                        chapter.CreatedDate = DateTime.Now;
                        chapter.ModifyDate  = DateTime.Now;
                        chapter.ModifyedBy  = MDIParent._UserMasterID;
                        chapter.Remarks     = rtxtDescreptio.Text.Trim();


                        ChapterDao.Insert(chapter);


                        ContentTextDto ctext = new ContentTextDto();
                        ctext.BookID      = Convert.ToInt64(cmbBook.SelectedValue.ToString());
                        ctext.ChapterID   = page;
                        ctext.Content     = s;
                        ctext.CreatedBy   = MDIParent._UserMasterID;
                        ctext.CreatedDate = DateTime.Now;
                        ctext.ModifyedBy  = MDIParent._UserMasterID;
                        ctext.ModifyDate  = DateTime.Now;
                        ctext.Remarks     = rtxtDescreptio.Text;
                        ContentTextDao.Insert(ctext);
                    }

                    MessageBox.Show(Constant.NOTIFICATION_SUCCESS_DATA_SAVING, Constant.NOTIFICATION_CAPTION_SAVE, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Constant.DBErrorMsg, Constant.NOTIFICATION_ERROR_DATA_SAVING, MessageBoxButtons.OK, MessageBoxIcon.Error);


                    MessageBox.Show(ex.Message);
                }
            }
        }