예제 #1
0
 //----------------------------------------------------------------------------------
 private void UpdateVisuel()
 {
     CGestionnaireEditeursActionsSur2iLink.CInfoTypeActionSur2iLink info = m_cmbTypeAction.SelectedValue as CGestionnaireEditeursActionsSur2iLink.CInfoTypeActionSur2iLink;
     m_panelDetailAction.SuspendDrawing();
     if (info != null)
     {
         if (m_editeur != null && m_editeur.GetType() != info.TypeEditeur)
         {
             m_panelDetailAction.Controls.Remove((Control)m_editeur);
             m_editeur.Dispose();
             m_editeur = null;
         }
         if (m_editeur == null)
         {
             m_editeur = Activator.CreateInstance(info.TypeEditeur, new object[0]) as IEditeurUneActionSur2iLink;
             Control ctrl = m_editeur as Control;
             ctrl.Parent = m_panelDetailAction;
             ctrl.Dock   = DockStyle.Fill;
             CWin32Traducteur.Translate(ctrl);
         }
         if (m_actionFinale == null || m_actionFinale.GetType() != info.TypeAction)
         {
             m_actionFinale = Activator.CreateInstance(info.TypeAction, new object[0]) as CActionSur2iLink;
         }
         m_editeur.InitChamps(m_actionFinale, m_objetPourSousProprietes);
     }
     m_panelDetailAction.ResumeDrawing();
 }
예제 #2
0
        private void m_btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = I.T("Action (*.2iAction)|*.2iAction|All files (*.*)|*.*|20867");
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (CFormAlerte.Afficher(I.T("Action data will be replaced, continue|20866"),
                                         EFormAlerteType.Question) == DialogResult.No)
                {
                    return;
                }
                CActionSaver   saver  = new CActionSaver();
                CResultAErreur result = CSerializerObjetInFile.ReadFromFile(saver, CActionSur2iLink.c_idFichier, dlg.FileName);
                if (!result)
                {
                    CFormAlerte.Afficher(result);
                }
                else
                {
                    m_actionFinale = saver.Action;
                    SelectTypeAction(m_actionFinale != null ?
                                     m_actionFinale.GetType() :
                                     null);
                    UpdateVisuel();
                }
            }
        }
        //--------------------------------------------------------------------------
        public static CInfoTypeActionSur2iLink GetInfoEditeurForAction(CActionSur2iLink action)
        {
            CInfoTypeActionSur2iLink info = null;

            if (action != null)
            {
                if (m_dicTypeActionToInfoEditeur.TryGetValue(action.GetType(), out info))
                {
                    return(info);
                }
            }
            return(null);
        }
예제 #4
0
        //---------------------------------------------------------------------
        private void CFormEditeActionSurLink_Load(object sender, EventArgs e)
        {
            CWin32Traducteur.Translate(this);
            FillComboActionsPossibles();


            SelectTypeAction(m_actionOriginale != null ?
                             m_actionOriginale.GetType() :
                             null);


            m_actionFinale = m_actionOriginale;
            UpdateVisuel();
        }
예제 #5
0
        //----------------------------------------------------------------------------------
        private void m_btnPaste_Click(object sender, EventArgs e)
        {
            I2iSerializable objet  = null;
            CResultAErreur  result = CSerializerObjetInClipBoard.Paste(ref objet, CActionSur2iLink.c_idFichier);

            if (!result)
            {
                CFormAlerte.Afficher(result);
                return;
            }
            if (CFormAlerte.Afficher(I.T("Action data will be replaced, continue|20866"),
                                     EFormAlerteType.Question) == DialogResult.No)
            {
                return;
            }
            m_actionFinale = (CActionSur2iLink)objet;
            SelectTypeAction(m_actionFinale != null?
                             m_actionFinale.GetType() :
                             null);
            UpdateVisuel();
        }
