• Welcome, Guest. Please login.
 
October 14, 2019, 04:31:36 am

News:

Welcome to the SQLitening support forums!


Recent posts

Pages 1 2 3 4 5 ... 10
21
You've got Questions? We've got Answers! / Re: Is Auto Checkout Guests Ca...
Last post by cj - September 06, 2019, 08:51:57 pm
Would it be better to use task scheduler in case your program isn't running?

https://www.windowscentral.com/how-create-automated-task-using-task-scheduler-windows-10
22
>>Using a timer, at startup, by a click?

Timer would be the best option in the situation. Say 12:05 everyday.
23
You've got Questions? We've got Answers! / Re: Is Auto Checkout Guests Ca...
Last post by cj - September 06, 2019, 08:27:06 pm
Rearranged the code into a couple of functions.
Not sure when you want to automatically call a function.
Using a timer, at startup, by a click?

#COMPILE EXE
#DIM ALL
#INCLUDE "sqlitening.inc"

FUNCTION PBMAIN AS LONG
 CreateRecords
 ViewRecords
END FUNCTION

FUNCTION CreateRecords AS LONG
 LOCAL x AS LONG
 LOCAL s$
 DIM sarray$()
 LOCAL Errorcode&
 LOCAL sRoomNo AS STRING
 LOCAL sRecordNo AS STRING

 sRoomNo = "501"
 slOpen ("GuestsProDB.db3","C")
 'Registration
  slExe BUILD$("Create Table If Not Exists tblRegistration(Surname TEXT COLLATE NOCASE, Othernames TEXT COLLATE NOCASE, Address TEXT,", _
  "MobileNo TEXT, CompanyName TEXT, Position TEXT, Nationality TEXT, ArrivalDate TEXT, ArrivalTime TEXT, NoOfNights TEXT, DepartureDate TEXT, DepartureTime TEXT,", _
  "StateArrivingFrom TEXT, StateGoingTo TEXT, Identification TEXT, IDNo TEXT, Sponsor TEXT, PurposeOfVisit TEXT, NoOfGuests TEXT, RoomNo TEXT, RoomRate TEXT,", _
  "RoomType TEXT, BillNo TEXT, StayOver)")

  slExe "Create Index If Not Exists Registrationndx1 ON tblRegistration(BillNo)"
  slExe "Create Index If Not Exists Registrationndx2 ON tblRegistration(Surname)"
  slExe "Create Index If Not Exists Registrationndx3 ON tblRegistration(Othernames)"

  slExe slBuildInsertOrUpdate("tblRoomRates", sRoomNo & $NUL & "Available", "RoomNo, Status", "RoomNo=" & sRoomNo)
        Errorcode& = slExe("Insert into tblRegistrationHistory Select * From tblRegistration Where RowID = '" + sRecordNo + "'","E")
        IF Errorcode& = 19 THEN
            MSGBOX "Bill No Already Sent And Is Still Existing In The Registeration History", %MB_TASKMODAL OR %MB_ICONINFORMATION, EXE.NAME$
            EXIT FUNCTION
        END IF

        slEXE "Delete From tblRegistration WHERE DepartureDate <= date('now') AND DepartureTime >= time('12')"
END FUNCTION

FUNCTION ViewRecords AS LONG
 LOCAL s,sArray() AS STRING
 s = "select DepartureDate,DepartureTime,"
 s+= " case"
 s+= "  when DepartureDate <= date('now') THEN 'greater'"
 s+= "  when DepartureDate = date('now') THEN 'less'"
 s+= "  WHEN DepartureTime > time('12') THEN 'Greater Than'"
 's$+= "  else            'equal'"
 s+= " end as NewColName"
 s+= " from tblRegistration"
 slselary s,sarray$(),"Q9"
 ? JOIN$(sarray$(),$CR)
END FUNCTION
24
Hello CJ,

Looks good. I would need to do some weeding.

How do I make this piece code activate itself without clicking anything to bring it to action? Thread?

#COMPILE EXE
#DIM ALL

#INCLUDE "sqlitening.inc"

FUNCTION CDate(Pbd AS STRING) AS STRING
     'Change PB date to mm-dd-yyyy to yyyy-mm-dd

     FUNCTION = MID$(Pbd,7,4) & "-" & MID$(Pbd,1,2) & "-" & MID$(Pbd,4,2)

END FUNCTION

