• Welcome, Guest. Please login.
 
October 14, 2019, 02:57:37 am

News:

Welcome to the SQLitening support forums!


Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - cj

1
Sounds like they owe another day or need to be evicted.
I think they would automatically be charged another day.
or
I suppose they could have left without checking out.
But if they come back would be a real problem if they still have a key.
2
What is auto checkout?
Doesn't someone have to pay the bill and hand in a room key?
3
If you have the room number you probably can get the bill number.
If you have the bill number you might not need the room number.

I
LOCAL sRoomNo AS STRING
LOCAL sBillNo AS STRING
LOCAL ecode   AS LONG
ecode = AutoCheckOutGuests(sRoomNo, sBillNo)
4
Yes
Function AutoCheckOutGuests(ByVal roomno As Long, ByVal billno As Long) As Long

BYVAL not required unless the value might be changed and caller needs original number.
If you use all strings then passing strings is fine.
5
I think the unique billno should be used instead of recordno.
Everything should be in a transaction.
I would think knowing the roomno or billno would have to be passed to the function.
I don't see any need for the CASE statement.
6
What values? 
Please supply something with a database and tables.
7
Welcome
Hope you have something working that didn't require a trigger.
8
FUNCTION PBMAIN () AS LONG
 LOCAL hThread AS LONG
 THREAD CREATE CheckEveryHour(1000 * 60 * 60) TO hThread
 THREAD CLOSE hThread TO hThread
 ? "Done"
END FUNCTION

THREAD FUNCTION CheckEveryHour(BYVAL Milliseconds AS LONG) AS LONG
 LOCAL x AS LONG
 DO
  IF LEFT$(TIME$,2) = "XX" THEN CALL Something
  SLEEP milliseconds
 LOOP
END FUNCTION

SUB Something
 BEEP
END SUB
11
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
12
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
14
Quote from: undefinedI find the way this is handled in SQLite to be one of the great features.
I normally create columns with no data type, which will result in an
affinity of none, by using the following create syntax:
Code Select
  Create Table T1 (C1, C2, C3)
I have found no advantage in assigning column affinity using the following:
Code Select
  Create Table T1 (C1 Integer, C2 Text, C3 Real)

Hi, Fredrick!

It goes against the above post #1, but had to say something.
Glad we are doing it the same way.
I haven't been assigning affinity or NOT NULL in my demos and will try to remember.
15
I am bringing back this very old subject because of problems not defining a column as TEXT.
Be careful not specifying INTEGER or TEXT in CREATE statements.

1. text and binary values are inserted into the column
2. 101 is not "101" so searching and sorting may not return expected value.

If column is UNIQUE:
insert 101 and '101' and two values are insert if no datatype
insert 101 and '101' and second value produces duplicate error if datatype was specified

Bottom line:
Specifying (or not specifing) data type in CREATE statements is very important

CREATE statement without specifying column type and 2 records are inserted
create table t1(key1 primary key) without rowid
insert into t1 values('101') 'insert success
insert into t1 values(101)   'insert sucess

CREATE statement specifying column as TEXT and 1 record is insert and second produces duplicate error
create table t1(key1 TEXT primary key) without rowid"
insert into t1 values('101') 'insert success
insert into t1 values(101)   'duplicate

This example demonstrates inserting 2-values into a unique column
The first loop creates table without a datatype and 2-values are insert
The second loop creates table with a datatype and 1-value is insert

#INCLUDE "sqlitening.inc"
FUNCTION PBMAIN () AS LONG
 slSetProcessMods "E1"
 LOCAL x AS LONG, sArray() AS STRING
 FOR x = 1 TO 2
  slopen "junk.db3","C"
  slexe "drop table if exists t1"

  IF x =1 THEN
   slexe "create table if not exists t1(key1 primary key) without rowid"
  ELSE
   slexe "create table if not exists t1(key1 TEXT primary key) without rowid"
  END IF

  slexe "insert into t1 values('101')"
  slexe "insert into t1 values(101)"
  slselary "select * from t1",sArray()
  ? JOIN$(sArray(),$CR),,"create table if not exists t1(key1 primary key) without rowid"
  slClose
 NEXT
END FUNCTION