예제 #6
0
        /*/// //////////////////////////////////////////////////////////////////
         * private static void CCreateur2iFormulaire_AfterCreateControl ( Control ctrl, C2iWnd wnd, object elementEdite )
         * {
         *      if ( wnd is C2iWndLink && ctrl is LinkLabel )
         *      {
         *              ctrl.Tag = new CInfoLinkLabel((C2iWndLink)wnd, elementEdite);
         *              ((LinkLabel)ctrl).LinkClicked += new LinkLabelLinkClickedEventHandler(CExecuteurActionSur2iLink_Click);
         *      }
         * }
         *
         * static void CCreateur2iFormulaire_AfterChangeElementEdite(Control ctrl, C2iWnd wnd, object elementEdite)
         * {
         *      if (wnd is C2iWndLink && ctrl is LinkLabel)
         *      {
         *              ctrl.Tag = new CInfoLinkLabel((C2iWndLink)wnd, elementEdite);
         *      }
         * }*/

        /*/// //////////////////////////////////////////////////////////////////
         * private static void CExecuteurActionSur2iLink_Click ( object sender, LinkLabelLinkClickedEventArgs args )
         * {
         *      if (sender is LinkLabel && ((LinkLabel)sender).Tag is CInfoLinkLabel)
         *      {
         *              CInfoLinkLabel info = (CInfoLinkLabel)((LinkLabel)sender).Tag;
         *              C2iWndLink link = info.WndLink;
         *              object cible = info.Cible;
         *              CResultAErreur result = CResultAErreur.True;
         *              if ( link.ActionAssociee != null )
         *              {
         *                      Form frm = ((Control)sender).FindForm();
         *                      if (cible == null)
         *                      {
         *                              if (frm != null && frm is IFormEditObjetDonnee)
         *                                      cible = ((IFormEditObjetDonnee)frm).GetObjetEdite();
         *                      }
         *                      if (frm != null && frm is CFormEditionStandard)
         *                      {
         *                              if (((CFormEditionStandard)frm).EtatEdition)
         *                              {
         *                                      if (CFormAlerte.Afficher(I.T("This action will save your data. Continue ?|1253"),
         *                                              EFormAlerteType.Question) == DialogResult.No)
         *                                              return;
         *                                      if (!((CFormEditionStandard)frm).OnClickValider())
         *                                              return;
         *                                      ((CFormEditionStandard)frm).OnClickModifier();
         *                              }
         *
         *                      }
         *                      if ( frm != null && frm is CFormListeStandard )
         *                      {
         *                              if ( link.ActionAssociee.GetType() == typeof ( CActionSur2iLinkAfficheFormulaireCustom ) ||
         *                                      link.ActionAssociee.GetType() == typeof ( CActionSur2iLinkAfficherFormulaire ) ||
         *                                      link.ActionAssociee.GetType() == typeof ( CActionSur2iLinkAfficherListe ))
         *                                              cible = ((CFormListeStandard)frm).ElementSelectionne;
         *                              else if ( link.ActionAssociee.GetType() == typeof ( CActionSur2iLinkExecuterProcess ) )
         *                                              cible = ((CFormListeStandard)frm).ElementsCoches;
         *                      }
         *                      result = ExecuteAction(link.ActionAssociee, cible);
         *                      if ( !result )
         *                              CFormAlerte.Afficher ( result.Erreur );
         *              }
         *      }
         * }*/

        /// <summary>
        /// //////////////////////////////////////////////////////////////////
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public static CResultAErreur ExecuteAction(object sender, CActionSur2iLink action, object objetCible)
        {
            CResultAErreur result = CResultAErreur.True;
            Form           frm    = null;

            if (!action.AutoriserEnEdition && sender != null && sender is Control)
            {
                frm = ((Control)sender).FindForm();
                object cible = objetCible;
                if (cible == null)
                {
                    if (frm != null && frm is IFormEditObjetDonnee)
                    {
                        cible = ((IFormEditObjetDonnee)frm).GetObjetEdite();
                    }
                }
                if (frm != null && frm is IFormEditObjetDonnee)
                {
                    if (((IFormEditObjetDonnee)frm).EtatEdition)
                    {
                        if (CFormAlerte.Afficher(I.T("This action will save your data. Continue ?|1253"),
                                                 EFormAlerteType.Question) == DialogResult.No)
                        {
                            return(result);
                        }
                        if (!((IFormEditObjetDonnee)frm).ValiderModifications())
                        {
                            return(result);
                        }
                        CObjetDonnee obj = ((IFormEditObjetDonnee)frm).GetObjetEdite();
                        if (obj != null)
                        {
                            if (cible is CObjetDonnee)
                            {
                                cible = ((CObjetDonnee)cible).GetObjetInContexte(obj.ContexteDonnee);
                            }
                        }
                        //((CFormEditionStandard)frm).OnClickModifier();
                    }
                }
                if (frm != null && frm is CFormListeStandard)
                {
                    if (
                        action.GetType() == typeof(CActionSur2iLinkAfficherFormulaire) ||
                        action.GetType() == typeof(CActionSur2iLinkAfficherListe))
                    {
                        cible = ((CFormListeStandard)frm).ElementSelectionne;
                    }
                    else
                    {
                        CActionSur2iLinkAfficheFormulaireCustom actionForm = action as CActionSur2iLinkAfficheFormulaireCustom;
                        if (actionForm != null)
                        {
                            cible = ((CFormListeStandard)frm).ElementSelectionne;
                            CFormulaire formulaire = new CFormulaire(CContexteDonneeSysteme.GetInstance());
                            if (formulaire.ReadIfExists(actionForm.IdFormulaireInDb))
                            {
                                if (formulaire.ElementEditeIsArray)
                                {
                                    cible = ((CFormListeStandard)frm).ElementsCoches;
                                }
                            }
                        }
                        else if (action.GetType() == typeof(CActionSur2iLinkExecuterProcess))
                        {
                            cible = ((CFormListeStandard)frm).ElementsCoches;
                        }
                    }
                }
                objetCible = cible;
            }
            if (action is CActionSur2iLinkAfficherFormulaire)
            {
                return(ExecuteActionFormulaire((CActionSur2iLinkAfficherFormulaire)action, objetCible));
            }
            else if (action is CActionSur2iLinkAfficherListe)
            {
                return(ExecuteActionListe((CActionSur2iLinkAfficherListe)action, objetCible));
            }
            else if (action is CActionSur2iLinkExecuterProcess)
            {
                result = ExecuteActionProcess((CActionSur2iLinkExecuterProcess)action, objetCible);
                CFormEditionStandard frmStd = frm as CFormEditionStandard;
                if (frmStd != null)
                {
                    try//La fenêtre peut être fermée par le process, donc ça peut faire des erreurs
                    {
                        frmStd.RefillDialog();
                    }
                    catch { }
                }
                else if (frm == CFormMain.GetInstance())
                {
                    CFormMain.GetInstance().RefreshPanelEtapeWorkflow();
                }
                return(result);
            }
            else if (action is CActionSur2iLinkAfficheFormulaireCustom)
            {
                return(ExecuteActionFormulaireCustom((CActionSur2iLinkAfficheFormulaireCustom)action, objetCible));
            }
            else if (action is CActionSur2iLinkAfficherEntite)
            {
                return(ExecuteActionAfficherEntite((CActionSur2iLinkAfficherEntite)action, objetCible));
            }
            else if (action is CActionSur2iLinkMenuDeroulant)
            {
                return(ExecuteActionMenuDeroulant((CActionSur2iLinkMenuDeroulant)action, sender, objetCible));
            }
            else if (action is CActionSur2iLinkFormulairePopup)
            {
                return(ExecuteActionFormulairePopup((CActionSur2iLinkFormulairePopup)action, sender, objetCible));
            }

            result = CResultAErreur.True;
            result.EmpileErreur(I.T("Action not managed|30076"));
            return(result);
        }