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.
118 lines
3.9 KiB
C#
118 lines
3.9 KiB
C#
using Ophelias.Managers;
|
|
using System.Data.SQLite;
|
|
|
|
namespace Ophelias.Models
|
|
{
|
|
internal class Guest
|
|
{
|
|
internal int Id;
|
|
internal string FirstName;
|
|
internal string LastName;
|
|
internal string Email;
|
|
internal string? CreditCard;
|
|
internal string? CCV;
|
|
internal string? Expiration;
|
|
|
|
internal Guest(string FirstName, string LastName, string Email, string? CreditCard = null, string? Expiration = null, string? CCV = null)
|
|
{
|
|
int Id;
|
|
using (Database Manager = new())
|
|
{
|
|
using (SQLiteCommand cmd = Manager.con.CreateCommand())
|
|
{
|
|
cmd.CommandText = "INSERT INTO guests (Fname, Lname, Email, CreditCard, Expiration, CCV) " +
|
|
"VALUES (@Fname, @Lname, @Email, @CreditCard, @Expiry, @CCV);";
|
|
cmd.Parameters.AddWithValue("@Fname", FirstName);
|
|
cmd.Parameters.AddWithValue("@Lname", LastName);
|
|
cmd.Parameters.AddWithValue("@Email", Email);
|
|
cmd.Parameters.AddWithValue("@CreditCard", CreditCard);
|
|
cmd.Parameters.AddWithValue("@Expiry", Expiration);
|
|
cmd.Parameters.AddWithValue("@CCV", CCV);
|
|
cmd.ExecuteNonQuery();
|
|
}
|
|
Id = (int)Manager.con.LastInsertRowId;
|
|
}
|
|
|
|
if (CreditCard != null && Expiration != null && CCV != null)
|
|
{
|
|
this.Id = Id;
|
|
this.FirstName = FirstName;
|
|
this.LastName = LastName;
|
|
this.Email = Email;
|
|
this.CreditCard = CreditCard;
|
|
this.Expiration = Expiration;
|
|
this.CCV = CCV;
|
|
}
|
|
else
|
|
{
|
|
this.Id = Id;
|
|
this.FirstName = FirstName;
|
|
this.LastName = LastName;
|
|
this.Email = Email;
|
|
}
|
|
}
|
|
internal Guest(int Id, string FirstName, string LastName, string Email, string? CreditCard = null, string? Expiration = null, string? CCV = null)
|
|
{
|
|
this.Id = Id;
|
|
this.FirstName = FirstName;
|
|
this.LastName = LastName;
|
|
this.Email = Email;
|
|
this.CreditCard = CreditCard;
|
|
this.Expiration = Expiration;
|
|
this.CCV = CCV;
|
|
}
|
|
internal void UpdateGuest(int Id, string? FirstName = null, string? LastName = null, string? Email = null, string? CreditCard = null, string? Expiration = null, string? CCV = null)
|
|
{
|
|
using (Database Manager = new())
|
|
{
|
|
using SQLiteCommand cmd = Manager.con.CreateCommand();
|
|
cmd.CommandText = QueryBuilder.UpdateGuest(Id, FirstName, LastName, Email, CreditCard, Expiration, CCV);
|
|
cmd.ExecuteNonQuery();
|
|
}
|
|
if (FirstName != null)
|
|
{
|
|
this.FirstName = FirstName;
|
|
}
|
|
|
|
if (LastName != null)
|
|
{
|
|
this.LastName = LastName;
|
|
}
|
|
|
|
if (Email != null)
|
|
{
|
|
this.Email = Email;
|
|
}
|
|
|
|
if (CreditCard != null)
|
|
{
|
|
this.CreditCard = CreditCard;
|
|
}
|
|
if (Expiration != null)
|
|
{
|
|
this.Expiration = Expiration;
|
|
}
|
|
|
|
if (CCV != null)
|
|
{
|
|
this.CCV = CCV;
|
|
}
|
|
}
|
|
internal void SetCreditCardInformation(string CreditCard, string Expiration, string CCV)
|
|
{
|
|
this.CreditCard = CreditCard;
|
|
this.Expiration = Expiration;
|
|
this.CCV = CCV;
|
|
}
|
|
}
|
|
internal class GuestList
|
|
{
|
|
internal List<Guest> Guests;
|
|
|
|
internal GuestList()
|
|
{
|
|
Guests = new();
|
|
}
|
|
}
|
|
}
|