FUNCTION PBMAIN AS LONG
 LOCAL x AS LONG
 LOCAL s$
 DIM sarray$()
 LOCAL Errorcode&
 LOCAL sRoomNo AS STRING
 LOCAL sRecordNo AS STRING

 sRoomNo = "501"

 slOpen ("GuestsProDB.db3","C")

 'Registration
  slExe BUILD$("Create Table If Not Exists tblRegistration(Surname TEXT COLLATE NOCASE, Othernames TEXT COLLATE NOCASE, Address TEXT,", _
  "MobileNo TEXT, CompanyName TEXT, Position TEXT, Nationality TEXT, ArrivalDate TEXT, ArrivalTime TEXT, NoOfNights TEXT, DepartureDate TEXT, DepartureTime TEXT,", _
  "StateArrivingFrom TEXT, StateGoingTo TEXT, Identification TEXT, IDNo TEXT, Sponsor TEXT, PurposeOfVisit TEXT, NoOfGuests TEXT, RoomNo TEXT, RoomRate TEXT,", _
  "RoomType TEXT, BillNo TEXT, StayOver)")

   slExe "Create Index If Not Exists Registrationndx1 ON tblRegistration(BillNo)"

   slExe "Create Index If Not Exists Registrationndx2 ON tblRegistration(Surname)"

   slExe "Create Index If Not Exists Registrationndx3 ON tblRegistration(Othernames)"

 FOR x = -10 TO 10:NEXT
 s$ = "select DepartureDate,DepartureTime,"
 s$+= " case"
 s$+= "   when DepartureDate <= date('now') THEN 'greater'"
 s$+= "   when DepartureDate = date('now') THEN 'less'"
 s$+= "   WHEN DepartureTime > time('12') THEN 'Greater Than'"
 's$+= "  else             'equal'"
 s$+= " end as NewColName"
 s$+= " from tblRegistration"
 ? s$
 slselary s$,sarray$(),"Q9"
 ? JOIN$(sarray$(),$CR)

  slExe slBuildInsertOrUpdate("tblRoomRates", sRoomNo & $NUL & "Available", "RoomNo, Status", "RoomNo=" & sRoomNo)
        Errorcode& = slExe("Insert into tblRegistrationHistory Select * From tblRegistration Where RowID = '" + sRecordNo + "'","E")
        IF Errorcode& = 19 THEN
             MSGBOX "Bill No Already Sent And Is Still Existing In The Registeration History", %MB_TASKMODAL OR %MB_ICONINFORMATION, EXE.NAME$
             EXIT FUNCTION
        END IF

        slEXE "Delete From tblRegistration WHERE DepartureDate <= date('now') AND DepartureTime >= time('12')"

END FUNCTION
                                   
25
Hello CJ,

Interesting. Trying to adapt your technique.

Thanks.
26
You've got Questions? We've got Answers! / Re: Is Auto Checkout Guests Ca...
Last post by cj - September 06, 2019, 10:24:47 am
Sorry, somebody else might have trigger logic.
Might be able to create a temporary table and create a trigger on it.

https://www.sqlitetutorial.net/sqlite-trigger/

A recordset could be created using a CASE statement
to test any conditions and write what to do for any
of those conditions.  When done, process the recordset.
CASE statements can test the same record multiple times
and can be nested.

#INCLUDE "sqlitening.inc"
FUNCTION PBMAIN AS LONG

 slopen ":memory:"
 slexe "create table t1(c1 integer)"
 FOR x& = -10 TO 10:slexe "insert into t1 values(" + STR$(x&) + ")":NEXT

 s$ = "select c1, "
 s$+= " case"
 s$+= "   when c1 > 0 THEN 'greater'"
 s$+= "   when c1 < 0 THEN 'less'"
 s$+= "  else             'equal'"
 s$+= " end as NewColName"
 s$+= " from t1"
 
 slselary s$,sarray$(),"Q9"
 ? JOIN$(sarray$(),$CR)

END FUNCTION
27
Hello,

I am stump trying to figure out how to automatically 'trigger' this sequence of SQL startements. I wonder if Trigger is the best condidate.

'Free room
slExe slBuildInsertOrUpdate("tblRoomRates", sRoomNo & $Nul & "Available", "RoomNo, Status", "RoomNo=" & sRoomNo)

'Copy record to History Table
Errorcode& = slExe("Insert into tblRegistrationHistory Select * From tblRegistration Where RowID = '" + sRecordNo + "'","E")

Delete Record     
slEXE "Delete From tblRegistration WHERE DepartureDate <= date('now') AND DepartureTime <= time('12')"

But triggers are only triggered when an INSERT, DELETE or UPDATE occurs. I want the statements triggered when this conditions are met:

If (sDepartureDate < Date$) Or (sDepartureDate = Date$ And Time$ > "12") Then
....
End If

Any help would be appreciated.
28
Hello Cj,

I currently use RMCharts and I am looking to use PowerBasic native Graphics to draw charts, using SQLitening data, just like I did in RMCharts.

So I thought I could use gbMasterCharts with SQLitening. But I could not find much success with it.

30
Hello Everyone,

Has anyone tried using SQLitening with Gary Beene's gbChartMaster here?

http://www.garybeene.com/sw/gbchartmaster.htm

Kind regards.

Pages 1 2 3 4 5 ... 10