Ejemplo n.º 1
0
        public List <BejermanConfig> getXml()
        {
            try
            {
                if (File.Exists(config))
                {
                    List <BejermanConfig> ListConfig = new List <BejermanConfig>();

                    XDocument Raiz            = XDocument.Load(".\\" + config, LoadOptions.None);
                    XElement  ElementBejerman = Raiz.Element("Bejerman");
                    RutaBejerman = ElementBejerman.Element("RutaExportacion").Value;
                    IEnumerable <XElement> Config = ElementBejerman.Descendants("Config");
                    foreach (XElement Parametro in Config)
                    {
                        BejermanConfig config = new BejermanConfig();
                        config.PuntodeVenta      = Parametro.Element("PuntodeVenta").Value;
                        config.PuntodeVentaElect = Parametro.Element("PuntodeVentaElect").Value;
                        config.CodigoZona        = Parametro.Element("CodigoZona").Value;
                        config.AperturaContable  = Parametro.Element("AperturaContable").Value;
                        ListConfig.Add(config);
                    }
                    return(ListConfig);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 private void BrnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         bool Validador = false;
         List <BejermanConfig> ListConfig = new List <BejermanConfig>();
         foreach (DataGridViewRow row in DGVConfig.Rows)
         {
             if (row.Cells[0].Value != null && row.Cells[1].Value != null && row.Cells[2].Value != null && row.Cells[3].Value != null)
             {
                 BejermanConfig config = new BejermanConfig();
                 config.PuntodeVenta      = string.Concat(Enumerable.Repeat("0", 4 - (row.Cells[0].Value.ToString()).Length)) + row.Cells[0].Value.ToString();
                 config.PuntodeVentaElect = string.Concat(Enumerable.Repeat("0", 4 - (row.Cells[1].Value.ToString()).Length)) + row.Cells[1].Value.ToString();
                 config.CodigoZona        = string.Concat(row.Cells[2].Value.ToString());
                 config.CodigoZona        = config.CodigoZona.PadRight(4);
                 config.AperturaContable  = string.Concat(row.Cells[3].Value.ToString());
                 config.AperturaContable  = config.AperturaContable.PadRight(4);
                 ListConfig.Add(config);
                 Validador = true;
             }
         }
         if (Validador == true)
         {
             Program.singleton.Crear(ListConfig, TxtOrigen.Text);
             MessageBox.Show("Se guardo la configuracion de manera correcta");
         }
         else
         {
             MessageBox.Show("Inserte datos");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }