コード例 #1
0
        //---------------------------------------------------------------
        private CItemBesoin CreateSoluce(CBesoin besoinSolutionné)
        {
            CBesoin newBesoin = new CBesoin(m_phaseSpecifications.ContexteDonnee);

            newBesoin.CreateNewInCurrentContexte();
            newBesoin.PhaseSpecifications = m_phaseSpecifications;

            Dictionary <int, int> dicMap = newBesoin.CopyFromTemplate(besoinSolutionné);

            if (dicMap != null)
            {
                foreach (KeyValuePair <int, int> kv in dicMap)
                {
                    CBesoin bOriginal = new CBesoin(m_phaseSpecifications.ContexteDonnee);
                    if (bOriginal.ReadIfExists(kv.Key, false))
                    {
                        if (!bOriginal.HasChildren)
                        {
                            CBesoin bNew = new CBesoin(m_phaseSpecifications.ContexteDonnee);
                            if (bNew.ReadIfExists(kv.Value, false))
                            {
                                bOriginal.AddSatisfaction(bNew, null);
                            }
                        }
                    }
                }
            }
            CItemBesoin item = new CItemBesoin(newBesoin, null);

            AddItem(item, false);
            item.Index = Items.Count();
            AddItemsFils(item);

            return(item);
        }
コード例 #2
0
        private void m_picDragBesoin_DragDrop(object sender, DragEventArgs e)
        {
            CReferenceObjetDonnee refObj = e.Data.GetData(typeof(CReferenceObjetDonnee)) as CReferenceObjetDonnee;

            if (refObj != null)
            {
                CBesoin besoin = refObj.GetObjet(m_commande.ContexteDonnee) as CBesoin;
                CDonneeBesoinTypeEquipement besoinEqpt = besoin.DonneeBesoin as CDonneeBesoinTypeEquipement;
                if (besoinEqpt != null)
                {
                    e.Effect = DragDropEffects.Link;
                    CLigneCommande ligne = new CLigneCommande(m_commande.ContexteDonnee);
                    ligne.CreateNewInCurrentContexte();
                    ligne.Commande       = m_commande;
                    ligne.TypeEquipement = besoinEqpt.GetTypeEquipement(m_commande.ContexteDonnee);
                    ligne.Quantite       = besoinEqpt.Quantite;
                    ligne.Libelle        = besoin.Libelle;
                    besoin = besoin.GetObjetInContexte(ligne.ContexteDonnee) as CBesoin;
                    besoin.AddSatisfaction(ligne, null);
                    CCustomizableItemLigneCommande item = new CCustomizableItemLigneCommande(ligne);
                    m_wndListeCommandes.AddItem(item, true);
                }
            }
        }
