/// <summary>
        /// Fill datagrid with data
        /// </summary>
        private void FillDatagrid(DBGuid ID)
        {
            try
              {
            string sSortColumn = "dCreatedDate";
            int nSelectedRow = -1;

            // Storing the previous sort order
            if (dtgMain.DataSource != null)
            {
              sSortColumn = ((DataTable) dtgMain.DataSource).DefaultView.Sort;
            }

            // Set filter
            DesignerDrog filter = new DesignerDrog( Guid.Empty );

            filter.FilterOnIsactive = DBInt.Null;
            if (cmbStatus.SelectedIndex > 0)
            {
              bool bIsActive = (cmbStatus.SelectedValue.ToString() == "1" ? true : false);
              filter.FilterOnIsactive = (DBInt)Convert.ToInt32( bIsActive );
              filter.IsActive = bIsActive;
            }

            filter.FilterOnIsActual = DBInt.Null;
            if (cmbActual.SelectedIndex > 0)
            {
              bool bIsActual = (cmbActual.SelectedValue.ToString() == "1" ? true : false);
              filter.FilterOnIsActual = (DBInt) Convert.ToInt32(bIsActual);
              filter.IsActual = bIsActual;
            }
            if (cmbCategoryRef != null && cmbCategoryRef.SelectedIndex > 0)
            {
              filter.CategoryRef = new Guid(cmbCategoryRef.SelectedValue.ToString());
            }

            // Retrieving data from BusinessServices
            IDesignerDrogService srv = ServiceFactory.GetDesignerDrogService();
            DataSet allData = srv.DesignerDrogSelectFiltered(filter);
            DataTable dt = allData.Tables[0];
            dt.DefaultView.Sort = sSortColumn;
            dtgMain.DataSource = dt;

            // Locates the row specified by ID param
            if (!ID.IsNull)
            {
              BindingManagerBase bm = dtgMain.BindingContext[dtgMain.DataSource, dtgMain.DataMember];
              DataRow dr;
              for (int i = 0; i < bm.Count; i++)
              {
            dr = ((DataRowView) bm.Current).Row;
            if (ID.Value.Equals(dr["uId"]))
            {
              nSelectedRow = i;
              break;
            }
            bm.Position += 1;
              }
            }

            // Makes the row selected
            if (nSelectedRow <= ((DataTable) dtgMain.DataSource).DefaultView.Count && nSelectedRow > -1)
            {
              dtgMain.Select(nSelectedRow);
              dtgMain.CurrentRowIndex = nSelectedRow;
            }
            else if (((DataTable) dtgMain.DataSource).DefaultView.Count != 0)
            {
              dtgMain.Select(0);
            }

            // Enabling or disabling the buttons according to record count.
            // And is because of previous disable state.
            bool bIsEmptyGrid = (((DataTable) dtgMain.DataSource).DefaultView.Count == 0);
            tbbModify.Enabled = ! bIsEmptyGrid;
            tbbInactivate.Enabled = ! bIsEmptyGrid;
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba lépett fel a lista frissítése során.", ex);
              }
        }
Esempio n. 2
0
 protected void SetListControl( Guid categoryId, PlaceHolder plMain, string color )
 {
     IDesignerDrogService srvDesignerDrog = ServiceFactory.GetDesignerDrogService();
       DesignerDrog filter = new DesignerDrog(new DBGuid());
       filter.FilterOnIsActual = 1;
       filter.FilterOnIsactive = 1;
       filter.CategoryRef = categoryId;
       DataSet dt = srvDesignerDrog.DesignerDrogSelectFiltered( filter );
       if(dt.Tables.Count > 0)
       {
     DesignerDrogContainer dsCont = new DesignerDrogContainer(dt.Tables[0]);
     IDesignerDrogCategoryService srvCategory = ServiceFactory.GetDesignerDrogCategoryService();
     //DesignerDrogContainer dsCont =
     //  srvCategory.SelectChildrenByCategoryOfDesignerDrogItem( categoryId );
     Controls.ListControl listControl = (Controls.ListControl) LoadControl("Controls/ListControl.ascx");
     listControl.DataSource = dsCont;
     listControl.Color = color;
     plMain.Controls.Add(listControl);
       }
 }
