Exemplo n.º 1
0
        public void ExcepcionGuardar()
        {
            Votacion v = new Votacion();
            SerializadorXML <Votacion> ser = new SerializadorXML <Votacion>();

            ser.Guardar("", v);
        }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        serializador = new SerializadorXML <ArrayEstructura>();

        string datosSer = serializador.Serializar2StringXML(datos);

        Debug.Log(datosSer);
    }
Exemplo n.º 3
0
        private void btnDeserializarXML_Click(object sender, EventArgs e)
        {
            try
            {
                string ruta = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\Archivo-Kevin-Quevedo.xml";
                SerializadorXML <Pedidos> archivoSerializable = new SerializadorXML <Pedidos>(ruta);
                List <Pedidos>            pedidos             = archivoSerializable.Leer();

                MessageBox.Show("El archivo se deserializó de XML con exito!");
                StringBuilder sb = new StringBuilder();
                foreach (Pedidos item in pedidos)
                {
                    sb.AppendLine(item.InformacionPedido());
                }
                MessageBox.Show(sb.ToString());
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("La ruta de acceso es null.", "Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Los caracteres de la ruta, no son validos.", "Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("El archivo no existe.", "Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (DirectoryNotFoundException)
            {
                MessageBox.Show("El directorio no existe.", "Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (PathTooLongException)
            {
                MessageBox.Show("La ruta supera la longitud maxima.", "Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (IOException)
            {
                MessageBox.Show("El archivo está en uso.", "Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (NotSupportedException)
            {
                MessageBox.Show("La ruta contiene dos puntos o un formato invalido.", "Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (SecurityException)
            {
                MessageBox.Show("El usuario no posee permisos.", "Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception)
            {
                MessageBox.Show("Ocurrio un error inesperado.", "Atención!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 4
0
        public void ManejadorVoto(string senador, Votacion.EVoto voto)
        {
            if (this.groupBox2.InvokeRequired)
            {
                Votacion.Voto recall = new Votacion.Voto(this.ManejadorVoto);
                this.Invoke(recall, new object[] { senador, voto });
            }
            else
            {
                // Leo la banca del Senador actual
                PictureBox p = this.graficos.ElementAt(int.Parse(senador) - 1);
                switch (voto)
                {
                case Votacion.EVoto.Afirmativo:
                    // Sumo votantes al Label correspondiente
                    lblAfirmativo.Text = (int.Parse(lblAfirmativo.Text) + 1).ToString();
                    // Marco la banca con color Verde
                    p.BackColor = Color.Green;
                    break;

                case Votacion.EVoto.Negativo:
                    // Sumo votantes al Label correspondiente
                    lblNegativo.Text = (int.Parse(lblNegativo.Text) + 1).ToString();
                    // Marco la banca con color Rojo
                    p.BackColor = Color.Red;
                    break;

                case Votacion.EVoto.Abstencion:
                    // Sumo votantes al Label correspondiente
                    lblAbstenciones.Text = (int.Parse(lblAbstenciones.Text) + 1).ToString();
                    // Marco la banca con color Amarillo
                    p.BackColor = Color.Yellow;
                    break;
                }
                // Quito un Senador de los que un no votaron, para marcar cuando termina la votación
                int aux = int.Parse(lblEsperando.Text) - 1;
                lblEsperando.Text = aux.ToString();
                // Si finaliza la votación, muestro si Es Ley o No Es Ley
                if (aux == 0)
                {
                    MessageBox.Show((int.Parse(lblAfirmativo.Text) - int.Parse(lblNegativo.Text)) > 0 ? "Es Ley" : "No es Ley", txtLeyNombre.Text);
                    // Guardar resultados
                    SerializadorXML <Votacion> xml = new SerializadorXML <Votacion>();
                    xml.Guardar("D:\\salida.xml", this.votacion);
                    DAO db = new DAO();
                    db.Guardar(string.Empty, this.votacion);
                }
            }
        }
Exemplo n.º 5
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                string  ruta = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\Prueba.xml";
                Persona p    = new Persona(this.richTextBox1.Text, this.textBox2.Text);
                SerializadorXML <Persona> a = new SerializadorXML <Persona>(ruta);
                a.Guardar(p);
                //this.textBox1.Text = a.Leer();

                MessageBox.Show("Guardado!!");
            }
            catch (Exception)
            {
                MessageBox.Show("ERROR");
            }
        }
Exemplo n.º 6
0
 public bool SalvaNotaFiscal()
 {
     if (notaFiscal == null)
     {
         return(false);
     }
     else
     {
         SerializadorXML serial = new SerializadorXML();
         if (serial.SalvarEmXML(notaFiscal, notaFiscal.Serie + ".xml"))
         {
             ProceduresNF insereNF = new ProceduresNF();
             return(insereNF.InsereNFnoBD(notaFiscal) > 0);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 7
0
        private void rbtnXML_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog()
            {
                Filter = "*.xml|*.xml"
            };

            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                var xmls = new SerializadorXML <List <Historico> >();
                xmls.SerializarXml(Global.Historico, new FileInfo(sfd.FileName));
                MessageBox.Show("Salvo com sucesso!");
            }
            catch (Exception exception)
            {
                exception.Show();
            }
        }