示例#1
0
        public List <TamanhosPreDefinidos> BuscarTamanhos()
        {
            try
            {
                List <TamanhosPreDefinidos> Lista = new List <TamanhosPreDefinidos>();

                xmlDoc.Descendants("TamanhosPreDefinidos").Select(p => new
                {
                    id      = p.Attribute("id").Value,
                    Nome    = p.Element("Nome").Value,
                    Valor   = p.Element("Valor").Value,
                    Altura  = p.Element("Altura").Value,
                    Largura = p.Element("Largura").Value
                }).ToList().ForEach(p =>
                {
                    TamanhosPreDefinidos tamanhosPreDefinidos = new TamanhosPreDefinidos();
                    tamanhosPreDefinidos.Id      = Convert.ToInt32(p.id);
                    tamanhosPreDefinidos.Nome    = p.Nome;
                    tamanhosPreDefinidos.Valor   = decimal.Parse(p.Valor);
                    tamanhosPreDefinidos.Altura  = int.Parse(p.Altura);
                    tamanhosPreDefinidos.Largura = int.Parse(p.Largura);
                    Lista.Add(tamanhosPreDefinidos);
                });

                return(Lista);
            }
            catch (Exception)
            {
                System.Windows.Forms.MessageBox.Show("Erro inesperado", "Erro", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return(null);
            }
        }
示例#2
0
 public void UpdateTamanho(TamanhosPreDefinidos tam)
 {
     try
     {
         var cliente = xmlDoc.Descendants("TamanhosPreDefinidos").Single(
             p => p.Attribute("id").Value.Equals(tam.Id.ToString()));
         cliente.SetElementValue("Nome", tam.Nome);
         cliente.SetElementValue("Valor", tam.Valor.ToString());
         cliente.SetElementValue("Altura", tam.Altura.ToString());
         cliente.SetElementValue("Largura", tam.Largura.ToString());
         xmlDoc.Save(pasta);
     }
     catch (Exception)
     {
         System.Windows.Forms.MessageBox.Show("Erro inesperado", "Erro", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
 }
示例#3
0
 public void CadastrarTamanhosPreDefinidos(TamanhosPreDefinidos tamanhos)
 {
     try
     {
         XElement emp = new XElement("TamanhosPreDefinidos",
                                     new XAttribute("id", tamanhos.Id),
                                     new XElement("Nome", tamanhos.Nome),
                                     new XElement("Valor", tamanhos.Valor.ToString()),
                                     new XElement("Altura", tamanhos.Altura.ToString()),
                                     new XElement("Largura", tamanhos.Largura.ToString()));
         xmlDoc.Root.Add(emp);
         xmlDoc.Save(pasta);
     }
     catch (Exception)
     {
         System.Windows.Forms.MessageBox.Show("Erro inesperado", "Erro", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
 }