public void createBalanza()
        {
            string strAccessConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=database\\" + this.databaseFileName;
            string strAccessSelect = "SELECT * FROM [Add Acumulados] INNER JOIN [CatalogoCuentasSatVendor] ON [Add Acumulados].[SUBCTA] = [CatalogoCuentasSatVendor].[NumCta]";

            DataSet myDataSet = new DataSet();
            OleDbConnection myAccessConn = null;

            try
            {
                myAccessConn = new OleDbConnection(strAccessConn);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: Failed to create a database connection. \n{0}", ex.Message);
                return;
            }

            try
            {
                myAccessConn.Open();
                OleDbCommand myAccessCommand = new OleDbCommand(strAccessSelect, myAccessConn);
                OleDbDataReader reader = myAccessCommand.ExecuteReader();
                List<SatContabilidad.Balanza.BalanzaCtas> balanzaCtas = new List<SatContabilidad.Balanza.BalanzaCtas>();

                while (reader.Read())
                {
                    SatContabilidad.Balanza.BalanzaCtas balanzaCta = new Balanza.BalanzaCtas();
                    balanzaCta.NumCta = reader["SUBCTA"].ToString().Trim();
                    balanzaCta.SaldoIni = 0;
                    balanzaCta.Debe = Decimal.Parse(reader["MOVDEB"].ToString());
                    balanzaCta.Haber = Decimal.Parse(reader["MOVHAB"].ToString());
                    balanzaCta.SaldoFin = balanzaCta.Haber - balanzaCta.Debe;
                    balanzaCtas.Add(balanzaCta);
                }

                reader.Close();
                myAccessConn.Close();

                SatContabilidad.Balanza.Balanza balanza = new Balanza.Balanza();
                balanza.TipoEnvio = "N";
                balanza.schemaLocation = "www.sat.gob.mx/esquemas/ContabilidadE/1_1/BalanzaComprobacion http://www.sat.gob.mx/esquemas/ContabilidadE/1_1/BalanzaComprobacion/BalanzaComprobacion_1_1.xsd";
                balanza.Anio = int.Parse(this.year);
                balanza.Ctas = balanzaCtas.ToArray<Balanza.BalanzaCtas>();
                Type mes = typeof(Balanza.BalanzaMes);

                balanza.Mes = (Balanza.BalanzaMes) Enum.Parse(mes, (int.Parse(this.month) - 1).ToString());
                balanza.RFC = this.rfc;

                XmlSerializer serializer = new XmlSerializer(typeof(SatContabilidad.Balanza.Balanza));
                System.IO.TextWriter writer = new System.IO.StreamWriter(this.outputPath + this.rfc + this.year + this.month + "BN.xml");

                XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
                ns.Add("BCE", "www.sat.gob.mx/esquemas/ContabilidadE/1_1/BalanzaComprobacion");
                ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");

                serializer.Serialize(writer, balanza, ns);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: Failed to retrive the required data from the Database.\n{0}", ex.Message);
                return;
            }
            finally
            {
                myAccessConn.Close();
            }
        }
        public void createBalanza()
        {
            string strAccessConn   = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=database\\" + this.databaseFileName;
            string strAccessSelect = "SELECT * FROM [Add Acumulados] INNER JOIN [CatalogoCuentasSatVendor] ON [Add Acumulados].[SUBCTA] = [CatalogoCuentasSatVendor].[NumCta]";

            DataSet         myDataSet    = new DataSet();
            OleDbConnection myAccessConn = null;

            try
            {
                myAccessConn = new OleDbConnection(strAccessConn);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: Failed to create a database connection. \n{0}", ex.Message);
                return;
            }

            try
            {
                myAccessConn.Open();
                OleDbCommand    myAccessCommand = new OleDbCommand(strAccessSelect, myAccessConn);
                OleDbDataReader reader          = myAccessCommand.ExecuteReader();
                List <SatContabilidad.Balanza.BalanzaCtas> balanzaCtas = new List <SatContabilidad.Balanza.BalanzaCtas>();

                while (reader.Read())
                {
                    SatContabilidad.Balanza.BalanzaCtas balanzaCta = new Balanza.BalanzaCtas();
                    balanzaCta.NumCta   = reader["SUBCTA"].ToString().Trim();
                    balanzaCta.SaldoIni = 0;
                    balanzaCta.Debe     = Decimal.Parse(reader["MOVDEB"].ToString());
                    balanzaCta.Haber    = Decimal.Parse(reader["MOVHAB"].ToString());
                    balanzaCta.SaldoFin = balanzaCta.Haber - balanzaCta.Debe;
                    balanzaCtas.Add(balanzaCta);
                }

                reader.Close();
                myAccessConn.Close();

                SatContabilidad.Balanza.Balanza balanza = new Balanza.Balanza();
                balanza.TipoEnvio      = "N";
                balanza.schemaLocation = "www.sat.gob.mx/esquemas/ContabilidadE/1_1/BalanzaComprobacion http://www.sat.gob.mx/esquemas/ContabilidadE/1_1/BalanzaComprobacion/BalanzaComprobacion_1_1.xsd";
                balanza.Anio           = int.Parse(this.year);
                balanza.Ctas           = balanzaCtas.ToArray <Balanza.BalanzaCtas>();
                Type mes = typeof(Balanza.BalanzaMes);

                balanza.Mes = (Balanza.BalanzaMes)Enum.Parse(mes, (int.Parse(this.month) - 1).ToString());
                balanza.RFC = this.rfc;

                XmlSerializer        serializer = new XmlSerializer(typeof(SatContabilidad.Balanza.Balanza));
                System.IO.TextWriter writer     = new System.IO.StreamWriter(this.outputPath + this.rfc + this.year + this.month + "BN.xml");

                XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
                ns.Add("BCE", "www.sat.gob.mx/esquemas/ContabilidadE/1_1/BalanzaComprobacion");
                ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");

                serializer.Serialize(writer, balanza, ns);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: Failed to retrive the required data from the Database.\n{0}", ex.Message);
                return;
            }
            finally
            {
                myAccessConn.Close();
            }
        }