Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Public Class Form1
- Private Sub btnExportar_Click(sender As Object, e As EventArgs) Handles btnExportar.Click
- Dim desde As Date = dtpDesde.Value
- Dim hasta As Date = dtpHasta.Value
- Dim dtGenerarTxt As DataTable = fGenerarTxt(desde, hasta)
- MessageBox.Show(String.Format("Desde: {0}, Hasta {1}", desde, hasta))
- End Sub
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- dtpDesde.MinDate = New Date(2003, 1, 1)
- dtpDesde.MaxDate = Date.Now
- End Sub
- Public Function fGenerarTxt(ByVal vDesde As Date, ByVal vHasta As Date) As DataTable
- 'Dim cCapaDatos As clsCapaDatos = New clsCapaDatos
- Dim dtTable As DataTable = New DataTable
- 'Try
- ' cCapaDatos.sConectarSQL()
- ' Dim sTextoSQL As String = "Tesoreria.obd_conusltar_ruc"
- ' cCapaDatos.sComandoSQL(sTextoSQL, CommandType.StoredProcedure)
- ' cCapaDatos.sParametroSQL("@min_date", DbType.Date, 10, vDesde)
- ' cCapaDatos.sParametroSQL("@max_date", DbType.Date, 10, vHasta)
- ' cCapaDatos.sAdaptadorSQL("R")
- ' dtTable = cCapaDatos.fListarTabla()
- ' Dim iNroRegistros As Integer = Convert.ToInt32(cCapaDatos.fListarTabla.DefaultView.Count)
- 'Catch ex As Exception
- ' cTempo.sMensaje(Convert.ToString(ex.Message))
- 'Finally
- ' cCapaDatos.sDesconectarSQL()
- 'End Try
- Return dtTable
- End Function
- Private Sub ExportarArchivos(ByVal dtGenerarTxt As DataTable)
- Dim cad As String = ""
- Dim maxRows As Integer = 100
- Dim contador As Integer
- Dim numArchivo As Integer = 1
- Dim ruta As String = "C:/ususario/carpeta/"
- If dtGenerarTxt.Rows.Count > 0 Then
- For i As Integer = 0 To dtGenerarTxt.Rows.Count - 1
- contador = contador + 1
- cad += dtGenerarTxt.Rows(i)("RUC").ToString & "|" & vbNewLine
- If contador = maxRows Or i = dtGenerarTxt.Rows.Count - 1 Then
- numArchivo += 1
- File.WriteAllText(ruta & "ruc_proveedor_" & dtGenerarTxt.Rows(0)("PERIODO").ToString & "_" & numArchivo & ".txt", cad)
- contador = 0
- End If
- Next
- MessageBox.Show("Se generó correctamente el archivo. ", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement