Ejemplo n.º 1
0
    private int mSetPriority()
    {
        MediaSubjects mediaSubjects = new MediaSubjects();

        mediaSubjects.LoadByIDSubjectAndIDMediaSubjectType(pSubjectID, pMediaSubjectTypeID);
        mediaSubjects.Sort = MediaSubjects.ColumnNames.Priority;
        if (mediaSubjects.RowCount > 0)
        {
            mediaSubjects.MoveTo(mediaSubjects.RowCount - 1);
            if (!mediaSubjects.IsColumnNull(MediaSubjects.ColumnNames.Priority))
            {
                return(mediaSubjects.pPriority + 1);
            }
            else
            {
                mediaSubjects.Rewind();
                int i = 1;
                if (mediaSubjects.RowCount > 0)
                {
                    do
                    {
                        mediaSubjects.pPriority = i;
                        i++;
                    }while (mediaSubjects.MoveNext());
                    mediaSubjects.Save();
                }
                return(i++);
            }
        }
        else
        {
            return(1);
        }
    }
Ejemplo n.º 2
0
    private void ReOrder(MediaSubjects unorderedMedias, string draggedPriority, string targetPriority, bool direction)
    {
        try
        {
            string initFilter = "";
            if (!string.IsNullOrEmpty(unorderedMedias.Filter))
            {
                initFilter = unorderedMedias.Filter + " AND ";
            }
            unorderedMedias.Filter    = initFilter + string.Format("{0}={1}", MediaSubjects.ColumnNames.Priority, draggedPriority);
            unorderedMedias.pPriority = -1;

            if (direction)
            {
                unorderedMedias.Filter = initFilter + string.Format("{0}>={1} AND {0} < {2}", MediaSubjects.ColumnNames.Priority, targetPriority, draggedPriority);
                if (unorderedMedias.RowCount > 0)
                {
                    do
                    {
                        unorderedMedias.pPriority += 1;
                    } while (unorderedMedias.MoveNext());
                }
            }
            else
            {
                unorderedMedias.Filter = initFilter + string.Format("{0}>{1} AND {0} <= {2}", MediaSubjects.ColumnNames.Priority, draggedPriority, targetPriority);
                if (unorderedMedias.RowCount > 0)
                {
                    do
                    {
                        unorderedMedias.pPriority -= 1;
                    } while (unorderedMedias.MoveNext());
                }
            }
            unorderedMedias.Filter    = initFilter + string.Format("{0}={1}", MediaSubjects.ColumnNames.Priority, "-1");
            unorderedMedias.pPriority = Convert.ToInt32(targetPriority);


            pMediaSubjects = unorderedMedias;
            MediaSubjects mediaSubjects = new MediaSubjects();
            mediaSubjects = pMediaSubjects;
            mediaSubjects.Save();

            mLoadAllPageMedias();
            pMessage.Add(Farschidus.Translator.AppTranslate["general.message.reordered"], Farschidus.Web.UI.Message.MessageTypes.Success);
        }
        catch (Exception ex)
        {
            pMessage.Add(ex.Message, Farschidus.Web.UI.Message.MessageTypes.Error);
        }
        finally
        {
            mShowMessage(pMessage);
            uplAddEdit.Update();
        }
    }
Ejemplo n.º 3
0
    private void mDeleteMediaSubject()
    {
        MediaSubjects mediaSubject = new MediaSubjects();

        mediaSubject.LoadByIDSubjectAndIDMediaSubjectType(pSubjectID, pMediaSubjectTypeID);
        if (mediaSubject.RowCount > 0)
        {
            mediaSubject.MarkAsDeleted(false);
            mediaSubject.Save();
        }
    }
