using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using System.IO;
using DevExpress.ExpressApp.Xpo;
using DevExpress.ExpressApp.Web;
using DevExpress.Persistent.BaseImpl;
using System.Web.UI.WebControls;
namespace Nuvolar.Module.Web.CSharp.Controllers
{
    // For more typical usage scenarios, be sure to check out https://documentation.devexpress.com/eXpressAppFramework/clsDevExpressExpressAppViewControllertopic.aspx.
    public partial class Invoice_VC : Nuvolar.Module.InvoiceVC
    {
        public Invoice_VC()
        {
            InitializeComponent();
            // Target required Views (via the TargetXXX properties) and create their Actions.
        }
        protected override void OnActivated()
        {
            base.OnActivated();
            // Perform various tasks depending on the target View.
        }
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            // Access and customize the target View control.
        }
        protected override void OnDeactivated()
        {
            // Unsubscribe from previously subscribed events and release other references and resources.
            base.OnDeactivated();
        }
        
        //public override void aPrintSelectedInvoices_Execute(object sender, SimpleActionExecuteEventArgs e)
        //{
        //    XPObjectSpace _ocur = (XPObjectSpace)View.ObjectSpace;
        //    ReportDataV2 _ReportData=null;
        //    string _Criteria = "(";
        //    if (View.SelectedObjects.Count>0)
        //    {
        //        foreach (InvoiceHeader _InvoiceHeader in View.SelectedObjects)
        //        {
        //            if (_Criteria=="(")
        //            {
        //                _ReportData = _InvoiceHeader.InvoiceType.ReportDataV2;
        //                _Criteria +=  "'"+_InvoiceHeader.Oid.ToString()+"'";
        //            }
        //            else
        //            {
        //                _Criteria += ",'" + _InvoiceHeader.Oid.ToString()+"'";
        //            }
        //        }
        //        _Criteria += ")";
        //        _Criteria = "InvoiceHeader.Oid in " + _Criteria;
        //        XAFPrintHelperWeb _XAFPrintHelperWeb = new XAFPrintHelperWeb(_ocur, Frame, _ReportData,CriteriaOperator.Parse(_Criteria));
        //        GeneralFunction.GLOBAL_Download_MemoryStream = _XAFPrintHelperWeb.GeneratePDF();
        //        GeneralFunction.GLOBAL_Download_FileName = Path.GetRandomFileName().Replace(".","").Substring(1,8);
        //        GeneralFunction.GLOBAL_Download_FileExtension = "pdf";
        //        WebApplication.Redirect("GetAttachments.ashx?ms=1");
        //    }
        //}
    }
}
