Torna al Thread
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Me.ListView2.Items.Clear()
Me.ListView2.BeginUpdate()
Dim idlista As Integer
For idlista = 0 To Me.ListView1.Items.Count - 1
Me.ListView1.Items(idlista).Selected = True
litem = ListView2.Items.Add(Me.ListView1.SelectedItems(idlista).Text)
Sublist = litem.SubItems.Add(Me.ListView1.SelectedItems(idlista).SubItems(1).Text)
Sublist = litem.SubItems.Add("")
Sublist = litem.SubItems.Add(Me.ListView1.SelectedItems(idlista).SubItems(9).Text)
Next
My.Application.DoEvents()
REM==========================
Me.ListView2.Items.Clear()
Me.ListView2.BeginUpdate()
' Dim idlista As Integer
For idlista = 0 To Me.ListView1.Items.Count - 1
Me.ListView1.Items(idlista).Selected = True
litem = ListView2.Items.Add(Me.ListView1.SelectedItems(idlista).Text)
Sublist = litem.SubItems.Add(Me.ListView1.SelectedItems(idlista).SubItems(1).Text)
Sublist = litem.SubItems.Add("")
Sublist = litem.SubItems.Add(Me.ListView1.SelectedItems(idlista).SubItems(9).Text)
Next
Me.ListView2.EndUpdate()
My.Application.DoEvents()
For indexalb = 0 To Me.ListView2.Items.Count - 1
Me.ListView2.Items(indexalb).Selected = True
Me.ListView2.EnsureVisible(indexalb)
' My.Application.DoEvents()
Dim r As Rectangle
r = ListView2.Items(indexalb).Bounds()
r.Width = ListView2.Columns(2).Width
Me.ProgressBar1.SetBounds(333, r.Y + 20, r.Width, r.Height - 2)
Me.ProgressBar1.Visible = True
My.Application.DoEvents()
Try
ObjC59.CodAlbergo = Convert.ToInt32(Me.ListView2.SelectedItems(indexalb).Text)
ObjC59.CodiceComAlbergo = Convert.ToInt32(Me.ListView2.SelectedItems(indexalb).SubItems(3).Text)
ObjC59.DallaData = CDate(Me.MaskedTextBox1.Text)
ObjC59.AllaData = CDate(Me.MaskedTextBox2.Text)
C59Coll = Read_record.NumeroRecAllAlb(ObjC59)
For i As Integer = 0 To C59Coll.Count - 1
valmax = C59Coll.Item(i).NumeroRecord
REM Me.ListView2.SelectedItems(indexalb).SubItems(2).Text = C59Coll.Item(i).NumeroRecord
totrecordalb = C59Coll.Item(i).NumeroRecord
Next
Me.ProgressBar1.Maximum = valmax
Catch ex As Exception
MessageBox.Show("Attenzione errore interno", "Receive.Net", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Me.ProgressBar1.Visible = False
Return
End Try
Try
elaboraalberghi(Convert.ToInt32(ListView2.SelectedItems(indexalb).Text), Convert.ToInt32(ListView2.SelectedItems(indexalb).SubItems(3).Text), CDate(Me.MaskedTextBox1.Text), CDate(Me.MaskedTextBox2.Text))
Catch ex As Exception
MessageBox.Show("Attenzione impossibile procedere con la creazione dei file C59", "Receive.Net", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Me.ProgressBar1.Value = 0 : Me.ProgressBar1.Visible = False
Me.Label5.Text = "Attesa elaborazione..." : Me.Label5.Refresh()
Return
End Try
My.Application.DoEvents()
Me.ProgressBar1.Value = 0
Me.Label5.Text = "Attesa elaborazione..." : Me.Label5.Refresh()
My.Application.DoEvents()
Next
End Sub
Private Sub elaboraalberghi(ByVal codalb As Integer, ByVal codcomalb As Integer, ByVal data1 As Date, ByVal data2 As Date)
Try
REM
REM=====CREO UNA VARIBILE DI TIPO NUMERICO IN MODO TALE DA GESTIRE SOLO UNA VOLTA GLI ALBERGHI CHE HANNO MOVIMENTO
REM=====NEL PERIODO SCELTO.
Dim IndexAlbergostart As Integer = 0
REM======================================================================
val = 0 REM RESETTO LA VARIABILE DEL CALCOLO DEL VALUE DELLA PROGRESS
ObjC59.CodAlbergo = codalb
ObjC59.CodiceComAlbergo = codcomalb
ObjC59.DallaData = data1
ObjC59.AllaData = data2
C59Coll = Read_record.CaricaRecAllAlb(ObjC59)
For i As Integer = 0 To C59Coll.Count - 1
val += 1
Me.ProgressBar1.Value = val
If IndexAlbergostart = 0 Then
strcom = String.Format("{0:D3}", CInt(C59Coll.Item(i).CodiceComAlbergo)).Substring(2, 3)
stralb = String.Format("{0:D4}", CInt(C59Coll.Item(i).CodAlbergo))
strmese = Me.MaskedTextBox1.Text.Substring(3, 2)
stranno = Convert.ToString(C59Coll.Item(i).Annogestionale)
If Directory.Exists("C:\Istatc59\" & C59Coll.Item(i).NomeAlbergo) = False Then
Directory.CreateDirectory("C:\Istatc59\" & C59Coll.Item(i).NomeAlbergo)
End If
'**********************************************************************
FileOpen(1, "C:\Istatc59\" & C59Coll.Item(i).NomeAlbergo & "\" & strcom & stralb & strmese & stranno & ".Txt", OpenMode.Output)
FileOpen(2, "C:\foglio\" & strcom & stralb & strmese & stranno & ".Txt", OpenMode.Output)
nfile += 1
End If
REM PrintLine(1, "'" & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodiceRegione), 3) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodiceProvincia), 3) & LSet(Convert.ToString(C59Coll.Item(i).CodiceComAlbergo).Substring(2, 3), 3) & LSet(String.Format("{0:D4}", C59Coll.Item(i).CodAlbergo), 4) & LSet(String.Format("{0:D3}", C59Coll.Item(i).co), 3) & LSet(C59Coll.Item(i).DataElaborazione.ToShortDateString, 10) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodStato_Res), 3) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodComune), 3) & LSet(C59Coll.Item(i).Tipostato, 1) & LSet(String.Format("{0:D4}", C59Coll.Item(i).NumeroComponenti), 4) & "'")
PrintLine(1, "'" & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodiceRegione), 3) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodiceProvincia), 3) & LSet(Convert.ToString(C59Coll.Item(i).CodiceComAlbergo).Substring(2, 3), 3) & LSet(String.Format("{0:D4}", C59Coll.Item(i).CodAlbergo), 4) & LSet(Convert.ToString(C59Coll.Item(i).CodiceCategoria), 2) & LSet(C59Coll.Item(i).DataArrivo, 10) & LSet(C59Coll.Item(i).DataPartenza, 10) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodStato_Res), 3) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodComune), 3) & "'")
PrintLine(2, "'" & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodiceRegione), 3) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodiceProvincia), 3) & LSet(Convert.ToString(C59Coll.Item(i).CodiceComAlbergo).Substring(2, 3), 3) & LSet(String.Format("{0:D4}", C59Coll.Item(i).CodAlbergo), 4) & LSet(Convert.ToString(C59Coll.Item(i).CodiceCategoria), 2) & LSet(C59Coll.Item(i).DataArrivo, 10) & LSet(C59Coll.Item(i).DataPartenza, 10) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodStato_Res), 3) & LSet(String.Format("{0:D3}", C59Coll.Item(i).CodComune), 3) & "'")
Me.Label5.Text = C59Coll.Item(i).NomeAlbergo & " - " & "Elaborazione record: " & val & "/" & totrecordalb & " in corso..."
Me.Label5.Refresh()
Me.ListView2.Items(indexalb).SubItems(2).Text = val & "/" & totrecordalb
Me.ListView2.Update()
IndexAlbergostart = C59Coll.Item(i).CodAlbergo
Next
FileClose(1) : FileClose(2)
Catch ex As Exception
MessageBox.Show("Attenzione impossibile procedere con la creazione dei file C59", "Receive.Net", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Me.ProgressBar1.Value = 0 : Me.ProgressBar1.Visible = False
Me.Label5.Text = "Attesa elaborazione..." : Me.Label5.Refresh()
Return
End Try
My.Application.DoEvents()
Me.ProgressBar1.Value = 0
Me.Label5.Text = "Attesa elaborazione..." : Me.Label5.Refresh()
My.Application.DoEvents()
End Sub