using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Xpo;
using MySql.Data.MySqlClient;
namespace Nuvolar.Module.Win.CSharp.Controllers
{
///
/// NAV Online számla ellenőrző rendszer ...
///
public partial class NAV_Online_WC : WindowController
{
private System.Windows.Forms.Timer _NAV_Timer;
private int invokeCount;
private bool _OnTick;
public NAV_Online_WC()
{
InitializeComponent();
}
protected override void OnActivated()
{
base.OnActivated();
invokeCount = 0;
_OnTick = false;
_NAV_Timer = new System.Windows.Forms.Timer();
_NAV_Timer.Interval = 15000;
_NAV_Timer.Start();
_NAV_Timer.Tick += NAV_Timer_Tick;
}
///
/// Időzített NAV Online számla feladás
///
///
///
private void NAV_Timer_Tick(object sender, EventArgs e)
{
if (_OnTick == false)
{
try
{
_OnTick = true;
MySqlConnection _MySqlConnection = new MySqlConnection(GeneralFunction.GLOBAL_ConnectionString.Replace("XpoProvider=MySql;",""));
_MySqlConnection.Open();
MySqlCommand _MySqlCommand = new MySqlCommand(" SELECT DocumentNumber " +
" FROM InvoiceHeader " +
" WHERE IsEditable=0 AND " +
" ABS(TotalVATHUF) >= 100000 AND " +
" IFNULL(DocumentNumber,'') !='' AND " +
" IsProforma=0 AND " +
" NAV_InvoiceStatus <> 'DONE' AND" +
" DateCreated >= '2018-07-01' ",
_MySqlConnection);
MySqlDataReader _MySqlDataReader = _MySqlCommand.ExecuteReader();
if (_MySqlDataReader.HasRows)
{
//string _message = string.Format("{0} NAV online számla ellenőrzés ... {1,2}.", DateTime.Now.ToString("h:mm:ss.fff"), (++invokeCount).ToString());
string _message = "NAV online számla feladás ...";
Application.ShowViewStrategy.ShowMessage(_message, InformationType.Info, 1000, InformationPosition.Bottom);
while (_MySqlDataReader.Read())
{
//NAV időzített feladás ...
string _DocumentNumber = _MySqlDataReader["DocumentNumber"] as string;
//HA VAN
XPObjectSpace _onew = Application.CreateObjectSpace() as XPObjectSpace;
}
}
_MySqlConnection.Close();
}
catch (Exception ex)
{
Application.ShowViewStrategy.ShowMessage(ex.Message, InformationType.Error, 5000, InformationPosition.Bottom);
}
finally
{
_OnTick = false;
}
}
}
protected override void OnDeactivated()
{
// Unsubscribe from previously subscribed events and release other references and resources.
base.OnDeactivated();
}
}
}