Torna al Thread
reportname = "report/movimenti.rpt"
Dim credentials As New TableLogOnInfo()
'Completiamo le proprietà con i nostri parametri per l'accesso a SQL
credentials.ConnectionInfo.DatabaseName = "reception"
credentials.ConnectionInfo.UserID = "sa"
credentials.ConnectionInfo.Password = "xxxxx"
credentials.ConnectionInfo.ServerName = "localhost"
'Aggiungiamo le credenziali al Report Viewer
CrystalReportViewer1.LogOnInfo.Add(credentials)
report = New ReportDocument
report.Load(Server.MapPath(reportname), OpenReportMethod.OpenReportByDefault)
Using Context As New receptionEntities
Dim Id As Integer = Session("idstruttura")
Dim query = (From m In Context.Tab_movimenti
Where m.Idstruttura = Id And m.arrivo = data
Group By codstruttura = m.Idstruttura, strprovenienza = m.Tab_comuni_nazioni.descrizione,
idtipogruppo = m.idtipogruppo, strtipogruppo = m.Tab_tipogruppo.nomegruppo, dataelaborazione = m.arrivo, movchiuso = m.movchiuso, tipo = m.Tab_comuni_nazioni.tipo, stato = "ARRIVO" Into mov = Group
Select New With {codstruttura, strprovenienza, strtipogruppo, dataelaborazione, .nmov = mov.Count, stato, .tipomov = If(tipo = "ITA", "ITALIANI", "STRANIERI")}).Concat _
(From m In Context.Tab_movimenti
Where m.Idstruttura = Id And m.partenza = data
Group By codstruttura = m.Idstruttura, strprovenienza = m.Tab_comuni_nazioni.descrizione,
idtipogruppo = m.idtipogruppo, strtipogruppo = m.Tab_tipogruppo.nomegruppo, dataelaborazione = m.partenza, movchiuso = m.movchiuso, tipo = m.Tab_comuni_nazioni.tipo, stato = "PARTENZA" Into mov = Group
Select New With {codstruttura, strprovenienza, strtipogruppo, dataelaborazione, .nmov = mov.Count, stato, .tipomov = If(tipo = "ITA", "ITALIANI", "STRANIERI")}).ToList
report.SetDataSource(query)
End Using
CrystalReportViewer1.ReportSource = report