Nov 16, 2012

Validation on FromDate and ToDate


public boolean validateWrite()
{
    boolean ret;
    SS_CategoryTradeAgreement      categoryTradeAgreement;
    ;

    ret = super();

    if(this.ToDate < this.FromDate)
        ret = checkFailed("Todate should be greater than or equal to Fromdate");

    while select categoryTradeAgreement where  categoryTradeAgreement.Category == this.Category
                                            && categoryTradeAgreement.Vendor == this.Vendor
                                            && categoryTradeAgreement.RecId != this.RecId
                                            && (( categoryTradeAgreement.FromDate <= this.FromDate && categoryTradeAgreement.ToDate >= this.FromDate)
                                                       ||(categoryTradeAgreement.FromDate <= this.ToDate   && categoryTradeAgreement.ToDate >= this.ToDate))
    {
    ret = checkfailed(strfmt("Duplicate Entries are not allowed - Same record is there for Vendor - %1 with Category %2 of period %3 - %4" ,
                         categoryTradeAgreement.Vendor,categoryTradeAgreement.Category,categoryTradeAgreement.FromDate,categoryTradeAgreement.ToDate));
    break;
    }


    return ret;
}

No comments: