// ------------------------------------------------------------------------------------- /// <summary> /// fill edit window controls /// </summary> // ------------------------------------------------------------------------------------- private void RetrieveData() { try { // Get data INewsService newsSrv = ServiceFactory.GetNewsService(); INewsPictureService newsPicSrv = ServiceFactory.GetNewsPictureService(); INewsAttachmentService attSrv = ServiceFactory.GetNewsAttachmentService(); m_CurrentNews = newsSrv.NewsSelectPicture(CurrentID); m_CurrentNews.NewsPictures = newsSrv.SelectChildrenByPictureOfNews(CurrentID); m_CurrentNews.NewsAttachments = newsSrv.SelectChildrenByAttachmentOfNews(CurrentID); foreach (NewsPicture pic in m_CurrentNews.NewsPictures.All) { NewsPicture picData = newsPicSrv.NewsPictureSelectPicture(pic.ID); pic.PictureData = picData.PictureData; } // Fill the controls txtTitle.Text = m_CurrentNews.Title; txtPictureUrl.Text = m_CurrentNews.PictureUrl; txtAbstract.Text = m_CurrentNews.Abstract; txtNewsBody.Text = m_CurrentNews.NewsBody; cbxVisibleForVisitor.Checked = m_CurrentNews.VisibleForVisitor; cbxVisibleForRegistered.Checked = m_CurrentNews.VisibleForRegistered; cbxActivate.Checked = m_CurrentNews.IsActive; cbxActual.Checked = m_CurrentNews.IsActual; if (cmbCategory != null && m_CurrentNews.CategoryRef != DBGuid.Null) { cmbCategory.SelectedValue = m_CurrentNews.CategoryRef.Value.ToString(); } // Show picture if (m_CurrentNews.PictureData != null && m_CurrentNews.PictureData.Length > 0) { MemoryStream imageStream = new MemoryStream(m_CurrentNews.PictureData); pbxPictureBase.Image = Image.FromStream(imageStream); } NewsAttachmentContainer avaiableFiles = new NewsAttachmentContainer(); foreach (NewsAttachment file in m_CurrentNews.NewsAttachments.All) { NewsAttachment oldFile = attSrv.NewsAttachmentSelectFile(file.ID); if (oldFile.FileData != null && oldFile.FileData.Length > 0) { file.FileData = oldFile.FileData; file.FileSize = oldFile.FileSize; if (!avaiableFiles.All.Items.Contains(file)) { avaiableFiles.Add(file); } } } m_CurrentNews.NewsAttachments = avaiableFiles; // 2nd page FillDatagrid(DBGuid.Null); //3. lap FillFileDatagrid(DBGuid.Null); } catch (Exception ex) { // --- Log exception ExceptionManager.Publish(ex); // --- Display Exception ErrorHandler.DisplayError("Hiba lépett fel az adatok lekérdezése során", ex); // --- invisible btnOk button btnOk.Visible = false; } }
public virtual NewsAttachmentContainer SelectChildrenByAttachmentOfNews(DBGuid IDVal) { TraceCallEnterEvent.Raise(); try { NewsAttachmentContainer result; DataSet entitySet = m_DataContext.ndihdAttachmentOfNewsSelectBy(IDVal); result = new NewsAttachmentContainer(entitySet.Tables[0]); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public virtual NewsAttachmentContainer NewsAttachmentSelectAll() { TraceCallEnterEvent.Raise(); try { NewsAttachmentContainer result; DataSet entitySet = m_DataContext.ndihdNewsAttachmentSelectAll(); result = new NewsAttachmentContainer(entitySet.Tables[0]); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }