0
現在我有一張表,我正在輸入spud日期和發佈日期。我想驗證當添加一個新行時,它在當前表中查找是否有其他的spud日期,以確保新的spud日期晚於先前的spud,並且還要驗證它之前是否有發佈日期它增加了一個新的行。有人知道怎麼做嗎。使用Lightswitch保存時的數據驗證
if (this.ReleaseDate < SpudDate)
{
results.AddPropertyError("Release Date cannot be before Spud Date");
}
我在validate函數中有這個代碼,但那只是當輸入當前項目。我也需要回去查看其他記錄以進行比較,就像我所說的那樣。
partial void ReleaseDate_Validate(EntityValidationResultsBuilder results)
{
IDataServiceQueryable<tblWellRigJunction> orders = (from o in this.DataWorkspace.RigStatusData.tblWellRigJunctions
orderby o.ReleaseDate
where WellID.Equals(this.WellID)
select o).Take(1);
foreach (tblWellRigJunction ord in orders)
{
if (ord.ReleaseDate.ToString() == "")
{
results.AddPropertyError("Previous Release Date entered is still null");
return;
}
int result = DateTime.Compare(ord.SpudDate, this.SpudDate);
if (result > 0)
{
results.AddPropertyError("Previous Spud Date is greater");
return;
}
}
這並不在release_validate功能 – Sirus
@Sirus您還沒有描述或顯示出足夠的代碼爲我告訴你在哪裏把它的工作。如果您點擊一個按鈕輸入數據,請在'Button_Execute'方法中執行。或者,如果您將這些添加到網格中,請使用'foreach'來檢查您的'ScreenName_Saving'方法中的每一個。 –
當我去救我有這個。 partial void ReleaseDate_Validate(EntityValidationResultsBuilder結果) { – Sirus