Ejemplo n.º 1
0
        //------------------------------------------
        private void m_picBox_Click(object sender, EventArgs e)
        {
            foreach (ToolStripItem item in new ArrayList(m_menuBesoins.Items))
            {
                if (item is CObjetDonneeMenuItem)
                {
                    m_menuBesoins.Items.Remove(item);
                    item.Dispose();
                }
            }
            if (m_satisfaction != null)
            {
                foreach (CBesoin besoin in m_satisfaction.BesoinsSolutionnes)
                {
                    CObjetDonneeMenuItem itemBesoin = new CObjetDonneeMenuItem(
                        besoin,
                        besoin.ObjetPourEditionElementACout,
                        besoin.LibelleResume);

                    double fPct = CUtilSatisfaction.GetPourcentageFor(besoin, m_satisfaction);
                    if (fPct < 99)
                    {
                        itemBesoin.Text = fPct.ToString("0.##") + "% " + besoin.LibelleResume;

                        CToolStripPourcentage toolStripPourcentage = new CToolStripPourcentage(fPct);
                        toolStripPourcentage.OnValideSaisie += new EventHandler(toolStripPourcentage_OnValideSaisie);
                        toolStripPourcentage.Tag             = besoin;
                        itemBesoin.DropDownItems.Add(toolStripPourcentage);

                        CObjetDonneeMenuItem itemEditBesoin = new CObjetDonneeMenuItem(
                            besoin,
                            besoin.ObjetPourEditionElementACout,
                            besoin.LibelleResume);
                        itemEditBesoin.Image = timos.Properties.Resources.PuzzleFem20;
                        itemBesoin.DropDownItems.Add(itemEditBesoin);
                    }
                    itemBesoin.Image = timos.Properties.Resources.PuzzleFem20;
                    m_menuBesoins.Items.Add(itemBesoin);
                }
            }
            if (m_menuBesoins.Items.Count > 0)
            {
                m_menuBesoins.Show(this, new Point(0, Height));
            }
        }
Ejemplo n.º 2
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);
                    }
                }
            }
        }