Added issue penalties function
This commit adds another piece of functinality allowing the staff to issue penalties. This currently just charges users for their owed amount and there are no actual penalty fees. The design document did not call for that. There is also some documentation that was written. The next several set of commits are likely to be documentation.
This commit is contained in:
@@ -37,7 +37,7 @@ namespace Ophelias.Managers
|
|||||||
cmd.CommandText = "SELECT RoomNum, Lname, Fname, EndDate FROM reservations " +
|
cmd.CommandText = "SELECT RoomNum, Lname, Fname, EndDate FROM reservations " +
|
||||||
"INNER JOIN guests ON reservations.GuestID = guests.ID " +
|
"INNER JOIN guests ON reservations.GuestID = guests.ID " +
|
||||||
"INNER JOIN rooms ON reservations.RoomNum = rooms.ID " +
|
"INNER JOIN rooms ON reservations.RoomNum = rooms.ID " +
|
||||||
"WHERE (DATE(@Date) BETWEEN StartDate AND EndDate) AND Status IN (@Status1,@Status2);";
|
"WHERE (DATE(@Date) BETWEEN StartDate AND EndDate) AND Status IN (@Status1,@Status2) AND CheckIn IS NOT NULL;";
|
||||||
cmd.Parameters.AddWithValue("@Date", DateTime.Now.Date.ToString("yyyy-MM-dd"));
|
cmd.Parameters.AddWithValue("@Date", DateTime.Now.Date.ToString("yyyy-MM-dd"));
|
||||||
cmd.Parameters.AddWithValue("@Status1", (int)ReservationStatus.Active);
|
cmd.Parameters.AddWithValue("@Status1", (int)ReservationStatus.Active);
|
||||||
cmd.Parameters.AddWithValue("@Status2", (int)ReservationStatus.Changed);
|
cmd.Parameters.AddWithValue("@Status2", (int)ReservationStatus.Changed);
|
||||||
@@ -774,13 +774,13 @@ namespace Ophelias.Managers
|
|||||||
"WHERE ID = (SELECT RoomNum FROM reservations WHERE GuestID = (SELECT ID FROM guests WHERE Email = @Email AND Status in (@SActive,@SChanged)));";
|
"WHERE ID = (SELECT RoomNum FROM reservations WHERE GuestID = (SELECT ID FROM guests WHERE Email = @Email AND Status in (@SActive,@SChanged)));";
|
||||||
cmd.Parameters.AddWithValue("@Email", Email);
|
cmd.Parameters.AddWithValue("@Email", Email);
|
||||||
cmd.Parameters.AddWithValue("@SActive", (int)ReservationStatus.Active);
|
cmd.Parameters.AddWithValue("@SActive", (int)ReservationStatus.Active);
|
||||||
cmd.Parameters.AddWithValue("@SChanged", (int)ReservationStatus.Ended);
|
cmd.Parameters.AddWithValue("@SChanged", (int)ReservationStatus.Changed);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
using (SQLiteCommand cmd = Manager.con.CreateCommand())
|
using (SQLiteCommand cmd = Manager.con.CreateCommand())
|
||||||
{
|
{
|
||||||
cmd.CommandText = "UPDATE reservations SET CheckOut = @Date, Status = @Status " +
|
cmd.CommandText = "UPDATE reservations SET CheckOut = @Date, Status = @Status " +
|
||||||
"WHERE GuestID = (SELECT ID FROM guests WHERE Email = @Email) AND RoomNum IS NOT NULL AND Status in (@SActive,@SChanged);";
|
"WHERE GuestID = (SELECT ID FROM guests WHERE Email = @Email) AND RoomNum IS NOT NULL AND Status in (@SActive,@SChanged) AND CheckIn IS NULL;";
|
||||||
cmd.Parameters.AddWithValue("@Email", Email);
|
cmd.Parameters.AddWithValue("@Email", Email);
|
||||||
cmd.Parameters.AddWithValue("@Status", (int)ReservationStatus.Ended);
|
cmd.Parameters.AddWithValue("@Status", (int)ReservationStatus.Ended);
|
||||||
cmd.Parameters.AddWithValue("@SActive", (int)ReservationStatus.Active);
|
cmd.Parameters.AddWithValue("@SActive", (int)ReservationStatus.Active);
|
||||||
@@ -872,6 +872,7 @@ namespace Ophelias.Managers
|
|||||||
List<Reservation> list = new();
|
List<Reservation> list = new();
|
||||||
using (Database Manager = new())
|
using (Database Manager = new())
|
||||||
{
|
{
|
||||||
|
using SQLiteTransaction Transaction = Manager.con.BeginTransaction();
|
||||||
using (SQLiteCommand cmd = Manager.con.CreateCommand())
|
using (SQLiteCommand cmd = Manager.con.CreateCommand())
|
||||||
{
|
{
|
||||||
cmd.CommandText = "SELECT * FROM reservations " +
|
cmd.CommandText = "SELECT * FROM reservations " +
|
||||||
@@ -936,6 +937,17 @@ namespace Ophelias.Managers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
using (SQLiteCommand cmd = Manager.con.CreateCommand())
|
||||||
|
{
|
||||||
|
cmd.CommandText = "UPDATE reservations SET IsNoShow = 1, DateChanged = @DateChanged " +
|
||||||
|
"WHERE DATE (@Date) > StartDate AND Status IN (@Status1,@Status2) AND CheckIn IS NULL";
|
||||||
|
cmd.Parameters.AddWithValue("@Date", DateTime.Now.Date.ToString("yyyy-MM-dd"));
|
||||||
|
cmd.Parameters.AddWithValue("@DateChanged", DateTime.Now.Date.ToString("yyyy-MM-dd"));
|
||||||
|
cmd.Parameters.AddWithValue("@Status1", (int)ReservationStatus.Active);
|
||||||
|
cmd.Parameters.AddWithValue("@Status2", (int)ReservationStatus.Changed);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
Transaction.Commit();
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,6 +188,16 @@ namespace Ophelias.Models
|
|||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Type == ReservationType.Conventional && _DateChanged.Date >= StartDate.AddDays(-3).Date)
|
||||||
|
{
|
||||||
|
Transaction.Pay(Transaction.Owed, Guest.CreditCard);
|
||||||
|
} else if (Type == ReservationType.Incentive && _DateChanged.Date >= StartDate.AddDays(-3).Date)
|
||||||
|
{
|
||||||
|
Transaction.Pay(Transaction.Owed, Guest.CreditCard);
|
||||||
|
} else if (_DateChanged.Date > StartDate.Date)
|
||||||
|
{
|
||||||
|
Transaction.Pay(Transaction.Owed, Guest.CreditCard);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal enum ReservationStatus
|
internal enum ReservationStatus
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ namespace Ophelias.Models
|
|||||||
{
|
{
|
||||||
return PaymentStatus.MissingCreditCard;
|
return PaymentStatus.MissingCreditCard;
|
||||||
}
|
}
|
||||||
if (Amount >= Owed)
|
if (AmountPaid >= Owed)
|
||||||
{
|
{
|
||||||
return PaymentStatus.AlreadyPaid;
|
return PaymentStatus.AlreadyPaid;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -993,6 +993,15 @@ internal class Program
|
|||||||
Console.WriteLine($"Daily occupancy has been written and appended to {f.FullName}");
|
Console.WriteLine($"Daily occupancy has been written and appended to {f.FullName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void IssuePenalties()
|
||||||
|
{
|
||||||
|
List<Reservation> reservations = Hotel.GetPastDueReservations();
|
||||||
|
foreach (Reservation reservation in reservations)
|
||||||
|
{
|
||||||
|
reservation.CancelReservation();
|
||||||
|
}
|
||||||
|
Console.WriteLine("Penalties have been issued.");
|
||||||
|
}
|
||||||
|
|
||||||
Console.Write(
|
Console.Write(
|
||||||
"\nWelcome to the Ophelias Oasis Hotel Management System!\n" +
|
"\nWelcome to the Ophelias Oasis Hotel Management System!\n" +
|
||||||
@@ -1009,7 +1018,7 @@ internal class Program
|
|||||||
case "generate operational report": GenerateOperationalReports(); break;
|
case "generate operational report": GenerateOperationalReports(); break;
|
||||||
case "generate accommodation bills": GenerateAccommodationBills(); break;
|
case "generate accommodation bills": GenerateAccommodationBills(); break;
|
||||||
case "notify pending payments": NotifyOutstandingPayments(); break;
|
case "notify pending payments": NotifyOutstandingPayments(); break;
|
||||||
case "issue penalties": break;
|
case "issue penalties": IssuePenalties(); break;
|
||||||
case "checkin guest": CheckIn(); break;
|
case "checkin guest": CheckIn(); break;
|
||||||
case "checkout guest": CheckOut(); break;
|
case "checkout guest": CheckOut(); break;
|
||||||
case "set rate": SetFutureBaseRate(); break;
|
case "set rate": SetFutureBaseRate(); break;
|
||||||
@@ -1026,34 +1035,41 @@ internal class Program
|
|||||||
{
|
{
|
||||||
if (!File.Exists("database.sqlite3") || new FileInfo("database.sqlite3").Length == 0)
|
if (!File.Exists("database.sqlite3") || new FileInfo("database.sqlite3").Length == 0)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Checks to see if the databse is created. If the database file is missing, that means
|
||||||
|
* it has not been initialized. Upon the initialization process, the tables are created
|
||||||
|
* and the rooms table is populated with 45 rooms. This is a preconfigured value within
|
||||||
|
* the InitializeRoomsTable() function since there was no requirement to make this configurable.
|
||||||
|
*/
|
||||||
SQLiteConnection.CreateFile("database.sqlite3");
|
SQLiteConnection.CreateFile("database.sqlite3");
|
||||||
using (Database Manager = new())
|
using Database Manager = new();
|
||||||
{
|
|
||||||
Manager.InitializeTables();
|
Manager.InitializeTables();
|
||||||
Manager.InitializeRoomsTable();
|
Manager.InitializeRoomsTable();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!Hotel.CheckBaseRate())
|
if (!Hotel.CheckBaseRate())
|
||||||
{
|
{
|
||||||
|
// Checks to see if the base rate is configured, if not a warning will be shown.
|
||||||
Console.WriteLine("No base rate is configured. As a result reservations cannot be made until one is configured.");
|
Console.WriteLine("No base rate is configured. As a result reservations cannot be made until one is configured.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool run = true;
|
bool run = true;
|
||||||
while (run)
|
while (run)
|
||||||
{
|
{
|
||||||
|
// Main loop for checking if the person is a customer or employee.
|
||||||
Console.Write(
|
Console.Write(
|
||||||
"Are you an employee or customer?\n" +
|
"Are you an employee or customer?\n" +
|
||||||
"1. Employee\n" +
|
"1. Employee\n" +
|
||||||
"2. Customer/ Guest\n" +
|
"2. Customer/ Guest\n" +
|
||||||
": "
|
": "
|
||||||
);
|
);
|
||||||
switch (Console.ReadLine().ToUpper())
|
switch (Console.ReadLine().ToUpper()) // Using .ToUpper() to support "q" without having to write a case for it.
|
||||||
{
|
{
|
||||||
case "1": AdminMode(); break;
|
case "1": AdminMode(); break; // Enter employee (administrative) mode
|
||||||
case "2": GuestMode(); break;
|
case "2": GuestMode(); break; // Enter guest (customer) mode
|
||||||
case "Q": run = false; break;
|
case "Q": run = false; break; // Quit
|
||||||
default: Console.WriteLine("You must either specify 1 for Employee, 2 for Customer/ Guest, or Q to quit.\n\n"); break;
|
default: Console.WriteLine("You must either specify 1 for Employee, 2 for Customer/ Guest, or Q to quit.\n\n"); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Console.WriteLine("Shutting system down.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user