using System;
using System.Linq;
using DevExpress.Xpo;
using DevExpress.Persistent.Base;
using System.Collections.Generic;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;
namespace Nuvolar.Module
{
    [DefaultClassOptions]
    [CreatableItem(false)]
    [NonPersistent]
    [NavigationItem("Reports")]
    [RuleCriteria("NAVInvoiceReport-OutputPath",DefaultContexts.Save,"CheckFilePath = true")]
    public class NAVInvoiceReport : BaseObject
    { // Inherit from a different class to provide a custom primary key, concurrency and deletion behavior, etc. (http://documentation.devexpress.com/#Xaf/CustomDocument3146).
        public NAVInvoiceReport(Session session)
            : base(session)
        {
        }
        public override void AfterConstruction()
        {
            base.AfterConstruction();
            // Place your initialization code here (http://documentation.devexpress.com/#Xaf/CustomDocument2834).
        }
        private DateTime _fromDate;
        private DateTime _toDate;
        private String _documentNumberFrom;
        private String _documentNumberTo;
        private String _documentNumberBegin;
        private String _outputPath;
        //[XafDisplayName("My display name"), ToolTip("My hint message")]
        //[ModelDefault("EditMask", "(000)-00"), Index(0), VisibleInListView(false)]
        //[Persistent("DatabaseColumnName"), RuleRequiredField(DefaultContexts.Save)]
        [RuleRequiredField("NAVInvoiceReport-FromDate", DefaultContexts.Save)]
        public DateTime FromDate
        {
            get { return _fromDate; }
            set { SetPropertyValue("FromDate", ref _fromDate, value); }
        }
        [RuleRequiredField("NAVInvoiceReport-ToDate", DefaultContexts.Save)]
        public DateTime ToDate
        {
            get { return _toDate; }
            set { SetPropertyValue("ToDate", ref _toDate, value); }
        }
        public String DocumentNumberFrom
        {
            get { return _documentNumberFrom; }
            set { SetPropertyValue("DocumentNumberFrom", ref _documentNumberFrom, value); }
        }
        public String DocumentNumberTo
        {
            get { return _documentNumberTo; }
            set { SetPropertyValue("DocumentNumberTo", ref _documentNumberTo, value); }
        }
        public String DocumentNumberBegin
        {
            get { return _documentNumberBegin; }
            set { SetPropertyValue("DocumentNumberBegin", ref _documentNumberBegin, value); }
        }
        [Size(900)]

        public String OutputPath
        {
            get { return _outputPath; }
            set { SetPropertyValue("OutputPath", ref _outputPath, value); }
        }
        private Boolean CheckFilePath
        {
            get
            {
                if (System.IO.Directory.Exists(OutputPath))
                {
                    return true;
                }
                else
                {
                    return false;
                };
            }
        }
        //[Action(Caption = "My UI Action", ConfirmationMessage = "Are you sure?", ImageName = "Attention", AutoCommit = true)]
        //public void ActionMethod() {
        //    // Trigger a custom business logic for the current record in the UI (http://documentation.devexpress.com/#Xaf/CustomDocument2619).
        //    this.PersistentProperty = "Paid";
        //}
    }
}
