First major version of the project

This finishes the first iteration of the project. Reports have been
tested and are functional in terms of writing out and outputting some
form of text. There are still a few bugs here and there that are found
but ultimately this commit is so testing can begin.

Since the changes are too large to individually summarize, here is the
generalization:

Reports have been integrated into the admin mode. They write out to text
files rather than export to say email or a printer as it was not to be
considered for this version. The files are appended too and exist in the
debug director of the project. I made this easier to find by outputting
where the files were output to after running the report.

Other changes included some bug fixes, optimizations, and a few bit of
automatic cleanup. This may lead to sylistic inconsistencies.

Documentation will come in a later commit.
This commit is contained in:
雲華
2022-04-16 04:42:13 -04:00
parent 6fb0f5c466
commit fbb75a583d
15 changed files with 1615 additions and 674 deletions

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ophelias.Managers;
using Ophelias.Managers;
using System.Data.SQLite;
namespace Ophelias.Models
@@ -39,23 +36,27 @@ namespace Ophelias.Models
case ReservationType.SixtyDayAdvance: Multiplier = TxFunctions.SixtyDayFee; break;
default: throw new NotImplementedException();
}
double? BaseRate = HotelManager.GetBaseRate();
if (BaseRate == null) {
double? BaseRate = Hotel.GetBaseRate();
if (BaseRate == null)
{
throw new NotImplementedException();
}
Transaction Transaction = new Transaction(
Transaction Transaction = new(
Rate: (double)BaseRate,
Owed: TxFunctions.CalculateOwed((double)BaseRate, (int)(EndDate.Date - StartDate.Date).TotalDays, Multiplier),
Multiplier: Multiplier,
PayBy: TxFunctions.GetPayByDate(Type, StartDate, EndDate)
);
using (DatabaseManager Manager = new DatabaseManager())
using (Database Manager = new())
{
using (SQLiteCommand cmd = Manager.con.CreateCommand())
{
if (RoomNum != null)
{
this.RoomNum = RoomNum;
}
cmd.CommandText =
"INSERT INTO reservations (RoomNum, GuestID, TransactionID, IsNoShow, Type, Status, CreationDate, StartDate, EndDate, CheckIn, CheckOut, DateChanged) " +
"VALUES (@RoomNum, @GuestID, @TransactionID, @IsNoShow, @Type, @Status, @CreationDate, @StartDate, @EndDate, @CheckIn, @CheckOut, @DateChanged);";
@@ -69,17 +70,31 @@ namespace Ophelias.Models
cmd.Parameters.AddWithValue("@StartDate", StartDate.ToString("yyyy-MM-dd"));
cmd.Parameters.AddWithValue("@EndDate", EndDate.ToString("yyyy-MM-dd"));
if (CheckIn.HasValue)
{
cmd.Parameters.AddWithValue("@CheckIn", CheckIn.Value.ToString("yyyy-MM-dd"));
}
else
{
cmd.Parameters.AddWithValue("@CheckIn", CheckIn);
}
if (CheckOut.HasValue)
{
cmd.Parameters.AddWithValue("@CheckOut", CheckOut.Value.ToString("yyyy-MM-dd"));
}
else
{
cmd.Parameters.AddWithValue("@CheckOut", CheckOut);
}
if (DateChanged.HasValue)
{
cmd.Parameters.AddWithValue("@DateChanged", DateChanged.Value.ToString("yyyy-MM-dd"));
}
else
{
cmd.Parameters.AddWithValue("@DateChanged", DateChanged);
}
cmd.ExecuteNonQuery();
}
@@ -99,7 +114,7 @@ namespace Ophelias.Models
this.CheckOut = CheckOut;
this.DateChanged = DateChanged;
}
internal Reservation(int Id, Guest Guest, Transaction Transaction, ReservationType Type, ReservationStatus Status,
internal Reservation(int Id, Guest Guest, Transaction Transaction, ReservationType Type, ReservationStatus Status,
DateTime CreationDate, DateTime StartDate, DateTime EndDate, bool IsNoShow = false, DateTime? CheckIn = null, DateTime? CheckOut = null, DateTime? DateChanged = null, int? RoomNum = null)
{
this.Id = Id;
@@ -121,14 +136,16 @@ namespace Ophelias.Models
this.StartDate = StartDate;
this.EndDate = EndDate;
DateChanged = DateTime.Now.Date;
using (DatabaseManager Manager = new DatabaseManager())
using (Database Manager = new())
{
using (SQLiteCommand cmd = Manager.con.CreateCommand())
{
string? query = QueryBuilder.UpdateReservation(Id: Id, Status: ReservationStatus.Changed, StartDate: this.StartDate, EndDate: this.EndDate, DateChanged: DateChanged);
if (query == null)
{
throw new Exception();
}
cmd.CommandText = query;
cmd.Parameters.AddWithValue("@ID", Id);
@@ -139,22 +156,27 @@ namespace Ophelias.Models
cmd.ExecuteNonQuery();
}
}
double? BaseRate = HotelManager.GetBaseRate();
double? BaseRate = Hotel.GetBaseRate();
if (BaseRate == null)
{
throw new ArgumentNullException(nameof(BaseRate));
}
Transaction.UpdateTransactionFees((double)BaseRate, TxFunctions.Changed, TxFunctions.GetPayByDate(Type, this.StartDate, this.EndDate));
}
internal void CancelReservation()
{
DateTime _DateChanged = DateTime.Now.Date;
using (DatabaseManager Manager = new DatabaseManager())
using (Database Manager = new())
{
using (SQLiteCommand cmd = Manager.con.CreateCommand())
{
string? query = QueryBuilder.UpdateReservation(Id: Id, Status: ReservationStatus.Cancelled, DateChanged: _DateChanged);
if (query == null)
{
throw new Exception();
}
Status = ReservationStatus.Cancelled;
DateChanged = _DateChanged;