Esempio n. 1
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();
     }
 }
Esempio n. 2
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();
 }