Ejemplo n.º 4
0
    protected void grvList_Select(object sender, CommandEventArgs e)
    {
        mDeleteMediaSubject();

        MediaSubjects mediaSubject = new MediaSubjects();

        mediaSubject.AddNew();
        mediaSubject.pIDMedia            = Convert.ToInt32(e.CommandArgument);
        mediaSubject.pIDSubject          = pSubjectID;
        mediaSubject.pIDMediaSubjectType = pMediaSubjectTypeID;
        mediaSubject.Save();

        mSave();
    }
Ejemplo n.º 5
0
    private void reorderMediaSubjects(MediaSubjects mediaSubjects)
    {
        mediaSubjects.LoadByIDSubjectAndIDMediaSubjectType(pSubjectID, pMediaSubjectTypeID);
        mediaSubjects.Sort = MediaSubjects.ColumnNames.Priority;
        int i = 1;

        if (mediaSubjects.RowCount > 0)
        {
            do
            {
                mediaSubjects.pPriority = i;
                i++;
            }while (mediaSubjects.MoveNext());
            mediaSubjects.Save();
        }
    }
Ejemplo n.º 6
0
    private void mDelete(Guid iDSubject, bool loadList = true)
    {
        if (mValidateDelete(iDSubject))
        {
            DAL.GlobalCore.TransactionMgr tx = DAL.GlobalCore.TransactionMgr.ThreadTransactionMgr();
            try
            {
                tx.BeginTransaction();
                MediaSubjects mediaSubjects = new MediaSubjects();
                mediaSubjects.LoadByIDSubject(iDSubject);
                mediaSubjects.DeleteAll();
                mediaSubjects.Save();

                SubjectPlugins subjectPlugin = new SubjectPlugins();
                subjectPlugin.LoadByIDSubject(iDSubject);
                subjectPlugin.DeleteAll();
                subjectPlugin.Save();

                GalleryPlugins GalleryPlugins = new GalleryPlugins();
                GalleryPlugins.LoadByIDSubject(iDSubject);
                GalleryPlugins.DeleteAll();
                GalleryPlugins.Save();


                Subjects subject = new Subjects(iDSubject);
                subject.MarkAsDeleted(false);
                subject.Save();

                tx.CommitTransaction();
                if (loadList)
                {
                    pMessage.Clear();
                    pMessage.Add(Farschidus.Translator.AppTranslate["general.message.deleted"], Farschidus.Web.UI.Message.MessageTypes.Success);
                    mShowMessage(pMessage);

                    mLoadList();
                }
            }
            catch (Exception ex)
            {
                tx.RollbackTransaction();
                pMessage.Clear();
                pMessage.Add(ex.Message, Farschidus.Web.UI.Message.MessageTypes.Error);
            }
        }
        mShowMessage(pMessage);
    }
Ejemplo n.º 7
0
 protected void btnAddToPage_Click(object sender, EventArgs e)
 {
     try
     {
         pMessage.Clear();
         bool          hasSelect = false;
         int           item;
         MediaSubjects mediaSubjects = new MediaSubjects();
         foreach (GridViewRow grvRow in grvList.Rows)
         {
             if (((CheckBox)grvRow.FindControl("chkList")).Checked)
             {
                 item = Convert.ToInt32(grvList.DataKeys[grvRow.RowIndex][Medias.ColumnNames.IDMedia].ToString());
                 mediaSubjects.LoadByPrimaryKey(item, pSubjectID, pMediaSubjectTypeID);
                 if (mediaSubjects.RowCount == 0)
                 {
                     mediaSubjects.AddNew();
                     mediaSubjects.pIDMedia            = item;
                     mediaSubjects.pIDSubject          = pSubjectID;
                     mediaSubjects.pIDMediaSubjectType = pMediaSubjectTypeID;
                     mediaSubjects.pPriority           = mSetPriority();
                     mediaSubjects.Save();
                     hasSelect = true;
                 }
                 else
                 {
                     pMessage.Add(Farschidus.Translator.AppTranslate["thumbnail.popup.message.alreadyExist"] + ": " + mediaSubjects.Medias.pFileName, Farschidus.Web.UI.Message.MessageTypes.Information);
                 }
             }
         }
         if (hasSelect)
         {
             mLoadAll();
             pMessage.Add(Farschidus.Translator.AppTranslate["general.message.success"], Farschidus.Web.UI.Message.MessageTypes.Success);
         }
     }
     catch (Exception ex)
     {
         pMessage.Add(ex.Message, Farschidus.Web.UI.Message.MessageTypes.Error);
     }
     finally
     {
         mShowMessage(pMessage);
         uplAddEdit.Update();
     }
 }
