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.
60 lines
2.0 KiB
C#
60 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Text.RegularExpressions;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Globalization;
|
|
|
|
namespace Ophelias.Expressions
|
|
{
|
|
internal static class Expressions
|
|
{
|
|
internal static Regex CardRx = new(@"^[0-9]{16}$", RegexOptions.Compiled);
|
|
internal static Regex ExpriationRx = new(@"^(0?[1-9]|1[012])/2[0-9]{1}$", RegexOptions.Compiled);
|
|
internal static Regex CCVRx = new(@"^[0-9]{3}$", RegexOptions.Compiled);
|
|
internal static Regex MoneyRx = new(@"^(\d+\.\d{2}|\d+)$", RegexOptions.Compiled);
|
|
}
|
|
internal static class Validation
|
|
{
|
|
internal static bool ValidateCreditCard(string CreditCard)
|
|
{
|
|
return Expressions.CardRx.IsMatch(CreditCard);
|
|
}
|
|
internal static bool ValidateExpirationDate(string Expiration)
|
|
{
|
|
if (Expressions.ExpriationRx.IsMatch(Expiration))
|
|
{
|
|
DateTime dt = DateTime.ParseExact(Expiration, "MM/yy", CultureInfo.InvariantCulture);
|
|
if (dt.Date >= DateTime.Now.Date)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
internal static bool ValidateExpirationNotBeforeReservation(string Expiration, DateTime CollectionDate)
|
|
{
|
|
DateTime dt = DateTime.ParseExact(Expiration, "MM/yy", CultureInfo.InvariantCulture);
|
|
if (dt.Date > CollectionDate.Date)
|
|
return true;
|
|
return false;
|
|
}
|
|
internal static bool ValidateEmail(string email)
|
|
{
|
|
EmailAddressAttribute EmailChecker = new();
|
|
return EmailChecker.IsValid(email);
|
|
}
|
|
internal static bool ValidateCCV(string CCV)
|
|
{
|
|
if (Expressions.CCVRx.IsMatch(CCV))
|
|
return true;
|
|
return false;
|
|
}
|
|
internal static bool ValidateMoney(string Money)
|
|
{
|
|
return Expressions.MoneyRx.IsMatch(Money);
|
|
}
|
|
|
|
}
|
|
}
|