Exemple #1
0
        //------------------------------------------
        void toolStripPourcentage_OnValideSaisie(object sender, EventArgs e)
        {
            CToolStripPourcentage pct = sender as CToolStripPourcentage;
            CBesoin besoin            = pct != null?pct.Tag  as CBesoin:null;

            if (besoin != null && pct.Value != null)
            {
                if (CFormAlerte.Afficher(I.T("Change repartition for '@1' uses '@2'% of '@3' cost ?|20687",
                                             besoin.LibelleComplet,
                                             pct.Value.Value.ToString("0.##"),
                                             m_satisfaction.Libelle),
                                         EFormAlerteBoutons.OuiNon,
                                         EFormAlerteType.Question) == DialogResult.Yes)
                {
                    if (!m_bIsEnEdition)
                    {
                        using (CContexteDonnee ctx = new CContexteDonnee(m_satisfaction.ContexteDonnee.IdSession, true, false))
                        {
                            besoin = besoin.GetObjetInContexte(ctx) as CBesoin;
                            CObjetDonnee satObj = m_satisfaction as CObjetDonnee;
                            if (satObj != null)
                            {
                                satObj = satObj.GetObjetInContexte(ctx);
                                ISatisfactionBesoin satInContexte = satObj as ISatisfactionBesoin;
                                CUtilSatisfaction.SetPourcentageFor(besoin, satInContexte, pct.Value.Value);
                            }
                            CResultAErreur result = ctx.SaveAll(false);
                            if (!result)
                            {
                                CFormAlerte.Afficher(result.Erreur);
                            }
                        }
                    }
                    else
                    {
                        CUtilSatisfaction.SetPourcentageFor(besoin, m_satisfaction, pct.Value.Value);
                    }
                }
            }
        }
Exemple #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);
                }
            }
        }