Esempio n. 3
0
        protected void Page_Load( object sender, EventArgs e )
        {
            DesignerDrog itemSelected = new DesignerDrog(new DBGuid());
              _itemSrv = ServiceFactory.GetDesignerDrogService();
              _itemCatSrv = ServiceFactory.GetDesignerDrogCategoryService();
              if (Application["DesignerDrogCategories"] == null)
              {
            _itemCatSrv = ServiceFactory.GetDesignerDrogCategoryService();
            Categories = _itemCatSrv.DesignerDrogCategorySelectAll();
            Application["DesignerDrogCategories"] = Categories;
              }
              else
              {
            Categories = (DesignerDrogCategoryContainer) Application["DesignerDrogCategories"];
              }
              Guid itemGuid = new Guid();
              try
              {
            string itemId = Request.QueryString["id"];
            if (itemId == null)
              throw new ApplicationException("Hiányzó kötelező paraméter: elem azonosító.");

            itemGuid = new Guid(itemId);

            itemSelected = _itemSrv.DesignerDrogSelect(itemGuid);
            SelectedItem = itemSelected;
              }
              catch (Exception ex)
              {

              }
              var title = itemSelected.Title;

              if (((NewsDetails)HttpContext.Current.Handler).Request.UrlReferrer.LocalPath.Contains( "Results.aspx" ))
              {
            title = string.Format("{0}: {1}",((DesignerDrogCategory)Categories[itemSelected.CategoryRef.ToString()]).Name,title);
              }

              base.CreateHeaderControl( new Guid(), title );
              LiteralControl objAbstract = pnlAbstract.Controls[0] as LiteralControl;
              LiteralControl objBody = pnlBody.Controls[0] as LiteralControl;
              objAbstract.Text = itemSelected.Abstract.Replace("\r\n", "<br/>");
              objBody.Text = itemSelected.Body.Replace("\r\n", "<br/>");
              //lblDate.Text = newsSelected.CreatedDate.ToShortDateString();
              lblAuthor.Text = itemSelected.Author;
              lblDate.Text = itemSelected.CreatedDate.ToShortDateString();
              lblSource.Text = itemSelected.Source;

              // kép megjelenítése:
              if (itemSelected.PictureUrl.IsNull)
              {
            imgNewsPicture.Visible = false;
            rowImg.Visible = false;
              }
              else
              {
            imgNewsPicture.Visible = true;
            rowImg.Visible = true;
            imgNewsPicture.ImageUrl = string.Format("ShowPicture.aspx?mode=newslist&designerDrogId={0}",
                                                itemSelected.ID.Value);
              }

              // hír további képei:
              DesignerDrogPictureContainer pics = _itemSrv.SelectChildrenByPictureOfDesignerDrogItems(itemSelected.ID);
              if (pics.AllCount > 1)
              {
            linkMorePictures.Visible = true;
            pnlMorePics.Visible = true;
            linkMorePictures.NavigateUrl = string.Format("MorePictures.aspx?id={0}", itemSelected.ID.Value);

            linkMorePictures.Attributes.Add("class", Color);
            }
              else
              {
            pnlMorePics.Visible = false;
            linkMorePictures.Visible = false;
              }
              DesignerDrogLinkContainer links = _itemSrv.SelectChildrenByLinkOfDesignerDrogItem(itemGuid);
              DesignerDrogAttachmentContainer attachments = _itemSrv.SelectChildrenByAttachmentOfDesignerDrogItem(itemGuid);
              if (attachments.AllCount > 0)
            ShowAttachmentGrid( itemGuid, attachments );
              if (links.AllCount > 0)
            ShowLinkGrid(itemGuid, links);

              pnlLinks.Visible = links.AllCount > 0;
              pnlAttachment.Visible = attachments.AllCount > 0;
        }
 public virtual DesignerDrog DesignerDrogSelect(DBGuid IDVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     DesignerDrog result = null;
     DataSet entitySet = m_DataContext.ndihdDesignerDrogSelect(IDVal);
     if (entitySet.Tables[0].Rows.Count != 0)
     {
       result = new DesignerDrog(entitySet);
     }
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
 public virtual void DesignerDrogUpdate(DesignerDrog entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       int count;
       m_DataContext.ndihdDesignerDrogUpdate(entity.ID,
     entity.Title,
     entity.Author,
     entity.Source,
     entity.Abstract,
     entity.PictureUrl,
     entity.Body,
     entity.CategoryRef,
     entity.CreatedDate,
     entity.IsActive,
     entity.IsActual, out count);
       if (count == 0) throw new ServiceUpdateException();
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
        public new void DesignerDrogInsert( DesignerDrog entity )
        {
            // check permission: admin
            PrincipalPermission permAdmin = new PrincipalPermission( Thread.CurrentPrincipal.Identity.Name, "Administrator" );
            permAdmin.Demand();

            TraceCallEnterEvent.Raise();
            try
            {

            // check required fields:
            if (entity.Title.Length == 0) throw new ArgumentNullException( "DesignerDrog.Title", "A Designer drog elem címe nincs megadva." );
            if (entity.Abstract.Length == 0)
              throw new ArgumentNullException( "DesignerDrog.Abstract", "A Designer drog elem rövid összefoglalója nincs megadva." );
            if (entity.Body.Length == 0)
              throw new ArgumentNullException( "DesignerDrog.Body", "A Designer drog elem szövege nincs megadva." );

            // logical checks:
            if (entity.PictureUrl.Length > 0 && entity.PictureUrl != DBString.Null)
            {
                string ext = Path.GetExtension( entity.PictureUrl ).ToLower();
                if (!(ext.Equals( ".gif" ) || ext.Equals( ".jpg" ) || ext.Equals( "jpeg" )))
                    throw new ApplicationException( "Csak jpeg vagy gif formátumú kép csatolható." );
                if (entity.PictureData == null || entity.PictureData.Length == 0)
                    throw new ApplicationException( "A fájlnévhez nem tartozik adat." );
            }
            if (entity.PictureData != null && entity.PictureData.Length > 0)
            {
                if (entity.PictureUrl.Length == 0)
                    throw new ApplicationException( "A kép adathoz nem tartozik fájlnév." );
            }

            // save data
            entity.CreatedDate = DBDateTime.Now;

            DesignerDrogPictureService designerDrogPictureSrv = new DesignerDrogPictureService( m_DataContext );
            m_DataContext.BeginNestedTran();
            try
            {
                // DesignerDrog
                base.DesignerDrogInsert( entity );

                if (entity.PictureData != null && entity.PictureData.Length > 0)
                {
                    FileDataContext fileDataContext = new FileDataContext();
                    fileDataContext.DesignerDrogInsert( entity.ID, entity.PictureData );
                }

                // DesignerDrogPictures
                foreach (DesignerDrogPicture pic in entity.DesignerDrogPictures.Current)
                {
                  if (/*pic.PicturePath.Length > 0 &&*/  entity.PictureUrl != DBString.Null && entity.PictureData != null && pic.PictureData.Length > 0)
                    designerDrogPictureSrv.DesignerDrogPictureInsert( pic );
                }
                DesignerDrogAttachmentService attSrv = new DesignerDrogAttachmentService( m_DataContext );
                DesignerDrogLinkService linkSrv = new DesignerDrogLinkService( m_DataContext );

                // EDocumentAttachments - insert:
                foreach (DesignerDrogAttachment file in entity.DesignerDrogAttachments.Current)
                {
                    file.ItemRef= entity.ID;
                    file.IsActive = true;
                    file.CreatedDate = DateTime.Now;
                    attSrv.DesignerDrogAttachmentInsert( file );
                }

                foreach (DesignerDrogLink link in entity.DesignerDrogLinks.Current)
                {
                  link.ItemRef = entity.ID;
                  linkSrv.DesignerDrogLinkInsert( link );
                }
                m_DataContext.CommitNested();
            }
            catch
            {
                m_DataContext.RollbackNested();
                throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter( "DesignerDrogID", entity.ID.ToString() ),
              new EventParameter( "DesignerDrogTitle", entity.Title )
              );
            TraceCallReturnEvent.Raise();
            return;
            }
            catch (Exception ex)
            {
            ExceptionManager.Publish( ex );
            BusinessAuditEvent.Fail(
              new EventParameter( "Exception", ex.ToString() ),
              new EventParameter( "DesignerDrogID", entity.ID.ToString() ),
              new EventParameter( "DesignerDrogTitle", entity.Title )
              );
            TraceCallReturnEvent.Raise( false );
            throw;
            }
        }
 public virtual void DesignerDrogDelete(DesignerDrog entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdDesignerDrogDelete(entity.ID);
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
        public new void DesignerDrogUpdate( DesignerDrog entity )
        {
            // Check permission: Admin
            PrincipalPermission permAdmin = new PrincipalPermission( Thread.CurrentPrincipal.Identity.Name, "Administrator" );
            permAdmin.Demand();

            TraceCallEnterEvent.Raise();
            try
            {
            // Check required fields:
              if (entity.Title.Length == 0) throw new ArgumentNullException( "DesignerDrog.Title", "A Designer drog elem címe nincs megadva." );
            if (entity.Abstract.Length == 0)
              throw new ArgumentNullException( "DesignerDrog.Abstract", "A Designer drog elem abstract nincs megadva." );
            if (entity.Body.Length == 0)
              throw new ArgumentNullException( "DesignerDrog.Body", "A Designer drog elem szövege nincs megadva." );

            if (entity.PictureUrl.Length > 0 && entity.PictureUrl != DBString.Null)
            {
                string ext = Path.GetExtension( entity.PictureUrl ).ToLower();
                if (!(ext.Equals( ".gif" ) || ext.Equals( ".jpg" ) || ext.Equals( ".jpeg" )))
                    throw new ApplicationException( "Csak jpeg vagy gif formátumú kép csatolható." );
                if (entity.PictureData == null || entity.PictureData.Length == 0)
                {
                  entity.PictureUrl = "";
                  //throw new ApplicationException("A fájlnévhez nem tartozik adat.");
                }
              if (entity.PictureData != null && entity.PictureData.Length > 0)
                {
                    if (entity.PictureUrl.Length == 0)
                        throw new ApplicationException( "A kép adathoz nem tartozik fájlnév." );
                }
            }
            // Logical checks
            DesignerDrog selected = DesignerDrogSelect( entity.ID );
            if (selected == null)
                throw new ApplicationException( "A megadott azonosítóval nem létezik hír." );

            //string oldFileName = selected.PictureUrl;

            // Save data
            selected.Title = entity.Title;
            selected.Abstract = entity.Abstract;
            selected.Body = entity.Body;
            selected.Source = entity.Source;
            selected.Author = entity.Author;
            selected.IsActive = entity.IsActive;
            selected.PictureUrl = entity.PictureUrl;
            selected.IsActual = entity.IsActual;
            selected.CategoryRef = entity.CategoryRef;

            DesignerDrogPictureService designerDrogPictureSrv = new DesignerDrogPictureService( m_DataContext );
                      DesignerDrogLinkService designerDrogLinkSrv = new DesignerDrogLinkService( m_DataContext );
            FileDataContext fileDataContext = new FileDataContext();
            m_DataContext.BeginNestedTran();
            try
            {
                // Clear old files:
                DesignerDrogPictureContainer oldPics = base.SelectChildrenByPictureOfDesignerDrogItems( entity.ID );
                foreach (DesignerDrogPicture oldPic in oldPics.All)
                {
                    designerDrogPictureSrv.DesignerDrogPictureDelete( oldPic );
                }

                // DesignerDrogPicture - insert:
                foreach (DesignerDrogPicture pic in entity.DesignerDrogPictures.Current)
                {
                  if (/*pic.PicturePath.Length > 0 &&*/  entity.PictureUrl != DBString.Null && entity.PictureData != null && pic.PictureData.Length > 0)
                        designerDrogPictureSrv.DesignerDrogPictureInsert( pic );
                }

                #region Links
                // Clear old files:
                DesignerDrogLinkContainer oldLinks = base.SelectChildrenByLinkOfDesignerDrogItem( entity.ID );
                foreach (DesignerDrogLink oldLink in oldLinks.All)
                {
                  designerDrogLinkSrv.DesignerDrogLinkDelete( oldLink );
                }

                // DesignerDrogPicture - insert:
                foreach (DesignerDrogLink link in entity.DesignerDrogLinks.Current)
                {
                  designerDrogLinkSrv.DesignerDrogLinkInsert( link );
                }
                #endregion

              selected.DesignerDrogLinks = entity.DesignerDrogLinks;
                selected.DesignerDrogAttachments = entity.DesignerDrogAttachments;

                DesignerDrogAttachmentService attSrv = new DesignerDrogAttachmentService( m_DataContext );

                // Clear old files:
                DesignerDrogAttachmentContainer oldFiles = base.SelectChildrenByAttachmentOfDesignerDrogItem( entity.ID );
                foreach (DesignerDrogAttachment oldFile in oldFiles.All)
                {
                    attSrv.DesignerDrogAttachmentDelete( oldFile );
                }
                DesignerDrogAttachment newFile;
                // EDocumentAttachments - insert:
                foreach (DesignerDrogAttachment file in selected.DesignerDrogAttachments.Current)
                {
                    if (file.FileData.Length == 0)
                    {
                        newFile = attSrv.DesignerDrogAttachmentSelectFile( file.ID );
                    }
                    else
                    {
                        newFile = file;
                    }
                    newFile.ItemRef = selected.ID;
                    newFile.Name = file.Name;
                    newFile.Description = file.Description;
                    newFile.CreatedDate = DateTime.Now;

                    if (attSrv.DesignerDrogAttachmentSelect( newFile.ID ) != null)
                    {
                        attSrv.DesignerDrogAttachmentUpdate( newFile );
                    }
                    else
                    {
                        attSrv.DesignerDrogAttachmentInsert( newFile );
                    }
                }
                // DesignerDrog
                base.DesignerDrogUpdate( selected );

                // DesignerDrog base picture update
                fileDataContext.DesignerDrogDelete( selected.ID );
                if (entity.PictureData != null && entity.PictureData.Length > 0)
                {
                    fileDataContext.DesignerDrogInsert( entity.ID, entity.PictureData );
                }

                m_DataContext.CommitNested();
            }
            catch
            {
                m_DataContext.RollbackNested();
                throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter( "DesignerDrogID", entity.ID.ToString() ),
              new EventParameter( "DesignerDrogTitle", entity.Title )
              );
            TraceCallReturnEvent.Raise();
            return;
            }
            catch (Exception ex)
            {
            ExceptionManager.Publish( ex );
            BusinessAuditEvent.Fail(
              new EventParameter( "Exception", ex.ToString() ),
              new EventParameter( "DesignerDrogID", entity.ID.ToString() ),
              new EventParameter( "DesignerDrogTitle", entity.Title )
              );
            TraceCallReturnEvent.Raise( false );
            throw;
            }
        }
 public DataSet DesignerDrogSelectFiltered( DesignerDrog filter )
 {
     TraceCallEnterEvent.Raise();
     try
     {
     DataSet result = m_DataContext.ndihdDesignerDrogSelectFiltered(
       filter.CategoryRef,
       filter.FilterOnIsactive,
       filter.FilterOnIsActual );
     TraceCallReturnEvent.Raise();
     return result;
     }
     catch (Exception ex)
     {
     ExceptionManager.Publish( ex );
     TraceCallReturnEvent.Raise( false );
     throw;
     }
 }
Esempio n. 10
0
   // -------------------------------------------------------------------------------------
   /// <summary>
   /// Copy constructor.
   /// </summary>
   /// <param name="IDVal">Value of 'uID' field</param>
   /// <param name="origInstance">Original document data to copy.</param>
   // -------------------------------------------------------------------------------------
   public DesignerDrog(DBGuid IDVal,
 DesignerDrog origInstance)
       : base(IDVal, origInstance)
   {
   }
Esempio n. 11
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public DesignerDrog(DesignerDrog origInstance)
     : base(origInstance)
 {
 }
Esempio n. 12
0
 public void SaveDesignerDrog( DesignerDrog entity )
 {
     TraceCallEnterEvent.Raise();
       try
       {
     //megnézzük hogy van e már hozzá megadott keresõ szöveg .. mert akkor azt update -eljük
     GlobalSearch search = base.GlobalSearchSelect( entity.ID, "DESIGNERDROG" );
     bool hasItem = search != null;
     var text = entity.Title.ToString() + " " + entity.Abstract.ToString()
       + " " +
             entity.Body.ToString() + " " + entity.Author + " " + entity.Source;
     if (hasItem)
     {
       search.SearchText = text;
       //ha van ilyen UPDATE
       base.GlobalSearchUpdate( search );
     }
     else //ha még nincs ilyen INSERT
     {
       search = new GlobalSearch( entity.ID, "DESIGNERDROG" );
       search.SearchText = text;
       base.GlobalSearchInsert( search );
     }
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish( ex );
     BusinessAuditEvent.Fail(
       new EventParameter( "Exception", ex.ToString() ),
       new EventParameter( "IDRef", entity.ID.ToString() ),
       new EventParameter( "SearchCategory", "NEWS" )
       );
     TraceCallReturnEvent.Raise( false );
     throw;
       }
 }