Fix problem not checking SellDate.

This commit is contained in:
2024-10-26 07:35:44 -04:00
parent 3aa0edff0f
commit b8282f54fd
2 changed files with 35 additions and 7 deletions

View File

@@ -138,11 +138,32 @@ namespace TradeBlotter.UIUtils
private bool Validate()
{
DateGenerator dateGenerator=new DateGenerator();
if(null==Symbol) return false;
if(Utility.IsEpoch(PurchaseDate)) return false;
if(Utility.IsEpoch(SellDate))return false;
if(!dateGenerator.IsMarketOpen(SellDate)) return false;
if(double.IsNaN(SellPrice)) return false;
if(null==Symbol)
{
SetMessage("Invalid Symbol.");
return false;
}
if(Utility.IsEpoch(PurchaseDate))
{
SetMessage("Invalid Purchase Date.");
return false;
}
if(Utility.IsEpoch(SellDate))
{
SetMessage("Invalid Sell Date.");
return false;
}
if(!dateGenerator.IsMarketOpen(SellDate))
{
SetMessage("Market closed on Sell Date.");
return false;
}
if(double.IsNaN(SellPrice))
{
SetMessage("Invalid Sell Price.");
return false;
}
SetMessage("");
return true;
}
private void UpdateSellPrice()
@@ -155,5 +176,9 @@ namespace TradeBlotter.UIUtils
if(null==companyProfile||null==companyProfile.CompanyName) return;
lblCompanyName.Content=companyProfile.CompanyName.ToUpper();
}
private void SetMessage(String message)
{
lblMessage.Content=message;
}
}
}