public static TS_BEMensaje SynchronizedSetSale(TerminalSIGES.Models.Lado Cara, TS_BEArticulo Transaccion)
        {
            TS_BELoadInput     cLoadingInput  = TSSalesInput.LoadInput();
            TS_BEClienteInput  cClienteInput  = TSSalesInput.InputClienteAutomaticMethod(Cara);
            TS_BECabeceraInput cCabeceraInput = TSSalesInput.InputCabeceraAutomaticMethod(Cara);

            TS_BEDetalleInput[]   cDetalleInput  = TSSalesInput.InputDetalleAutomaticMethod(Transaccion).ToArray();
            List <TS_BEPagoInput> vPagos         = TSSalesInput.InputPagosAutomaticMethod(Cara, Transaccion);
            TS_BEGrabarConfig     vConfiguracion = new TS_BEGrabarConfig()
            {
                IsNotPrint = Cara.IsImprimir
            };

            if (vPagos == null)
            {
                return(new TS_BEMensaje()
                {
                    mensaje = "EL MONTO TOTAL NO COINCIDE CON LOS PAGOS DE LA VENTA", Ok = false
                });
            }

            TS_BEPagoInput[] cPagoInput = vPagos.ToArray();

            TSSalesInput.InputMoneyAutomaticMethod(Cara, cCabeceraInput, cDetalleInput, cPagoInput);
            TS_SISalesClient client = null;

            try
            {
                client = new TS_SISalesClient(Helper.ServicioSoapBinding(), new EndpointAddress(Config.Services.Sales));
                TS_BERetornoTransaccion respuesta = client.GrabarTransaccion(cDetalleInput, cCabeceraInput, cPagoInput, cClienteInput, cLoadingInput, vConfiguracion);
                if (respuesta.Ok)
                {
                    return(new TS_BEMensaje()
                    {
                        mensaje = respuesta.Codigo, Ok = true
                    });
                }
                else
                {
                    return(new TS_BEMensaje()
                    {
                        mensaje = respuesta.Mensaje, Ok = false
                    });
                }
            }
            catch (Exception e)
            {
                if (client != null)
                {
                    if (client.State == CommunicationState.Opened)
                    {
                        client.Close();
                    }
                }
                return(new TS_BEMensaje()
                {
                    mensaje = e.Message, Ok = false
                });
            }
        }
        public static async Task <SalesEstado> GrabarVenta(bool ConIgv, bool IsCanje, bool IsNoImprimir)
        {
            SalesEstado Respuesta = SalesEstado.ErrorSistema;
            await Task.Run(() => {
                TS_SISalesClient cliente = null;
                try
                {
                    TSCustomerApp.IsCanje = IsCanje;
                    cliente        = new TS_SISalesClient(Helper.ServicioSoapBinding(), new EndpointAddress(Config.Services.Sales));
                    cDetalleInput  = new TS_BEDetalleInput[] { };
                    cCabeceraInput = new TS_BECabeceraInput();
                    cClienteInput  = new TS_BEClienteInput();
                    cCabeceraInput = TSSalesInput.InputcCabecera();
                    cClienteInput  = TSSalesInput.InputcCliente();
                    cDetalleInput  = TSSalesInput.Inputcdetalle(cCabeceraInput).ToArray();
                    cLoadingInput  = new TS_BELoadInput();
                    cLoadingInput  = TSSalesInput.LoadInput();
                    vConfiguracion = new TS_BEGrabarConfig()
                    {
                        IsNotPrint = IsNoImprimir
                    };

                    if (ConIgv)
                    {
                        TSSalesInput.RecalcularIGV(cDetalleInput);
                    }

                    _GrabarTransaccionCompleted(cliente.GrabarTransaccion(cDetalleInput, cCabeceraInput, cPagoInput, cClienteInput, cLoadingInput, vConfiguracion));
                    Respuesta = SalesEstado.EsperandoRespuesta;
                }
                catch
                {
                    Respuesta = SalesEstado.ErrorSistema;
                }
                finally
                {
                    if (cliente != null)
                    {
                        if (cliente.State == CommunicationState.Opened)
                        {
                            cliente.Close();
                        }
                    }
                }
            });

            return(Respuesta);
        }
        public static async Task <SalesEstado> ObtenerOpTransaccion()
        {
            SalesEstado Respuesta = SalesEstado.ErrorSistema;
            await Task.Run(() => {
                TS_SISalesClient cliente = null;
                try
                {
                    cliente = new TS_SISalesClient(Helper.ServicioSoapBinding(), new EndpointAddress(Config.Services.Sales));
                    TS_BEOpTransInput input = new TS_BEOpTransInput()
                    {
                        cara        = Cara,
                        Serie       = TSLoginApp.Serie,
                        cdcliente   = TSCustomerApp.TipoComprobante.Nombre.Equals(TSSalesInput.NotaDeDespacho().Nombre) ? TSCustomerApp.ClientOuput.nroTarjeta : TSCustomerApp.ClientOuput.cdcliente,
                        tipocliente = "",
                        automatic   = false
                    };

                    _ObtenerOpTransaccionCompleted(cliente.ObtenerOpTransaccion(input));
                    Respuesta = SalesEstado.EsperandoRespuesta;
                }
                catch
                {
                    Respuesta = SalesEstado.ErrorSistema;
                }
                finally
                {
                    if (cliente != null)
                    {
                        if (cliente.State == CommunicationState.Opened)
                        {
                            cliente.Close();
                        }
                    }
                }
            });

            return(Respuesta);
        }