Updateed some formatting and bug fixes
Fixed inconsistencies in queries that would result in errors because the parameters were missing. Updating a guest is an example that had this issue. After checking parameters should all be supplied where needed.
This commit is contained in:
@@ -51,9 +51,10 @@ namespace Ophelias.Managers
|
|||||||
using SQLiteDataReader reader = cmd.ExecuteReader(); // Create a new reader to read the SQL data
|
using SQLiteDataReader reader = cmd.ExecuteReader(); // Create a new reader to read the SQL data
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
foreach (int item in reader.GetValues())
|
foreach (var item in reader.GetValues())
|
||||||
{
|
{
|
||||||
previousOccupancies.Add(item);
|
if (item.GetType().Equals(typeof(int)))
|
||||||
|
previousOccupancies.Add((int)item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -554,8 +555,12 @@ namespace Ophelias.Managers
|
|||||||
using (Database Manager = new()) // Opens a database connection
|
using (Database Manager = new()) // Opens a database connection
|
||||||
{
|
{
|
||||||
using SQLiteCommand cmd = Manager.con.CreateCommand(); // Creates a new command
|
using SQLiteCommand cmd = Manager.con.CreateCommand(); // Creates a new command
|
||||||
cmd.CommandText = $"SELECT * FROM reservation WHERE Email = @Email AND Status IN (@Status1,@Status2)";
|
cmd.CommandText = "SELECT * FROM reservations " +
|
||||||
|
"INNER JOIN guests ON reservations.GuestID = guests.ID " +
|
||||||
|
"WHERE Email = @Email AND Status IN (@Status1,@Status2)";
|
||||||
cmd.Parameters.AddWithValue("@Email", Email);
|
cmd.Parameters.AddWithValue("@Email", Email);
|
||||||
|
cmd.Parameters.AddWithValue("@Status1", (int)ReservationStatus.Active);
|
||||||
|
cmd.Parameters.AddWithValue("@Status2", (int)ReservationStatus.Changed);
|
||||||
using SQLiteDataReader reader = cmd.ExecuteReader(); // Creates a new SQL data reader
|
using SQLiteDataReader reader = cmd.ExecuteReader(); // Creates a new SQL data reader
|
||||||
reader.Read();
|
reader.Read();
|
||||||
if (reader.HasRows)
|
if (reader.HasRows)
|
||||||
@@ -798,7 +803,7 @@ namespace Ophelias.Managers
|
|||||||
* occupied as a guest has been assigned it.
|
* occupied as a guest has been assigned it.
|
||||||
*/
|
*/
|
||||||
cmd.CommandText = "UPDATE rooms SET Occupied = 1 " +
|
cmd.CommandText = "UPDATE rooms SET Occupied = 1 " +
|
||||||
"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.Changed);
|
cmd.Parameters.AddWithValue("@SChanged", (int)ReservationStatus.Changed);
|
||||||
@@ -818,7 +823,7 @@ namespace Ophelias.Managers
|
|||||||
reader.Read();
|
reader.Read();
|
||||||
if (reader.HasRows)
|
if (reader.HasRows)
|
||||||
{
|
{
|
||||||
RoomID = (int)reader.GetValue(0);
|
RoomID = reader.GetInt32(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Transaction.Commit(); // Commits the transaction
|
Transaction.Commit(); // Commits the transaction
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ namespace Ophelias.Models
|
|||||||
{
|
{
|
||||||
using SQLiteCommand cmd = Manager.con.CreateCommand(); // Creates a new command that will be executed in the database
|
using SQLiteCommand cmd = Manager.con.CreateCommand(); // Creates a new command that will be executed in the database
|
||||||
cmd.CommandText = QueryBuilder.UpdateGuest(Id, FirstName, LastName, Email, CreditCard, Expiration, CCV);
|
cmd.CommandText = QueryBuilder.UpdateGuest(Id, FirstName, LastName, Email, CreditCard, Expiration, CCV);
|
||||||
|
cmd.Parameters.AddWithValue("@Id", Id);
|
||||||
cmd.Parameters.AddWithValue("@Fname", FirstName);
|
cmd.Parameters.AddWithValue("@Fname", FirstName);
|
||||||
cmd.Parameters.AddWithValue("@Lname", LastName);
|
cmd.Parameters.AddWithValue("@Lname", LastName);
|
||||||
cmd.Parameters.AddWithValue("@Email", Email);
|
cmd.Parameters.AddWithValue("@Email", Email);
|
||||||
|
|||||||
@@ -576,6 +576,19 @@ internal class Program
|
|||||||
Console.WriteLine("You currently do not have an active registration.");
|
Console.WriteLine("You currently do not have an active registration.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (activeReservation.StartDate.Date < DateTime.Now.Date && activeReservation.CheckIn == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Your reservation is no longer valid, it has been cancelled. You may be charged based on your reservation type.");
|
||||||
|
activeReservation.CancelReservation();
|
||||||
|
activeReservation = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (activeReservation.CheckIn != null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("You can't update a reservation that has been checked in.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Console.Write("Your current reservation details are:\n" +
|
Console.Write("Your current reservation details are:\n" +
|
||||||
$"\tStarts on: {activeReservation.StartDate.ToString("yyyy-MM-dd")}\n" +
|
$"\tStarts on: {activeReservation.StartDate.ToString("yyyy-MM-dd")}\n" +
|
||||||
@@ -711,6 +724,7 @@ internal class Program
|
|||||||
}
|
}
|
||||||
activeReservation.CancelReservation();
|
activeReservation.CancelReservation();
|
||||||
Console.WriteLine("Your reservation has been cancelled because you failed to pay within the payment period.");
|
Console.WriteLine("Your reservation has been cancelled because you failed to pay within the payment period.");
|
||||||
|
activeReservation = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ namespace Ophelias.Reporting
|
|||||||
{
|
{
|
||||||
string report = $"ACCOMMODATION BILL - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
|
string report = $"ACCOMMODATION BILL - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
|
||||||
$"Name: {r.Guest.LastName}, {r.Guest.FirstName}\n" +
|
$"Name: {r.Guest.LastName}, {r.Guest.FirstName}\n" +
|
||||||
$"Arrival Date: {r.StartDate}\n" +
|
$"Arrival Date: {r.StartDate.Date.ToString("yyyy-MM-dd")}\n" +
|
||||||
$"Departure Date: {r.EndDate}\n" +
|
$"Departure Date: {r.EndDate.Date.ToString("yyyy-MM-dd")}\n" +
|
||||||
$"Length of Stay: {(int)(r.EndDate.Date - r.StartDate.Date).TotalDays} days\n" +
|
$"Length of Stay: {(int)(r.EndDate.Date - r.StartDate.Date).TotalDays} days\n" +
|
||||||
$"Charged: ${r.Transaction.Owed}\n\n";
|
$"Charged: ${Math.Round(r.Transaction.Owed, 2)}\n\n";
|
||||||
File.AppendAllText(Path.GetFullPath("AccommodationBills.txt"), report);
|
File.AppendAllText(Path.GetFullPath("AccommodationBills.txt"), report);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Ophelias.Reporting
|
|||||||
string report = $"EXPECTED 30 DAY OCCUPANCY REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
|
string report = $"EXPECTED 30 DAY OCCUPANCY REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
|
||||||
$"Date\tRooms Filled\tConventional\tPrepaid\t60-Day\tIncentive\n" +
|
$"Date\tRooms Filled\tConventional\tPrepaid\t60-Day\tIncentive\n" +
|
||||||
$"{string.Join("\n", entries)}\n" + // Combine entries at this location in the string
|
$"{string.Join("\n", entries)}\n" + // Combine entries at this location in the string
|
||||||
$"Average Occupancy Rate: {average}\n\n";
|
$"Average Occupancy Rate: {Math.Round(average, 2)}\n\n";
|
||||||
|
|
||||||
File.AppendAllText(Path.GetFullPath("ExpectedOccupancy.txt"), report); // Write to file
|
File.AppendAllText(Path.GetFullPath("ExpectedOccupancy.txt"), report); // Write to file
|
||||||
}
|
}
|
||||||
@@ -40,13 +40,13 @@ namespace Ophelias.Reporting
|
|||||||
List<string> entries = new();
|
List<string> entries = new();
|
||||||
foreach (var x in items) // Build a list of entries
|
foreach (var x in items) // Build a list of entries
|
||||||
{
|
{
|
||||||
entries.Add($"{x.Item1.Date.ToString("yyyy-MM-dd")}\t{x.Item2}");
|
entries.Add($"{x.Item1.Date.ToString("yyyy-MM-dd")}\t{Math.Round(x.Item2, 2)}");
|
||||||
}
|
}
|
||||||
string report = $"EXPECTED 30 DAY INCOME REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
|
string report = $"EXPECTED 30 DAY INCOME REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
|
||||||
$"Date\tIncome\n" +
|
$"Date\tIncome\n" +
|
||||||
$"{string.Join("\n", entries)}\n" + // Combine entries at this location in the string
|
$"{string.Join("\n", entries)}\n" + // Combine entries at this location in the string
|
||||||
$"Average Income: {average}\n" +
|
$"Average Income: {Math.Round(average, 2)}\n" +
|
||||||
$"Total Income: {totalIncome}\n\n";
|
$"Total Income: {Math.Round(totalIncome, 2)}\n\n";
|
||||||
|
|
||||||
File.AppendAllText(Path.GetFullPath("ExpectedIncome.txt"), report); // Write to file
|
File.AppendAllText(Path.GetFullPath("ExpectedIncome.txt"), report); // Write to file
|
||||||
}
|
}
|
||||||
@@ -59,13 +59,13 @@ namespace Ophelias.Reporting
|
|||||||
List<string> entries = new();
|
List<string> entries = new();
|
||||||
foreach (var x in items) // Build a list of entries
|
foreach (var x in items) // Build a list of entries
|
||||||
{
|
{
|
||||||
entries.Add($"{x.Item1.Date.ToString("yyyy-MM-dd")}\t{x.Item2}");
|
entries.Add($"{x.Item1.Date.ToString("yyyy-MM-dd")}\t{Math.Round(x.Item2, 2)}");
|
||||||
}
|
}
|
||||||
string report = $"EXPECTED 30 DAY LOSSES (TO INCENTIVE) REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
|
string report = $"EXPECTED 30 DAY LOSSES (TO INCENTIVE) REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
|
||||||
$"Date\tLosses\n" +
|
$"Date\tLosses\n" +
|
||||||
$"{string.Join("\n", entries)}\n" + // Combine entries at this location in the string
|
$"{string.Join("\n", entries)}\n" + // Combine entries at this location in the string
|
||||||
$"Average Losses (Due to incentive): {average}\n" +
|
$"Average Losses (Due to incentive): {Math.Round(average, 2)}\n" +
|
||||||
$"Total Losses (Due to incentive): {totalLosses}\n\n";
|
$"Total Losses (Due to incentive): {Math.Round(totalLosses, 2)}\n\n";
|
||||||
|
|
||||||
File.AppendAllText(Path.GetFullPath("IncentiveLosses.txt"), report); // Write to file
|
File.AppendAllText(Path.GetFullPath("IncentiveLosses.txt"), report); // Write to file
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace Ophelias.Reporting
|
|||||||
roominfo = r.RoomNum.Value.ToString();
|
roominfo = r.RoomNum.Value.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.Add($"{r.Guest.LastName}, {r.Guest.FirstName}\t{r.Type}\t{roominfo}\t{r.EndDate}");
|
entries.Add($"{r.Guest.LastName}, {r.Guest.FirstName}\t{r.Type}\t{roominfo}\t{r.EndDate.Date.ToString("yyyy-MM-dd")}");
|
||||||
}
|
}
|
||||||
string report = $"DAILY ARRIVAL REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
|
string report = $"DAILY ARRIVAL REPORT - GENERATED ON {DateTime.Now.Date.ToString("yyyy-MM-dd")}\n" +
|
||||||
$"Last, First\tType\tRoom\tDeparture\n" +
|
$"Last, First\tType\tRoom\tDeparture\n" +
|
||||||
|
|||||||
Reference in New Issue
Block a user