コード例 #1
0
        private IEnumerable <Scheda> ReadScheda()
        {
            List <Scheda> schede      = new List <Scheda>();
            XmlElement    rootElement = (XmlElement)_xmlDocument.SelectSingleNode("Schede");

            if (rootElement == null)
            {
                throw new IOException("Invalid Format Exception");
            }

            foreach (XmlNode elemento in rootElement.ChildNodes)
            {
                if (elemento.LocalName != "Scheda")
                {
                    throw new IOException("Invalid Format Exception - Scheda non valida");
                }
                Scheda s = new Scheda(((XmlElement)elemento).GetAttribute("name"));
                foreach (XmlNode campo in elemento.ChildNodes)
                {
                    if (campo.LocalName != "Campo")
                    {
                        throw new IOException("Invalid Format Exception - Campo non trovato");
                    }
                    s.SetValore(((XmlElement)campo).GetAttribute("name"), ((XmlElement)campo).GetAttribute("valore"));
                }
                schede.Add(s);
            }

            return(schede);
        }
コード例 #2
0
 private void GeneraSchedaRecursion(ElementoTemplate e, Scheda s)
 {
     if (e is Contenitore)
     {
         foreach (ElementoTemplate figlio in ((Contenitore)e).Children)
         {
             GeneraSchedaRecursion(figlio, s);
         }
     }
     else if (e is Contenuto)
     {
         s.SetValore(e.Id, "");
     }
 }
コード例 #3
0
        protected void ModificaCampoScheda(string idScheda, string idCampo, string valore)
        {
            bool      isValid    = true;
            int       defaultInt = default(int);
            Scheda    scheda     = (from s in _schede.Keys where s.IdScheda == idScheda select s).ElementAt(0);
            Contenuto et         = GetContenutoById(_schede[scheda], idCampo);

            if (et == null)
            {
                isValid = false;
            }
            switch (et.Tipo)
            {
            case TipoValore.Numero:
                if (String.IsNullOrEmpty(valore))
                {
                    valore = defaultInt + "";
                }
                else if (!Int32.TryParse(valore, out defaultInt))
                {
                    isValid = false;
                }
                break;

            case TipoValore.Testo: break;

            default: isValid = false; break;
            }

            if (isValid)
            {
                scheda.SetValore(idCampo, valore);
                _values[GenerateId(idScheda, idCampo)][0] = valore;
            }
            _values[GenerateId(idScheda, idCampo)][1] = null;
            if (_schedaCorrente != null)
            {
                if (_schedaCorrente.IdScheda == idScheda)
                {
                    DisplayScheda();
                }
            }
            this.ColoraSchedeView(_schedeView.Nodes);
        }