Ejemplo n.º 8
0
    private void mDelete(Guid iDUser)
    {
        DAL.GlobalCore.TransactionMgr tx = DAL.GlobalCore.TransactionMgr.ThreadTransactionMgr();
        try
        {
            Subjects subjects = new Subjects();
            subjects.LoadBySubjectAliasAndIDSubjectType(pIDUser.Value.ToString(), (byte)SubjectTypes.Enum.userPage);
            if (subjects.RowCount > 0)
            {
                tx.BeginTransaction();
                MediaSubjects mediaSubjects = new MediaSubjects();
                mediaSubjects.LoadByIDSubject(subjects.pIDSubject);
                mediaSubjects.DeleteAll();
                mediaSubjects.Save();

                SubjectPlugins subjectPlugin = new SubjectPlugins();
                subjectPlugin.LoadByIDSubject(subjects.pIDSubject);
                subjectPlugin.DeleteAll();
                subjectPlugin.Save();

                GalleryPlugins GalleryPlugins = new GalleryPlugins();
                GalleryPlugins.LoadByIDSubject(subjects.pIDSubject);
                GalleryPlugins.DeleteAll();
                GalleryPlugins.Save();

                Subjects subject = new Subjects(subjects.pIDSubject);
                subject.MarkAsDeleted(false);
                subject.Save();

                tx.CommitTransaction();
                pMessage.Clear();
                pMessage.Add(Farschidus.Translator.AppTranslate["general.message.deleted"], Farschidus.Web.UI.Message.MessageTypes.Success);
                mShowMessage(pMessage);

                mLoadList();
            }
        }
        catch (Exception ex)
        {
            tx.RollbackTransaction();
            pMessage.Clear();
            pMessage.Add(ex.Message, Farschidus.Web.UI.Message.MessageTypes.Error);
            mShowMessage(pMessage);
        }
    }
Ejemplo n.º 9
0
 protected void btnRemoveFromPage_Click(object sender, EventArgs e)
 {
     try
     {
         pMessage.Clear();
         bool          hasSelect = false;
         int           item;
         MediaSubjects mediaSubjects = new MediaSubjects();
         foreach (GridViewRow grvRow in grvPageList.Rows)
         {
             if (((CheckBox)grvRow.FindControl("chkPageList")).Checked)
             {
                 item = Convert.ToInt32(grvPageList.DataKeys[grvRow.RowIndex][Medias.ColumnNames.IDMedia].ToString());
                 mediaSubjects.LoadByPrimaryKey(item, pSubjectID, pMediaSubjectTypeID);
                 if (mediaSubjects.RowCount > 0)
                 {
                     mediaSubjects.MarkAsDeleted(false);
                     mediaSubjects.Save();
                     hasSelect = true;
                 }
             }
         }
         if (hasSelect)
         {
             reorderMediaSubjects(mediaSubjects);
             mLoadAll();
             pMessage.Add(Farschidus.Translator.AppTranslate["general.message.deleted"], Farschidus.Web.UI.Message.MessageTypes.Success);
         }
     }
     catch (Exception ex)
     {
         pMessage.Add(ex.Message, Farschidus.Web.UI.Message.MessageTypes.Error);
     }
     finally
     {
         mShowMessage(pMessage);
     }
     uplAddEdit.Update();
 }