コード例 #3
0
        //--------------------------------------------------------------------
        protected override void m_panelDessin_DragDrop(object sender, DragEventArgs e)
        {
            HideHighlight();
            DragDropEffects eff = GetDragDropEffect(e);

            if (eff == DragDropEffects.Move && !LockEdition)
            {
                base.m_panelDessin_DragDrop(sender, e);
            }
            if (eff == DragDropEffects.Link && m_nIdBesoinLinkingSatisfaction != null && m_satisfactionEnCoursDragDrop != null)
            {
                CItemBesoin item = Items[m_nIdBesoinLinkingSatisfaction.Value] as CItemBesoin;
                if (item != null && item.Besoin != null && m_satisfactionEnCoursDragDrop.CanSatisfaire(item.Besoin))
                {
                    if (CUtilElementACout.IsSourceDe(item.Besoin, m_satisfactionEnCoursDragDrop))
                    {
                        CFormAlerte.Afficher(I.T("Can not perform requested operation. @1 is a solution of @2|20675",
                                                 item.Besoin.Libelle,
                                                 m_satisfactionEnCoursDragDrop.LibelleSatisfactionComplet), EFormAlerteType.Exclamation);
                        return;
                    }
                    if (CFormAlerte.Afficher(I.T("@1 will be considered as a solution of @2. Continue ?|20631",
                                                 m_satisfactionEnCoursDragDrop.LibelleSatisfactionComplet, item.Besoin.Libelle),
                                             EFormAlerteBoutons.OuiNon, EFormAlerteType.Question) == DialogResult.Yes)
                    {
                        CBesoin besoin = item.Besoin;
                        if (LockEdition)
                        {
                            besoin = item.Besoin;
                            besoin.BeginEdit();
                        }
                        besoin.AddSatisfaction(m_satisfactionEnCoursDragDrop, null);
                        if (LockEdition)
                        {
                            CResultAErreur result = besoin.CommitEdit();
                            if (!result)
                            {
                                CFormAlerte.Afficher(result.Erreur);
                                besoin.CancelEdit();
                            }
                        }
                        RefreshItem(item);
                        m_panelDessin.Invalidate();
                    }
                    else
                    {
                        e.Effect = DragDropEffects.None;
                    }
                }
            }
            else if (eff == DragDropEffects.Copy && m_phaseSpecifications != null && !LockEdition)
            {
                CBesoin besoinDrag = m_satisfactionEnCoursDragDrop as CBesoin;
                if (besoinDrag != null && besoinDrag.PhaseSpecifications != m_phaseSpecifications)
                {
                    CItemBesoin newItem = CreateSoluce(besoinDrag);
                    RenumerotteItems();
                    Refresh();
                }
            }
        }
コード例 #4
0
 //------------------------------------------
 private void m_picBox_DragDrop(object sender, DragEventArgs e)
 {
     CReferenceObjetDonnee[] refs = e.Data.GetData(typeof(CReferenceObjetDonnee[])) as CReferenceObjetDonnee[];
     if (refs == null)
     {
         CReferenceObjetDonnee refe = e.Data.GetData(typeof(CReferenceObjetDonnee)) as CReferenceObjetDonnee;
         if (refe != null)
         {
             refs = new CReferenceObjetDonnee[] { refe };
         }
     }
     if (refs != null)
     {
         List <CBesoin> lstBesoins = new List <CBesoin>();
         StringBuilder  blListe    = new StringBuilder();
         foreach (CReferenceObjetDonnee refO in refs)
         {
             if (typeof(CBesoin).IsAssignableFrom(refO.TypeObjet))
             {
                 CBesoin besoin = refO.GetObjet(m_satisfaction.ContexteDonnee) as CBesoin;
                 if (besoin != null)
                 {
                     if (m_satisfaction.CanSatisfaire(besoin))
                     {
                         lstBesoins.Add(besoin);
                         blListe.Append(besoin.Libelle);
                         blListe.Append(" ,");
                     }
                 }
             }
         }
         if (lstBesoins.Count > 0)
         {
             blListe.Remove(blListe.Length - 2, 2);
             if (MessageBox.Show(I.T("@1 will be considered as a solution of @2. Continue ?|20631",
                                     m_satisfaction.Libelle, blListe.ToString()), "",
                                 MessageBoxButtons.YesNo,
                                 MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 CContexteDonnee ctx = m_satisfaction.ContexteDonnee;
                 if (!m_bIsEnEdition)
                 {
                     ctx = ctx.GetContexteEdition();
                 }
                 foreach (CBesoin besoin in lstBesoins)
                 {
                     CBesoin besoinEdit = besoin.GetObjetInContexte(ctx) as CBesoin;
                     besoinEdit.AddSatisfaction(m_satisfaction, null);
                 }
                 if (!m_bIsEnEdition)
                 {
                     CResultAErreur result = ctx.CommitEdit();
                     if (!result)
                     {
                         CFormAlerte.Afficher(result.Erreur);
                         ctx.CancelEdit();
                     }
                     ctx.Dispose();
                 }
             }
         }
     }
 }