Example #1
0
 private void m_btnEditerObjet_Click(object sender, EventArgs e)
 {
     if (m_contexteEdition == null)
     {
         CObjetDonnee objet = m_objetEdite as CObjetDonnee;
         if (objet != null)
         {
             objet.BeginEdit();
             m_contexteEdition       = objet.ContexteDonnee;
             m_createur.ElementEdite = objet;
         }
         else
         {
             CObjetDonnee[] objets = m_objetEdite as CObjetDonnee[];
             if (objets != null && objets.Length > 0)
             {
                 objet = (CObjetDonnee)Activator.CreateInstance(objets[0].GetType(), new object[] { objets[0].Row.Row });
                 objet.BeginEdit();
                 m_contexteEdition = objet.ContexteDonnee;
                 List <CObjetDonnee> lst = new List <CObjetDonnee>();
                 foreach (CObjetDonnee objetToAdd in objets)
                 {
                     CObjetDonnee tmp = objetToAdd.GetObjetInContexte(m_contexteEdition);
                     lst.Add(tmp);
                 }
                 m_createur.ElementEdite = lst.ToArray();
             }
             else
             {
                 m_contexteEdition       = CSc2iWin32DataClient.ContexteCourant.GetContexteEdition();
                 m_createur.ElementEdite = m_contexteEdition;
             }
         }
         m_extModeEdition.ModeEdition = true;
         m_createur.LockEdition       = false;
     }
 }
        //----------------------------------------------------
        private void Init()
        {
            Visible = m_etapeEnCours != null;
            CBlocWorkflowFormulaire blocFormulaire = m_etapeEnCours != null &&
                                                     m_etapeEnCours.TypeEtape != null ?
                                                     m_etapeEnCours.TypeEtape.Bloc as CBlocWorkflowFormulaire : null;

            SetSecondaireEdite(null);
            if (blocFormulaire == null)
            {
                return;
            }
            if (blocFormulaire.HideAfterValidation && m_etapeEnCours.EtatCode == (int)EEtatEtapeWorkflow.Terminée)
            {
                SetEtapeEnCours(null, null);
                return;
            }
            ResetClignote();
            this.SuspendDrawing();
            m_lblNomEtape.Text = m_etapeEnCours.Libelle;
            if (blocFormulaire.FormuleInstructions != null)
            {
                C2iExpression expInstructions         = blocFormulaire.FormuleInstructions;
                CContexteEvaluationExpression ctxEval = new CContexteEvaluationExpression(m_etapeEnCours);
                CResultAErreur result = expInstructions.Eval(ctxEval);
                if (result && result.Data != null)
                {
                    m_lblInstructions.Text = result.Data.ToString();
                }
                else
                {
                    m_lblInstructions.Text = m_etapeEnCours.Libelle + Environment.NewLine +
                                             result.Erreur.ToString();
                }
            }
            //m_btnTerminer.Visible = m_etapeEnCours.EtatCode == (int)EEtatEtapeWorkflow.Démarrée;
            if (m_formulaire != null)
            {
                bool bConsultationOnly = m_etapeEnCours.EtatCode != (int)EEtatEtapeWorkflow.Démarrée;
                if (m_etapeEnCours.EtatCode == (int)EEtatEtapeWorkflow.Terminée &&
                    !blocFormulaire.LockerElementEditeEnFinDEtape)
                {
                    bConsultationOnly = false;
                }
                m_formulaire.ConsultationOnly = bConsultationOnly;
            }
            m_bIsCollapse = false;
            UpdateImagePanelBas();
            m_btnTerminer.Visible = m_etapeEnCours.DateFin == null && m_etapeEnCours.DateDebut != null;
            m_btnTerminer.Enabled = !m_etapeEnCours.EstGelee;
            m_btnAnnuler.Visible  = !blocFormulaire.MasquerSurChangementDeFormulaire || m_etapeEnCours.DateFin != null;
            m_btnActions.Visible  = CRecuperateurDeclencheursActions.GetActionsManuelles(m_etapeEnCours, true).Count() > 0;

            Image imgTask = m_etapeEnCours.EtatCode == (int)EEtatEtapeWorkflow.Terminée ?
                            Resources._1346738948_taskok : Resources._1346738948_task;

            if (m_etapeEnCours.EstGelee)
            {
                imgTask = Resources._1346738948_task_pending;
            }
            SetImageTask(imgTask);

            int nHeight = m_panelTop.Height + m_panelInstructions.Height + m_panelBas.Height +
                          ClientSize.Height - Size.Height;
            bool bShowFormulaireSecondaire = false;

            if (blocFormulaire.DbKeyFormulaireSecondaire != null &&
                blocFormulaire.FormuleElementEditeSecondaire != null)
            {
                CContexteEvaluationExpression ctxEval = new CContexteEvaluationExpression(m_etapeEnCours);
                CResultAErreur result = blocFormulaire.FormuleElementEditeSecondaire.Eval(ctxEval);
                CObjetDonnee   objet  = result.Data as CObjetDonnee;
                if (result && objet != null)
                {
                    CFormulaire formulaire = new CFormulaire(m_etapeEnCours.ContexteDonnee);
                    if (formulaire.ReadIfExists(blocFormulaire.DbKeyFormulaireSecondaire))
                    {
                        C2iWnd wnd = formulaire.Formulaire;
                        if (wnd != null)
                        {
                            Size = new Size(Size.Width,
                                            nHeight +
                                            wnd.Size.Height + 2);
                            if (blocFormulaire.SecondaireEnEdition)
                            {
                                objet.BeginEdit();
                            }
                            m_panelFormulalire.InitPanel(wnd, objet);
                            SetSecondaireEdite(blocFormulaire.SecondaireEnEdition ? objet : null);
                            if (!blocFormulaire.SecondaireEnEdition)
                            {
                                m_panelFormulalire.LockEdition = true;
                            }
                            else
                            {
                                m_panelFormulalire.LockEdition = m_etapeEnCours.DateFin != null;
                            }

                            bShowFormulaireSecondaire = true;
                        }
                    }
                }
            }
            if (!bShowFormulaireSecondaire)
            {
                Size = new Size(Size.Width, nHeight);
            }
            m_nSizeUncollapse = Size.Height;
            this.ResumeDrawing();
        }