Line 1: Imports System.Data
Line 2: Imports System.Data.OleDb
Line 3: Imports System.IO
Line 4: Imports System.Net
Line 5: Imports System.Xml
Line 6: Imports Turismo40
Line 7: Imports Turismo51
Line 8: 'Imports 'System.Net.Security
Line 9: 'Imports 'System.Security.Cryptography
Line 10: 'Imports 'System.Security.Cryptography.X509Certificates
Line 11:
Line 12:
Line 13:
Line 14:
Line 15: Public Class DataClass
Line 16:
Line 17:
Line 18:
Line 19: Dim privata As Boolean
Line 20: Dim session_giornodate As String
Line 21:
Line 22:
Line 23: 'Public Sub dammitutti()
Line 24:
Line 25: ' Dim items As Array
Line 26: ' items = System.Enum.GetName(Stato)
Line 27: ' Dim item As String
Line 28: ' For Each item In items
Line 29: ' MsgBox(item)
Line 30: ' Next
Line 31: 'End Sub
Line 32:
Line 33: Public Function EsisteStato(s As String) As Boolean
Line 34:
Line 35:
Line 36:
Line 37: Try
Line 38: Dim res As Stato = CType([Enum].Parse(GetType(Stato), s), Stato)
Line 39:
Line 40: EsisteStato = True
Line 41: Exit Function
Line 42: Catch
Line 43: EsisteStato = False
Line 44: Exit Function
Line 45:
Line 46: Finally
Line 47: 'Codice da eseguire sia che si sia verificato un errore nel
Line 48: 'blocco try sia che non ci siano stati problemi.
Line 49: End Try
Line 50:
Line 51: End Function
Line 52:
Line 53: Public Sub Turismo5(idprog As String, Nome As String, Cognome As String, persone As Integer, notti As Integer, statopren As String, datapren As String, prezzo As Double, ostello As Integer)
Line 54: Dim postitotali = DammiPostiTotaliNoTs() - 30
Line 55: Dim occupate As Integer = DammiPostiOccupatiNoTs(DateAnormal(Now.Date(), True)) \ 7 + 2
Line 56: Dim aperto As Struttura = New Struttura(Apertura.SI) With {
Line 57: .camereoccupate = occupate,
Line 58: .cameredisponibili = postitotali \ 7 - occupate,
Line 59: .lettidisponibili = postitotali - occupate
Line 60: }
Line 61:
Line 62:
Line 63: Dim giornoPrenotazione As Movimento = New Movimento(datapren)
Line 64: Dim giornoArrivo As Movimento = New Movimento(DateTime.Now)
Line 65: Dim giornoPartenza As Movimento = New Movimento(DateTime.Now.AddDays(notti))
Line 66: Dim nuova As Prenotazione = New Prenotazione(idprog, Nome, Cognome, persone, [Enum].Parse(GetType(Stato), statopren), giornoPrenotazione, giornoArrivo, giornoPartenza) With {
Line 67: .prezzo = prezzo
Line 68: }
Line 69:
Line 70: If ostello <> 2 Then
Line 71: Dim movimenti As Movimenti = New Movimenti("F00017")
Line 72: movimenti.AggiungiMovimento(giornoArrivo, aperto)
Line 73: Movimenti.Invia("KOALAHOSTELMILANO", "Zostello1!")
Line 74: Else
Line 75: Dim movimenti As Movimenti = New Movimenti("F00028")
Line 76: movimenti.AggiungiMovimento(giornoArrivo, aperto)
Line 77: Movimenti.Invia("PANDAHOSTELMILANO", "Zostello0!")
Line 78: End If
Line 79:
Line 80: End Sub
Line 81:
Line 82:
Line 83: Private Function Apici(ByVal s As String) As String
Line 84: Dim t As String
Line 85: t = s
Line 86: t = Replace(t, """", "")
Line 87: t = Replace(t, "'", "''")
Line 88: t = Replace(t, "*", "")
Line 89: t = Replace(t, "%", "")
Line 90: t = Replace(t, Chr(27), "")
Line 91:
Line 92: Apici = Replace(t, """", """""")
Line 93:
Line 94: End Function
Line 95:
Line 96: Public Function TabSessione(ByVal modalita As Integer, ByVal Campo As String, ByVal Valore As String) As String
Line 97:
Line 98: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 99: Dim strSQL As String = ""
Line 100: Dim cmd As OleDbCommand
Line 101: Dim dr As OleDbDataReader
Line 102:
Line 103: TabSessione = ""
Line 104:
Line 105: Cn.Open()
Line 106:
Line 107: If modalita Then
Line 108:
Line 109: strSQL = "SELECT Valore FROM TabSessione Where Campo='" & Apici(Campo) & "'"
Line 110:
Line 111: cmd = New OleDbCommand(strSQL, Cn)
Line 112:
Line 113: dr = cmd.ExecuteReader
Line 114:
Line 115:
Line 116: If dr.HasRows Then
Line 117: strSQL = "UPDATE TabSessione SET Valore='" & Apici(Valore) & "' "
Line 118: strSQL += " WHERE campo='" & Apici(Campo) & "'"
Line 119:
Line 120: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 121: cmd.ExecuteNonQuery()
Line 122: Else
Line 123: strSQL = "INSERT INTO TabSessione (Campo,Valore)"
Line 124: strSQL += " Values('" & Apici(Campo) & "','" & Apici(Valore) & "')"
Line 125:
Line 126: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 127: cmd.ExecuteNonQuery()
Line 128: End If
Line 129:
Line 130: TabSessione = Valore
Line 131: Else
Line 132:
Line 133: strSQL = "SELECT Valore FROM TabSessione Where Campo='" & Apici(Campo) & "'"
Line 134:
Line 135: cmd = New OleDbCommand(strSQL, Cn)
Line 136:
Line 137: dr = cmd.ExecuteReader
Line 138:
Line 139:
Line 140: If dr.HasRows Then
Line 141: dr.Read()
Line 142:
Line 143: TabSessione = dr("Valore")
Line 144:
Line 145: End If
Line 146:
Line 147: dr.Close()
Line 148:
Line 149:
Line 150: End If
Line 151:
Line 152: Cn.Close()
Line 153:
Line 154:
Line 155:
Line 156: End Function
Line 157: Protected Function DammiTipoStanzaSuo(ByVal ts As String, ByVal h As Integer) As String
Line 158:
Line 159: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 160: Dim strSQL As String = ""
Line 161: Dim cmd As OleDbCommand
Line 162: Dim dr As OleDbDataReader
Line 163:
Line 164: Cn.Open()
Line 165:
Line 166: DammiTipoStanzaSuo = ""
Line 167:
Line 168: strSQL = "SELECT C.tipoimport FROM TipiStanzaChannel C WHERE C.hostel=" & h & " AND C.codice='" & ts & "'"
Line 169:
Line 170: cmd = New OleDbCommand(strSQL, Cn)
Line 171:
Line 172: dr = cmd.ExecuteReader
Line 173:
Line 174: If dr.HasRows Then
Line 175: dr.Read()
Line 176: DammiTipoStanzaSuo = Trim(dr("tipoimport") & "")
Line 177: End If
Line 178:
Line 179: dr.Close()
Line 180: Cn.Close()
Line 181:
Line 182:
Line 183: End Function
Line 184:
Line 185: Public Function DammiStatoSuo(ByVal s As String) As String
Line 186:
Line 187: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 188: Dim strSQL As String = ""
Line 189: Dim cmd As OleDbCommand
Line 190: Dim dr As OleDbDataReader
Line 191:
Line 192: Cn.Open()
Line 193:
Line 194: DammiStatoSuo = ""
Line 195:
Line 196: strSQL = "SELECT StatoSuo FROM TraduciStato WHERE StatoMio='" & Replace(s, "'", "''") & "'"
Line 197:
Line 198: cmd = New OleDbCommand(strSQL, Cn)
Line 199:
Line 200: dr = cmd.ExecuteReader
Line 201:
Line 202: If dr.HasRows Then
Line 203: dr.Read()
Line 204: DammiStatoSuo = Trim(dr("StatoSuo") & "")
Line 205: End If
Line 206:
Line 207: dr.Close()
Line 208: Cn.Close()
Line 209:
Line 210: End Function
Line 211:
Line 212: Public Sub ScriviStatoSuo(ByVal mio As String, ByVal suo As String)
Line 213: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 214: Dim strSQL As String = ""
Line 215: Dim cmd As OleDbCommand
Line 216:
Line 217: Cn.Open()
Line 218:
Line 219: strSQL = "INSERT INTO TraduciStato (StatoMio,StatoSuo) VALUES("
Line 220: strSQL += "'" & mio & "','" & suo & "')"
Line 221:
Line 222: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 223: cmd.ExecuteNonQuery()
Line 224:
Line 225: Cn.Close()
Line 226:
Line 227: End Sub
Line 228:
Line 229:
Line 230: Public Function DammiTipoStanzaOcto(ByVal ts As String, ByVal h As Integer, ByVal tornaocto As Boolean) As String
Line 231:
Line 232: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 233: Dim strSQL As String = ""
Line 234: Dim cmd As OleDbCommand
Line 235: Dim dr As OleDbDataReader
Line 236:
Line 237: Cn.Open()
Line 238:
Line 239: DammiTipoStanzaOcto = ""
Line 240:
Line 241: If Not tornaocto Then
Line 242: strSQL = "SELECT C.codice FROM TipiStanzaChannel C WHERE C.hostel=" & h & " AND C.octocodice='" & ts & "'"
Line 243:
Line 244: cmd = New OleDbCommand(strSQL, Cn)
Line 245:
Line 246: dr = cmd.ExecuteReader
Line 247:
Line 248: If dr.HasRows Then
Line 249: dr.Read()
Line 250: DammiTipoStanzaOcto = Trim(dr("codice") & "")
Line 251: End If
Line 252: Else
Line 253: strSQL = "SELECT C.octocodice FROM TipiStanzaChannel C WHERE C.hostel=" & h & " AND C.codice='" & ts & "'"
Line 254:
Line 255: cmd = New OleDbCommand(strSQL, Cn)
Line 256:
Line 257: dr = cmd.ExecuteReader
Line 258:
Line 259: If dr.HasRows Then
Line 260: dr.Read()
Line 261: DammiTipoStanzaOcto = Trim(dr("octocodice") & "")
Line 262: End If
Line 263: End If
Line 264:
Line 265: dr.Close()
Line 266: Cn.Close()
Line 267:
Line 268: End Function
Line 269:
Line 270: Public Function DammiIdStrutturaOcto(ByVal h As Integer, ByVal ts As String, ByVal tornaocto As Boolean) As String
Line 271:
Line 272: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 273: Dim strSQL As String = ""
Line 274: Dim cmd As OleDbCommand
Line 275: Dim dr As OleDbDataReader
Line 276:
Line 277: Cn.Open()
Line 278:
Line 279: DammiIdStrutturaOcto = ""
Line 280:
Line 281: If Not tornaocto Then
Line 282: strSQL = "SELECT C.codice FROM TipiStanzaChannel C WHERE C.hostel=" & h & " AND C.octocodice='" & ts & "'"
Line 283:
Line 284: cmd = New OleDbCommand(strSQL, Cn)
Line 285:
Line 286: dr = cmd.ExecuteReader
Line 287:
Line 288: If dr.HasRows Then
Line 289: dr.Read()
Line 290: DammiIdStrutturaOcto = Trim(dr("codice") & "")
Line 291: End If
Line 292: Else
Line 293: strSQL = "SELECT C.octocodice FROM TipiStanzaChannel C WHERE C.hostel=" & h & " AND C.codice='" & ts & "'"
Line 294:
Line 295: cmd = New OleDbCommand(strSQL, Cn)
Line 296:
Line 297: dr = cmd.ExecuteReader
Line 298:
Line 299: If dr.HasRows Then
Line 300: dr.Read()
Line 301: DammiIdStrutturaOcto = Trim(dr("octocodice") & "")
Line 302: End If
Line 303: End If
Line 304:
Line 305: dr.Close()
Line 306: Cn.Close()
Line 307:
Line 308: End Function
Line 309:
Line 310: Protected Function DammiSePrivata(ByVal ts As String) As Boolean
Line 311:
Line 312: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 313: Dim strSQL As String = ""
Line 314: Dim cmd As OleDbCommand
Line 315: Dim dr As OleDbDataReader
Line 316:
Line 317: Cn.Open()
Line 318:
Line 319: DammiSePrivata = False
Line 320:
Line 321: strSQL = "SELECT T.privata FROM Tipistanza T WHERE T.codice='" & ts & "'"
Line 322:
Line 323: cmd = New OleDbCommand(strSQL, Cn)
Line 324:
Line 325: dr = cmd.ExecuteReader
Line 326:
Line 327: If dr.HasRows Then
Line 328: dr.Read()
Line 329: DammiSePrivata = dr("privata")
Line 330: End If
Line 331:
Line 332: dr.Close()
Line 333: Cn.Close()
Line 334:
Line 335: End Function
Line 336:
Line 337: Protected Function DammiSconto(ByVal DataX As Long) As Single
Line 338:
Line 339: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 340: Dim strSQL As String = ""
Line 341: Dim cmd As OleDbCommand
Line 342: Dim dr As OleDbDataReader
Line 343:
Line 344: Cn.Open()
Line 345:
Line 346: DammiSconto = 0
Line 347:
Line 348: strSQL = "SELECT Discountval FROM Discounts WHERE DateFrom <=" & DataX & " AND DateTo >=" & DataX & " AND Active=True"
Line 349:
Line 350: cmd = New OleDbCommand(strSQL, Cn)
Line 351:
Line 352: dr = cmd.ExecuteReader
Line 353:
Line 354: If dr.HasRows Then
Line 355: dr.Read()
Line 356: DammiSconto = dr("Discountval")
Line 357: End If
Line 358:
Line 359: dr.Close()
Line 360: Cn.Close()
Line 361:
Line 362: End Function
Line 363:
Line 364: Public Function AggiornaPrezziEDisponibilita(ByVal ts As String, ByVal DataX As String, ByVal Prezzo As String, ByVal PrezzoWe As String, ByVal bedmargin As Integer, ByVal h As Integer) As String
Line 365:
Line 366:
Line 367:
Line 368: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 369: Dim strSQL As String = ""
Line 370: Dim cmd As OleDbCommand
Line 371:
Line 372: Dim myFunc As New DataClass
Line 373: Dim ret As String = ""
Line 374: Dim prezzomod As Double = 0
Line 375: Dim liberi As Integer = 0
Line 376:
Line 377: AggiornaPrezziEDisponibilita = ""
Line 378:
Line 379: Dim g As Integer = 0
Line 380: Dim m As Integer = 0
Line 381: Dim a As Integer = 0
Line 382:
Line 383: g = Day(DataX)
Line 384: m = Month(DataX)
Line 385: a = Year(DataX)
Line 386:
Line 387: Dim esito As String = ""
Line 388:
Line 389: Cn.Open()
Line 390:
Line 391:
Line 392: If Not Noavaibility(ts, DateAnormal(DataX, True)) Then
Line 393:
Line 394: Dim postitot As Integer = myFunc.DammiPostiTotali(ts)
Line 395:
Line 396: Dim occupati As Integer = myFunc.DammiPostiOccupati(ts, DateAnormal(DataX, True))
Line 397:
Line 398: liberi = postitot - occupati - bedmargin
Line 399:
Line 400: 'If dr("codice") = "1swc" And h = 2 Then Stop
Line 401:
Line 402: If liberi < 0 Then liberi = 0
Line 403:
Line 404: If Prezzo <> "" Then
Line 405:
Line 406: strSQL = "DELETE FROM DailyRates WHERE TipoStanza='" & ts & "' AND Giorno=" & Day(CDate(DataX)) & " AND Mese=" & Month(DataX)
Line 407:
Line 408: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 409: cmd.ExecuteNonQuery()
Line 410:
Line 411: strSQL = "INSERT INTO DailyRates(TipoStanza,Giorno,Mese,Prezzo,prezzowe,giornoanorm,Manual) VALUES("
Line 412: strSQL += "'" & ts & "'," & g & "," & m & "," & Replace(Replace(Prezzo, ".", ""), ",", ".") & "," & Replace(Replace(PrezzoWe, ".", ""), ",", ".") & "," & a & Format(m, "00") & Format(g, "00") & ",True)"
Line 413:
Line 414:
Line 415:
Line 416: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 417: cmd.ExecuteNonQuery()
Line 418:
Line 419: If Weekday(DataX) = vbFriday Or Weekday(DataX) = vbSaturday Then
Line 420: prezzomod = PrezzoWe
Line 421: Else
Line 422: prezzomod = Prezzo
Line 423: End If
Line 424: Else
Line 425: prezzomod = myFunc.DammiPrezzoGiusto(ts, DammiSePrivata(ts), DateAnormal(DataX, True))
Line 426: End If
Line 427:
Line 428: Dim giornomod As String = Format(a, "00") & "-" & Format(m, "00") & "-" & Format(g, "00")
Line 429: ret = myFunc.AggiornaDispOctoXML(ts, DateAnormal(giornomod, True), prezzomod, IIf(DammiSePrivata(ts), Int(liberi / 2), liberi), CInt(bedmargin), h)
Line 430: esito = esito & ret & g & "/" & m & " " & prezzomod & " " & ts & " " & "<br>"
Line 431:
Line 432: End If
Line 433:
Line 434:
Line 435: Cn.Close()
Line 436:
Line 437: AggiornaPrezziEDisponibilita = esito
Line 438:
Line 439:
Line 440: End Function
Line 441:
Line 442:
Line 443: Public Function AggiornaDispOctoXML(ByVal t As String, ByVal d As String, ByVal p As Double, ByVal n As String, ByVal bedmargin As Integer, ByVal h As Integer) As String
Line 444:
Line 445: AggiornaDispOctoXML = ""
Line 446:
Line 447: Dim strp As String = ""
Line 448: Dim strn As String = ""
Line 449:
Line 450: If p = 0 Then 'prezzo
Line 451: strp = ""
Line 452: Else
Line 453: strp = p
Line 454: End If
Line 455:
Line 456: If n < 0 Then 'avail
Line 457:
Line 458: strn = 0
Line 459: Else
Line 460: strn = n
Line 461: End If
Line 462:
Line 463:
Line 464: strp = Replace(strp, ",", ".")
Line 465:
Line 466: 'AggiornaDispOctoXML = "OK"
Line 467: 'Exit Function
Line 468:
Line 469: Dim req As System.Net.WebRequest = Nothing
Line 470: Dim rsp As System.Net.WebResponse = Nothing
Line 471: Dim str As String = ""
Line 472: Dim str2 As String = ""
Line 473: Dim sr As StreamReader
Line 474:
Line 475: Dim xlmmodelzebra As String = ""
Line 476: Dim xlmmodelkoala As String = ""
Line 477: Dim xlmmodelpanda As String = ""
Line 478: Dim xmlmodel As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf
Line 479: xmlmodel += "<SetAllocation>" & vbCrLf
Line 480: xmlmodel += "<Auth>" & vbCrLf
Line 481: xmlmodel += "<ApiKey>ec590e33ac077d1c792133a0db003dbe</ApiKey>" & vbCrLf
Line 482: xmlmodel += "<PropertyId>" & DammiIdOstello(h, True) & "</PropertyId>" & vbCrLf
Line 483: xmlmodel += "</Auth>" & vbCrLf
Line 484:
Line 485: xmlmodel += "<UpdateMethod>bulk</UpdateMethod>" & vbCrLf
Line 486: xmlmodel += "<NoUpdateMapRoom></NoUpdateMapRoom>" & vbCrLf
Line 487: xmlmodel += "<Channels>" & vbCrLf
Line 488: xmlmodel += "<Channel>0</Channel>" & vbCrLf
Line 489: xmlmodel += "</Channels>" & vbCrLf
Line 490: xmlmodel += "<DateRange>" & vbCrLf
Line 491:
Line 492: xmlmodel += "<StartDate>" & Format(CDate(DateAnormal(d, False)), "yyyy-MM-dd") & "</StartDate>" & vbCrLf
Line 493: xmlmodel += "<EndDate>" & Format(CDate(DateAnormal(d, False)), "yyyy-MM-dd") & "</EndDate>" & vbCrLf
Line 494:
Line 495: xmlmodel += "</DateRange>" & vbCrLf
Line 496:
Line 497:
Line 498: xmlmodel += "<Allocations>" & vbCrLf
Line 499: xmlmodel += "<Allocation>" & vbCrLf
Line 500: xmlmodel += "<RoomTypeId>" & DammiTipoStanzaOcto(t, h, True) & "</RoomTypeId>" & vbCrLf
Line 501: xmlmodel += "<Units>" & strn & "</Units>" & vbCrLf
Line 502: xmlmodel += "<Min></Min>" & vbCrLf
Line 503: xmlmodel += "<Cta></Cta>" & vbCrLf
Line 504: xmlmodel += "<Price>" & strp & "</Price>" & vbCrLf
Line 505:
Line 506: xmlmodel += "</Allocation>" & vbCrLf
Line 507: xmlmodel += "</Allocations>" & vbCrLf
Line 508: xmlmodel += "</SetAllocation>" & vbCrLf
Line 509:
Line 510:
Line 511:
Line 512:
Line 513: If h <> 1 Or (h = 1 And t <> "2dwc" And t <> "2twc") Then
Line 514:
Line 515: Try
Line 516:
Line 517: ServicePointManager.Expect100Continue = True
Line 518: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Line 519:
Line 520:
Line 521: req = System.Net.WebRequest.Create("https://api.octorate.com/api/live/callApi.php?method=UpdateAvailbb")
Line 522:
Line 523: req.Method = "POST"
Line 524: req.ContentType = "application/x-www-form-urlencoded; charset=utf-8"
Line 525: Dim writer As New System.IO.StreamWriter(req.GetRequestStream())
Line 526: xlmmodelkoala = "xml=" & xmlmodel
Line 527:
Line 528: writer.WriteLine(xlmmodelkoala)
Line 529: writer.Close()
Line 530:
Line 531:
Line 532: rsp = req.GetResponse()
Line 533:
Line 534: sr = New StreamReader(rsp.GetResponseStream)
Line 535: str = sr.ReadToEnd.Trim
Line 536: sr.Close()
Line 537:
Line 538: If InStr(str, "Successfully updated") <> 0 Then
Line 539: AggiornaDispOctoXML = "OK "
Line 540:
Line 541: 'ScriviLog2("Aggiornato " & h & " " & t & " " & d & " " & strp)
Line 542: Else
Line 543: AggiornaDispOctoXML = "ERR"
Line 544: 'ScriviLog2("ERRORE IMPORT " & h & " " & t & " " & d & " " & Replace(strp, "'", "") & " " & Replace(Left(str, 150), "'", ""))
Line 545:
Line 546: End If
Line 547:
Line 548:
Line 549:
Line 550:
Line 551: Catch
Line 552: If Err.Description <> "" Then
Line 553: ScriviLog2(Err.Description)
Line 554: End If
Line 555:
Line 556:
Line 557:
Line 558: Throw
Line 559:
Line 560: Finally
Line 561: If Err.Description <> "" Then
Line 562: ScriviLog2(Err.Description)
Line 563: End If
Line 564:
Line 565: If req IsNot Nothing Then
Line 566: 'req.GetRequestStream().Close()
Line 567: End If
Line 568: If rsp IsNot Nothing Then
Line 569: rsp.GetResponseStream().Close()
Line 570: End If
Line 571: End Try
Line 572: Else
Line 573: AggiornaDispOctoXML = "SKIP"
Line 574: End If
Line 575:
Line 576:
Line 577:
Line 578:
Line 579: 'panda---------------------------------------------------------------------------
Line 580:
Line 581: End Function
Line 582:
Line 583: Public Function GetBookings(ByVal modification As Boolean, ByVal h As Integer, ByVal sessione As String, ByVal cavallo As Boolean, ByVal No_update As Boolean, ByVal bedmargin As Integer) As String
Line 584:
Line 585: 'ServicePointManager.Expect100Continue = True
Line 586: 'ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls.
Line 587:
Line 588: GetBookings = ""
Line 589:
Line 590: Dim req As System.Net.WebRequest = Nothing
Line 591: Dim rsp As System.Net.WebResponse = Nothing
Line 592: Dim str As String = ""
Line 593: Dim sr As StreamReader
Line 594: Dim enddate As String = Format(Now.Date(), "yyyy-MM-dd")
Line 595:
Line 596: Dim startdate As String = ""
Line 597: If cavallo Then
Line 598: startdate = Format(DateAdd(DateInterval.Day, -1, Now.Date()), "yyyy-MM-dd")
Line 599: Else
Line 600: startdate = Format(Now.Date(), "yyyy-MM-dd")
Line 601: End If
Line 602:
Line 603: Dim xlmmodelkoala As String = ""
Line 604: Dim xmlmodel As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf
Line 605: xmlmodel += "<GetBookings>" & vbCrLf
Line 606: xmlmodel += "<Auth>" & vbCrLf
Line 607: xmlmodel += "<ApiKey>ec590e33ac077d1c792133a0db003dbe</ApiKey>" & vbCrLf
Line 608: xmlmodel += "<PropertyId>" & DammiIdOstello(h, True) & "</PropertyId>" & vbCrLf
Line 609: xmlmodel += "</Auth>" & vbCrLf
Line 610: 'Format(CDate(DateAnormal(d, False)), "yyyy-MM-dd")
Line 611: xmlmodel += "<ArrivalStartDate></ArrivalStartDate>" & vbCrLf
Line 612: xmlmodel += "<ArrivalEndDate></ArrivalEndDate>" & vbCrLf
Line 613:
Line 614: If modification Then
Line 615: xmlmodel += "<CreationStartDate></CreationStartDate>"
Line 616: xmlmodel += "<CreationEndDate></CreationEndDate>"
Line 617: xmlmodel += "<ModificationStartDate>" & startdate & "</ModificationStartDate>"
Line 618: xmlmodel += "<ModificationEndDate>" & enddate & "</ModificationEndDate>"
Line 619: Else
Line 620: xmlmodel += "<CreationStartDate>" & startdate & "</CreationStartDate>"
Line 621: xmlmodel += "<CreationEndDate>" & enddate & "</CreationEndDate>"
Line 622: xmlmodel += "<ModificationStartDate></ModificationStartDate>"
Line 623: xmlmodel += "<ModificationEndDate></ModificationEndDate>"
Line 624:
Line 625: End If
Line 626:
Line 627: xmlmodel += "<ReservationId></ReservationId>"
Line 628: xmlmodel += "<NotNotifiedResa>nonotify</NotNotifiedResa>"
Line 629: xmlmodel += "<Checkin></Checkin>"
Line 630: xmlmodel += "</GetBookings>"
Line 631:
Line 632:
Line 633:
Line 634: Try
Line 635: 'ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType)
Line 636: 'ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
Line 637: 'ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Line 638:
Line 639: 'ServicePointManager.ServerCertificateValidationCallback = AddressOf CertificateValidationCallBack
Line 640:
Line 641: ServicePointManager.Expect100Continue = True
Line 642: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Line 643:
Line 644: req = System.Net.WebRequest.Create("https://api.octorate.com/api/live/callApi.php?method=GetBookings") 'https://api.octorate.com/api/live/callApi.php?method=GetBookings
Line 645: req.Method = "POST"
Line 646: req.ContentType = "application/x-www-form-urlencoded; charset=utf-8"
Line 647: Dim writer As New System.IO.StreamWriter(req.GetRequestStream())
Line 648: xlmmodelkoala = "xml=" & xmlmodel
Line 649:
Line 650: writer.WriteLine(xlmmodelkoala)
Line 651: writer.Close()
Line 652:
Line 653: 'ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CertificateValidationCallBack)
Line 654:
Line 655:
Line 656: 'ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType)
Line 657:
Line 658:
Line 659:
Line 660: rsp = req.GetResponse()
Line 661:
Line 662: sr = New StreamReader(rsp.GetResponseStream)
Line 663: str = sr.ReadToEnd.Trim
Line 664: sr.Close()
Line 665:
Line 666: If InStr(str, "Success") <> 0 Then
Line 667: GetBookings = "OK"
Line 668: If IsValidXML(str) Then
Line 669: ElaboraBookings(modification, str, h, sessione, No_update, bedmargin)
Line 670: Else
Line 671: GetBookings = "INVALID XML"
Line 672: End If
Line 673:
Line 674: Else
Line 675: GetBookings = "ERR"
Line 676:
Line 677: End If
Line 678: Catch
Line 679: Throw
Line 680:
Line 681: Finally
Line 682: If req IsNot Nothing Then
Line 683: 'req.GetRequestStream().Close()
Line 684: End If
Line 685: If rsp IsNot Nothing Then
Line 686: rsp.GetResponseStream().Close()
Line 687: End If
Line 688: End Try
Line 689:
Line 690:
Line 691:
Line 692: End Function
Line 693:
Line 694: Function IsValidXML(ByVal xmlStr As String) As Boolean
Line 695: Try
Line 696: If Not String.IsNullOrEmpty(xmlStr) Then
Line 697: Dim xmlDoc As New System.Xml.XmlDocument()
Line 698: xmlDoc.LoadXml(xmlStr)
Line 699: Return True
Line 700: Else
Line 701: Return False
Line 702: End If
Line 703: Catch generatedExceptionName As System.Xml.XmlException
Line 704: Return False
Line 705: End Try
Line 706: End Function
Line 707:
Line 708: 'Private Shared Function CertificateValidationCallBack(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
Line 709: ' Return True
Line 710: 'End Function
Line 711:
Line 712: Protected Function MarkNotify(ByVal str As String, ByVal h As Integer) As String
Line 713:
Line 714: MarkNotify = ""
Line 715:
Line 716: Dim req As System.Net.WebRequest = Nothing
Line 717: Dim rsp As System.Net.WebResponse = Nothing
Line 718: Dim sr As StreamReader
Line 719: Dim xlmmodelkoala As String = ""
Line 720:
Line 721: Dim xmlmodel As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf
Line 722: xmlmodel += "<MarkNotified>" & vbCrLf
Line 723: xmlmodel += "<Auth>" & vbCrLf
Line 724: xmlmodel += "<ApiKey>ec590e33ac077d1c792133a0db003dbe</ApiKey>" & vbCrLf
Line 725: xmlmodel += "<PropertyId>" & DammiIdOstello(h, True) & "</PropertyId>" & vbCrLf
Line 726: xmlmodel += "</Auth>" & vbCrLf
Line 727: xmlmodel += "<Ids>" & str & "</Ids>" & vbCrLf
Line 728: xmlmodel += "</MarkNotified>" & vbCrLf
Line 729:
Line 730: Try
Line 731:
Line 732: req = System.Net.WebRequest.Create("https://api.octorate.com/api/live/callApi.php?method=MarkNotified")
Line 733: req.Method = "POST"
Line 734: req.ContentType = "application/x-www-form-urlencoded; charset=utf-8"
Line 735: Dim writer As New System.IO.StreamWriter(req.GetRequestStream())
Line 736: xlmmodelkoala = "xml=" & xmlmodel
Line 737:
Line 738: writer.WriteLine(xlmmodelkoala)
Line 739: writer.Close()
Line 740:
Line 741:
Line 742: 'ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType)
Line 743: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Line 744:
Line 745: rsp = req.GetResponse()
Line 746:
Line 747: sr = New StreamReader(rsp.GetResponseStream)
Line 748: str = sr.ReadToEnd.Trim
Line 749: sr.Close()
Line 750:
Line 751: If InStr(str, "Successfully") <> 0 Then
Line 752: MarkNotify = "OK"
Line 753: Else
Line 754: MarkNotify = "ERR"
Line 755:
Line 756: End If
Line 757:
Line 758: Catch
Line 759: Throw
Line 760: Finally
Line 761: If req IsNot Nothing Then
Line 762: req.GetRequestStream().Close()
Line 763: End If
Line 764: If rsp IsNot Nothing Then
Line 765: rsp.GetResponseStream().Close()
Line 766: End If
Line 767: End Try
Line 768:
Line 769: End Function
Line 770: Protected Function DammiNazione(ByVal naz As String) As String
Line 771:
Line 772: Dim s As String = ""
Line 773: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 774: Dim strSQL As String = ""
Line 775: Dim cmd As OleDbCommand
Line 776: Dim dr As OleDbDataReader
Line 777:
Line 778: Cn.Open()
Line 779:
Line 780: DammiNazione = naz
Line 781:
Line 782: strSQL = "SELECT descrizione from nazioni Where LCASE(codice)='" & LCase(Apici(naz)) & "'"
Line 783:
Line 784: cmd = New OleDbCommand(strSQL, Cn)
Line 785:
Line 786: dr = cmd.ExecuteReader
Line 787:
Line 788: If dr.HasRows Then
Line 789: dr.Read()
Line 790:
Line 791: DammiNazione = dr("descrizione")
Line 792: End If
Line 793:
Line 794: dr.Close()
Line 795: Cn.Close()
Line 796:
Line 797: End Function
Line 798:
Line 799: Protected Function ElaboraBookings(ByVal modifica As Boolean, ByVal s As String, ByVal h As Integer, ByVal sessione As String, ByVal No_update As Boolean, ByVal bedmargin As Integer) As String
Line 800:
Line 801:
Line 802: 'Dim ConfirmationNumber As String = Request("ConfirmationNumber")
Line 803: Dim Status As String = "" 'Request("Status")
Line 804: 'Dim RefHotel As String = Request("RefHotel")
Line 805: 'Dim idHostel As Integer = 0
Line 806: Dim NumMsg As String = "" 'Request("NumMsg")
Line 807: Dim GroupId As String = "" 'Request("GroupId")
Line 808: Dim LastName As String = ""
Line 809: Dim FirstName As String = ""
Line 810: 'Session("nameprenot") = FirstName & " " & LastName
Line 811: Dim OriginCountry As String = "" 'DammiNazione(Request("OriginCountry"))
Line 812: Dim PhoneNumber As String = ""
Line 813: 'Session("telprenot") = PhoneNumber
Line 814: Dim EmailPren As String = ""
Line 815: Dim CheckIn As String = ""
Line 816: 'Dim ExpectedArrivalTime As String = Request("ExpectedArrivalTime")
Line 817: Dim NbAdults As Integer = 0
Line 818: Dim Pax As Integer = 0
Line 819:
Line 820: Dim NbNights As String
Line 821: Dim RoomType As String = ""
Line 822: Dim ResId As String = ""
Line 823: Dim RoomRefundable As String = ""
Line 824: Dim BbliverateId As String = ""
Line 825: Dim RefIdsss As String = ""
Line 826: Dim RoomRate As String = "" 'Request("RoomRate")
Line 827: Dim RoomTypeNameExt As String = ""
Line 828: 'Session("TotalaAmount") = RoomRate
Line 829: Dim Comment As String = "" 'Request("Comment")
Line 830: Dim BookingOrigin As String = ""
Line 831: 'Session("sitodesc") = BookingOrigin
Line 832: 'Dim CreditCardNumber As String = Request("CreditCardNumber")
Line 833: 'Dim CreditCardExpiry As String = Request("CreditCardExpiry")
Line 834: 'Dim NoModif As Boolean = False
Line 835: 'Dim MyFunc As New DataClass
Line 836: 'Dim ret As String = ""
Line 837:
Line 838:
Line 839: 'idHostel = MyFunc.DammiIdDescOstello(RefHotel, True)
Line 840: 'RoomType = DammiTipoStanza(RoomType, idHostel)
Line 841:
Line 842: 'Session("tipostanza") = RoomType
Line 843:
Line 844: Dim lastcampo As String = ""
Line 845: Dim lastvalue As String = ""
Line 846: Dim PaxVal As Integer = 0
Line 847:
Line 848: Dim xmlString As String = Replace(s, "&", "&")
Line 849: Using reader As XmlReader = XmlReader.Create(New StringReader(xmlString))
Line 850: ' Parse the file and display each of the nodes.
Line 851: While reader.Read()
Line 852: Select Case reader.NodeType
Line 853: Case XmlNodeType.Element
Line 854: lastcampo = reader.Name
Line 855: 'If reader.Name = "Rooms" Then
Line 856: ' NbAdults = 0
Line 857: 'End If
Line 858: 'If reader.Name = "Room" Then
Line 859: ' NbAdults += 1
Line 860: 'End If
Line 861: Case XmlNodeType.Text
Line 862: lastvalue = reader.Value
Line 863: Case XmlNodeType.XmlDeclaration
Line 864: Case XmlNodeType.ProcessingInstruction
Line 865:
Line 866: Case XmlNodeType.Comment
Line 867:
Line 868: Case XmlNodeType.EndElement
Line 869: If reader.Name = "Booking" Then
Line 870:
Line 871: If NbAdults > Pax Then
Line 872:
Line 873: Else
Line 874: NbAdults = Pax
Line 875: End If
Line 876:
Line 877: If PaxVal > NbAdults Then NbAdults = PaxVal
Line 878:
Line 879: ImportBooking(ResId, Status, BbliverateId, LastName, FirstName, OriginCountry, PhoneNumber, EmailPren, CheckIn, NbAdults, NbNights, RoomType, RoomRate, Comment, BookingOrigin, NumMsg, GroupId, h, RoomRefundable, sessione, RoomTypeNameExt, No_update, bedmargin)
Line 880: RefIdsss = RefIdsss & "," & ResId
Line 881:
Line 882: Status = ""
Line 883: FirstName = ""
Line 884: LastName = ""
Line 885: EmailPren = ""
Line 886: CheckIn = ""
Line 887: OriginCountry = ""
Line 888: PhoneNumber = ""
Line 889: NbNights = 0
Line 890: NbAdults = 0
Line 891: Pax = 0
Line 892: RoomType = ""
Line 893: RoomRefundable = ""
Line 894: BookingOrigin = ""
Line 895: Comment = ""
Line 896: ResId = ""
Line 897: BbliverateId = 0
Line 898: RoomRate = 0
Line 899: RoomTypeNameExt = ""
Line 900: End If
Line 901: If reader.Name = "GetBookingsResponse" Then
Line 902: SalvaXML(xmlString)
Line 903: RefIdsss = Mid(RefIdsss, 2)
Line 904: MarkNotify(RefIdsss, h)
Line 905: End If
Line 906:
Line 907: Case XmlNodeType.CDATA
Line 908: lastvalue = reader.Value
Line 909: End Select
Line 910:
Line 911: If reader.NodeType = XmlNodeType.Text Or reader.NodeType = XmlNodeType.CDATA Then
Line 912: Select Case lastcampo
Line 913: Case "FirstName"
Line 914: FirstName = lastvalue
Line 915: Case "LastName"
Line 916: LastName = lastvalue
Line 917: If LastName = "Gunji" Then Stop
Line 918: Case "CustomerFName"
Line 919: If InStr(lastvalue, " ") <> 0 Then
Line 920: FirstName = Trim(Left(lastvalue, InStr(lastvalue, " ") - 1))
Line 921: LastName = Trim(Mid(lastvalue, InStr(lastvalue, " ")))
Line 922: End If
Line 923: Case "CustomerEmail"
Line 924: EmailPren = lastvalue
Line 925: Case "StartDate"
Line 926: CheckIn = lastvalue
Line 927: Case "EndDate"
Line 928: NbNights = DateDiff(DateInterval.Day, CDate(CheckIn), CDate(lastvalue))
Line 929: 'Case "Status"
Line 930: 'Case "RefHotel"
Line 931: 'Case "NumMsg"
Line 932: 'Case "GroupId"
Line 933: Case "CustomerNationality"
Line 934: OriginCountry = lastvalue
Line 935: Case "CustomerPhone"
Line 936: PhoneNumber = lastvalue
Line 937: 'Case "ExpectedArrivalTime"
Line 938: Case "Pax"
Line 939: 'If InStr(BookingOrigin, "booking") = 0 Then
Line 940: Pax += 1
Line 941: PaxVal = lastvalue
Line 942:
Line 943:
Line 944: 'Else
Line 945: 'NbAdults = lastvalue
Line 946: 'End If
Line 947: Case "Room"
Line 948: 'If InStr(LCase(BookingOrigin), "hostelworld") <> 0 Then
Line 949: NbAdults += 1
Line 950: 'End If
Line 951: Case "RoomTypeId"
Line 952: RoomType = lastvalue
Line 953: Case "RoomTypeNameExt"
Line 954: RoomTypeNameExt = lastvalue
Line 955: Case "TotalPrice", "BillDue"
Line 956: RoomRate = lastvalue
Line 957: Case "CustomerNote"
Line 958: Comment = lastvalue
Line 959: Case "ResSource"
Line 960: BookingOrigin = Replace(Replace(Replace(Replace(lastvalue, "_xml", ""), "_ycs5", ""), "octoevo", "Octorate"), "Hostelclub", "Hostelsclub")
Line 961: Case "RoomRefundable"
Line 962: RoomRefundable = lastvalue
Line 963: Case "ResId"
Line 964: ResId = lastvalue
Line 965: Case "BbliverateId"
Line 966: BbliverateId = lastvalue
Line 967: Case "IsCancellation"
Line 968: If lastvalue = "true" Then
Line 969: Status = "CANCELLATION"
Line 970: Else
Line 971: If modifica Then
Line 972: Status = "MODIFICATION"
Line 973: Else
Line 974: Status = "BOOKING"
Line 975: End If
Line 976:
Line 977: End If
Line 978:
Line 979: End Select
Line 980: End If
Line 981:
Line 982: End While
Line 983: End Using
Line 984: 'End Using
Line 985: 'ElaboraBookings = output.ToString()
Line 986: End Function
Line 987: Protected Function DammiPrenID(ByVal ConfirmationNumber As String, ByVal guests As Integer, ByVal nights As Integer, ByVal tipostanza As String) As Long
Line 988:
Line 989: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 990: Dim strSQL As String = ""
Line 991: Dim cmd As OleDbCommand
Line 992: Dim dr As OleDbDataReader
Line 993:
Line 994: Cn.Open()
Line 995:
Line 996: DammiPrenID = -1
Line 997:
Line 998: strSQL = "SELECT id, giornodate from Prenotaz WHERE ConfirmationNumber='" & ConfirmationNumber & "' AND persone=" & guests & " AND notti=" & nights & " AND InitTipoStanza='" & tipostanza & "'"
Line 999:
Line 1000: cmd = New OleDbCommand(strSQL, Cn)
Line 1001:
Line 1002: dr = cmd.ExecuteReader
Line 1003:
Line 1004: If dr.HasRows Then
Line 1005: dr.Read()
Line 1006: DammiPrenID = dr("id")
Line 1007: session_giornodate = dr("giornodate")
Line 1008: End If
Line 1009:
Line 1010: dr.Close()
Line 1011: Cn.Close()
Line 1012:
Line 1013: End Function
Line 1014: Protected Function EsisteGia(ByVal firstname As String, ByVal lastname As String, ByVal ConfirmationNumber As String, ByVal NbAdults As String, ByVal NbNights As String, ByVal RoomType As String, ByVal giorno As String, ByVal status As String, ByVal BookingOrigin As String) As Long
Line 1015:
Line 1016: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1017: Dim strSQL As String = ""
Line 1018: Dim cmd As OleDbCommand
Line 1019: Dim dr As OleDbDataReader
Line 1020: Dim crit As String = ""
Line 1021:
Line 1022: Cn.Open()
Line 1023:
Line 1024:
Line 1025: Dim idSito As Integer = DatiSitoID(BookingOrigin)
Line 1026:
Line 1027: Select Case status
Line 1028: Case "CANCELLATION"
Line 1029: crit = " AND (P.stato=4 OR P.Stato=7) AND P.Sito=" & idSito
Line 1030: Case "MODIFICATION"
Line 1031: crit = " AND P.stato=4 " 'AND P.Sito=" & idSito
Line 1032: Case "BOOKING"
Line 1033: crit = " AND P.Sito=" & idSito ' AND (P.Stato=4 OR P.Stato=5 OR P.Stato=7)"
Line 1034: End Select
Line 1035: 'strSQL = "SELECT id from Prenotaz Where Stato=4 AND ConfirmationNumber='" & ConfirmationNumber & "' AND persone=" & NbAdults & " AND notti=" & NbNights & " AND TipoStanza='" & RoomType & "' AND giorno=" & giorno
Line 1036: strSQL = "SELECT P.id,P.giornodate from Prenotaz P, Ospiti O Where P.idCli=O.id AND P.ConfirmationNumber='" & ConfirmationNumber & "' " & crit
Line 1037:
Line 1038: cmd = New OleDbCommand(strSQL, Cn)
Line 1039:
Line 1040: dr = cmd.ExecuteReader
Line 1041:
Line 1042: If dr.HasRows Then
Line 1043: dr.Read()
Line 1044: EsisteGia = dr("id")
Line 1045: session_giornodate = dr("giornodate")
Line 1046: Else
Line 1047: 'dr.Close()
Line 1048: 'strSQL = "SELECT P.id,P.giornodate from Prenotaz P, Ospiti O Where P.idCli=O.id AND ((O.name='" & Apici(firstname) & "' AND O.surname='" & Apici(lastname) & "') OR (O.surname='" & Apici(firstname) & "' AND O.name='" & Apici(lastname) & "')) AND p.giorno=" & giorno & " " & crit
Line 1049:
Line 1050: 'cmd = New OleDbCommand(strSQL, Cn)
Line 1051:
Line 1052: 'dr = cmd.ExecuteReader
Line 1053:
Line 1054: 'If dr.HasRows Then
Line 1055: ' dr.Read()
Line 1056: ' EsisteGia = dr("id")
Line 1057: ' session_giornodate = dr("giornodate")
Line 1058: 'Else
Line 1059:
Line 1060: EsisteGia = -1
Line 1061: 'End If
Line 1062: End If
Line 1063:
Line 1064: dr.Close()
Line 1065: Cn.Close()
Line 1066:
Line 1067: End Function
Line 1068: Protected Function EsisteGiaCli(ByVal nome As String, ByVal cognome As String, ByVal email As String) As Long
Line 1069:
Line 1070: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1071: Dim strSQL As String = ""
Line 1072: Dim cmd As OleDbCommand
Line 1073: Dim dr As OleDbDataReader
Line 1074:
Line 1075: Cn.Open()
Line 1076:
Line 1077: strSQL = "SELECT id from Ospiti Where name='" & Apici(nome) & "' AND Surname='" & Apici(cognome) & "' AND email='" & email & "'"
Line 1078:
Line 1079: cmd = New OleDbCommand(strSQL, Cn)
Line 1080:
Line 1081: dr = cmd.ExecuteReader
Line 1082:
Line 1083: If dr.HasRows Then
Line 1084: dr.Read()
Line 1085: EsisteGiaCli = dr("id")
Line 1086: Else
Line 1087: dr.Close()
Line 1088: strSQL = "SELECT id from Ospiti Where Name='" & Apici(nome) & "' AND Surname='" & Apici(cognome) & "'"
Line 1089:
Line 1090: cmd = New OleDbCommand(strSQL, Cn)
Line 1091:
Line 1092: dr = cmd.ExecuteReader
Line 1093:
Line 1094: If dr.HasRows Then
Line 1095: dr.Read()
Line 1096: EsisteGiaCli = dr("id")
Line 1097: Else
Line 1098: EsisteGiaCli = -1
Line 1099: End If
Line 1100: End If
Line 1101:
Line 1102: dr.Close()
Line 1103: Cn.Close()
Line 1104:
Line 1105: End Function
Line 1106: Protected Function DataPerCarrello(ByVal d As String) As String
Line 1107:
Line 1108: Dim mese As String = Choose(Mid(d, 5, 2), "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "nov", "Dec")
Line 1109: Dim giorno As String = Choose(Weekday(DateAnormal(d, 0)), "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
Line 1110:
Line 1111:
Line 1112: DataPerCarrello = giorno & " " & Val(Right(d, 2)) & " " & mese
Line 1113: End Function
Line 1114: Protected Sub ScriviLog(ByVal sito As String)
Line 1115: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1116: Dim strSQL As String = ""
Line 1117: Dim cmd As OleDbCommand
Line 1118:
Line 1119: Cn.Open()
Line 1120:
Line 1121: strSQL = "INSERT INTO LogTab (username,Descrip,cod) VALUES('Auto','"
Line 1122: strSQL += "non trovato sito " & sito & " in import'" & ",11)"
Line 1123:
Line 1124: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1125: cmd.ExecuteNonQuery()
Line 1126:
Line 1127: Cn.Close()
Line 1128:
Line 1129: End Sub
Line 1130: Protected Sub ScriviLog2(ByVal desc As String)
Line 1131: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1132: Dim strSQL As String = ""
Line 1133: Dim cmd As OleDbCommand
Line 1134:
Line 1135: Cn.Open()
Line 1136:
Line 1137: strSQL = "INSERT INTO LogTab (username,Descrip,cod) VALUES('Auto','"
Line 1138: strSQL += Replace(desc, "'", "''") & "'" & ",15)"
Line 1139:
Line 1140: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1141: cmd.ExecuteNonQuery()
Line 1142:
Line 1143: Cn.Close()
Line 1144:
Line 1145: End Sub
Line 1146:
Line 1147: Protected Sub ScriviLog3(ByVal desc As String, cod As String)
Line 1148: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1149: Dim strSQL As String = ""
Line 1150: Dim cmd As OleDbCommand
Line 1151:
Line 1152: Cn.Open()
Line 1153:
Line 1154: strSQL = "INSERT INTO LogTab (username,Descrip,cod) VALUES('Auto','"
Line 1155: strSQL += desc & "'" & "," & cod & ")"
Line 1156:
Line 1157: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1158: cmd.ExecuteNonQuery()
Line 1159:
Line 1160: Cn.Close()
Line 1161:
Line 1162:
Line 1163: End Sub
Line 1164:
Line 1165: Protected Function DatiSitoID(ByVal sitoid As String) As Integer
Line 1166:
Line 1167: Dim s As String = ""
Line 1168: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1169: Dim strSQL As String = ""
Line 1170: Dim cmd As OleDbCommand
Line 1171: Dim dr As OleDbDataReader
Line 1172:
Line 1173: Cn.Open()
Line 1174:
Line 1175: DatiSitoID = -1
Line 1176:
Line 1177: strSQL = "SELECT id from Sites Where LCASE(sito) LIKE '%" & LCase(Apici(sitoid)) & "%'"
Line 1178:
Line 1179: cmd = New OleDbCommand(strSQL, Cn)
Line 1180:
Line 1181: dr = cmd.ExecuteReader
Line 1182:
Line 1183: If dr.HasRows Then
Line 1184: dr.Read()
Line 1185:
Line 1186: DatiSitoID = dr("id")
Line 1187: Else
Line 1188: ScriviLog(LCase(Apici(sitoid)))
Line 1189:
Line 1190: End If
Line 1191:
Line 1192: dr.Close()
Line 1193: Cn.Close()
Line 1194:
Line 1195: End Function
Line 1196: Protected Sub CreaCalendario(ByVal idView As Long, ByVal night As Integer, ByVal giorno As Long, ByVal Guests As Integer)
Line 1197: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1198: Dim strSQL As String = ""
Line 1199: Dim cmd As OleDbCommand
Line 1200: Dim i As Integer = 0
Line 1201: Dim j As Integer = 0
Line 1202: Dim giornoxxx As String = ""
Line 1203: Dim comodo As Date
Line 1204: Cn.Open()
Line 1205: Dim days As String = ""
Line 1206:
Line 1207: 'Session("Days") = ""
Line 1208:
Line 1209: strSQL = "DELETE FROM Calendario WHERE idPrenotaz= " & idView
Line 1210: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1211: cmd.ExecuteNonQuery()
Line 1212:
Line 1213: For j = 1 To night
Line 1214: days += DateAdd(DateInterval.Day, j - 1, CDate(DateAnormal(giorno, False))) & " - "
Line 1215: For i = 1 To Guests
Line 1216:
Line 1217: strSQL = "INSERT INTO Calendario (idPrenotaz,prog,giorno,giornodate,ultimo) VALUES("
Line 1218: comodo = DateAdd(DateInterval.Day, j - 1, CDate(DateAnormal(giorno, False)))
Line 1219: giornoxxx = DateAnormal(comodo, True)
Line 1220: strSQL += idView & ","
Line 1221: strSQL += i & "," & giorno & ","
Line 1222: strSQL += "'" & comodo & "'," & IIf(night = j, -1, 0) & ")"
Line 1223:
Line 1224: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1225: cmd.ExecuteNonQuery()
Line 1226:
Line 1227: Next i
Line 1228: Next j
Line 1229:
Line 1230: 'Session("Days") = days
Line 1231:
Line 1232: Cn.Close()
Line 1233:
Line 1234: End Sub
Line 1235:
Line 1236: Public Sub MettiCadaBatchDailyRates(TipoStanza As String, DataDa As String, DataA As String, Prezzo As String, PrezzoWe As String, chkAll As Boolean, BedMargin As Integer, Hostel As Integer)
Line 1237:
Line 1238:
Line 1239: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1240: Dim strSQL As String = ""
Line 1241: Dim dr As OleDbDataReader
Line 1242: Dim cmd As OleDbCommand
Line 1243: Dim k As Integer = 0
Line 1244: Dim d As Date
Line 1245: Dim i As Integer = 0
Line 1246: Dim g As Integer = 0
Line 1247: Dim m As Integer = 0
Line 1248: Dim a As Integer = 0
Line 1249:
Line 1250: Cn.Open()
Line 1251:
Line 1252: i = DateDiff(DateInterval.Day, CDate(DataDa), CDate(DataA))
Line 1253:
Line 1254: For k = 0 To i
Line 1255: d = DateAdd(DateInterval.Day, k, CDate(DataDa))
Line 1256:
Line 1257: g = Day(d)
Line 1258: m = Month(d)
Line 1259: a = Year(d)
Line 1260:
Line 1261: Dim giornomod As String = Format(a, "00") & "-" & Format(m, "00") & "-" & Format(g, "00")
Line 1262:
Line 1263: If DateAnormal(giornomod, True) >= DateAnormal(Now.Date(), True) Then
Line 1264:
Line 1265: strSQL = "SELECT * FROM tipistanza Where Attivo=True" & IIf(Not chkAll, " AND codice='" & TipoStanza & "'", "")
Line 1266: cmd = New OleDbCommand(strSQL, Cn)
Line 1267:
Line 1268: dr = cmd.ExecuteReader
Line 1269:
Line 1270: If dr.HasRows Then
Line 1271: Do While dr.Read()
Line 1272:
Line 1273:
Line 1274:
Line 1275:
Line 1276: strSQL = "DELETE FROM BatchDailyRates WHERE "
Line 1277: strSQL += "TipoStanza='" & dr("codice") & "' AND "
Line 1278: strSQL += "DataX='" & DateAnormal(giornomod, True) & "' AND "
Line 1279: strSQL += "Hostel=" & Hostel
Line 1280:
Line 1281: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1282: cmd.ExecuteNonQuery()
Line 1283:
Line 1284: strSQL = "INSERT INTO BatchDailyRates (TipoStanza,DataX,Prezzo,PrezzoWe,BedMargin,Hostel) VALUES("
Line 1285: strSQL += "'" & dr("codice") & "',"
Line 1286: strSQL += "'" & DateAnormal(giornomod, True) & "',"
Line 1287: strSQL += "" & IIf(Prezzo = "", "null", Prezzo) & ","
Line 1288: strSQL += "" & IIf(PrezzoWe = "", "null", PrezzoWe) & ","
Line 1289: strSQL += "" & BedMargin & ","
Line 1290: strSQL += "" & Hostel & ")"
Line 1291:
Line 1292: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1293: cmd.ExecuteNonQuery()
Line 1294:
Line 1295:
Line 1296: Loop
Line 1297:
Line 1298: dr.Close()
Line 1299:
Line 1300: End If
Line 1301: End If
Line 1302:
Line 1303:
Line 1304:
Line 1305:
Line 1306: Next k
Line 1307:
Line 1308: Cn.Close()
Line 1309: End Sub
Line 1310:
Line 1311: Public Sub ControllaDoppiTurni()
Line 1312:
Line 1313: Dim giorno As String = ""
Line 1314: Dim occupatiarivati As Integer = 0
Line 1315: Dim occupatiarivare As Integer = 0
Line 1316: Dim daArrivareGGPassati As Integer = 0
Line 1317: Dim MyFunc As New DataClass
Line 1318:
Line 1319: Dim arr() As String
Line 1320: Dim comodo As String = ""
Line 1321:
Line 1322: Dim cboid As Integer = 0
Line 1323: Dim ia As Integer = 0
Line 1324:
Line 1325: Dim d As Integer = 0
Line 1326:
Line 1327: For d = 0 To 5
Line 1328:
Line 1329: Dim datan As Date = Now.Date() 'CDate(DateAnormal(Session("giorno"), False))
Line 1330:
Line 1331: giorno = DateAnormal(DateAdd(DateInterval.Day, d, datan), True)
Line 1332:
Line 1333: comodo = DammiPostiOccupatiNots2(giorno)
Line 1334: arr = Split(comodo, "#")
Line 1335:
Line 1336: occupatiarivati = arr(0)
Line 1337: occupatiarivare = arr(1)
Line 1338:
Line 1339: Dim diffe As Integer = DateDiff(DateInterval.Day, Now.Date(), datan)
Line 1340:
Line 1341: Dim liberi As Integer = MyFunc.DammiPostiTotaliNoTs() - (occupatiarivati + occupatiarivare)
Line 1342: If diffe <= 2 Then
Line 1343: If liberi <= 40 Then
Line 1344: AggiungiDoppioTurno(giorno)
Line 1345: End If
Line 1346: ElseIf diffe <= 7 And diffe > 2 Then
Line 1347: If liberi <= 55 Then
Line 1348: AggiungiDoppioTurno(giorno)
Line 1349: End If
Line 1350: Else
Line 1351: If liberi <= 60 Then 'And DateAdd(DateInterval.Day, 5, Now.Date) < DateAnormal(giorno, False)
Line 1352: AggiungiDoppioTurno(giorno)
Line 1353: End If
Line 1354: End If
Line 1355:
Line 1356: Next d
Line 1357:
Line 1358: End Sub
Line 1359:
Line 1360: Protected Sub AggiungiDoppioTurno(ByVal giorno As String)
Line 1361:
Line 1362: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1363: Dim cmd As OleDbCommand
Line 1364: Dim strSQL As String = ""
Line 1365: Dim dr As OleDbDataReader
Line 1366:
Line 1367:
Line 1368: strSQL = "SELECT *"
Line 1369: strSQL += " from TurniDoppiLiberi "
Line 1370: strSQL += " where Giorno = " & giorno
Line 1371: strSQL += " AND fascia = 20"
Line 1372:
Line 1373: Cn.Open()
Line 1374:
Line 1375: cmd = New OleDbCommand(strSQL, Cn)
Line 1376:
Line 1377: dr = cmd.ExecuteReader
Line 1378:
Line 1379: If Not dr.HasRows Then
Line 1380: 'dr.Read()
Line 1381: 'If Trim(dr("username") & "") = "" Then
Line 1382:
Line 1383: strSQL = "INSERT INTO TurniDoppiLiberi (fascia, giorno)"
Line 1384: strSQL += " VALUES(20," & giorno & ")"
Line 1385:
Line 1386: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1387: cmd.ExecuteNonQuery()
Line 1388:
Line 1389: 'MandaMailDT(giorno)
Line 1390:
Line 1391: 'End If
Line 1392: End If
Line 1393:
Line 1394: dr.Close()
Line 1395:
Line 1396: Cn.Close()
Line 1397:
Line 1398: End Sub
Line 1399:
Line 1400: Public Function ElaboraBatchDailyRates() As Integer
Line 1401: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1402: Dim strSQL As String = ""
Line 1403: Dim dr As OleDbDataReader
Line 1404: Dim cmd As OleDbCommand
Line 1405: Dim k As Integer = 0
Line 1406: Dim d As Date
Line 1407: Dim i As Integer = 0
Line 1408: Dim g As Integer = 0
Line 1409: Dim m As Integer = 0
Line 1410: Dim a As Integer = 0
Line 1411: Dim conta As Integer = 0
Line 1412:
Line 1413:
Line 1414: Cn.Open()
Line 1415:
Line 1416: strSQL = "SELECT top 25 * FROM BatchDailyRates "
Line 1417: cmd = New OleDbCommand(strSQL, Cn)
Line 1418:
Line 1419: dr = cmd.ExecuteReader
Line 1420:
Line 1421: If dr.HasRows Then
Line 1422: Do While dr.Read()
Line 1423:
Line 1424: Dim ret As String
Line 1425:
Line 1426: ret = AggiornaPrezziEDisponibilita(dr("tipostanza"), DateAnormal(dr("datax"), False), dr("prezzo") & "", dr("prezzowe") & "", dr("bedmargin"), dr("hostel"))
Line 1427:
Line 1428: If Left(ret, 3) = "ERR" Then
Line 1429: ScriviLog3("ERR IMPORT " & ret, 777)
Line 1430: ElaboraBatchDailyRates = conta
Line 1431: Exit Do
Line 1432: Else
Line 1433: strSQL = "DELETE FROM BatchDailyRates WHERE id=" & dr("id")
Line 1434:
Line 1435: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1436: cmd.ExecuteNonQuery()
Line 1437:
Line 1438: conta += 1
Line 1439:
Line 1440: ScriviLog3("OK IMPORT " & ret & " " & conta, 777)
Line 1441: End If
Line 1442:
Line 1443: Loop
Line 1444:
Line 1445: End If
Line 1446:
Line 1447: dr.Close()
Line 1448:
Line 1449: Cn.Close()
Line 1450:
Line 1451:
Line 1452: End Function
Line 1453:
Line 1454: Public Sub CancellaBatch()
Line 1455:
Line 1456: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1457: Dim strSQL As String = ""
Line 1458: Dim cmd As OleDbCommand
Line 1459:
Line 1460: Cn.Open()
Line 1461:
Line 1462: strSQL = "DELETE FROM BatchDailyRates"
Line 1463:
Line 1464: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1465: cmd.ExecuteNonQuery()
Line 1466:
Line 1467: Cn.Close()
Line 1468: End Sub
Line 1469: Protected Sub ImportBooking(ByVal ConfirmationNumber As String, ByVal status As String, ByVal RefHotel As String, ByVal lastname As String, ByVal firstname As String, ByVal OriginCountry As String, ByVal PhoneNumber As String, ByVal email As String, ByVal CheckIn As String, ByVal NbAdults As String, ByVal NbNights As String, ByVal RoomType As String, ByVal roomrate As String, ByVal Comment As String, ByVal BookingOrigin As String, ByVal NumMsg As String, ByVal GroupId As String, ByVal h As Integer, ByVal RoomRefundable As String, ByVal sessione As String, ByVal RoomTypeNameExt As String, ByVal No_update As Boolean, ByVal bedmargin As Integer)
Line 1470:
Line 1471: Randomize()
Line 1472: Dim TelID As String = sessione & Int(Rnd() * 999999).ToString
Line 1473:
Line 1474:
Line 1475: 'Dim ConfirmationNumber As String = Request("ConfirmationNumber")
Line 1476: 'Dim Status As String = Request("Status")
Line 1477: 'Dim RefHotel As String = Request("RefHotel")
Line 1478: Dim idHostel As Integer = h
Line 1479: 'Dim NumMsg As String 'Request("NumMsg")
Line 1480: 'Dim GroupId As String = Request("GroupId")
Line 1481: 'Dim LastName As String = Request("LastName")
Line 1482: 'Dim FirstName As String = Request("FirstName")
Line 1483: Dim Session_nameprenot As String = firstname & " " & lastname
Line 1484:
Line 1485: 'Dim PhoneNumber As String = Request("PhoneNumber")
Line 1486: Dim Session_telprenot As String = PhoneNumber
Line 1487: 'Dim Email As String = Request("Email")
Line 1488: Dim Session_emailprenot As String = email
Line 1489: 'Dim CheckIn As String = Request("CheckIn")
Line 1490: Dim ExpectedArrivalTime As String = "" 'Request("ExpectedArrivalTime")
Line 1491: 'Dim NbAdults As String = Request("NbAdults")
Line 1492: 'Dim NbNights As String = Request("NbNights")
Line 1493: 'Dim RoomType As String = Request("RoomType")
Line 1494: 'Dim RoomRate As String = Request("RoomRate")
Line 1495: Dim Session_TotalaAmount As String = roomrate
Line 1496: 'Dim Comment As String = Request("Comment")
Line 1497: 'Dim BookingOrigin As String = Request("BookingOrigin")
Line 1498: Dim Session_sitodesc As String = BookingOrigin
Line 1499: Dim CreditCardNumber As String = "" 'Request("CreditCardNumber")
Line 1500: Dim CreditCardExpiry As String = "" 'Request("CreditCardExpiry")
Line 1501: Dim NoModif As Boolean = False
Line 1502: 'Dim MyFunc As New DataClass
Line 1503: Dim Session_idOspite As Long = 0
Line 1504: Dim ret As String = ""
Line 1505: Dim Session_night As String = ""
Line 1506: Dim Session_giorno As String = ""
Line 1507: Dim Session_day As String = ""
Line 1508: Dim Session_year As String = ""
Line 1509: Dim Session_month As String = ""
Line 1510: Dim Session_guests As String = ""
Line 1511:
Line 1512: Dim Session_depositpaid As String = ""
Line 1513:
Line 1514: 'idHostel = DammiIdDescOstello(RefHotel, True)
Line 1515: RoomType = DammiTipoStanzaOcto(RoomType, idHostel, False)
Line 1516:
Line 1517: If RoomType = "" Then
Line 1518: Comment = RoomTypeNameExt & "-" & Comment
Line 1519: End If
Line 1520:
Line 1521: Dim Session_tipostanza As String = RoomType
Line 1522: Dim Session_idView As Long = 0
Line 1523:
Line 1524: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1525: Dim strSQL As String = ""
Line 1526: Dim cmd As OleDbCommand
Line 1527: Dim dr As OleDbDataReader
Line 1528:
Line 1529: Cn.Open()
Line 1530:
Line 1531:
Line 1532: If CInt(NbAdults) = 0 Then NbAdults = "1"
Line 1533:
Line 1534:
Line 1535: If status = "CANCELLATION" Or status = "MODIFICATION" Then
Line 1536:
Line 1537: 'Dim idView As Long = DammiPrenID(ConfirmationNumber, NbAdults, NbNights, RoomType)
Line 1538:
Line 1539: Dim idView As Long = EsisteGia(firstname, lastname, ConfirmationNumber, NbAdults, NbNights, RoomType, DateAnormal(CheckIn, True), status, BookingOrigin)
Line 1540:
Line 1541: Session_idView = idView
Line 1542:
Line 1543: If idView <> -1 Then
Line 1544:
Line 1545: If status = "CANCELLATION" Then
Line 1546: If DateDiff(DateInterval.Day, Now.Date(), CDate(session_giornodate)) >= 2 Then
Line 1547: strSQL = "UPDATE Colors C, SituaTime S SET C.taken=0 WHERE C.color=S.colore AND S.idPren= " & idView
Line 1548: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1549: cmd.ExecuteNonQuery()
Line 1550:
Line 1551: strSQL = "DELETE FROM SituaTime S WHERE S.idPren=" & idView
Line 1552: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1553: cmd.ExecuteNonQuery()
Line 1554:
Line 1555: strSQL = "DELETE FROM Calendario C WHERE C.idPrenotaz=" & idView
Line 1556: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1557: cmd.ExecuteNonQuery()
Line 1558:
Line 1559: strSQL = "update Prenotaz SET Stato = 7, Notexxx='" & status & " by user on " & Date.Now() & "'+left([Notexxx],150)"
Line 1560: strSQL += " where id=" & idView
Line 1561:
Line 1562: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1563: cmd.ExecuteNonQuery()
Line 1564:
Line 1565:
Line 1566: strSQL = "INSERT INTO LogTab (username,Descrip,cod) VALUES('Auto','"
Line 1567: strSQL += status & " " & DataPerCarrello(DateAnormal(CheckIn, True)) & " " & Apici(firstname & " " & lastname) & " " & BookingOrigin & " " & ConfirmationNumber & " " & DammiIdDescOstello(h, False) & "',999)"
Line 1568:
Line 1569: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1570: cmd.ExecuteNonQuery()
Line 1571:
Line 1572: NoModif = True
Line 1573:
Line 1574: Else 'cancellazione in ritardo
Line 1575: strSQL = "update Prenotaz SET CheckReservation = True, Notexxx='Too late " & status & " by user on " & Date.Now() & "'+left([Notexxx],200)"
Line 1576: strSQL += " where id=" & idView
Line 1577:
Line 1578: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1579: cmd.ExecuteNonQuery()
Line 1580:
Line 1581: NoModif = True
Line 1582:
Line 1583:
Line 1584: strSQL = "INSERT INTO LogTab (username,Descrip,cod) VALUES('Auto','too late "
Line 1585: strSQL += status & " " & DataPerCarrello(DateAnormal(CheckIn, True)) & " " & Apici(firstname & " " & lastname) & " " & BookingOrigin & " " & ConfirmationNumber & " " & DammiIdDescOstello(h, False) & "',999)"
Line 1586:
Line 1587: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1588: cmd.ExecuteNonQuery()
Line 1589:
Line 1590: CancellaPlan(Session_idView)
Line 1591: End If
Line 1592: Else 'modifica
Line 1593:
Line 1594: strSQL = "update Prenotaz SET CheckReservation = True,Notexxx='" & status & " by user on " & Date.Now() & "'"
Line 1595: strSQL += " where id=" & idView
Line 1596:
Line 1597: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1598: cmd.ExecuteNonQuery()
Line 1599:
Line 1600: End If
Line 1601:
Line 1602: End If
Line 1603:
Line 1604:
Line 1605: End If
Line 1606:
Line 1607: If (status = "BOOKING" Or status = "MODIFICATION") And Not NoModif Then '
Line 1608:
Line 1609: If EsisteGia(firstname, lastname, ConfirmationNumber, NbAdults, NbNights, RoomType, DateAnormal(CheckIn, True), status, BookingOrigin) = -1 Then 'Or Status = "MODIFICATION"
Line 1610:
Line 1611: Dim numcli As Long = 0
Line 1612: numcli = EsisteGiaCli(firstname, lastname, email)
Line 1613:
Line 1614: Dim nazione As String = Trim(Apici(DammiNazione(OriginCountry)))
Line 1615: 'If Left(LCase(nazione), 4) = "ital" Then nazione = "xxxx"
Line 1616:
Line 1617:
Line 1618: If numcli = -1 Then
Line 1619: strSQL = "INSERT INTO Ospiti (Name,surname,address,zip,city,prov,state,telephone,email,gender,sessione) values"
Line 1620: strSQL += " ('" & Trim(Apici(firstname)) & "',"
Line 1621: strSQL += " '" & Trim(Apici(lastname)) & "',"
Line 1622: strSQL += " '',"
Line 1623: strSQL += " '',"
Line 1624: strSQL += " '',"
Line 1625: strSQL += " '',"
Line 1626: strSQL += " '" & nazione & "',"
Line 1627: strSQL += " '" & Trim(Apici(PhoneNumber)) & "',"
Line 1628: strSQL += " '" & Trim(Apici(email)) & "',"
Line 1629: strSQL += " 'Male',"
Line 1630: strSQL += " '" & TelID & "')"
Line 1631:
Line 1632: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1633: cmd.ExecuteNonQuery()
Line 1634:
Line 1635: strSQL = "SELECT * FROM Ospiti "
Line 1636: strSQL += " WHERE Sessione='" & TelID & "'"
Line 1637:
Line 1638: cmd = New OleDbCommand(strSQL, Cn)
Line 1639: dr = cmd.ExecuteReader
Line 1640:
Line 1641: If dr.HasRows Then
Line 1642: dr.Read()
Line 1643: Session_idOspite = dr("id")
Line 1644: End If
Line 1645:
Line 1646: dr.Close()
Line 1647: Else
Line 1648: Session_idOspite = numcli
Line 1649:
Line 1650: End If
Line 1651:
Line 1652:
Line 1653:
Line 1654: strSQL = "SELECT * FROM Prenotaz "
Line 1655: strSQL += " WHERE Sessione='" & TelID & "'"
Line 1656:
Line 1657: cmd = New OleDbCommand(strSQL, Cn)
Line 1658: dr = cmd.ExecuteReader
Line 1659:
Line 1660: Dim deposit As Double = 0
Line 1661: Dim virt = IIf(InStr(LCase(Comment), "virtual") = 0, "false", "True")
Line 1662:
Line 1663:
Line 1664: Session_night = NbNights
Line 1665: Session_giorno = DateAnormal(CheckIn, True)
Line 1666: Session_day = Right(Session_giorno, 2)
Line 1667: Session_year = Left(Session_giorno, 4)
Line 1668: Session_month = Mid(Session_giorno, 5, 2)
Line 1669: Session_guests = NbAdults
Line 1670: If Not dr.HasRows Then
Line 1671:
Line 1672:
Line 1673:
Line 1674:
Line 1675: strSQL = "INSERT INTO Prenotaz (idCli, "
Line 1676: strSQL += " ConfirmationNumber,"
Line 1677: strSQL += " Sessione,"
Line 1678: strSQL += " Giorno,"
Line 1679: strSQL += " Giornonorm,giornodate,"
Line 1680: strSQL += " Persone,"
Line 1681: strSQL += " Notti,"
Line 1682: strSQL += " TipoStanza,"
Line 1683: strSQL += " Notexxx,"
Line 1684: strSQL += " Deposit,"
Line 1685: strSQL += " InitDep,"
Line 1686: strSQL += " Total,"
Line 1687: strSQL += " InitTot,"
Line 1688: strSQL += " Stato,"
Line 1689: strSQL += " Sito,"
Line 1690:
Line 1691: strSQL += " CCNo,"
Line 1692: strSQL += " CCExp,"
Line 1693: strSQL += " CCGt,"
Line 1694: strSQL += " LowCost,"
Line 1695: strSQL += " Inittipostanza,"
Line 1696: strSQL += " InitPersone,"
Line 1697: strSQL += " InitNotti,"
Line 1698: strSQL += " InitPricePNight,"
Line 1699: strSQL += " Arrivo,zebrauser,hostel,NumMsg,GroupId,Refundable,CCVirtual) VALUES(" & Session_idOspite & ","
Line 1700: strSQL += " '" & Left(ConfirmationNumber, 29) & "',"
Line 1701: strSQL += " '" & TelID & "',"
Line 1702: strSQL += " " & DateAnormal(CheckIn, True) & ","
Line 1703: strSQL += " '" & DataPerCarrello(DateAnormal(CheckIn, True)) & "','" & CheckIn & "',"
Line 1704: strSQL += " " & NbAdults & ","
Line 1705: strSQL += " " & NbNights & ","
Line 1706: strSQL += " '" & IIf(RoomType = "", "na", RoomType) & "',"
Line 1707: strSQL += " '" & Apici(Left(IIf(status = "MODIFICATION", "MODIFIED ON " & Date.Now() & Comment, Comment), 240)) & "',"
Line 1708: 'If Not chkDeposit.Checked Then
Line 1709: strSQL += " 0,"
Line 1710: strSQL += " 0,"
Line 1711: Session_depositpaid = "0"
Line 1712: deposit = 0
Line 1713:
Line 1714:
Line 1715: Dim teltot As Double = Replace(roomrate, ".", ",")
Line 1716: Dim teltots As String = Replace(roomrate, ",", ".")
Line 1717:
Line 1718: strSQL += " " & teltots & ","
Line 1719: strSQL += " " & teltots & ","
Line 1720: strSQL += " 4,"
Line 1721: strSQL += DatiSitoID(BookingOrigin) & " ,"
Line 1722: strSQL += " '" & Trim(CreditCardNumber) & "',"
Line 1723: strSQL += " '" & Trim(CreditCardExpiry) & "',"
Line 1724: strSQL += " ''," 'txtCCGT
Line 1725: strSQL += "False ," 'low cost
Line 1726: strSQL += " '" & IIf(RoomType = "", "na", RoomType) & "',"
Line 1727: strSQL += NbAdults & " ,"
Line 1728: strSQL += NbNights & " ,"
Line 1729: strSQL += Replace(CStr((teltot - deposit) / CInt(NbNights) / CInt(NbAdults)), ",", ".") & " ,"
Line 1730: strSQL += " '" & ExpectedArrivalTime & "','Auto'," & idHostel & ",'" & NumMsg & "','" & GroupId & "',"
Line 1731: strSQL += IIf(LCase(RoomRefundable) = "no", "false", "True") & ","
Line 1732: strSQL += virt & ")"
Line 1733:
Line 1734:
Line 1735: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1736:
Line 1737:
Line 1738: cmd.ExecuteNonQuery()
Line 1739:
Line 1740: strSQL = "INSERT INTO LogTab (username,Descrip,cod) VALUES('Auto','"
Line 1741: strSQL += status & " " & DataPerCarrello(DateAnormal(CheckIn, True)) & " " & Apici(firstname & " " & lastname) & " " & BookingOrigin & " " & ConfirmationNumber & " " & DammiIdDescOstello(h, False) & "',999)"
Line 1742:
Line 1743: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 1744: cmd.ExecuteNonQuery()
Line 1745: End If
Line 1746:
Line 1747: dr.Close()
Line 1748:
Line 1749: strSQL = "SELECT * FROM Prenotaz "
Line 1750: strSQL += " WHERE Sessione='" & TelID & "'"
Line 1751:
Line 1752: cmd = New OleDbCommand(strSQL, Cn)
Line 1753: dr = cmd.ExecuteReader
Line 1754:
Line 1755: If dr.HasRows Then
Line 1756: dr.Read()
Line 1757: Session_idView = dr("id")
Line 1758: End If
Line 1759:
Line 1760: dr.Close()
Line 1761:
Line 1762: CreaCalendario(Session_idView, Session_night, Session_giorno, Session_guests)
Line 1763:
Line 1764:
Line 1765: If Not No_update Then
Line 1766:
Line 1767: Dim datada As String = Format(CDate(CheckIn), "dd/MM/yyyy")
Line 1768: Dim dataa As String = Format(CDate(DateAdd(DateInterval.Day, CDbl(NbNights), CDate(datada))))
Line 1769:
Line 1770:
Line 1771: MettiCadaBatchDailyRates("", datada, dataa, "", "", True, bedmargin, 1)
Line 1772: MettiCadaBatchDailyRates("", datada, dataa, "", "", True, bedmargin, 2)
Line 1773:
Line 1774: 'ret = AggiornaPrezziEDisponibilita("", datada, dataa, "", "", True, bedmargin, 1)
Line 1775:
Line 1776:
Line 1777: 'ret = AggiornaPrezziEDisponibilita("", datada, dataa, "", "", True, bedmargin, 2)
Line 1778:
Line 1779: End If
Line 1780:
Line 1781:
Line 1782: 'ControllaDisponibilita()
Line 1783:
Line 1784: Policy(firstname & " " & lastname, RoomType, Session_giorno, Session_night, Session_guests, ConfirmationNumber, email, BookingOrigin, roomrate, h, virt)
Line 1785:
Line 1786:
Line 1787: End If
Line 1788:
Line 1789: End If
Line 1790:
Line 1791:
Line 1792: Cn.Close()
Line 1793:
Line 1794:
Line 1795: End Sub
Line 1796:
Line 1797: Protected Sub Policy(ByVal nameprenot As String, ByVal RoomType As String, ByVal Session_giorno As String, ByVal Session_night As String, ByVal Session_guests As String, ByVal ConfirmationNumber As String, ByVal email As String, ByVal BookingOrigin As String, ByVal roomrate As String, ByVal h As Integer, virt As String)
Line 1798:
Line 1799: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 1800: Dim strSQL As String = ""
Line 1801: Dim cmd As OleDbCommand
Line 1802: Dim dr As OleDbDataReader
Line 1803:
Line 1804: Dim sitopolicy As String = ""
Line 1805: Dim headermail As String = ""
Line 1806: Dim footermail As String = ""
Line 1807:
Line 1808: Dim tassasoggiorno As String = ""
Line 1809: Dim EmailFrom As String = ""
Line 1810: Dim EmailServer As String = ""
Line 1811: Dim EmailUser As String = ""
Line 1812: Dim EmailPassword As String = ""
Line 1813: Dim HostelName As String = ""
Line 1814: Dim HostelSite As String = ""
Line 1815: Dim mincheckin As String = ""
Line 1816:
Line 1817: Cn.Open()
Line 1818:
Line 1819: strSQL = "SELECT * FROM Settingz "
Line 1820:
Line 1821: cmd = New OleDbCommand(strSQL, Cn)
Line 1822:
Line 1823: dr = cmd.ExecuteReader
Line 1824:
Line 1825: If dr.HasRows Then
Line 1826: dr.Read()
Line 1827:
Line 1828: Dim iva As Double = dr("iva")
Line 1829: Dim sitocommission As Double = dr("cccommission")
Line 1830: 'Session("ccmin") = dr("ccmin")
Line 1831: sitopolicy = dr("ccpolicy") & ""
Line 1832: headermail = dr("headermail") & ""
Line 1833: footermail = dr("footermail") & ""
Line 1834:
Line 1835: tassasoggiorno = dr("tassasoggiorno")
Line 1836: EmailFrom = dr("EmailFrom")
Line 1837: EmailServer = dr("EmailServer")
Line 1838: EmailUser = dr("EmailUser")
Line 1839: EmailPassword = dr("EmailPassword")
Line 1840: HostelName = dr("HostelName")
Line 1841: HostelSite = dr("HostelSite")
Line 1842: mincheckin = Val(dr("MinCheckin") & "")
Line 1843: End If
Line 1844:
Line 1845: dr.Close()
Line 1846: Cn.Close()
Line 1847:
Line 1848: Dim sito As String = ""
Line 1849:
Line 1850: Dim strMessaggio As String = ""
Line 1851: Dim strMessaggio2 As String = ""
Line 1852: Dim strMessaggio0 As String = ""
Line 1853: Dim strMessaggio3 As String = ""
Line 1854:
Line 1855: strMessaggio0 = headermail
Line 1856:
Line 1857: strMessaggio3 = "Booking date: <b>" & Now.Date() & "<br>" & "</b>"
Line 1858: strMessaggio3 += "Check in: <b>" & DataPerCarrello(Session_giorno) & "<br>" & "</b>"
Line 1859: strMessaggio3 += "Guests: <b>" & Session_guests & "<br>" & "</b>"
Line 1860: strMessaggio3 += "Nights: <b>" & Session_night & "<br>" & "</b>"
Line 1861: strMessaggio3 += "Name: <b>" & nameprenot & "<br>" & "</b>"
Line 1862: strMessaggio3 += "Accomodation type: <b>" & DammiTipoStanza(RoomType) & "<br>" & "</b>"
Line 1863: strMessaggio3 += "Booking code: <b>" & ConfirmationNumber & "<br>" & "</b>"
Line 1864: strMessaggio3 += "Email: <b>" & email & "<br>" & "</b>"
Line 1865: If Trim(BookingOrigin & "") <> "Airbnb" Then
Line 1866: strMessaggio3 += "Total amount: <b>" & IIf(Trim(LCase(BookingOrigin)) = "airbnb" Or Trim(BookingOrigin) = "Airbnb", "0€", IIf(virt = "True", "(City tax only)", roomrate)) & "€<br>" & "</b>"
Line 1867: End If
Line 1868:
Line 1869: strMessaggio3 += "Booked on: " & "<b>" & BookingOrigin & "<br>" & "</b>"
Line 1870: strMessaggio3 += "<br><br>"
Line 1871:
Line 1872: 'sitopolicy = Replace(sitopolicy & Session("sitocurre") & "", "**commission**", Session("sitocommission") & "")
Line 1873:
Line 1874: strMessaggio3 += Replace(BookingOrigin & "", "**balancedue**", roomrate)
Line 1875:
Line 1876:
Line 1877: strMessaggio += "</b>"
Line 1878:
Line 1879: strMessaggio2 = sitopolicy
Line 1880:
Line 1881: strMessaggio += "</b>"
Line 1882:
Line 1883: strMessaggio = Replace(strMessaggio & strMessaggio2 & footermail, "@datipren", strMessaggio3)
Line 1884:
Line 1885: If h = 2 Then
Line 1886: strMessaggio = Replace(strMessaggio, "koala.png", "panda.png")
Line 1887: End If
Line 1888: 'lblPolicy.Text = strMessaggio3 & "<br><br>" & strMessaggio2
Line 1889: If DateAnormal(Now.Date(), True) <> Session_giorno Then 'And Session("sito") <> 0
Line 1890: If email & "" <> "" And email <> EmailFrom Then
Line 1891:
Line 1892: Dim Msg As New System.Net.Mail.MailMessage(EmailFrom, email, IIf(h = 1, "KOALA HOSTEL", "PANDA HOSTEL") & " BOOKING (print)", strMessaggio)
Line 1893:
Line 1894: Msg.IsBodyHtml = True
Line 1895:
Line 1896: Dim Smtp As New System.Net.Mail.SmtpClient(EmailServer)
Line 1897:
Line 1898: '25/8/2021 rimettere per allegato
Line 1899: 'Dim attachment As New System.Net.Mail.Attachment(HttpContext.Current.Server.MapPath(IIf(h = 1, "/docs/Map.pdf", "/docs/Map_Panda.pdf"))) 'create the attachment
Line 1900: 'Msg.Attachments.Add(attachment) 'add the attachment
Line 1901:
Line 1902: Smtp.Credentials = New System.Net.NetworkCredential(EmailUser, EmailPassword)
Line 1903: On Error Resume Next
Line 1904: Smtp.Send(Msg)
Line 1905: On Error GoTo 0
Line 1906:
Line 1907: 'Dim Msg2 As New System.Net.Mail.MailMessage(email, EmailFrom, "copy sent to " & Session("nameprenot"), strMessaggio)
Line 1908:
Line 1909: 'Msg2.IsBodyHtml = True
Line 1910:
Line 1911: 'Dim Smtp2 As New System.Net.Mail.SmtpClient(Session("EmailServer"))
Line 1912:
Line 1913: 'Smtp2.Credentials = New System.Net.NetworkCredential(CStr(Session("EmailUser")), CStr(Session("EmailPassword")))
Line 1914: 'On Error Resume Next
Line 1915: 'Smtp2.Send(Msg2)
Line 1916: 'On Error GoTo 0
Line 1917: End If
Line 1918:
Line 1919: End If
Line 1920: End Sub
Line 1921:
Line 1922: Protected Sub Mandamailxml(ByVal str As String)
Line 1923:
Line 1924: Dim strMessaggio As String = ""
Line 1925:
Line 1926: strMessaggio = str
Line 1927:
Line 1928: Dim Msg As New System.Net.Mail.MailMessage("<info@koalahostel.it>", "info@koalahostel.it", "DATA FOR PMS", strMessaggio)
Line 1929:
Line 1930: Msg.IsBodyHtml = False
Line 1931:
Line 1932: Dim Smtp As New System.Net.Mail.SmtpClient("smtp.koalahostelmilan.it")
Line 1933:
Line 1934: Smtp.Credentials = New System.Net.NetworkCredential("info@koalahostelmilan.it", "m2y5k2ti")
Line 1935: On Error Resume Next
Line 1936: Smtp.Send(Msg)
Line 1937: On Error GoTo 0
Line 1938:
Line 1939:
Line 1940:
Line 1941: End Sub
Line 1942:
Line 1943:
Line 1944: Function DammiPrezzoXML(ByVal xml As String, ByVal ts As String, ByVal giorno As String) As String
Line 1945:
Line 1946: Dim str As String = ""
Line 1947: Dim i As Integer = 0
Line 1948: Dim doc As New XmlDocument()
Line 1949: doc.LoadXml(xml)
Line 1950: Dim nodes As XmlNodeList = doc.DocumentElement.SelectNodes("./RoomsAvailability/RoomAvailability")
Line 1951: For Each node As XmlNode In nodes
Line 1952:
Line 1953: If ts = Val(Replace(Mid(node.OuterXml, InStr(node.OuterXml, "RoomId=") + 8, 6), "", "")) Then
Line 1954: 'product_name = node.SelectSingleNode("Price").InnerText
Line 1955: 'MessageBox.Show(product_id & " " & product_name & " " & product_price)
Line 1956: DammiPrezzoXML = DammiXMLTag(node.OuterXml, "<Price>")
Line 1957: Exit For
Line 1958: End If
Line 1959:
Line 1960: Next
Line 1961: 'nodes = doc.GetElementsByTagName("RoomsAvailability")
Line 1962: 'For i = 0 To nodes.Count - 1
Line 1963: ' nodes(i).ChildNodes.Item(0).InnerText.Trim()
Line 1964: ' str = nodes(i).ChildNodes.Item(0).InnerText.Trim() & " " & nodes(i).ChildNodes.Item(1).InnerText.Trim() & " " & nodes(i).ChildNodes.Item(2).InnerText.Trim()
Line 1965: ' MsgBox(str)
Line 1966: 'Next
Line 1967:
Line 1968: End Function
Line 1969:
Line 1970:
Line 1971:
Line 1972: Function DammiXMLTag(ByVal str As String, ByVal xmltag As String) As String
Line 1973:
Line 1974: Dim finetag As String = Mid(xmltag, 1, 1) & "/" & Mid(xmltag, 2)
Line 1975: Dim fine As Integer = InStr(str, finetag)
Line 1976: Dim inizio As Integer = InStr(str, xmltag) + Len(xmltag)
Line 1977: DammiXMLTag = Mid(str, inizio, fine - inizio)
Line 1978:
Line 1979: End Function
Line 1980:
Line 1981: Public Function DammiPrezzoEDispXML(ByVal d As String, ByVal t As String, ByVal h As Integer) As String
Line 1982:
Line 1983: DammiPrezzoEDispXML = ""
Line 1984:
Line 1985: Dim req As System.Net.WebRequest = Nothing
Line 1986: Dim rsp As System.Net.WebResponse = Nothing
Line 1987: Dim str As String = ""
Line 1988: Dim str2 As String = ""
Line 1989: Dim sr As StreamReader
Line 1990: 'd = "2017-11-13"
Line 1991: 'h = "99127024"
Line 1992: Dim xmlmodel As String = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf
Line 1993: xmlmodel += "<GetAvailability>" & vbCrLf
Line 1994: xmlmodel += "<Auth>" & vbCrLf
Line 1995: xmlmodel += "<ApiKey>ec590e33ac077d1c792133a0db003dbe</ApiKey>" & vbCrLf
Line 1996: xmlmodel += "<PropertyId>" & DammiIdOstello(h, True) & "</PropertyId>" & vbCrLf
Line 1997: xmlmodel += "</Auth>" & vbCrLf
Line 1998: xmlmodel += "<From>" & d & "</From>" & vbCrLf
Line 1999: xmlmodel += "<To>" & d & "</To>" & vbCrLf
Line 2000: xmlmodel += "</GetAvailability>" & vbCrLf
Line 2001:
Line 2002: 'Newcall(xmlmodel)
Line 2003:
Line 2004: Try
Line 2005:
Line 2006: req = System.Net.WebRequest.Create("https://api.octorate.com/api/live/callApi.php?method=GetAvailability")
Line 2007: req.Method = "POST"
Line 2008:
Line 2009: req.ContentType = "application/x-www-form-urlencoded; charset=utf-8"
Line 2010: Dim writer As New System.IO.StreamWriter(req.GetRequestStream())
Line 2011: xmlmodel = "xml=" & xmlmodel
Line 2012: 'xlmmodelkoala = Replace(xmlmodel, "@@@TIPOSTANZA@@@", DammiTipoStanzaSuo(t, 1))
Line 2013: writer.WriteLine(xmlmodel)
Line 2014: writer.Close()
Line 2015:
Line 2016: 'ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType)
Line 2017: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Line 2018: rsp = req.GetResponse()
Line 2019:
Line 2020: sr = New StreamReader(rsp.GetResponseStream)
Line 2021: str = sr.ReadToEnd.Trim
Line 2022: sr.Close()
Line 2023:
Line 2024: DammiPrezzoEDispXML = DammiPrezzoXML(str, t, d)
Line 2025:
Line 2026: Catch
Line 2027: Throw
Line 2028: Finally
Line 2029: If req IsNot Nothing Then
Line 2030: 'req.GetRequestStream().Close()
Line 2031: End If
Line 2032: If rsp IsNot Nothing Then
Line 2033: rsp.GetResponseStream().Close()
Line 2034: End If
Line 2035: End Try
Line 2036:
Line 2037:
Line 2038:
Line 2039: End Function
Line 2040: Protected Function DammiTipoStanza(ByVal ts As String) As String
Line 2041:
Line 2042: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2043: Dim cmd As OleDbCommand
Line 2044: Dim strSQL As String = ""
Line 2045: Dim dr As OleDbDataReader
Line 2046:
Line 2047: DammiTipoStanza = ""
Line 2048:
Line 2049: strSQL = "SELECT * FROM TipiStanza WHERE Codice='" & ts & "'"
Line 2050:
Line 2051: Cn.Open()
Line 2052:
Line 2053: cmd = New OleDbCommand(strSQL, Cn)
Line 2054:
Line 2055: dr = cmd.ExecuteReader
Line 2056:
Line 2057:
Line 2058: If dr.HasRows Then
Line 2059: dr.Read()
Line 2060:
Line 2061: DammiTipoStanza = dr("descrizione")
Line 2062:
Line 2063: End If
Line 2064:
Line 2065: dr.Close()
Line 2066:
Line 2067: Cn.Close()
Line 2068:
Line 2069:
Line 2070: End Function
Line 2071: Public Function DammiDailyRate(ByVal g As Long, ByVal ts As String) As Double
Line 2072:
Line 2073: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2074: Dim drSSS As OleDbDataReader
Line 2075: Dim cmdSSS As OleDbCommand
Line 2076: Dim strSQL As String = ""
Line 2077: Dim SQL As String = ""
Line 2078: Dim p As Double = 0
Line 2079: Dim cosa As String = ""
Line 2080: Dim d As Date = CDate(DateAnormal(g, False))
Line 2081:
Line 2082: Cn.Open()
Line 2083:
Line 2084: strSQL = "SELECT prezzo as pp,prezzowe as pw from DailyRates WHERE TipoStanza='" & ts & "' AND Giornoanorm=" & g
Line 2085:
Line 2086: cmdSSS = New OleDbCommand(strSQL, Cn)
Line 2087: drSSS = cmdSSS.ExecuteReader
Line 2088:
Line 2089: If drSSS.HasRows Then
Line 2090:
Line 2091: drSSS.Read()
Line 2092:
Line 2093: If Weekday(d) = vbFriday Or Weekday(d) = vbSaturday Then
Line 2094:
Line 2095: DammiDailyRate = drSSS("pw")
Line 2096: Else
Line 2097: DammiDailyRate = drSSS("pp")
Line 2098: End If
Line 2099: Else
Line 2100: DammiDailyRate = -1
Line 2101: End If
Line 2102:
Line 2103: drSSS.Close()
Line 2104:
Line 2105:
Line 2106: Cn.Close()
Line 2107:
Line 2108: End Function
Line 2109:
Line 2110: Public Function DammiNumPrenotazioni(g As Long) As Integer
Line 2111: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2112: Dim cmd As OleDbCommand
Line 2113: Dim strSQL As String = ""
Line 2114: Dim dr As OleDbDataReader
Line 2115:
Line 2116:
Line 2117:
Line 2118: DammiNumPrenotazioni = 0
Line 2119:
Line 2120:
Line 2121:
Line 2122:
Line 2123: strSQL = "SELECT count(*) as numpren"
Line 2124: strSQL += " from (select distinct idPrenotaz FROM Calendario "
Line 2125: strSQL += " where Giorno = " & g & ")"
Line 2126:
Line 2127:
Line 2128: Cn.Open()
Line 2129:
Line 2130: cmd = New OleDbCommand(strSQL, Cn)
Line 2131:
Line 2132: dr = cmd.ExecuteReader
Line 2133:
Line 2134: If dr.HasRows Then
Line 2135: dr.Read()
Line 2136: DammiNumPrenotazioni = dr("numpren")
Line 2137:
Line 2138:
Line 2139: End If
Line 2140:
Line 2141: dr.Close()
Line 2142:
Line 2143: Cn.Close()
Line 2144: End Function
Line 2145: Public Function DammiPrezzoGiusto(ByVal ts As String, privata As Boolean, ByVal giorno As String) As Double
Line 2146:
Line 2147: Dim prezzoDaily As Double = DammiDailyRate(giorno, ts)
Line 2148: Dim toaddperc As Integer = 0
Line 2149: Dim toaddval As Double = 0
Line 2150: Dim prezzo As Double
Line 2151:
Line 2152: If prezzoDaily = -1 Then
Line 2153: Dim quantomanca As Integer = DateDiff(DateInterval.Day, Now.Date(), CDate(Left(giorno, 4) & "-" & Mid(giorno, 5, 2) & "-" & Right(giorno, 2)))
Line 2154: Dim aggiungimanca As Integer = 0
Line 2155: Dim numpren = DammiNumPrenotazioni(CLng(giorno))
Line 2156: If numpren > 20 Then
Line 2157: Select Case quantomanca
Line 2158: Case 0
Line 2159: aggiungimanca = 0
Line 2160: Case 1
Line 2161: aggiungimanca = 10
Line 2162: Case 2 To 5
Line 2163: aggiungimanca = 15
Line 2164: Case Is > 5
Line 2165: aggiungimanca = 20
Line 2166: End Select
Line 2167: End If
Line 2168:
Line 2169: prezzo = DammiPrezzolistino(Right(giorno, 2), Mid(giorno, 5, 2), Left(giorno, 4), ts)
Line 2170: Dim postitot As Integer = DammiPostiTotaliNoTs()
Line 2171:
Line 2172: Dim occupati As Integer = DammiPostiOccupatiNoTs(giorno)
Line 2173:
Line 2174: Dim liberi As Integer = postitot - occupati
Line 2175:
Line 2176: Dim percentualeoccupaz As Double = (occupati * 100) / postitot
Line 2177:
Line 2178:
Line 2179:
Line 2180: 'If privata Then
Line 2181: Select Case Int(percentualeoccupaz)
Line 2182: Case 35 To 50
Line 2183: toaddperc = 25 + aggiungimanca
Line 2184: Case 51 To 70
Line 2185: toaddperc = 35 + aggiungimanca
Line 2186: Case 71 To 90
Line 2187: toaddperc = 45 + aggiungimanca
Line 2188: Case 91 To 95
Line 2189: toaddperc = 55 + aggiungimanca
Line 2190: Case Is > 96
Line 2191: toaddperc = 65 + aggiungimanca
Line 2192: Case Else
Line 2193: End Select
Line 2194: 'Else
Line 2195: ' Select Case Int(percentualeoccupaz)
Line 2196: ' Case 35 To 50
Line 2197: ' toaddperc = 15 + aggiungimanca
Line 2198: ' Case 51 To 70
Line 2199: ' toaddperc = 25 + aggiungimanca
Line 2200: ' Case 71 To 90
Line 2201: ' toaddperc = 35 + aggiungimanca
Line 2202: ' Case 91 To 95
Line 2203: ' toaddperc = 45 + aggiungimanca
Line 2204: ' Case Is > 96
Line 2205: ' toaddperc = 65 + aggiungimanca
Line 2206: ' Case Else
Line 2207:
Line 2208: ' 'Stop
Line 2209: ' End Select
Line 2210: 'End If
Line 2211:
Line 2212: If toaddperc > 0 Then
Line 2213: toaddval = Int((toaddperc * prezzo) / 100)
Line 2214:
Line 2215: DammiPrezzoGiusto = toaddval + prezzo
Line 2216: Else
Line 2217:
Line 2218: DammiPrezzoGiusto = prezzo 'toaddval
Line 2219: End If
Line 2220: Else
Line 2221: DammiPrezzoGiusto = prezzoDaily
Line 2222: End If
Line 2223:
Line 2224:
Line 2225: End Function
Line 2226:
Line 2227:
Line 2228: Protected Function DateAnormal(ByVal DateToGir As String, ByVal modo As Boolean) As String
Line 2229: Dim d As String
Line 2230: If modo Then
Line 2231: d = Format(CDate(DateToGir), "dd/MM/yyyy")
Line 2232: DateAnormal = Right(d, 4) & Mid(d, 4, 2) & Left(d, 2)
Line 2233: Else
Line 2234: d = DateToGir
Line 2235: DateAnormal = Right(d, 2) & "/" & Mid(d, 5, 2) & "/" & Left(d, 4)
Line 2236: End If
Line 2237:
Line 2238: End Function
Line 2239: Public Function DateAdjust(ByVal d As String, ByVal m As String, ByVal y As String, ByVal toadd As Integer) As String
Line 2240: Dim comodo As Date
Line 2241:
Line 2242: If d = "" Then
Line 2243: DateAdjust = ""
Line 2244: Exit Function
Line 2245: End If
Line 2246:
Line 2247:
Line 2248: comodo = DateAdd(DateInterval.Day, toadd, CDate(d & "/" & m & "/" & y))
Line 2249:
Line 2250: DateAdjust = Format(comodo, "dd/MM/yyyy")
Line 2251:
Line 2252: End Function
Line 2253: Public Function Noavaibility(ByVal ts As String, ByVal dxx As String) As Boolean
Line 2254:
Line 2255: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2256: Dim cmd As OleDbCommand
Line 2257: Dim strSQL As String = ""
Line 2258: Dim dr As OleDbDataReader
Line 2259: Dim TotPosti As Integer = 0
Line 2260: Dim g As Integer = 0
Line 2261: Dim m As Integer = 0
Line 2262:
Line 2263:
Line 2264: Noavaibility = False
Line 2265:
Line 2266:
Line 2267: m = Val(Mid(dxx, 5, 2))
Line 2268: g = Val(Right(dxx, 2))
Line 2269:
Line 2270:
Line 2271: strSQL = "SELECT *"
Line 2272: strSQL += " from Noavailability "
Line 2273: strSQL += " where Giorno = " & g
Line 2274: strSQL += " and mese = " & m
Line 2275: strSQL += " and TipoStanza='" & ts & "'"
Line 2276:
Line 2277: Cn.Open()
Line 2278:
Line 2279: cmd = New OleDbCommand(strSQL, Cn)
Line 2280:
Line 2281: dr = cmd.ExecuteReader
Line 2282:
Line 2283: If dr.HasRows Then
Line 2284:
Line 2285: Noavaibility = True
Line 2286:
Line 2287:
Line 2288: End If
Line 2289:
Line 2290: dr.Close()
Line 2291:
Line 2292: Cn.Close()
Line 2293:
Line 2294: End Function
Line 2295:
Line 2296:
Line 2297: Protected Function ControllaDisponibilita(ByVal ts As String, ByVal giorno As String, ByVal nights As Integer, ByVal bedmargin As Integer) As String
Line 2298:
Line 2299: ControllaDisponibilita = ""
Line 2300: 'Dim giorno As Long = 0
Line 2301: Dim d As Integer = 0
Line 2302: Dim str As String = ""
Line 2303: Dim giorno2 As String = ""
Line 2304:
Line 2305: 'If ts = "6fdwc" Then Stop
Line 2306:
Line 2307: For d = 0 To nights - 1
Line 2308:
Line 2309: giorno2 = DateAnormal(DateAdjust(Right(giorno, 2), Mid(giorno, 5, 2), Left(giorno, 4), d), True)
Line 2310:
Line 2311: Dim occupati As Integer = 0
Line 2312:
Line 2313: Dim liberi As Integer = 0
Line 2314:
Line 2315:
Line 2316:
Line 2317: If Noavaibility(ts, giorno2) Then
Line 2318: liberi = 0
Line 2319: str += "<Inventory date=""" & Format(CDate(DateAnormal(giorno2, False)), "yyyy-MM-dd") & """ Allocation=""0"" maxavail=""4""/>" & vbCrLf
Line 2320: Else
Line 2321:
Line 2322: Dim postitot As Integer = DammiPostiTotali(ts)
Line 2323:
Line 2324: occupati = DammiPostiOccupati(ts, giorno2)
Line 2325:
Line 2326: liberi = postitot - occupati - bedmargin
Line 2327:
Line 2328: If liberi < 0 Then liberi = 0
Line 2329:
Line 2330:
Line 2331: str += "<Inventory date=""" & Format(CDate(DateAnormal(giorno2, False)), "yyyy-MM-dd") & """ Allocation=""" & IIf(privata, Int(liberi / 2), liberi) & """ maxavail=""4""/>" & vbCrLf
Line 2332:
Line 2333:
Line 2334: End If
Line 2335:
Line 2336: 'If liberi - Val(Session("guests")) <= 2 Then
Line 2337:
Line 2338: 'MandaAvvisoBlocco(Session("tipostanza"), giorno)
Line 2339:
Line 2340: 'End If
Line 2341:
Line 2342: Next
Line 2343:
Line 2344: ControllaDisponibilita = str
Line 2345:
Line 2346: End Function
Line 2347:
Line 2348:
Line 2349:
Line 2350:
Line 2351:
Line 2352: Public Function DammiPostiOccupati(ByVal ts As String, ByVal d As String) As Integer
Line 2353:
Line 2354: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2355: Dim cmd As OleDbCommand
Line 2356: Dim strSQL As String = ""
Line 2357: Dim dr As OleDbDataReader
Line 2358: Dim TotPosti As Integer = 0
Line 2359:
Line 2360:
Line 2361: DammiPostiOccupati = "0"
Line 2362:
Line 2363: strSQL = "SELECT p.makeavailable,p.stato, p.giorno, o.name + ' ' + o.surname as surrname"
Line 2364: strSQL += " from Calendario C, Prenotaz P , Ospiti O "
Line 2365: strSQL += " where O.id=P.idCli AND C.idPrenotaz = P.id " 'And C.Giorno = " & d
Line 2366: strSQL += " and C.giornodate=#" & Left(d, 4) & "-" & Mid(d, 5, 2) & "-" & Right(d, 2) & "#"
Line 2367: strSQL += " and P.TipoStanza='" & ts & "'"
Line 2368:
Line 2369: Cn.Open()
Line 2370:
Line 2371: cmd = New OleDbCommand(strSQL, Cn)
Line 2372:
Line 2373: dr = cmd.ExecuteReader
Line 2374:
Line 2375: Do While dr.Read()
Line 2376:
Line 2377: If Not dr("makeavailable") Then
Line 2378: Select Case dr("stato")
Line 2379: Case 4
Line 2380: If dr("giorno") >= DateAnormal(DateAdd(DateInterval.Day, -1, Now.Date()), True) Then
Line 2381: TotPosti += 1
Line 2382: 'End If
Line 2383: End If
Line 2384:
Line 2385: Case 5
Line 2386: TotPosti += 1
Line 2387: End Select
Line 2388: End If
Line 2389:
Line 2390:
Line 2391: Loop
Line 2392:
Line 2393: DammiPostiOccupati = TotPosti
Line 2394:
Line 2395:
Line 2396: dr.Close()
Line 2397:
Line 2398: Cn.Close()
Line 2399:
Line 2400: End Function
Line 2401:
Line 2402: Protected Function DammiPostiOccupatiNots2(ByVal d As String) As String
Line 2403:
Line 2404: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2405: Dim cmd As OleDbCommand
Line 2406: Dim strSQL As String = ""
Line 2407: Dim dr As OleDbDataReader
Line 2408: Dim TotPosti As Integer = 0
Line 2409: Dim arrivati As Integer = 0
Line 2410: Dim daarrivare As Integer = 0
Line 2411:
Line 2412: DammiPostiOccupatiNots2 = "0#0"
Line 2413:
Line 2414: strSQL = "SELECT p.stato, p.giorno, o.name + o.surname as surrname"
Line 2415: strSQL += " from Calendario C, Prenotaz P , Ospiti O "
Line 2416: strSQL += " where O.id=P.idCli AND C.idPrenotaz = P.id And C.Giorno = " & d
Line 2417: strSQL += " and (P.Stato=4 or p.stato=5)"
Line 2418:
Line 2419:
Line 2420: Cn.Open()
Line 2421:
Line 2422: cmd = New OleDbCommand(strSQL, Cn)
Line 2423:
Line 2424: dr = cmd.ExecuteReader
Line 2425:
Line 2426: Do While dr.Read()
Line 2427:
Line 2428: Select Case dr("stato")
Line 2429: Case 4
Line 2430: 'If dr("giorno") >= d Then
Line 2431: TotPosti += 1
Line 2432: 'End If
Line 2433: daarrivare += 1
Line 2434: Case 5
Line 2435: TotPosti += 1
Line 2436:
Line 2437: arrivati += 1
Line 2438: End Select
Line 2439:
Line 2440:
Line 2441: Loop
Line 2442:
Line 2443: DammiPostiOccupatiNots2 = arrivati & "#" & daarrivare
Line 2444:
Line 2445: dr.Close()
Line 2446:
Line 2447: Cn.Close()
Line 2448:
Line 2449: End Function
Line 2450:
Line 2451: Protected Function DammiPostiOccupatiNoTs(ByVal d As String) As Integer
Line 2452:
Line 2453: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2454: Dim cmd As OleDbCommand
Line 2455: Dim strSQL As String = ""
Line 2456: Dim dr As OleDbDataReader
Line 2457: Dim TotPosti As Integer = 0
Line 2458:
Line 2459:
Line 2460: DammiPostiOccupatiNoTs = "0"
Line 2461:
Line 2462: strSQL = "SELECT p.makeavailable,p.stato, p.giorno, o.name + o.surname as surrname"
Line 2463: strSQL += " from Calendario C, Prenotaz P , Ospiti O "
Line 2464: strSQL += " where O.id=P.idCli AND C.idPrenotaz = P.id And C.Giorno = " & d
Line 2465:
Line 2466: Cn.Open()
Line 2467:
Line 2468: cmd = New OleDbCommand(strSQL, Cn)
Line 2469:
Line 2470: dr = cmd.ExecuteReader
Line 2471:
Line 2472: Do While dr.Read()
Line 2473:
Line 2474: If Not dr("makeavailable") Then
Line 2475: Select Case dr("stato")
Line 2476: Case 4
Line 2477: If dr("giorno") >= DateAnormal(DateAdd(DateInterval.Day, -1, Now.Date()), True) Then
Line 2478: TotPosti += 1
Line 2479:
Line 2480: End If
Line 2481: Case 5
Line 2482: TotPosti += 1
Line 2483: End Select
Line 2484: End If
Line 2485:
Line 2486:
Line 2487: Loop
Line 2488:
Line 2489: DammiPostiOccupatiNoTs = TotPosti
Line 2490:
Line 2491:
Line 2492: dr.Close()
Line 2493:
Line 2494: Cn.Close()
Line 2495:
Line 2496: End Function
Line 2497: Public Function DammiPostiTotali(ByVal ts As String) As Integer
Line 2498:
Line 2499: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2500: Dim cmd As OleDbCommand
Line 2501: Dim strSQL As String = ""
Line 2502: Dim dr As OleDbDataReader
Line 2503:
Line 2504:
Line 2505: DammiPostiTotali = "0"
Line 2506:
Line 2507:
Line 2508: strSQL = "SELECT count(*) as maxposti from Stanze S, Letti L WHERE S.Numero=L.Stanza AND S.Tipo='" & ts & "' AND S.Attiva=True"
Line 2509:
Line 2510: Cn.Open()
Line 2511:
Line 2512: cmd = New OleDbCommand(strSQL, Cn)
Line 2513:
Line 2514: dr = cmd.ExecuteReader
Line 2515:
Line 2516: If dr.HasRows Then
Line 2517: dr.Read()
Line 2518:
Line 2519: DammiPostiTotali = dr("maxposti")
Line 2520:
Line 2521: End If
Line 2522:
Line 2523:
Line 2524: dr.Close()
Line 2525:
Line 2526: Cn.Close()
Line 2527:
Line 2528: End Function
Line 2529:
Line 2530: Public Function DammiPostiTotaliNoTs() As Integer
Line 2531:
Line 2532: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2533: Dim cmd As OleDbCommand
Line 2534: Dim strSQL As String = ""
Line 2535: Dim dr As OleDbDataReader
Line 2536:
Line 2537:
Line 2538: DammiPostiTotaliNoTs = 0
Line 2539:
Line 2540:
Line 2541: strSQL = "SELECT count(*) as maxposti from Stanze S, Letti L WHERE S.Numero=L.Stanza AND S.Attiva=True"
Line 2542:
Line 2543: Cn.Open()
Line 2544:
Line 2545: cmd = New OleDbCommand(strSQL, Cn)
Line 2546:
Line 2547: dr = cmd.ExecuteReader
Line 2548:
Line 2549: If dr.HasRows Then
Line 2550: dr.Read()
Line 2551:
Line 2552: DammiPostiTotaliNoTs = dr("maxposti")
Line 2553:
Line 2554: End If
Line 2555:
Line 2556:
Line 2557: dr.Close()
Line 2558:
Line 2559: Cn.Close()
Line 2560:
Line 2561: End Function
Line 2562: Public Function DammiPrezzo(ByVal g As Integer, ByVal m As Integer, ByVal y As Integer, ByVal ts As String, ByVal season As String) As Double
Line 2563:
Line 2564: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2565: Dim drSSS As OleDbDataReader
Line 2566: Dim cmdSSS As OleDbCommand
Line 2567: Dim strSQL As String = ""
Line 2568: Dim SQL As String = ""
Line 2569: Dim p As Double = 0
Line 2570: Dim cosa As String = ""
Line 2571:
Line 2572: Cn.Open()
Line 2573:
Line 2574: 'ss = Format(CDate(g & "/" & m & "/" & y), "dd/MM/yyyy")
Line 2575:
Line 2576: 'Response.Write(ss)
Line 2577:
Line 2578: 'Response.End()
Line 2579:
Line 2580:
Line 2581:
Line 2582: If Weekday(Format(CDate(g & "/" & m & "/" & y), "dd/MM/yyyy")) = 6 Or Weekday(Format(CDate(g & "/" & m & "/" & y), "dd/MM/yyyy")) = 7 Then
Line 2583: cosa = "prezzowe"
Line 2584: Else
Line 2585: cosa = "prezzo"
Line 2586: End If
Line 2587:
Line 2588:
Line 2589: strSQL = "SELECT " & cosa & " as pp from DailyRatesLocal WHERE TipoStanza='" & ts & "' AND Giorno=" & g & " AND Mese=" & m
Line 2590:
Line 2591: cmdSSS = New OleDbCommand(strSQL, Cn)
Line 2592: drSSS = cmdSSS.ExecuteReader
Line 2593:
Line 2594: If drSSS.HasRows Then
Line 2595:
Line 2596: drSSS.Read()
Line 2597:
Line 2598: p = drSSS("pp")
Line 2599:
Line 2600: drSSS.Close()
Line 2601:
Line 2602:
Line 2603:
Line 2604: Else
Line 2605:
Line 2606: If season = "1" Then
Line 2607: If Weekday(Format(CDate(g & "/" & m & "/" & y), "dd/MM/yyyy")) = 6 Or Weekday(Format(CDate(g & "/" & m & "/" & y), "dd/MM/yyyy")) = 7 Then
Line 2608: cosa = "prezzolowwe"
Line 2609: Else
Line 2610: cosa = "prezzolow"
Line 2611: End If
Line 2612: End If
Line 2613:
Line 2614: drSSS.Close()
Line 2615:
Line 2616: strSQL = "SELECT " & cosa & " as pp from TipiStanza WHERE codice='" & ts & "'"
Line 2617:
Line 2618: cmdSSS = New OleDbCommand(strSQL, Cn)
Line 2619: drSSS = cmdSSS.ExecuteReader
Line 2620:
Line 2621: If drSSS.HasRows Then
Line 2622:
Line 2623: drSSS.Read()
Line 2624:
Line 2625: p = drSSS("pp")
Line 2626:
Line 2627: drSSS.Close()
Line 2628:
Line 2629:
Line 2630: End If
Line 2631: End If
Line 2632:
Line 2633: DammiPrezzo = p
Line 2634:
Line 2635: Cn.Close()
Line 2636:
Line 2637: End Function
Line 2638:
Line 2639:
Line 2640: Public Function DammiPrezzolistino(ByVal g As Integer, ByVal m As Integer, ByVal y As Integer, ByVal ts As String) As Double
Line 2641:
Line 2642: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2643: Dim drSSS As OleDbDataReader
Line 2644: Dim cmdSSS As OleDbCommand
Line 2645: Dim strSQL As String = ""
Line 2646: Dim SQL As String = ""
Line 2647: Dim p As Double = 0
Line 2648: Dim cosa As String = ""
Line 2649: Dim altastagione As Boolean = False
Line 2650: Dim originaly As Integer
Line 2651:
Line 2652: originaly = y
Line 2653:
Line 2654: 'If CDate(Format(g, "00") & "/" & Format(m, "00") & "/" & Format(y, "0000")) > CDate("03/11/" & y) Then
Line 2655:
Line 2656: 'Else
Line 2657: ' y = y - 1
Line 2658: 'End If
Line 2659: Cn.Open()
Line 2660:
Line 2661: Dim finesettimana As Boolean = Weekday(Format(CDate(g & "/" & m & "/" & originaly), "dd/MM/yyyy")) = 6 Or Weekday(Format(CDate(g & "/" & m & "/" & originaly), "dd/MM/yyyy")) = 7
Line 2662:
Line 2663: If CDate(Format(g, "00") & "/" & Format(m, "00") & "/" & Format(originaly, "0000")) > CDate("10/02/" & y) And CDate(Format(g, "00") & "/" & Format(m, "00") & "/" & Format(originaly, "0000")) < CDate("03/11/" & y) Then
Line 2664: If finesettimana Then
Line 2665: cosa = "prezzowe"
Line 2666: Else
Line 2667: cosa = "prezzo"
Line 2668: End If
Line 2669: altastagione = True
Line 2670: Else
Line 2671:
Line 2672: If finesettimana Then
Line 2673: cosa = "prezzolowwe"
Line 2674: Else
Line 2675: cosa = "prezzolow"
Line 2676: End If
Line 2677:
Line 2678: End If
Line 2679: strSQL = "SELECT " & cosa & " as pp from TipiStanza WHERE codice='" & ts & "'"
Line 2680:
Line 2681: cmdSSS = New OleDbCommand(strSQL, Cn)
Line 2682: drSSS = cmdSSS.ExecuteReader
Line 2683:
Line 2684: If drSSS.HasRows Then
Line 2685:
Line 2686: drSSS.Read()
Line 2687:
Line 2688: If altastagione Then
Line 2689: 'If Format(m, "00") = "04" Or Format(m, "00") = "09" Then
Line 2690: ' Dim aggiungialta As Double = 0
Line 2691: ' aggiungialta = (drSSS("pp") / 100) * 10
Line 2692: ' p = Int(drSSS("pp") + aggiungialta)
Line 2693: 'Else
Line 2694:
Line 2695: p = drSSS("pp")
Line 2696: 'End If
Line 2697: Else
Line 2698: p = drSSS("pp")
Line 2699: End If
Line 2700:
Line 2701:
Line 2702: drSSS.Close()
Line 2703:
Line 2704:
Line 2705: End If
Line 2706:
Line 2707: Dim sconto As Single = DammiSconto(CLng(Format(originaly, "00") & Format(m, "00") & Format(g, "00")))
Line 2708:
Line 2709: If sconto <> 0 Then
Line 2710: Dim ScontoValore = (p / 100) * sconto
Line 2711: DammiPrezzolistino = p + ScontoValore
Line 2712: Else
Line 2713:
Line 2714: DammiPrezzolistino = p
Line 2715: End If
Line 2716:
Line 2717: Cn.Close()
Line 2718:
Line 2719: End Function
Line 2720:
Line 2721:
Line 2722:
Line 2723: Sub CancellaPlan(ByVal idView As Long)
Line 2724:
Line 2725: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2726: Dim strSQL As String = ""
Line 2727: Dim cmd As OleDbCommand
Line 2728:
Line 2729: Cn.Open()
Line 2730:
Line 2731: strSQL = "UPDATE Colors C, SituaTime S SET C.taken=0 WHERE C.color=S.colore AND S.idPren= " & idView
Line 2732: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 2733: cmd.ExecuteNonQuery()
Line 2734:
Line 2735: strSQL = "DELETE FROM SituaTime WHERE idPren= " & idView
Line 2736: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 2737: cmd.ExecuteNonQuery()
Line 2738:
Line 2739: strSQL = "UPDATE Prenotaz SET BedsPlanned='' "
Line 2740: strSQL += " WHERE id=" & idView
Line 2741:
Line 2742: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 2743: cmd.ExecuteNonQuery()
Line 2744:
Line 2745: Cn.Close()
Line 2746:
Line 2747: End Sub
Line 2748:
Line 2749: Sub SalvaXML(ByVal str As String)
Line 2750:
Line 2751: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2752: Dim strSQL As String = ""
Line 2753: Dim cmd As OleDbCommand
Line 2754:
Line 2755: Cn.Open()
Line 2756:
Line 2757:
Line 2758: strSQL = "INSERT INTO Importxml(recordxml) VALUES('" & Apici(str) & "')"
Line 2759:
Line 2760: cmd = New OleDb.OleDbCommand(strSQL, Cn)
Line 2761: cmd.ExecuteNonQuery()
Line 2762:
Line 2763: Cn.Close()
Line 2764:
Line 2765: End Sub
Line 2766:
Line 2767: Public Function DammiIdDescOstello(ByVal idDesc As String, ByVal id As Boolean) As String
Line 2768:
Line 2769: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2770: Dim cmd As OleDbCommand
Line 2771: Dim strSQL As String = ""
Line 2772: Dim dr As OleDbDataReader
Line 2773:
Line 2774:
Line 2775: DammiIdDescOstello = ""
Line 2776:
Line 2777: strSQL = "SELECT * from Hostels WHERE "
Line 2778: If id Then
Line 2779: strSQL += " Hostel='" & idDesc & "'"
Line 2780: Else
Line 2781: strSQL += " id=" & Val(idDesc & "")
Line 2782: End If
Line 2783:
Line 2784: Cn.Open()
Line 2785:
Line 2786: cmd = New OleDbCommand(strSQL, Cn)
Line 2787:
Line 2788: dr = cmd.ExecuteReader
Line 2789:
Line 2790: If dr.HasRows Then
Line 2791: dr.Read()
Line 2792:
Line 2793: If id Then
Line 2794: DammiIdDescOstello = CStr(dr("id")) & ""
Line 2795: Else
Line 2796: DammiIdDescOstello = dr("Hostel") & ""
Line 2797: End If
Line 2798:
Line 2799: End If
Line 2800:
Line 2801:
Line 2802: dr.Close()
Line 2803:
Line 2804: Cn.Close()
Line 2805:
Line 2806: End Function
Line 2807:
Line 2808: Public Function DammiIdOstello(ByVal id As String, ByVal tornaocto As Boolean) As String
Line 2809:
Line 2810: Dim Cn As New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString") & HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings("dbname")))
Line 2811: Dim cmd As OleDbCommand
Line 2812: Dim strSQL As String = ""
Line 2813: Dim dr As OleDbDataReader
Line 2814:
Line 2815:
Line 2816: DammiIdOstello = ""
Line 2817:
Line 2818: strSQL = "SELECT * from Hostels WHERE "
Line 2819: If tornaocto Then
Line 2820: strSQL += " id=" & id
Line 2821: Else
Line 2822: strSQL += " hostelocto='" & id & "'"
Line 2823: End If
Line 2824:
Line 2825: Cn.Open()
Line 2826:
Line 2827: cmd = New OleDbCommand(strSQL, Cn)
Line 2828:
Line 2829: dr = cmd.ExecuteReader
Line 2830:
Line 2831: If dr.HasRows Then
Line 2832: dr.Read()
Line 2833:
Line 2834: If tornaocto Then
Line 2835: DammiIdOstello = dr("Hostelocto") & ""
Line 2836:
Line 2837: Else
Line 2838:
Line 2839: DammiIdOstello = CStr(dr("id")) & ""
Line 2840: End If
Line 2841:
Line 2842: End If
Line 2843:
Line 2844:
Line 2845: dr.Close()
Line 2846:
Line 2847: Cn.Close()
Line 2848:
Line 2849: End Function
Line 2850: End Class
Line 2851:
|