Files
2018-10-14 23:26:09 +02:00

107 lines
4.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Layout;
using DevExpress.ExpressApp.Model.NodeGenerators;
using DevExpress.ExpressApp.SystemModule;
using DevExpress.ExpressApp.Templates;
using DevExpress.ExpressApp.Utils;
using DevExpress.ExpressApp.Xpo;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Validation;
using Newtonsoft.Json;
using SISBusiness.Module.StaticClass;
namespace SISBusiness.Module
{
// For more typical usage scenarios, be sure to check out https://documentation.devexpress.com/eXpressAppFramework/clsDevExpressExpressAppViewControllertopic.aspx.
public partial class NAV_Invoice_VC : ViewController
{
public NAV_Invoice_VC()
{
InitializeComponent();
// Target required Views (via the TargetXXX properties) and create their Actions.
}
protected override void OnActivated()
{
base.OnActivated();
Frame.GetController<InvoiceVC>().FireNAVmanageInvoiceFinalWork += FireNAVmanageInvoice;
}
private void FireNAVmanageInvoice(InvoiceHeader _InvoiceHeader)
{
XPObjectSpace _ocur =Application.CreateObjectSpace() as XPObjectSpace;
string _operation = "CREATE";
if (_InvoiceHeader.IsStorno)
{
_operation = "STORNO";
}
var _postData = new
{
documentnumber = _InvoiceHeader.DocumentNumber,
customersfrom = _InvoiceHeader.CustomersFrom.Oid.ToString(),
operation = _operation,
technicalAnnulment = false,
softwareId = "123456789123456789",
softwareName = "3C ERP System",
softwareOperation = "ONLINE_SERVICE",
softwareMainVersion = "17.2.3",
softwareDevName = "3C Távközlési Kft.",
softwareDevContact = "http:\\3ctelecom.hu",
softwareDevCountryCode = "HU",
softwareDevTaxNumber = "10644209-2-43"
};
RestAPI.ExecuteRootePOST("onlineinvoice/manageinvoice", true, JsonConvert.SerializeObject(_postData));
var _StatusCode = RestAPI.StatusCode;
var _StatusDescription = RestAPI.StatusMessage;
Tracing.Tracer.LogText(_StatusCode.ToString());
Tracing.Tracer.LogText(_StatusDescription.ToString());
if (_StatusCode == 200)
{
dynamic _ResultJSON = JsonConvert.DeserializeObject(_StatusDescription);
if (_ResultJSON.status.ToString() == "OK")
{
_ocur.Session.ExecuteNonQuery(string.Format("UPDATE InvoiceHeader set NAV_transactionID='{0}' WHERE Oid = '{1}'", _ResultJSON.transactionId["0"].ToString(), _InvoiceHeader.Oid.ToString()));
Application.ShowViewStrategy.ShowMessage("A számla beküldése megtörtént !", InformationType.Success, 2000, InformationPosition.Bottom);
}
if (_ResultJSON.status.ToString() == "ERROR")
{
string _ERROR = "A számla beküldése nem történt meg !";
_ERROR += " [" + _ResultJSON.ToString() + "]";
Application.ShowViewStrategy.ShowMessage(_ERROR, InformationType.Error, 5000, InformationPosition.Bottom);
}
}
else
{
string _ERROR = "A számla beküldése nem történt meg !";
_ERROR += " [" + _StatusDescription + "]";
Application.ShowViewStrategy.ShowMessage(_ERROR, InformationType.Error, 5000, InformationPosition.Bottom);
}
}
protected override void OnViewControlsCreated()
{
base.OnViewControlsCreated();
// Access and customize the target View control.
}
protected override void OnDeactivated()
{
Frame.GetController<InvoiceVC>().FireNAVmanageInvoiceFinalWork -= FireNAVmanageInvoice;
base.OnDeactivated();
}
}
}