From bbc9fedba677ccd09a3ba69fe1d5b90a44c0e926 Mon Sep 17 00:00:00 2001 From: GEORGE Date: Thu, 21 May 2026 15:16:34 -0500 Subject: [PATCH] primer commit de toda la solucion y proyecto Factura Negociable --- .editorconfig | 202 ++ .gitignore | 99 + .vsconfig | 16 + FacturaNegociable/App.config | 22 + FacturaNegociable/Constantes.cs | 190 ++ FacturaNegociable/DataModel/Columna.cs | 23 + FacturaNegociable/DataModel/DataTable.cs | 79 + FacturaNegociable/DataModel/Factura.cs | 76 + .../DataModel/FacturaNegociableBBVA.cs | 34 + .../DataModel/FacturaNegociableBCP.cs | 32 + FacturaNegociable/DataModel/State.cs | 11 + FacturaNegociable/FacturaNegociable.csproj | 141 + .../FolderBrowserDialogWrapper.cs | 210 ++ .../FormularioFacturaNegociable.cs | 2776 +++++++++++++++++ FacturaNegociable/FormularioWebBrowser.cs | 122 + FacturaNegociable/Funciones.cs | 94 + FacturaNegociable/Menu.cs | 69 + FacturaNegociable/OpenFileDialogWrapper.cs | 264 ++ FacturaNegociable/Program.cs | 200 ++ FacturaNegociable/Properties/AssemblyInfo.cs | 36 + .../Properties/Resources.Designer.cs | 63 + FacturaNegociable/Properties/Resources.resx | 117 + .../Properties/Settings.Designer.cs | 26 + .../Properties/Settings.settings | 7 + FacturaNegociable/WindowWrapper.cs | 23 + FacturaNegociable/packages.config | 9 + SolucionTagumedica.sln | 151 + 27 files changed, 5092 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .vsconfig create mode 100644 FacturaNegociable/App.config create mode 100644 FacturaNegociable/Constantes.cs create mode 100644 FacturaNegociable/DataModel/Columna.cs create mode 100644 FacturaNegociable/DataModel/DataTable.cs create mode 100644 FacturaNegociable/DataModel/Factura.cs create mode 100644 FacturaNegociable/DataModel/FacturaNegociableBBVA.cs create mode 100644 FacturaNegociable/DataModel/FacturaNegociableBCP.cs create mode 100644 FacturaNegociable/DataModel/State.cs create mode 100644 FacturaNegociable/FacturaNegociable.csproj create mode 100644 FacturaNegociable/FolderBrowserDialogWrapper.cs create mode 100644 FacturaNegociable/FormularioFacturaNegociable.cs create mode 100644 FacturaNegociable/FormularioWebBrowser.cs create mode 100644 FacturaNegociable/Funciones.cs create mode 100644 FacturaNegociable/Menu.cs create mode 100644 FacturaNegociable/OpenFileDialogWrapper.cs create mode 100644 FacturaNegociable/Program.cs create mode 100644 FacturaNegociable/Properties/AssemblyInfo.cs create mode 100644 FacturaNegociable/Properties/Resources.Designer.cs create mode 100644 FacturaNegociable/Properties/Resources.resx create mode 100644 FacturaNegociable/Properties/Settings.Designer.cs create mode 100644 FacturaNegociable/Properties/Settings.settings create mode 100644 FacturaNegociable/WindowWrapper.cs create mode 100644 FacturaNegociable/packages.config create mode 100644 SolucionTagumedica.sln diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2a341ec --- /dev/null +++ b/.editorconfig @@ -0,0 +1,202 @@ +# Rules in this file were initially inferred by Visual Studio IntelliCode from the Template Studio codebase. +# You can modify the rules from these initially generated values to suit your own policies. +# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference. + +[*.cs] + +#Core editorconfig formatting - indentation + +#use soft tabs (spaces) for indentation +indent_style = space + +#Formatting - new line options + +#place else statements on a new line +csharp_new_line_before_else = true +#require braces to be on a new line for lambdas, methods, control_blocks, types, properties, and accessors (also known as "Allman" style) +csharp_new_line_before_open_brace = all + +#Formatting - organize using options + +#sort System.* using directives alphabetically, and place them before other usings +dotnet_sort_system_directives_first = true + +#Formatting - spacing options + +#require NO space between a cast and the value +csharp_space_after_cast = false +#require a space before the colon for bases or interfaces in a type declaration +csharp_space_after_colon_in_inheritance_clause = true +#require a space after a keyword in a control flow statement such as a for loop +csharp_space_after_keywords_in_control_flow_statements = true +#require a space before the colon for bases or interfaces in a type declaration +csharp_space_before_colon_in_inheritance_clause = true +#remove space within empty argument list parentheses +csharp_space_between_method_call_empty_parameter_list_parentheses = false +#remove space between method call name and opening parenthesis +csharp_space_between_method_call_name_and_opening_parenthesis = false +#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call +csharp_space_between_method_call_parameter_list_parentheses = false +#remove space within empty parameter list parentheses for a method declaration +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list. +csharp_space_between_method_declaration_parameter_list_parentheses = false + +#Formatting - wrapping options + +#leave code block on separate lines +csharp_preserve_single_line_blocks = false + +#Style - Code block preferences + +#prefer curly braces even for one line of code +csharp_prefer_braces = true:suggestion + +#Style - expression bodied member options + +#prefer expression bodies for accessors +csharp_style_expression_bodied_accessors = true:warning +#prefer block bodies for constructors +csharp_style_expression_bodied_constructors = false:suggestion +#prefer expression bodies for methods +csharp_style_expression_bodied_methods = when_on_single_line:silent +#prefer expression-bodied members for properties +csharp_style_expression_bodied_properties = true:warning + +#Style - expression level options + +#prefer out variables to be declared before the method call +csharp_style_inlined_variable_declaration = false:suggestion +#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them +dotnet_style_predefined_type_for_member_access = true:suggestion + +#Style - Expression-level preferences + +#prefer default over default(T) +csharp_prefer_simple_default_expression = true:suggestion +#prefer objects to be initialized using object initializers when possible +dotnet_style_object_initializer = true:suggestion + +#Style - implicit and explicit types + +#prefer var over explicit type in all cases, unless overridden by another code style rule +csharp_style_var_elsewhere = true:suggestion +#prefer var is used to declare variables with built-in system types such as int +csharp_style_var_for_built_in_types = true:suggestion +#prefer var when the type is already mentioned on the right-hand side of a declaration expression +csharp_style_var_when_type_is_apparent = true:suggestion + +#Style - language keyword and framework type options + +#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion + +#Style - Language rules +csharp_style_implicit_object_creation_when_type_is_apparent = true:warning +csharp_style_var_for_built_in_types = true:warning + +#Style - modifier options + +#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods. +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion + +#Style - Modifier preferences + +#when this rule is set to a list of modifiers, prefer the specified ordering. +csharp_preferred_modifier_order = public,private,protected,internal,static,async,readonly,override,sealed,abstract,virtual:warning +dotnet_style_readonly_field = true:warning + +#Style - Pattern matching + +#prefer pattern matching instead of is expression with type casts +csharp_style_pattern_matching_over_as_with_null_check = true:warning + +#Style - qualification options + +#prefer events not to be prefaced with this. or Me. in Visual Basic +dotnet_style_qualification_for_event = false:suggestion +#prefer fields not to be prefaced with this. or Me. in Visual Basic +dotnet_style_qualification_for_field = false:suggestion +#prefer methods not to be prefaced with this. or Me. in Visual Basic +dotnet_style_qualification_for_method = false:suggestion +#prefer properties not to be prefaced with this. or Me. in Visual Basic +dotnet_style_qualification_for_property = false:suggestion +csharp_indent_labels = one_less_than_current +csharp_using_directive_placement = outside_namespace:silent +csharp_prefer_simple_using_statement = true:warning +csharp_style_namespace_declarations = file_scoped:warning +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent + +[*.{cs,vb}] +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +indent_size = 4 +end_of_line = crlf +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +[*.{cs,vb}] + +#Style - Unnecessary code rules +csharp_style_unused_value_assignment_preference = discard_variable:warning + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_compound_assignment = true:warning +dotnet_style_prefer_simplified_interpolation = true:suggestion diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..93e51a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,99 @@ +# ========================================== +# Visual Studio 2022 +# Solo código fuente + bin/x64/Debug +# ========================================== + +# ---------------------------- +# Carpetas temporales +# ---------------------------- +.vs/ +TestResults/ +packages/ + +# ---------------------------- +# Ignorar compilados generales +# ---------------------------- +[Bb]in/ +[Oo]bj/ +x86/ +x64/ +Debug/ +Release/ + +# ---------------------------- +# EXCEPCIÓN: +# Mantener bin/x64/Debug +# ---------------------------- +!bin/ +!bin/x64/ +!bin/x64/Debug/ + +# Mantener contenido interno +!bin/x64/Debug/** + +# ---------------------------- +# Ignorar ejecutables y binarios +# incluso dentro de Debug +# ---------------------------- +*.exe +*.dll +*.pdb +*.cache +*.ilk +*.obj +*.lib +*.exp +*.ipch +*.aps +*.ncb +*.suo +*.user +*.userosscache +*.sln.docstates + +# ---------------------------- +# Archivos NuGet +# ---------------------------- +*.nupkg +.nuget/ + +# ---------------------------- +# Publicaciones +# ---------------------------- +publish/ +app.publish/ + +# ---------------------------- +# Logs +# ---------------------------- +*.log + +# ---------------------------- +# Rider / Resharper +# ---------------------------- +_ReSharper*/ +*.DotSettings.user + +# ---------------------------- +# Archivos de sistema +# ---------------------------- +.DS_Store +Thumbs.db + +# ---------------------------- +# Configuración local sensible +# ---------------------------- +appsettings.Development.json +secrets.json + +# ---------------------------- +# OPCIONAL: +# Ignorar proyectos no revisados +# ---------------------------- +CrearEntrega/ +CrearEntregaDropShip +DescargarExportacion +netActualizacionLotes +OrdenImpresion +VisualizadorCargos +FacturaNegociable/Instalador/* diff --git a/.vsconfig b/.vsconfig new file mode 100644 index 0000000..fbe0556 --- /dev/null +++ b/.vsconfig @@ -0,0 +1,16 @@ +{ + "version": "1.0", + "components": [ + "Microsoft.Component.MSBuild", + "Microsoft.NetCore.Component.Runtime.6.0", + "Microsoft.NetCore.Component.SDK", + "Microsoft.VisualStudio.Component.ManagedDesktop.Core", + "Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites", + "Microsoft.VisualStudio.Component.NuGet", + "Microsoft.VisualStudio.Component.Windows10SDK.19041", + "Microsoft.VisualStudio.Component.Windows10SDK", + "Microsoft.VisualStudio.ComponentGroup.MSIX.Packaging", + "Microsoft.VisualStudio.ComponentGroup.WindowsAppSDK.Cs", + "Microsoft.VisualStudio.Workload.ManagedDesktop" + ] +} \ No newline at end of file diff --git a/FacturaNegociable/App.config b/FacturaNegociable/App.config new file mode 100644 index 0000000..f98652e --- /dev/null +++ b/FacturaNegociable/App.config @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/FacturaNegociable/Constantes.cs b/FacturaNegociable/Constantes.cs new file mode 100644 index 0000000..50f83ce --- /dev/null +++ b/FacturaNegociable/Constantes.cs @@ -0,0 +1,190 @@ +namespace FacturaNegociable +{ + #region 'Menu SAP' + public static class SAPMenu + { + public const string New = "1282"; + public const string Find = "1281"; + } + #endregion + + #region 'Archivos de Formularios' + public static class Archivos + { + + public const string ArchivoFormularioFacturaNegociable = "formularioFacturaNegociable.srf"; + public const string ArchivoFormularioWebBrowser = "formularioWebBrowser.srf"; + + } + #endregion + + #region 'Menu Usuario' + public static class MenuUsuario + { + public const string MenuPrincipal = "mnuFRN00"; + public const string MenuFacturaNegociable = "mnuFRN01"; + + + } + #endregion + + #region 'Tipos Formulario de Usuario' + public static class UserFormType + { + public const string FormularioFacturaNegociable = "fn001"; + public const string FormularioWebBrowser = "wb365"; + } + #endregion + + #region 'Codigos de Documento Electronico' + public static class CodigosDocumentoElectronico + { + public const string FacturaElectronica = "33"; + public const string FacturaNoAfectaElectronica = "34"; + public const string BoletaElectronica = "39"; + public const string BoletaNoAfectaElectronica = "41"; + public const string LiquidacionFacturaElectronica = "43"; + public const string FacturaDeCompraElectronica = "46"; + public const string GuiaDespachoElectronica = "52"; + public const string NotaDebitoElectronica = "56"; + public const string NotaCreditoElectronica = "61"; + public const string FacturaExportacionElectronica = "110"; + public const string NotaDebitoExportacionElectronica = "111"; + public const string NotaCreditoExportacionElectronica = "112"; + + public static string[] All = { FacturaElectronica, FacturaNoAfectaElectronica, BoletaElectronica, BoletaNoAfectaElectronica, + LiquidacionFacturaElectronica, FacturaDeCompraElectronica, GuiaDespachoElectronica, NotaDebitoElectronica, + NotaCreditoElectronica, FacturaExportacionElectronica, NotaDebitoExportacionElectronica, + NotaCreditoExportacionElectronica }; + } + + #endregion + + #region 'Formularios SAP' + public static class SAPFormType + { + public const string OfertaVentas = "149"; + public const string PedidoCliente = "139"; + public const string Entrega = "140"; + public const string Devolucion = "180"; + public const string SolicitudAnticipoCliente = "65308"; + public const string FacturaAnticipoCliente = "65300"; + public const string FacturaDeudores = "133"; + public const string FacturaExentaDeudores = "65302"; + public const string NotaDebitoCliente = "65303"; + public const string Boleta = "65304"; + public const string BoletaExenta = "65305"; + public const string FacturaExportacion = "65307"; + public const string NotaCreditoCliente = "179"; + public const string FacturaReservaCliente = "60091"; + public const string FacturaDeudorPago = "60090"; + + public const string SolicitudCompra = "1470000200"; + public const string OfertaCompra = "540000988"; + public const string Pedido = "142"; + public const string EntradaMercancias = "143"; + public const string DevolucionMercancias = "182"; + public const string SolicitudAnticipoProveedor = "65309"; + public const string FacturaAnticipoProveedor = "65301"; + public const string FacturaProveedor = "141"; + public const string NotaDebitoProveedor = "65306"; + public const string NotaCreditoProveedor = "181"; + public const string FacturaReservaProveedor = "60092"; + + public const string EntradaMercanciasInventario = "721"; + public const string SalidaMercanciasInventario = "720"; + public const string SolicitudTraslado = "1250000940"; + public const string TransferenciaStock = "940"; + + public static string[] All = { OfertaVentas, PedidoCliente, Entrega, Devolucion, SolicitudAnticipoCliente, FacturaAnticipoCliente, FacturaDeudores, NotaDebitoCliente, Boleta, + FacturaExportacion, NotaCreditoCliente, FacturaReservaCliente, + SolicitudCompra, OfertaCompra, Pedido, EntradaMercancias, DevolucionMercancias, SolicitudAnticipoProveedor, FacturaAnticipoProveedor, FacturaProveedor, + NotaDebitoProveedor, NotaCreditoProveedor,FacturaReservaProveedor, + EntradaMercanciasInventario, SalidaMercanciasInventario, SolicitudTraslado, TransferenciaStock}; + + public static string[] WithFolio = {Entrega, FacturaAnticipoCliente, FacturaDeudores, NotaDebitoCliente, Boleta, BoletaExenta, FacturaExportacion, NotaCreditoCliente, + FacturaReservaCliente, FacturaDeudorPago, FacturaExentaDeudores, + SalidaMercanciasInventario, TransferenciaStock, + DevolucionMercancias, FacturaProveedor}; + + public static string[] VentasFolio = {Entrega, FacturaAnticipoCliente, FacturaDeudores, NotaDebitoCliente, Boleta, BoletaExenta, FacturaExportacion, NotaCreditoCliente, + FacturaReservaCliente, FacturaDeudorPago, FacturaExentaDeudores}; + + public static string[] InventarioFolio = { SalidaMercanciasInventario, TransferenciaStock }; + + public static string[] ComprasFolio = { DevolucionMercancias, FacturaProveedor }; + } + + #endregion + + #region 'Colores' + public static class Colores + { + public static int White = (System.Drawing.Color.White.R) | (System.Drawing.Color.White.G << 8) | (System.Drawing.Color.White.B << 16); + public static int Black = (System.Drawing.Color.Black.R) | (System.Drawing.Color.Black.G << 8) | (System.Drawing.Color.Black.B << 16); + public static int Blue = (System.Drawing.Color.Blue.R) | (System.Drawing.Color.Blue.G << 8) | (System.Drawing.Color.Blue.B << 16); + public static int Yellow = (System.Drawing.Color.Yellow.R) | (System.Drawing.Color.Yellow.G << 8) | (System.Drawing.Color.Yellow.B << 16); + public static int Red = (System.Drawing.Color.Red.R) | (System.Drawing.Color.Red.G << 8) | (System.Drawing.Color.Red.B << 16); + public static int Green = (System.Drawing.Color.Green.R) | (System.Drawing.Color.Green.G << 8) | (System.Drawing.Color.Green.B << 16); + public static int Orange = (System.Drawing.Color.Orange.R) | (System.Drawing.Color.Orange.G << 8) | (System.Drawing.Color.Orange.B << 16); + public static int LightGray = (System.Drawing.Color.LightGray.R) | (System.Drawing.Color.LightGray.G << 8) | (System.Drawing.Color.LightGray.B << 16); + public static int GreenYellow = (System.Drawing.Color.GreenYellow.R) | (System.Drawing.Color.GreenYellow.G << 8) | (System.Drawing.Color.GreenYellow.B << 16); + } + #endregion + + #region Recursos + public static class B1Resources + { + public static string MENU1288 = "1288_MENU"; + public static string MENU1291 = "1291_MENU"; + public static string MENU1304 = "1304_MENU"; + public static string MENU1289 = "1289_MENU"; + + public static string SBERROR = "SB_ERROR"; + public static string SBSUCCESS = "SB_SUCCESS"; + public static string SBWARNING = "SB_WARNING"; + + public static string RIGHTBLACKTRIANGLE = "RIGHT_TRIANGLE"; + + public static string LUPA = "7427_MENU"; + + public static string DISKETE = "516_MENU"; + public static string IMPRESORA = "520_MENU"; + public static string BLOQUEAR_PANTALLA = "524_MENU"; + public static string PARAMETRIZACION_FORMULARIO = "580_MENU"; + + public static string EXCEL = "7169_MENU"; + public static string WORD = "7170_MENU"; + public static string PDF = "7176_MENU"; + + public static string BARCODE = "6163_MENU"; + + public static string LICENSELOCK = "BUTTON_LICENSE_LOCK"; + public static string LICENSEUNLOCK = "BUTTON_LICENSE_UNLOCK"; + + public static string ADDSTEPICON = "ADD_STEP_ICON"; + public static string ADDTENPLATEICON = "ADD_TEMPLATE_ICON"; + + public static string NOVACLOSE = "BUTTON_NOVA_CLOSE"; + public static string NOVAMAXIMIZE = "BUTTON_NOVA_MAXIMIZE"; + + public static string EMPTYTASK = "MEMPTYTASK"; + public static string FULLDOC = "MFULLDOC"; + public static string FULLSTACK = "MFULLTASK"; + public static string LOCKT = "MLOCKT"; + + public static string MVMARK = "MVMARK"; + public static string MXMARK = "MXMARK"; + + public static string NUMERO_1 = "I20116"; + public static string NUMERO_2 = "I20117"; + public static string NUMERO_3 = "I20118"; + public static string NUMERO_4 = "I20119"; + + public static string MENSAJE = "6657_MENU"; + public static string FLECHA_DERECHA = "6164_MENU"; + + } + #endregion + +} \ No newline at end of file diff --git a/FacturaNegociable/DataModel/Columna.cs b/FacturaNegociable/DataModel/Columna.cs new file mode 100644 index 0000000..3cfa121 --- /dev/null +++ b/FacturaNegociable/DataModel/Columna.cs @@ -0,0 +1,23 @@ +using SAPbouiCOM; + +namespace FacturaNegociable.DataModel +{ + public class Columna + { + public int Posicion + { + get; set; + } + public string Nombre + { + get; set; + } + public BoFieldsType Tipo { get; set; } = BoFieldsType.ft_AlphaNumeric; + public int Largo { get; set; } = 10; + public bool RightJustified { get; set; } = false; + public bool Editable { get; set; } = false; + public BoColumnSumType SumType { get; set; } = BoColumnSumType.bst_None; + public bool Sortable { get; set; } = false; + + } +} diff --git a/FacturaNegociable/DataModel/DataTable.cs b/FacturaNegociable/DataModel/DataTable.cs new file mode 100644 index 0000000..ef2fb9f --- /dev/null +++ b/FacturaNegociable/DataModel/DataTable.cs @@ -0,0 +1,79 @@ +using System.Collections.Generic; +using System.Xml.Serialization; + + +namespace FacturaNegociable.DataModel +{ + [XmlRoot(ElementName = "DataTable")] + public class DataTable + { + + [XmlElement(ElementName = "Rows")] + public Rows Rows + { + get; set; + } + + [XmlAttribute(AttributeName = "Uid")] + public string Uid + { + get; set; + } + + [XmlText] + public string Text + { + get; set; + } + } + + [XmlRoot(ElementName = "Row")] + public class Row + { + + [XmlElement(ElementName = "Cells")] + public Cells Cells + { + get; set; + } + } + + [XmlRoot(ElementName = "Rows")] + public class Rows + { + + [XmlElement(ElementName = "Row")] + public List Row + { + get; set; + } + } + + [XmlRoot(ElementName = "Cell")] + public class Cell + { + + [XmlElement(ElementName = "ColumnUid")] + public string ColumnUid + { + get; set; + } + + [XmlElement(ElementName = "Value")] + public string Value + { + get; set; + } + } + + [XmlRoot(ElementName = "Cells")] + public class Cells + { + + [XmlElement(ElementName = "Cell")] + public List Cell + { + get; set; + } + } +} diff --git a/FacturaNegociable/DataModel/Factura.cs b/FacturaNegociable/DataModel/Factura.cs new file mode 100644 index 0000000..18924fe --- /dev/null +++ b/FacturaNegociable/DataModel/Factura.cs @@ -0,0 +1,76 @@ +using System; +using System.ComponentModel; + +namespace FacturaNegociable.DataModel +{ + public class Factura + { + public string Seleccionado { get; set; } = string.Empty; + public string DocNum { get; set; } = string.Empty; + public string BoeKey { get; set; } = string.Empty; + public string DocEntry { get; set; } = string.Empty; + public DateTime FechaContabilizacion + { + get; set; + } + public DateTime FechaVencimiento + { + get; set; + } + public string Moneda { get; set; } = string.Empty; + public double Total + { + get; set; + } + public double PaidSum + { + get; set; + } + public double PaidToDate + { + get; set; + } + public double Saldo + { + get; set; + } + public string GroupNum { get; set; } = string.Empty; + public string CardCode { get; set; } = string.Empty; + public string Cliente { get; set; } = string.Empty; + public string LicTradNum { get; set; } = string.Empty; + public string Indicator { get; set; } = string.Empty; + public string Serie { get; set; } = string.Empty; + public string Numero { get; set; } = string.Empty; + public int Cargo { get; set; } = 0; + public string Xml { get; set; } = string.Empty; + public string Banco { get; set; } = string.Empty; + public string Cuota { get; set; } = string.Empty; + public string Cuotas { get; set; } = string.Empty; + public string BankCode { get; set; } = string.Empty; + public double Amount + { + get; set; + } + public DateTime FechaNegociada + { + get; set; + } + public string Correo + { + get; set; + } = string.Empty; + public string Direccion + { + get; set; + } = string.Empty; + public string Ubigeo { get; set; } = string.Empty; + public int MesaPartes { get; set; } = 0; + public string FechaMesaPartes { get; set; } = string.Empty; + + public string Planilla { get; set; } = string.Empty; + + public string TipoCobranza { get; set; } = string.Empty; + public string TipoVenta { get; set; } = string.Empty; + + } +} diff --git a/FacturaNegociable/DataModel/FacturaNegociableBBVA.cs b/FacturaNegociable/DataModel/FacturaNegociableBBVA.cs new file mode 100644 index 0000000..99401c7 --- /dev/null +++ b/FacturaNegociable/DataModel/FacturaNegociableBBVA.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FacturaNegociable.DataModel +{ + public class FacturaNegociableBBVA + { + public string TipoComprobante { get; set; } = string.Empty; + public string RucProveedor { get; set; } = string.Empty; + public string Serie { get; set; } = string.Empty; + public string Numeracion { get; set; } = string.Empty; + public string FechaVencimiento { get; set; } = string.Empty; + public string DepartamentoProveedor { get; set; } = string.Empty; + public string ProvinciaProveedor { get; set; } = string.Empty; + public string DistritoProveedor { get; set; } = string.Empty; + public string DomicilioProveedor { get; set; } = string.Empty; + public string DepartamentoAdquiriente { get; set; } = string.Empty; + public string ProvinciaAdquiriente { get; set; } = string.Empty; + public string DistritoAdquiriente { get; set; } = string.Empty; + public string DomicilioAdquiriente { get; set; } = string.Empty; + public string TipoPago { get; set; } = string.Empty; + public string NumeroCuota { get; set; } = string.Empty; + public string FechaComunicacionAdquiriente { get; set; } = string.Empty; + public string FechaAceptacion { get; set; } = string.Empty; + public string FechaPago { get; set; } = string.Empty; + public double ImporteNetoPendientePago { get; set; } = 0.00; + public string ClausulasEspeciales { get; set; } = string.Empty; + public string Observaciones { get; set; } = string.Empty; + + } +} diff --git a/FacturaNegociable/DataModel/FacturaNegociableBCP.cs b/FacturaNegociable/DataModel/FacturaNegociableBCP.cs new file mode 100644 index 0000000..7e56dbd --- /dev/null +++ b/FacturaNegociable/DataModel/FacturaNegociableBCP.cs @@ -0,0 +1,32 @@ +namespace FacturaNegociable.DataModel +{ + public class FacturaNegociableBCP + { + public string TipoProducto { get; set; } = string.Empty; + public string Moneda { get; set; } = string.Empty; + public string NumeroCuentaCorriente { get; set; } = string.Empty; + //public double ImporteTotalPlanilla { get; set; } = 0.00; + public string TipoComprobante { get; set; } = string.Empty; + public string RucProveedor { get; set; } = string.Empty; + public string Serie { get; set; } = string.Empty; + public string Numeracion { get; set; } = string.Empty; + public string FechaVencimiento { get; set; } = string.Empty; + public string DepartamentoProveedor { get; set; } = string.Empty; + public string ProvinciaProveedor { get; set; } = string.Empty; + public string DistritoProveedor { get; set; } = string.Empty; + public string DomicilioProveedor { get; set; } = string.Empty; + public string DepartamentoAdquiriente { get; set; } = string.Empty; + public string ProvinciaAdquiriente { get; set; } = string.Empty; + public string DistritoAdquiriente { get; set; } = string.Empty; + public string DomicilioAdquiriente { get; set; } = string.Empty; + public string TipoPago { get; set; } = string.Empty; + public string NumeroCuota { get; set; } = string.Empty; + public string FechaComunicacionAdquiriente { get; set; } = string.Empty; + public string FechaAceptacion { get; set; } = string.Empty; + public string FechaPago { get; set; } = string.Empty; + public double ImporteNetoPendientePago { get; set; } = 0.00; + public int ClausulaProrroga { get; set; } = 0; + public string ClausulasEspeciales { get; set; } = string.Empty; + public string Observaciones { get; set; } = string.Empty; + } +} diff --git a/FacturaNegociable/DataModel/State.cs b/FacturaNegociable/DataModel/State.cs new file mode 100644 index 0000000..54d47f7 --- /dev/null +++ b/FacturaNegociable/DataModel/State.cs @@ -0,0 +1,11 @@ +using System.Globalization; + +namespace FacturaNegociable.DataModel +{ + public class State + { + public CultureInfo Result { + get; set; + } + } +} diff --git a/FacturaNegociable/FacturaNegociable.csproj b/FacturaNegociable/FacturaNegociable.csproj new file mode 100644 index 0000000..9cd84bc --- /dev/null +++ b/FacturaNegociable/FacturaNegociable.csproj @@ -0,0 +1,141 @@ + + + + + Debug + AnyCPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9} + WinExe + FacturaNegociable + FacturaNegociable + v4.8 + 512 + true + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + true + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + true + true + + + + ..\packages\DocumentFormat.OpenXml.2.5\lib\DocumentFormat.OpenXml.dll + + + ..\packages\DocumentFormat.OpenXml.Framework.3.0.2\lib\net46\DocumentFormat.OpenXml.Framework.dll + + + False + ..\..\..\..\..\..\Program Files\sap\SAP Business One\SAPBusinessOneSDK.dll + + + ..\packages\SpreadsheetLight.3.4.7\lib\SpreadsheetLight.dll + + + + + ..\packages\System.Drawing.Common.8.0.4\lib\net462\System.Drawing.Common.dll + + + ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + True + True + + + ..\packages\System.IO.Packaging.4.7.0\lib\net46\System.IO.Packaging.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/FacturaNegociable/FolderBrowserDialogWrapper.cs b/FacturaNegociable/FolderBrowserDialogWrapper.cs new file mode 100644 index 0000000..0a6d364 --- /dev/null +++ b/FacturaNegociable/FolderBrowserDialogWrapper.cs @@ -0,0 +1,210 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Management; +using System.Threading; +using System.Windows.Forms; +using ThreadState = System.Threading.ThreadState; + +namespace FacturaNegociable +{ + public static class FolderBrowserDialogWrapper + { + #region Private members + + private const string SapProcessName = "SAP Business One"; + + private static string folderName; + + #endregion + + /// + /// Determina el número de instancias actuales de Business One en la computadora. + /// + /// Número encontrado de instancias + public static int IsBusinessOneRunning() + { + var returnValue = 0; + + var userName = Environment.UserName; + + folderName = string.Empty; + + try + { + var processes = Process.GetProcessesByName(SapProcessName); + + for (var i = 0; i <= processes.Length - 1; i++) + { + var processUserName = GetProcessUserName(processes[i]); + if (processUserName != userName) + { + continue; + } + + returnValue++; + } + } + catch (Exception ex) + { + Program.sbo_application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + } + + return returnValue; + } + + /// + /// Muestra un diálogo estándar FileBrowser para obtener un nombre de archivo del usuario + /// + /// + /// The file Filter. + /// + /// + /// Nombre de archivo si está seleccionado, más cadena. Vacio + /// + public static string SelectPath() + { + string returnValue = string.Empty; + + + try + { + var showFolderBrowserThread = new Thread(ShowFolderBrowser); + if (showFolderBrowserThread.ThreadState == ThreadState.Unstarted) + { + showFolderBrowserThread.SetApartmentState(ApartmentState.STA); + } + + showFolderBrowserThread.Start(); + showFolderBrowserThread.Join(); + + while (showFolderBrowserThread.ThreadState == ThreadState.Running) + { + Application.DoEvents(); + } + + if (false == string.IsNullOrEmpty(folderName)) + { + returnValue = folderName; + } + } + catch (Exception ex) + { + Program.sbo_application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + + } + return returnValue; + } + private static void ShowFolderBrowser() + { + var userName = Environment.UserName; + var folderBrowser = new FolderBrowserDialog(); + + folderName = string.Empty; + + try + { + + + Process currentProcess = Process.GetCurrentProcess(); + + int parentProcessId = -1; + + Process parentProcess = GetParent(currentProcess); + + if (parentProcess == null) + { + Program.sbo_application.StatusBar.SetText("No hay proceso padre.", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + } + else + { + parentProcessId = parentProcess.Id; + + var myWindow = new WindowWrapper(parentProcess.MainWindowHandle); + + var ret = folderBrowser.ShowDialog(myWindow); + + if (ret == DialogResult.OK) + { + folderName = folderBrowser.SelectedPath; + } + else + { + Application.ExitThread(); + } + } + + } + catch (Exception ex) + { + + Program.sbo_application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + + } + finally + { + folderBrowser.Dispose(); + GC.Collect(); + } + } + + public static Process GetParent(this Process process) + { + try + { + using (var query = new ManagementObjectSearcher( + "SELECT * " + + "FROM Win32_Process " + + "WHERE ProcessId=" + process.Id)) + { + return query + .Get() + .OfType() + .Select(p => Process.GetProcessById((int)(uint)p["ParentProcessId"])) + .FirstOrDefault(); + } + } + catch + { + return null; + } + } + + private static string GetProcessUserName(Process process) + { + var returnValue = string.Empty; + var query = string.Format( + CultureInfo.InvariantCulture, + "Select * from Win32_Process Where ProcessID = '{0}'", + process.Id); + var sq = new ObjectQuery(query); + + using (var searcher = new ManagementObjectSearcher(sq)) + { + ManagementObjectCollection processList = searcher.Get(); + if (0 == processList.Count) + { + return string.Empty; + } + + foreach (var o in processList) + { + var managementObject = (ManagementObject)o; + var args = new object[2]; + + // Invoca el método y rellena el var con el nombre de usuario y el dominio + managementObject.InvokeMethod("GetOwner", args); + + if (null != args[0]) + { + returnValue = args[0].ToString(); + break; + } + } + } + + return returnValue; + } + } +} diff --git a/FacturaNegociable/FormularioFacturaNegociable.cs b/FacturaNegociable/FormularioFacturaNegociable.cs new file mode 100644 index 0000000..8631a6a --- /dev/null +++ b/FacturaNegociable/FormularioFacturaNegociable.cs @@ -0,0 +1,2776 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using System.Xml; +using System.Xml.Linq; +using System.Xml.Serialization; +using FacturaNegociable.DataModel; +using SAPbobsCOM; +using SAPbouiCOM; +using SpreadsheetLight; + +namespace FacturaNegociable +{ + public static class FormularioFacturaNegociable + { + + #region Columnas + + private enum OrdenGridFacturasVentas + { + Cargo = 0, + MesaPartes = 1, + FechaMP =2, + Seleccionado = 3, + Serie = 4, + Correlativo = 5, + Cliente = 6, + FechaContabilizacion = 7, + FechaVencimiento = 8, + DiasPorVencer = 9, + FechaNegociada = 10, + TipoCobranza = 11, + TipoVenta = 12, + + Total = 13, + Aplicado = 14, + Saldo = 15, + PorAplicar = 16, + Moneda = 17, + Banco = 18, + Clave = 19, + Numero = 20, + Ruc = 21, + Grupo = 22, + Codigo = 23, + Indicador = 24, + Xml = 25, + Cuota = 26, + Cuotas = 27, + Correo = 28, + Direccion = 29, + Ubigeo = 30 + + } + + private enum OrdenGridFacturasNegociables + { + Seleccionado = 0, + Serie = 1, + Correlativo = 2, + Numero = 3, + Planilla = 4, + Cliente = 5, + FechaContabilizacion = 6, + FechaVencimiento = 7, + + Banco = 8, + + Moneda = 9, + Total = 10, + + Clave = 11, + Codigo = 12, + Ruc = 13, + Correo = 14, + Direccion = 15, + Ubigeo = 16, + Factura = 17, + Xml = 18 + + } + + public static DataModel.Columna[] ColumnasGridFacturasVentas = + new Columna[] { + + new Columna{Posicion = (int)OrdenGridFacturasVentas.Cargo, Nombre = "Cargo", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.MesaPartes, Nombre = "MesaPartes", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.FechaMP, Nombre = "FechaMP", + Tipo = BoFieldsType.ft_Date, Largo = 20}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Seleccionado, Nombre = "Seleccionado", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 1, Editable = true}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Serie, Nombre = "Serie", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 4}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Correlativo, Nombre = "Correlativo", + Tipo = BoFieldsType.ft_Integer, Largo = 20, Sortable = true}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Cliente, Nombre = "Cliente", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 100, Sortable = true}, + + new Columna{Posicion = (int)OrdenGridFacturasVentas.FechaContabilizacion, Nombre = "Contabilizacion", + Tipo = BoFieldsType.ft_Date, Largo = 8, Sortable = true}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.FechaVencimiento, Nombre = "Vencimiento", + Tipo = BoFieldsType.ft_Date, Largo = 8, Editable = false, Sortable = true}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.DiasPorVencer, Nombre = "DiasPorVencer", + Tipo = BoFieldsType.ft_ShortNumber, Largo = 10, Editable = false, Sortable = true}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.FechaNegociada, Nombre = "FechaNegociada", + Tipo = BoFieldsType.ft_Date, Largo = 8, Editable = true}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.TipoCobranza, Nombre = "TipoCobranza", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 10, Editable = false}, + + new Columna{Posicion = (int)OrdenGridFacturasVentas.TipoVenta, Nombre = "TipoVenta", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 10, Editable = false}, + + new Columna{Posicion = (int)OrdenGridFacturasVentas.Total, Nombre = "Total", + Tipo = BoFieldsType.ft_Sum, Largo = 20, RightJustified = true, SumType = BoColumnSumType.bst_Auto}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Aplicado, Nombre = "Aplicado", + Tipo = BoFieldsType.ft_Sum, Largo = 20, RightJustified = true, SumType = BoColumnSumType.bst_Auto}, + + new Columna{Posicion = (int)OrdenGridFacturasVentas.Saldo, Nombre = "Saldo", + Tipo = BoFieldsType.ft_Sum, Largo = 20, RightJustified = true, SumType = BoColumnSumType.bst_Auto}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.PorAplicar, Nombre = "PorAplicar", + Tipo = BoFieldsType.ft_Sum, Largo = 20, RightJustified = true}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Moneda, Nombre = "Moneda", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 3}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Banco, Nombre = "Banco", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Clave, Nombre = "Clave", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Numero, Nombre = "Numero", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Ruc, Nombre = "Ruc", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 32}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Grupo, Nombre = "Grupo", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Codigo, Nombre = "Codigo", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 25}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Indicador, Nombre = "Indicador", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 10}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Xml, Nombre = "Xml", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Cuota, Nombre = "Cuota", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 10}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Cuotas, Nombre = "Cuotas", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 10}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Correo, Nombre = "Correo", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 100}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Direccion, Nombre = "Direccion", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 254}, + new Columna{Posicion = (int)OrdenGridFacturasVentas.Ubigeo, Nombre = "Ubigeo", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20} + }; + + + public static DataModel.Columna[] ColumnasGridFacturasNegociables = + new Columna[] { + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Seleccionado, Nombre = "Seleccionado", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 1, Editable = true}, + + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Serie, Nombre = "Serie", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 4}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Correlativo, Nombre = "Correlativo", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20, Sortable = true}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Numero, Nombre = "Numero", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20, Sortable = true}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Planilla, Nombre = "Planilla", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20, Sortable = true}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Cliente, Nombre = "Cliente", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 200, Sortable = true}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.FechaContabilizacion, Nombre = "Contabilizacion", + Tipo = BoFieldsType.ft_Date, Largo = 8, Sortable = true}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.FechaVencimiento, Nombre = "Vencimiento", + Tipo = BoFieldsType.ft_Date, Largo = 8, Editable = false, Sortable = true}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Banco, Nombre = "Banco", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Moneda, Nombre = "Moneda", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 3}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Total, Nombre = "Total", + Tipo = BoFieldsType.ft_Sum, Largo = 20, RightJustified = true, SumType = BoColumnSumType.bst_Auto, Sortable = true}, + + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Clave, Nombre = "Clave", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20, Sortable = true}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Codigo, Nombre = "Codigo", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 25}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Ruc, Nombre = "Ruc", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 32}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Correo, Nombre = "Correo", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 100}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Direccion, Nombre = "Direccion", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 254}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Ubigeo, Nombre = "Ubigeo", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Factura, Nombre = "Factura", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 20}, + new Columna{Posicion = (int)OrdenGridFacturasNegociables.Xml, Nombre = "Xml", + Tipo = BoFieldsType.ft_AlphaNumeric, Largo = 500} + }; + #endregion + + #region Formulario + public struct Formulario + { + public const string Object = ""; + + public struct DataSources + { + public struct DBDataSources + { + public const string Cabecera = ""; + } + + public struct UserDataSources + { + public const string DiferenciaPesos = "UD4"; + public const string BancosFiltro = "UD7"; + public const string RutaCarpetas = "UD9"; + public const string Excel = "UD11"; + public const string Cliente = "UD15"; + public const string Serie = "UD19"; + public const string Correo = "UD21"; + public const string Codigo = "UD23"; + + public const string CantidadSeleccionada = "UD25"; + public const string TotalSeleccionado = "UD27"; + public const string NumeroLetra = "UD28"; + public const string MetodoPago = "UD29"; + + public const string PaneFolder = "UD31"; + + public const string FechaContabilizacion = "UD34"; + + } + + public struct DataTables + { + public const string Facturas = "DT_0"; + + } + } + + public struct Items + { + public const string ButtonCrear = "1"; + public const string ButtonCancelar = "2"; + public const string ButtonListarFacturas = "3"; + public const string GridFacturas = "4"; + public const string StaticTextDescripcion = "5"; + public const string StaticTextBanco = "6"; + public const string ComboBoxBancosFiltro = "7"; + public const string StaticTextRutaArchivo = "8"; + public const string EditTextRutaCarpeta = "9"; + public const string ButtonSeleccionarCarpeta = "10"; + public const string ButtonComboDescargarExcel = "11"; + public const string ButtonBorrarSeleccion = "12"; + public const string ButtonDescargarXml = "13"; + public const string StaticTextCliente = "14"; + public const string EditTextCliente = "15"; + public const string StaticTextNombre = "16"; + public const string ComboBoxSeries = "19"; + public const string EditTextCorreo = "21"; + public const string EditTextCodigo = "23"; + public const string StaticTextCantidadSeleccionada = "24"; + public const string StaticTextTotalSeleccionado = "26"; + public const string EditTextNumeroLetra = "28"; + public const string EditTextMetodoPago = "29"; + public const string FolderCrearFacturasNegociables = "31"; + public const string FolderCrearArchivo = "32"; + + public const string StaticTextFechaContabilizacion = "33"; + public const string EditTextFechaContabilizacion = "34"; + public const string ButtonSeleccionarTodo = "30"; + } + + public struct ChooseFromList + { + public const string Cliente = "CFL_0"; + public const string MetodoPago = "CFL_29"; + + } + + } + + #endregion + + #region FormLoad + + public static void FormLoad(ref SAPbouiCOM.MenuEvent menuEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + + SAPbouiCOM.FormCreationParams oFormCreationPackage; + SAPbouiCOM.Form Form; + + if (menuEvent.BeforeAction) + { + oFormCreationPackage = (SAPbouiCOM.FormCreationParams)oApplication.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams); + try + { + var xmlFormulario = new XmlDocument(); + xmlFormulario.Load(Archivos.ArchivoFormularioFacturaNegociable); + + oFormCreationPackage.XmlData = xmlFormulario.InnerXml; + oFormCreationPackage.UniqueID = "UF" + Funciones.Random().ToString(); + Form = oApplication.Forms.AddEx(oFormCreationPackage); + + + Form.Mode = BoFormMode.fm_ADD_MODE; + Form.Visible = true; + + SetChooseFromList(Form, oCompany, ref oApplication); + + LoadComboQuery(Form, oCompany, ref oApplication); + + DefaultValue(Form, oCompany, ref oApplication); + + } + catch (Exception ex) + { + + oApplication.StatusBar.SetText($"{ex.Message}", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + } + } + } + + public static void SetChooseFromList(SAPbouiCOM.Form form, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication) + { + + SAPbouiCOM.ChooseFromListCollection ChooseFromListCollection; + SAPbouiCOM.Conditions Conditions; + SAPbouiCOM.Condition Condition; + SAPbouiCOM.ChooseFromList ChooseFromList; + + ChooseFromListCollection = form.ChooseFromLists; + + + + #region ChosseFromList Codigo de Cliente + ChooseFromList = ChooseFromListCollection.Item(Formulario.ChooseFromList.Cliente); + Conditions = ChooseFromList.GetConditions(); + + Condition = Conditions.Add(); + Condition.Alias = "CardType"; + Condition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL; + Condition.CondVal = "C"; + + ChooseFromList.SetConditions(Conditions); + #endregion + + + } + + public static void DefaultValue(SAPbouiCOM.Form form, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication) + { + SAPbouiCOM.UserDataSource uds; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Codigo); + uds.ValueEx = DateTime.Now.ToString("yyMMddhhmm"); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.FechaContabilizacion); + uds.ValueEx = DateTime.Now.ToString("yyyyMMdd"); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Correo); + uds.ValueEx = "finanzas@tagumedica.com"; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.RutaCarpetas); + uds.ValueEx = Path.GetTempPath(); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.PaneFolder); + uds.ValueEx = "1"; + + form.PaneLevel = 1; + + #region Default Series + + //SAPbobsCOM.CompanyService oCmpSrv; + + //SAPbobsCOM.SeriesService oSeriesService; + + //SAPbobsCOM.Series oSeries; + //SAPbobsCOM.SeriesCollection oSeriesCollection; + + //SAPbobsCOM.DocumentTypeParams oDocumentTypeParams; + + //oCmpSrv = oCompany.GetCompanyService(); + + //oSeriesService = (SAPbobsCOM.SeriesService)oCmpSrv.GetBusinessService(SAPbobsCOM.ServiceTypes.SeriesService); + + //oSeries = (SAPbobsCOM.Series)oSeriesService.GetDataInterface(SAPbobsCOM.SeriesServiceDataInterfaces.ssdiSeries); + + //oDocumentTypeParams = (SAPbobsCOM.DocumentTypeParams)oSeriesService.GetDataInterface(SAPbobsCOM.SeriesServiceDataInterfaces.ssdiDocumentTypeParams); + //oDocumentTypeParams.Document = "24"; + + //oSeriesCollection = oSeriesService.GetDocumentSeries(oDocumentTypeParams); + + //for (int i = 0; i < oSeriesCollection.Count; i++) + //{ + + // oApplication.StatusBar.SetText($"{oSeriesCollection.Item(i).Series}", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + //} + + #endregion + + } + + public static void LoadComboQuery(SAPbouiCOM.Form form, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication) + { + + SAPbouiCOM.ComboBox comboBox; + SAPbouiCOM.ButtonCombo buttonCombo; + SAPbouiCOM.UserDataSource uds; + + string query; + + #region Cargar codigos de Bancos + + query = "SELECT \"BankCode\", \"BankName\" FROM ODSC WHERE \"Locked\" = 'N' UNION ALL SELECT '###', 'Todos' FROM DUMMY;"; + + comboBox = (SAPbouiCOM.ComboBox)form.Items.Item(Formulario.Items.ComboBoxBancosFiltro).Specific; + + Funciones.LoadComboQuery(query, ref comboBox, "BankCode", "BankName", oCompany); + + comboBox.Select("###", BoSearchKey.psk_ByValue); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.BancosFiltro); + uds.ValueEx = "###"; + + #endregion + + + + + #region Cargar Series de Pagos recibidos + + query = "SELECT T0.\"Series\", T0.\"SeriesName\" FROM NNM1 T0 WHERE T0.\"ObjectCode\" = '24' AND T0.\"Locked\" = 'N' AND T0.\"BeginStr\" ='FN'"; + + comboBox = (SAPbouiCOM.ComboBox)form.Items.Item(Formulario.Items.ComboBoxSeries).Specific; + + Funciones.LoadComboQuery(query, ref comboBox, "Series", "SeriesName", oCompany); + + if (comboBox.ValidValues.Count > 0) + { + comboBox.Select(0, BoSearchKey.psk_Index); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Serie); + + uds.ValueEx = comboBox.Selected.Value; + + query = $"SELECT \"NextNumber\" FROM NNM1 WHERE \"Series\" = {comboBox.Selected.Value}"; + + SAPbobsCOM.Recordset rs = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(BoObjectTypes.BoRecordset); + + rs.DoQuery(query); + + var nextNumber = ""; + + while (!rs.EoF) + { + nextNumber = rs.Fields.Item(0).Value.ToString().Trim(); + rs.MoveNext(); + } + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.NumeroLetra); + + uds.ValueEx = nextNumber; + } + + #endregion + + #region Cargar ButtonComboBox + + buttonCombo = (SAPbouiCOM.ButtonCombo)form.Items.Item(Formulario.Items.ButtonComboDescargarExcel).Specific; + + while (buttonCombo.ValidValues.Count > 0) + { + buttonCombo.ValidValues.Remove(oCompany, BoSearchKey.psk_Index); + } + + buttonCombo.ValidValues.Add("000", "--Excel--"); + buttonCombo.ValidValues.Add("002", "BANCO DE CREDITO DEL PERU"); + buttonCombo.ValidValues.Add("011", "BANCO BBVA"); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Excel); + uds.ValueEx = "000"; + #endregion + + } + + #endregion + + #region HandleItemEvent + + public static void HandleItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + switch (ItemEvent.EventType) + { + case SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST: + ChooseFromList(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT: + ComboSelect(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED: + ItemPressed(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case SAPbouiCOM.BoEventTypes.et_VALIDATE: + Validate(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case BoEventTypes.et_FORM_RESIZE: + FormResize(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + default: break; + + } + } + + #endregion + + #region Validate + + public static void Validate(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + if (ItemEvent.BeforeAction) + { + switch (ItemEvent.ItemUID) + { + case Formulario.Items.GridFacturas: + Grid_Validate_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + default: + break; + } + } + else + { + + } + } + + public static void Grid_Validate_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + //ColumnasGridFacturas[(int)OrdenGridFacturas.FechaNegociada].Nombre; + + switch (ItemEvent.ColUID) + { + case "FechaNegociada": + ColumnGrid_FechaNegociada_Validate_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + default: + break; + } + + + } + + public static void ColumnGrid_FechaNegociada_Validate_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + if (ItemEvent.ItemChanged) + { + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + SAPbouiCOM.Grid grid = (SAPbouiCOM.Grid)form.Items.Item(Formulario.Items.GridFacturas).Specific; + SAPbobsCOM.Recordset rs = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(BoObjectTypes.BoRecordset); + + + var rowIndex = grid.GetDataTableRowIndex(ItemEvent.Row); + + var factura = grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasNegociables.Clave].Nombre, rowIndex).ToString(); + + var dataValue = grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.FechaNegociada].Nombre, rowIndex); + + var auxiliar = dataValue == null? string.Empty : dataValue.ToString(); + + string query; + + if (auxiliar.Length == 0) + query = $@"UPDATE OINV SET ""U_SIS_FECPAG"" = NULL WHERE ""DocEntry"" = {factura} "; + else + { + DateTime fecha = DateTime.Parse(auxiliar, CultureInfo.DefaultThreadCurrentCulture); + + query = $@"UPDATE OINV SET ""U_SIS_FECPAG"" = '{fecha:yyyyMMdd}' WHERE ""DocEntry"" = {factura} "; + } + + + try + { + rs.DoQuery(query); + + oApplication.StatusBar.SetText($"Fecha negociada actualizada en la factura [DocEntry = {factura}]", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + } + catch (Exception ex) + { + oApplication.StatusBar.SetText(ex.Message, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); + + } + + } + + } + #endregion + + #region FormResize + + public static void FormResize(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + if (ItemEvent.BeforeAction) + { + + } + else + { + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + SAPbouiCOM.Item item; + + if (form.Items.Count > 0) + { + int left; + + left = 30; + + #region Pane 1 + item = form.Items.Item(Formulario.Items.StaticTextDescripcion); + item.Left = left; + + item = form.Items.Item(Formulario.Items.StaticTextBanco); + item.Left = left; + + item = form.Items.Item(Formulario.Items.StaticTextCliente); + item.Left = left; + + item = form.Items.Item(Formulario.Items.StaticTextCantidadSeleccionada); + item.Left = left; + + item = form.Items.Item(Formulario.Items.StaticTextTotalSeleccionado); + item.Left = left; + + item = form.Items.Item(Formulario.Items.GridFacturas); + item.Left = left; + + item = form.Items.Item(Formulario.Items.EditTextCliente); + left = item.Left + item.Width + 1; + + item = form.Items.Item(Formulario.Items.StaticTextNombre); + item.Left = left; + #endregion + + + left = 30; + #region Pane 2 + item = form.Items.Item(Formulario.Items.StaticTextRutaArchivo); + item.Left = left; + #endregion + + } + } + } + #endregion + + #region ChooseFromList + + public static void ChooseFromList(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + if (ItemEvent.BeforeAction) + { + switch (ItemEvent.ItemUID) + { + case Formulario.Items.EditTextMetodoPago: + EditTextMetodoPago_ChooseFromList_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + default: + break; + } + } + else + { + switch (ItemEvent.ItemUID) + { + case Formulario.Items.EditTextCliente: + EditTextCliente_ChooseFromList_NotBeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case Formulario.Items.EditTextMetodoPago: + EditTextMetodoPago_ChooseFromList_NotBeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + default: + break; + } + } + + } + + public static void EditTextCliente_ChooseFromList_NotBeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + SAPbouiCOM.DataTable dt; + SAPbouiCOM.UserDataSource uds; + SAPbouiCOM.StaticText st; + + dt = Funciones.GetDataTableFromCLF(ItemEvent, form); + + if (dt != null) + { + var cardcode = dt.GetValue("CardCode", 0).ToString(); + var cardname = dt.GetValue("CardName", 0).ToString(); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Cliente); + uds.ValueEx = cardcode; + + st = (SAPbouiCOM.StaticText)form.Items.Item(Formulario.Items.StaticTextNombre).Specific; + + st.Caption = cardname; + } + else + { + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Cliente); + uds.ValueEx = string.Empty; + + st = (SAPbouiCOM.StaticText)form.Items.Item(Formulario.Items.StaticTextNombre).Specific; + + st.Caption = string.Empty; + } + } + + public static void EditTextMetodoPago_ChooseFromList_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + //SAPbouiCOM.DataTable dt; + SAPbouiCOM.UserDataSource uds; + //SAPbouiCOM.StaticText st; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.BancosFiltro); + var bancoSeleccionado = uds.ValueEx.Trim(); + + if (bancoSeleccionado == "###") + { + BubbleEvent = false; + oApplication.StatusBar.SetText("Primero seleccione un banco.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + } + else + { + SAPbouiCOM.ChooseFromListCollection ChooseFromListCollection; + SAPbouiCOM.Conditions Conditions; + SAPbouiCOM.Condition Condition; + SAPbouiCOM.ChooseFromList ChooseFromList; + + ChooseFromListCollection = form.ChooseFromLists; + + + + #region ChosseFromList Metodo de Pago + ChooseFromList = ChooseFromListCollection.Item(Formulario.ChooseFromList.MetodoPago); + + Conditions = ChooseFromList.GetConditions(); + + // Colocar las condiciones vacias parael nuevo filtro + Conditions.LoadFromXML((new XElement("conditions")).ToString()); + ChooseFromList.SetConditions(Conditions); + + + Condition = Conditions.Add(); + Condition.Alias = "BankTransf"; + Condition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL; + Condition.CondVal = "B"; + + + Condition.Relationship = BoConditionRelationship.cr_AND; + + Condition = Conditions.Add(); + Condition.Alias = "Type"; + Condition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL; + Condition.CondVal = "I"; + + Condition.Relationship = BoConditionRelationship.cr_AND; + + Condition = Conditions.Add(); + Condition.Alias = "BnkDflt"; + Condition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL; + Condition.CondVal = bancoSeleccionado; + + ChooseFromList.SetConditions(Conditions); + #endregion + + } + } + + public static void EditTextMetodoPago_ChooseFromList_NotBeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + SAPbouiCOM.DataTable dt; + SAPbouiCOM.UserDataSource uds; + //SAPbouiCOM.StaticText st; + + dt = Funciones.GetDataTableFromCLF(ItemEvent, form); + + if (dt != null) + { + var paymentMetohd = dt.GetValue("PayMethCod", 0).ToString(); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.MetodoPago); + uds.ValueEx = paymentMetohd; + + } + else + { + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.MetodoPago); + uds.ValueEx = string.Empty; + } + } + + #endregion + + #region ItemPressed + + public static void ItemPressed(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + if (ItemEvent.BeforeAction) + { + + switch (ItemEvent.ItemUID) + { + case Formulario.Items.ButtonListarFacturas: + ButtonListafacturas_ItemPressed_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case Formulario.Items.ButtonCrear: + ButtonCrear_ItemPressed_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case Formulario.Items.ButtonSeleccionarCarpeta: + ButtonSeleccionarCarpeta_ItemPressed_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case Formulario.Items.ButtonComboDescargarExcel: + ButtonDescargarExcel_ItemPressed_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case Formulario.Items.ButtonDescargarXml: + ButtonDescargarXml_ItemPressed_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case Formulario.Items.ButtonBorrarSeleccion: + ButtonBorrarSeleccion_ItemPressed_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case Formulario.Items.ButtonSeleccionarTodo: + ButtonSeleccionarTodo_ItemPressed_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + default: + break; + } + } + else + { + switch (ItemEvent.ItemUID) + { + + case Formulario.Items.GridFacturas: + GridFacturas_ItemPressed_Not_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case Formulario.Items.FolderCrearFacturasNegociables: + FolderCrearFacturasNegociables_ItemPressed_Not_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case Formulario.Items.FolderCrearArchivo: + FolderCrearArchivo_ItemPressed_Not_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + + default: + break; + } + } + } + + public static void FolderCrearFacturasNegociables_ItemPressed_Not_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + var form = oApplication.Forms.Item(FormUID); + + SAPbouiCOM.UserDataSource uds; + SAPbouiCOM.StaticText staticText; + SAPbouiCOM.Item item; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.PaneFolder); + uds.ValueEx = "1"; + + form.PaneLevel = 1; + + staticText = (SAPbouiCOM.StaticText)form.Items.Item(Formulario.Items.StaticTextDescripcion).Specific; + staticText.Caption = $@"Listado de facturas disponibles para enviar al banco como ""factura negociable"""; + + item = form.Items.Item(Formulario.Items.ButtonCrear); + item.Enabled = true; + } + + public static void FolderCrearArchivo_ItemPressed_Not_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + SAPbouiCOM.UserDataSource uds; + SAPbouiCOM.StaticText staticText; + SAPbouiCOM.Item item; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.PaneFolder); + uds.ValueEx = "2"; + + form.PaneLevel = 2; + + staticText = (SAPbouiCOM.StaticText)form.Items.Item(Formulario.Items.StaticTextDescripcion).Specific; + staticText.Caption = $@"Listado de facturas negociables, para creacion de archivo para el banco"; + + item = form.Items.Item(Formulario.Items.ButtonCrear); + item.Enabled = false; + } + + public static void ButtonDescargarXml_ItemPressed_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + + SAPbouiCOM.UserDataSource uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.RutaCarpetas); + + var ruta = uds.ValueEx.Trim(); + + if (ruta.Length == 0) + { + BubbleEvent = false; + + oApplication.StatusBar.SetText("Debe seleccionar una ruta para la descarga del archivos xml", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + return; + } + + if (oApplication.MessageBox("Desea continuar?",1, "Si", "No") == 2) + { + BubbleEvent = false; + return; + } + + SAPbouiCOM.Grid grid; + + grid = (SAPbouiCOM.Grid)form.Items.Item(Formulario.Items.GridFacturas).Specific; + + //SAPbobsCOM.Recordset rs = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); + + List archivos = new List(); + + for (var i = 0; i < grid.Rows.Count; i++) + { + var rowIndex = grid.GetDataTableRowIndex(i); + + var seleccionado = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Seleccionado].Nombre, rowIndex).ToString(); + + if (seleccionado.Equals("Y")) + { + + var fullpath = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Xml].Nombre, rowIndex).ToString(); + + if (fullpath.Length > 0) + archivos.Add(fullpath); + + + } + + } + + + oApplication.StatusBar.SetText($"se encontraron {archivos.Count} archivoz XML para descargar", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + + var cantidadDescargas = 0; + foreach (var archivo in archivos) + { + FileInfo fileInfo = new FileInfo(archivo); + + if (fileInfo.Exists) + { + //oApplication.StatusBar.SetText($" si existe archivo {archivo} || nombre = {fileInfo.Name}", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + + try + { + fileInfo.CopyTo(Path.Combine(ruta, fileInfo.Name), true); + cantidadDescargas++; + } + catch (Exception ex) + { + oApplication.StatusBar.SetText($"error al copiar archivo xml: {ex.Message}", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); + } + + } + else + { + oApplication.StatusBar.SetText($"no existe {archivo} || nombre = {fileInfo.Name}", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); + } + + } + + oApplication.StatusBar.SetText($"se descargaron {cantidadDescargas} archivo(s)", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success); + + } + + public static void ButtonDescargarExcel_ItemPressed_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + SAPbouiCOM.UserDataSource uds; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.RutaCarpetas); + var ruta = uds.ValueEx; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Correo); + var correo_tagumedica = uds.ValueEx; + + //uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Serie); + //var serie_factura_negociable = uds.ValueEx; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Excel); + var bancoExcel = uds.ValueEx.Trim(); + + if ( bancoExcel.Length == 0 || bancoExcel == "000") + { + BubbleEvent = false; + + oApplication.StatusBar.SetText("Debe seleccionar un banco.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); + return; + } + + string[] bancos = { "002","011"}; + + if (!bancos.Contains(bancoExcel)) + { + BubbleEvent = false; + + oApplication.StatusBar.SetText("Este banco no tiene formato de descarga de archivo excel.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + return; + } + + if (ruta.Length == 0) + { + BubbleEvent = false; + + oApplication.StatusBar.SetText("Debe seleccionar una ruta para la descarga del archivo.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + return; + } + + if (correo_tagumedica.Length == 0) + { + BubbleEvent = false; + + oApplication.StatusBar.SetText("Debe ingresar un correo remitente de tagumedica.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + return; + } + + //if (serie_factura_negociable.Length == 0) + //{ + // BubbleEvent = false; + + // oApplication.StatusBar.SetText("Debe seleccionar serie SAP para la creacion de efectos.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + // return; + //} + + if (oApplication.MessageBox("Desea continuar?", 1, "Si", "No") == 2) + { + BubbleEvent = false; + return; + } + + switch (bancoExcel) + { + // BCP + case "002": + Archivo_Excel_BCP(form); + + oApplication.StatusBar.SetText("Proceso finalizado...", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success); + break; + // BBVA + case "011": + Archivo_Excel_BBVA(form); + + oApplication.StatusBar.SetText("Proceso finalizado...", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success); + break; + default: + break; + } + + + } + + public static void ButtonSeleccionarCarpeta_ItemPressed_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + var path = FolderBrowserDialogWrapper.SelectPath(); + + + if (path != string.Empty) + { + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + SAPbouiCOM.UserDataSource uds; + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.RutaCarpetas); + uds.ValueEx = path; + } + } + + public static void ButtonCrear_ItemPressed_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + + var form = oApplication.Forms.Item(FormUID); + SAPbouiCOM.Grid grid; + SAPbouiCOM.UserDataSource uds; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.PaneFolder); + var panelevel = uds.ValueEx.Trim(); + + if (panelevel == "1") + { + SAPbobsCOM.Recordset rs; + rs = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); + + grid = (SAPbouiCOM.Grid)form.Items.Item(Formulario.Items.GridFacturas).Specific; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Serie); + var serie_factura_negociable = uds.ValueEx.Trim(); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Codigo); + var codigo_planilla = uds.ValueEx.Trim(); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.MetodoPago); + var metodo_pago = uds.ValueEx.Trim(); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.FechaContabilizacion); + var fecha_value = uds.ValueEx.Trim(); + + var editText = (SAPbouiCOM.EditText)form.Items.Item(Formulario.Items.EditTextFechaContabilizacion).Specific; + var fecha_string = editText.String; + + + if (metodo_pago.Length == 0) + { + BubbleEvent = false; + + oApplication.StatusBar.SetText("Debe seleccionar un metodo de pago.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + return; + } + + if (serie_factura_negociable.Length == 0) + { + BubbleEvent = false; + + oApplication.StatusBar.SetText("Debe seleccionar serie SAP para la creacion de efectos.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + return; + } + + if (codigo_planilla.Length == 0) + { + BubbleEvent = false; + + oApplication.StatusBar.SetText("Debe ingresar un codigo unico de planilla.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + return; + } + + + if (oApplication.MessageBox($"La fecha de contabilizacion sera {fecha_string}.Desea continuar?", 2, "Si", "No") == 2) + { + BubbleEvent = false; + return; + } + + + /// Obtener numero de Letra para Factura Negociable + /// + + var nextnumber = 0; + + var query = $@"SELECT MAX(""BoeNum"") + 1 FROM ORCT WHERE ""Series"" = {serie_factura_negociable}"; + rs.DoQuery(query); + while (!rs.EoF) + { + nextnumber = int.Parse(rs.Fields.Item(0).Value.ToString()); + + rs.MoveNext(); + } + /// + + for (var i = 0; i < grid.DataTable.Rows.Count; i++) + { + var rowIndex = grid.GetDataTableRowIndex(i); + + var seleccion = grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Seleccionado].Nombre, rowIndex).ToString(); + + if (seleccion == "Y") + { + var cc = grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Codigo].Nombre, rowIndex).ToString(); + var du = grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.FechaNegociada].Nombre, rowIndex).ToString(); + var vencimiento = DateTime.Parse(du, CultureInfo.DefaultThreadCurrentCulture); + + var de = grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Clave].Nombre, rowIndex).ToString(); + //var cu = grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Cuota].Nombre, rowIndex).ToString(); + var am = grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Saldo].Nombre, rowIndex).ToString(); + + var pf = grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Serie].Nombre, rowIndex).ToString(); + var fn = grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Correlativo].Nombre, rowIndex).ToString(); + + /// + XDocument xBOM = new XDocument(new XDeclaration("1.0", "utf-16", ""), new XElement("BOM")); + XElement xBO = new XElement("BO" + , new XElement("AdmInfo", new XElement("Object", "24"), new XElement("Version", 2)) + , new XElement("Payments" + , new XElement("row" + , new XElement("CardCode", cc) + , new XElement("DocType", "rCustomer") + , new XElement("Series", serie_factura_negociable) + , new XElement("DocDate", fecha_value) + , new XElement("CounterReference", "") + , new XElement("Remarks", $"FACTURA NEGOCIABLE {pf}-{fn}") + , new XElement("BillOfExchangeAmount", am) + , new XElement("JournalRemarks", $"FACTURA NEGOCIABLE {pf}-{fn}") + , new XElement("U_SIS_CODPAG", codigo_planilla) + , new XElement("TaxDate", fecha_value) + ))); + + //xBO.Descendants("Payments").Descendants("row").SingleOrDefault().Add(new XElement("Remarks", "FACTURA NEGOCIABLE")); + + XElement XPayments_Invoices = new XElement("Payments_Invoices"); + XPayments_Invoices.Add(new XElement("row" + , new XElement("DocEntry", de) + , new XElement("SumApplied", am) + , new XElement("InvoiceType", "it_Invoice") + , new XElement("InstallmentId", 1) + )); + xBO.Add(XPayments_Invoices); + + XElement XBillOfExchange = new XElement("BillOfExchange"); + XBillOfExchange.Add(new XElement("row" + , new XElement("BillOfExchangeDueDate", vencimiento.ToString("yyyyMMdd")) + , new XElement("BillOfExchangeNo", nextnumber) + , new XElement("Remarks", $"FACTURA NEGOCIABLE {pf}-{fn}") + , new XElement("PaymentMethodCode", metodo_pago) + , new XElement("U_SIS_PLANILLA", codigo_planilla) + )); + + + xBO.Add(XBillOfExchange); + xBOM.Root.Add(xBO); + /// + + + oCompany.XMLAsString = true; + + dynamic payment = oCompany.GetBusinessObjectFromXML(xBOM.ToString(), 0); + + if (payment.Add() == 0) + { + BubbleEvent = true; + + oApplication.StatusBar.SetText("creacion con exito ", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + + var new_objectkey = oCompany.GetNewObjectKey(); + + query = $@"UPDATE OBOE SET ""FolioPref"" = '{pf}', ""FolioNum"" = {fn} + WHERE ""PmntNum"" = {new_objectkey}"; + + rs.DoQuery(query); + + nextnumber++; + + } + else + { + BubbleEvent = false; + var m = oCompany.GetLastErrorDescription(); + + oApplication.StatusBar.SetText(m, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); + } + + } + } + } + + } + + public static void GridFacturas_ItemPressed_Not_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + switch (ItemEvent.ColUID) + { + case "Cargo": + Columna_Cargo_ItemPressed_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case "Xml": + Columna_Xml_ItemPressed_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + case "Seleccionado": + Columna_Seleccionado_ItemPressed_Not_BeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + default: + break; + } + } + + public static void Columna_Seleccionado_ItemPressed_Not_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + SAPbouiCOM.Grid grid; + SAPbouiCOM.UserDataSource uds; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.PaneFolder); + var panelevel = uds.ValueEx.Trim(); + + grid = (SAPbouiCOM.Grid)form.Items.Item(Formulario.Items.GridFacturas).Specific; + + var rowIndex = grid.GetDataTableRowIndex(ItemEvent.Row); + + var seleccionado = panelevel == "1" ? + grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Seleccionado].Nombre, rowIndex).ToString() + : grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Seleccionado].Nombre, rowIndex).ToString(); + + var importe_string = panelevel == "1" ? + grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Saldo].Nombre, rowIndex).ToString() + : grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Total].Nombre, rowIndex).ToString() + ; + var importe = Double.Parse(importe_string, CultureInfo.DefaultThreadCurrentCulture); + + + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.CantidadSeleccionada); + var cantidad_string = uds.ValueEx; + var cantidad = int.Parse(cantidad_string, CultureInfo.InvariantCulture); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.TotalSeleccionado); + var total_string = uds.ValueEx; + var total = Double.Parse(total_string, CultureInfo.InvariantCulture); + + + if (seleccionado == "N") + { + if (panelevel == "1") + grid.DataTable.SetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.PorAplicar].Nombre, rowIndex, "0.00"); + cantidad -= 1; + total -= importe; + + } + else + { + if (panelevel == "1") + grid.DataTable.SetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.PorAplicar].Nombre, rowIndex, importe.ToString(CultureInfo.InvariantCulture)); + + cantidad += 1; + total += importe; + } + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.CantidadSeleccionada); + uds.ValueEx = $"{cantidad}"; + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.TotalSeleccionado); + uds.ValueEx = total.ToString(CultureInfo.InvariantCulture); + + #region teclas + + var keydown = ItemEvent.CharPressed; + var modifiers = ItemEvent.Modifiers; + + oApplication.StatusBar.SetText($"{keydown} || {modifiers.ToString()}", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + + + #endregion + } + + public static void Columna_Xml_ItemPressed_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + } + + public static void Columna_Cargo_ItemPressed_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + SAPbouiCOM.Grid grid; + //SAPbouiCOM.EditTextColumn editTextColumn; + SAPbouiCOM.UserDataSource uds; + var form = oApplication.Forms.Item(FormUID); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.RutaCarpetas); + var ruta = uds.ValueEx; + + if (ruta.Length == 0) + { + BubbleEvent = false; + + oApplication.StatusBar.SetText("Debe seleccionar una ruta para la descarga del archivo", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + return; + } + + grid = (Grid)form.Items.Item(Formulario.Items.GridFacturas).Specific; + + var rowIndex = grid.GetDataTableRowIndex(ItemEvent.Row); + + var docentry = grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Clave].Nombre, rowIndex).ToString(); + + oApplication.StatusBar.SetText(docentry, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + + var query = $@"SELECT T3.""srcPath"", T3.""trgtPath"", T3.""FileName"", T3.""FileExt"" + FROM OATC T2 + INNER JOIN OINV T0 ON T0.""AtcEntry"" = T2.""AbsEntry"" + INNER JOIN ATC1 T3 ON T3.""AbsEntry"" = T2.""AbsEntry"" + WHERE T0.""DocEntry"" = {docentry} AND T3.""FileExt"" = 'pdf'"; + + var rs = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); + + var archivos = new List(); + + rs.DoQuery(query); + + while (!rs.EoF) + { + var targetPath = rs.Fields.Item("trgtPath").Value.ToString(); + var filename = rs.Fields.Item("FileName").Value.ToString(); + var extension = rs.Fields.Item("FileExt").Value.ToString(); + + if (extension.Equals("pdf")) + { + + var fullPath = Path.Combine(targetPath, filename + "." + extension); + + archivos.Add(fullPath); + } + + rs.MoveNext(); + } + + try + { + + foreach (var archivo in archivos) + { + var fileInfo = new FileInfo(archivo); + if (fileInfo.Exists) + { + try + { + var downloadfile = Path.Combine(ruta, fileInfo.Name); + fileInfo.CopyTo(downloadfile, true); + + FormularioWebBrowser.FormLoad(downloadfile, $"Cargo {fileInfo.Name}", oCompany, ref oApplication, out BubbleEvent); + } + catch (Exception) + { + + throw; + } + } + else + { + oApplication.StatusBar.SetText($"no existe {archivo} || nombre = {fileInfo.Name}", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); + } + } + + } + catch (Exception ex) + { + oApplication.StatusBar.SetText(ex.Message, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); + + } + + + } + + public static void ButtonListafacturas_ItemPressed_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + + if (oApplication.MessageBox("Este proceso puede demorar unos minutos. Desea continuar?", 1, "Si", "No") == 2) + { + BubbleEvent = false; + return; + } + + + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + SAPbouiCOM.UserDataSource uds; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.PaneFolder); + var panelevel = uds.ValueEx.Trim(); + + + switch (panelevel) + { + case "1": + CargarGridFacturasVentas(form, oCompany); + break; + case "2": + CargarGridFacturasNegociables(form, oCompany); + break; + default: + break; + } + + + + } + + public static void ButtonBorrarSeleccion_ItemPressed_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + + try + { + form.Freeze(true); + + SAPbouiCOM.Grid grid = (SAPbouiCOM.Grid)form.Items.Item(Formulario.Items.GridFacturas).Specific; + + for (var i = 0; i < grid.Rows.Count; i++) + { + var s = grid.DataTable.GetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Seleccionado].Nombre, i).ToString().Trim(); + if (s.Equals("Y")) + grid.DataTable.SetValue(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Seleccionado].Nombre, i, "N"); + } + + SAPbouiCOM.UserDataSource uds; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.CantidadSeleccionada); + uds.ValueEx = "0"; + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.TotalSeleccionado); + uds.ValueEx = "0.00"; + } + catch (Exception ex) + { + + oApplication.StatusBar.SetText(ex.Message, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); + } + finally + { + form.Freeze(false); + } + } + + public static void ButtonSeleccionarTodo_ItemPressed_BeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + + try + { + form.Freeze(true); + + var grid = (SAPbouiCOM.Grid)form.Items.Item(Formulario.Items.GridFacturas).Specific; + + var total = 0.00; + + for (var i = 0; i < grid.Rows.Count; i++) + { + grid.DataTable.SetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Seleccionado].Nombre, i, "Y"); + + var string_total = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Total].Nombre, i).ToString(); + + total += Double.Parse(string_total, NumberStyles.Number); + } + + SAPbouiCOM.UserDataSource uds; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.CantidadSeleccionada); + uds.ValueEx = $"{grid.Rows.Count}"; + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.TotalSeleccionado); + uds.ValueEx = $"{total}"; + } + catch (Exception ex) + { + + oApplication.StatusBar.SetText(ex.Message, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); + } + finally + { + form.Freeze(false); + } + } + + #endregion + + #region ComboSelect + + public static void ComboSelect(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + if (ItemEvent.BeforeAction) + { + + + } + else + { + switch (ItemEvent.ItemUID) + { + case Formulario.Items.ComboBoxBancosFiltro: + ComboBoxBancos_ComboSelect_NotBeforeAction(FormUID, ref ItemEvent, oCompany, ref oApplication, out BubbleEvent); + break; + + default: + break; + } + } + } + + public static void ComboBoxBancos_ComboSelect_NotBeforeAction(string FormUID, ref SAPbouiCOM.ItemEvent ItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool BubbleEvent) + { + BubbleEvent = true; + + SAPbouiCOM.Form form = oApplication.Forms.Item(FormUID); + + SAPbouiCOM.ComboBox comboBox; + SAPbouiCOM.UserDataSource uds; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.MetodoPago); + uds.ValueEx = string.Empty; + + comboBox = (SAPbouiCOM.ComboBox)form.Items.Item(Formulario.Items.ComboBoxBancosFiltro).Specific; + + oApplication.StatusBar.SetText(comboBox.Selected.Description, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); + + + } + + #endregion + + #region Funciones Extras Facturas de Ventas + + public static void CargarGridFacturasVentas(SAPbouiCOM.Form form, SAPbobsCOM.Company oCompany) + { + + SAPbouiCOM.Grid grid; + SAPbouiCOM.EditTextColumn editTextColumn; + SAPbouiCOM.UserDataSource uds; + + grid = (Grid)form.Items.Item(Formulario.Items.GridFacturas).Specific; + + var facturas = ObtenerFacturasVentas(oCompany); + var fechas = ObtenerFechaMesaPartes(oCompany); + + /// filtrar facturas + /// + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.BancosFiltro); + var banco = uds.ValueEx.Trim(); + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Cliente); + var cliente = uds.ValueEx.Trim(); + + var facturas_filtradas = banco == "###" ? facturas : facturas.Where(x => x.BankCode == banco).ToList(); + + facturas_filtradas = cliente.Equals(string.Empty) ? facturas_filtradas : facturas_filtradas.Where(x => x.CardCode == cliente).ToList(); + /// + + facturas_filtradas.Where(x => x.Cargo > 0 || x.MesaPartes > 0).ToList().ForEach(c => { c.Seleccionado = "Y"; c.Amount = c.Total - c.PaidToDate; }); + + facturas_filtradas.ForEach(x => x.FechaMesaPartes = fechas.ContainsKey(x.DocEntry) ? + x.FechaMesaPartes = fechas[x.DocEntry] : x.FechaMesaPartes = string.Empty); + /// Calcular totales + /// + + var cantidad_seleccionadas = 0; + var total_seleccionado = 0.00; + cantidad_seleccionadas = facturas_filtradas.Where(x => x.Seleccionado == "Y").Count(); + total_seleccionado = facturas_filtradas.Where(x => x.Seleccionado == "Y").Sum(w => w.Total - w.PaidToDate); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.CantidadSeleccionada); + uds.ValueEx = $"{cantidad_seleccionadas}"; + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.TotalSeleccionado); + uds.ValueEx = total_seleccionado.ToString(CultureInfo.InvariantCulture); //$"{total_seleccionado:#.##}"; + + + var xColumns = CrearColumnsFacturasVentas(); + + var xRows = CrearFilasFacturasVentas(facturas_filtradas.OrderBy(x => x.Cliente).ToList()); + + var xDataTable = new XDocument(new XElement("DataTable", new XAttribute("Uid", Formulario.DataSources.DataTables.Facturas))); + xDataTable.Root.Add(xColumns); + xDataTable.Root.Add(xRows); + + try + { + form.Freeze(true); + + grid.DataTable.LoadSerializedXML(BoDataTableXmlSelect.dxs_All, xDataTable.ToString()); + + grid.RowHeaders.TitleObject.Caption = "#"; + + grid.CommonSetting.FixedColumnsCount = 4; + + foreach (var columna in ColumnasGridFacturasVentas) + { + grid.Columns.Item(columna.Nombre).RightJustified = columna.RightJustified; + grid.Columns.Item(columna.Nombre).Editable = columna.Editable; + grid.Columns.Item(columna.Nombre).TitleObject.Sortable = columna.Sortable; + + + if (columna.SumType == BoColumnSumType.bst_Auto) + { + + editTextColumn = (SAPbouiCOM.EditTextColumn)grid.Columns.Item(columna.Nombre); + editTextColumn.ColumnSetting.SumType = BoColumnSumType.bst_Auto; + + } + } + + for (var i = 0; i < grid.Rows.Count; i++) + grid.RowHeaders.SetText(i, $"{i + 1}"); + + + editTextColumn = (SAPbouiCOM.EditTextColumn)grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Clave].Nombre); + editTextColumn.LinkedObjectType = "13"; + + editTextColumn = (SAPbouiCOM.EditTextColumn)grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Codigo].Nombre); + editTextColumn.LinkedObjectType = "2"; + + grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Seleccionado].Nombre).Type = BoGridColumnType.gct_CheckBox; + grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Grupo].Nombre).Type = BoGridColumnType.gct_ComboBox; + grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Banco].Nombre).Type = BoGridColumnType.gct_ComboBox; + + grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Xml].Nombre).Type = BoGridColumnType.gct_Picture; + grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Cargo].Nombre).Type = BoGridColumnType.gct_Picture; + grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.MesaPartes].Nombre).Type = BoGridColumnType.gct_Picture; + grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.TipoCobranza].Nombre).Type = BoGridColumnType.gct_ComboBox; + grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.TipoVenta].Nombre).Type = BoGridColumnType.gct_ComboBox; + + + var rs = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); + SAPbouiCOM.ComboBoxColumn comboBoxColumn; + var query = string.Empty; + + // combo box columna condicion de pago + query = "SELECT TX.\"GroupNum\", TX.\"PymntGroup\" FROM OCTG TX"; + rs.DoQuery(query); + + comboBoxColumn = (SAPbouiCOM.ComboBoxColumn)grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Grupo].Nombre); + comboBoxColumn.DisplayType = BoComboDisplayType.cdt_both; + + while (comboBoxColumn.ValidValues.Count > 0) + comboBoxColumn.ValidValues.Remove(0, BoSearchKey.psk_Index); + + while (!rs.EoF) + { + comboBoxColumn.ValidValues.Add(rs.Fields.Item("GroupNum").Value.ToString(), rs.Fields.Item("PymntGroup").Value.ToString()); + rs.MoveNext(); + } + + // combo box columna bancos + query = "SELECT TX.\"BankCode\", TX.\"BankName\" FROM ODSC TX"; + rs.DoQuery(query); + comboBoxColumn = (SAPbouiCOM.ComboBoxColumn)grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Banco].Nombre); + comboBoxColumn.DisplayType = BoComboDisplayType.cdt_both; + + while (comboBoxColumn.ValidValues.Count > 0) + comboBoxColumn.ValidValues.Remove(0, BoSearchKey.psk_Index); + + while (!rs.EoF) + { + comboBoxColumn.ValidValues.Add(rs.Fields.Item("BankCode").Value.ToString(), rs.Fields.Item("BankName").Value.ToString()); + rs.MoveNext(); + } + + + // combo box columna tipo de cobranza + + comboBoxColumn = (SAPbouiCOM.ComboBoxColumn)grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.TipoCobranza].Nombre); + comboBoxColumn.DisplayType = BoComboDisplayType.cdt_both; + + while (comboBoxColumn.ValidValues.Count > 0) + comboBoxColumn.ValidValues.Remove(0, BoSearchKey.psk_Index); + + comboBoxColumn.ValidValues.Add("", ""); + comboBoxColumn.ValidValues.Add("101", "Cobranza"); + comboBoxColumn.ValidValues.Add("102", "Descuento"); + + // combo box columna tipo de venta + + query = @"SELECT ""FldValue"", ""Descr"" FROM UFD1 T1 WHERE T1.""TableID"" = 'OINV' AND ""FieldID"" = 116"; + rs.DoQuery(query); + comboBoxColumn = (SAPbouiCOM.ComboBoxColumn)grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.TipoVenta].Nombre); + comboBoxColumn.DisplayType = BoComboDisplayType.cdt_both; + + while (comboBoxColumn.ValidValues.Count > 0) + comboBoxColumn.ValidValues.Remove(0, BoSearchKey.psk_Index); + + while (!rs.EoF) + { + comboBoxColumn.ValidValues.Add(rs.Fields.Item("FldValue").Value.ToString(), rs.Fields.Item("Descr").Value.ToString()); + rs.MoveNext(); + } + + } + catch (Exception) + { + + } + finally + { + form.Freeze(false); + } + + + } + + public static XElement CrearColumnsFacturasVentas() + { + + var xColumns = new XElement("Columns"); + + for (var i = 0; i < ColumnasGridFacturasVentas.Length; i++) + { + xColumns.Add(new XElement("Column", + new XAttribute("Uid", ColumnasGridFacturasVentas[i].Nombre), + new XAttribute("Type", (int)ColumnasGridFacturasVentas[i].Tipo), + new XAttribute("MaxLength", ColumnasGridFacturasVentas[i].Largo) + )); + } + + return xColumns; + } + + public static XElement CrearFilasFacturasVentas(List facturas) + { + XElement xRows = new XElement("Rows"); + + foreach (var factura in facturas) + { + + XElement xRow = new XElement("Row"); + XElement xCells = new XElement("Cells", + + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Cargo].Nombre), + new XElement("Value", factura.Cargo > 0 ? B1Resources.PDF : "")), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.MesaPartes].Nombre), + new XElement("Value", factura.MesaPartes > 0 ? B1Resources.FLECHA_DERECHA : "")), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Seleccionado].Nombre), + new XElement("Value", factura.Seleccionado)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.FechaMP].Nombre), + new XElement("Value", factura.FechaMesaPartes)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Serie].Nombre), + new XElement("Value", factura.Serie)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Correlativo].Nombre), + new XElement("Value", factura.Numero)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Cliente].Nombre), + new XElement("Value", factura.Cliente)), + + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.FechaContabilizacion].Nombre), + new XElement("Value", factura.FechaContabilizacion.ToString("yyyyMMdd"))), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.FechaVencimiento].Nombre), + new XElement("Value", factura.FechaVencimiento.ToString("yyyyMMdd"))), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.DiasPorVencer].Nombre), + new XElement("Value", factura.FechaVencimiento.Subtract(DateTime.Now).Days)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.FechaNegociada].Nombre), + new XElement("Value", factura.FechaNegociada.ToString("yyyyMMdd"))), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.TipoCobranza].Nombre), + new XElement("Value", factura.TipoCobranza)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.TipoVenta].Nombre), + new XElement("Value", factura.TipoVenta)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Total].Nombre), + new XElement("Value", factura.Total)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Aplicado].Nombre), + new XElement("Value", factura.PaidToDate)), + + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Saldo].Nombre), + new XElement("Value", factura.Total - factura.PaidToDate)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.PorAplicar].Nombre), + new XElement("Value", factura.Amount)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Moneda].Nombre), + new XElement("Value", factura.Moneda)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Banco].Nombre), + new XElement("Value", factura.BankCode)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Clave].Nombre), + new XElement("Value", factura.DocEntry)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Numero].Nombre), + new XElement("Value", factura.DocNum)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Ruc].Nombre), + new XElement("Value", factura.LicTradNum)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Grupo].Nombre), + new XElement("Value", factura.GroupNum)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Codigo].Nombre), + new XElement("Value", factura.CardCode)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Indicador].Nombre), + new XElement("Value", factura.Indicator)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Xml].Nombre), + new XElement("Value", factura.Xml.Length > 0 ? B1Resources.BARCODE : "")), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Cuota].Nombre), + new XElement("Value", factura.Cuota)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Cuotas].Nombre), + new XElement("Value", factura.Cuotas)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Correo].Nombre), + new XElement("Value", factura.Correo)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Direccion].Nombre), + new XElement("Value", factura.Direccion)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Ubigeo].Nombre), + new XElement("Value", factura.Ubigeo)) + ); + xRow.Add(xCells); + + xRows.Add(xRow); + } + + return xRows; + } + + public static List ObtenerFacturasVentas(SAPbobsCOM.Company oCompany) + { + var facturas = new List(); + + var query = ObtenerQuery_FacturasVentas(); + + var emails = ObtenerEmailsContactos(oCompany); + + var rs = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); + + rs.DoQuery(query); + + while (!rs.EoF) + { + var s_docdate = rs.Fields.Item("DocDate").Value.ToString(); + var s_docduedate = rs.Fields.Item("DocDueDate").Value.ToString(); + var s_fechapago = rs.Fields.Item("FechaPago").Value.ToString(); + var s_doctotal = rs.Fields.Item("DocTotal").Value.ToString(); + var s_paidsum = rs.Fields.Item("PaidSum").Value.ToString(); + var s_paidtodate = rs.Fields.Item("PaidToDate").Value.ToString(); + + var cliente = rs.Fields.Item("CardCode").Value.ToString(); + + facturas.Add( + new DataModel.Factura + { + Seleccionado = "N", + DocEntry = rs.Fields.Item("DocEntry").Value.ToString(), + DocNum = rs.Fields.Item("DocNum").Value.ToString(), + FechaContabilizacion = DateTime.ParseExact(s_docdate, "yyyyMMdd", CultureInfo.InvariantCulture), + FechaVencimiento = DateTime.ParseExact(s_docduedate, "yyyyMMdd", CultureInfo.InvariantCulture), + Moneda = rs.Fields.Item("DocCur").Value.ToString(), + Total = Double.Parse(s_doctotal, new CultureInfo("en-US")), + PaidSum = Double.Parse(s_paidsum, new CultureInfo("en-US")), + PaidToDate = Double.Parse(s_paidtodate, new CultureInfo("en-US")), + GroupNum = rs.Fields.Item("GroupNum").Value.ToString(), + TipoVenta = rs.Fields.Item("TipoVenta").Value.ToString(), + CardCode = cliente, + Cliente = rs.Fields.Item("CardName").Value.ToString(), + LicTradNum = rs.Fields.Item("LicTradNum").Value.ToString(), + Indicator = rs.Fields.Item("Indicator").Value.ToString(), + Serie = rs.Fields.Item("FolioPref").Value.ToString(), + Numero = rs.Fields.Item("FolioNum").Value.ToString(), + Cargo = int.Parse(rs.Fields.Item("Cargo").Value.ToString()), + Xml = rs.Fields.Item("Xml").Value.ToString(), + BankCode = rs.Fields.Item("BankCode").Value.ToString(), + Cuota = rs.Fields.Item("InstlmntID").Value.ToString(), + Cuotas = rs.Fields.Item("Installmnt").Value.ToString(), + FechaNegociada = DateTime.ParseExact(s_fechapago, "yyyyMMdd", CultureInfo.InvariantCulture), + Correo = emails.ContainsKey(cliente) ? emails[cliente] : string.Empty, + Direccion = rs.Fields.Item("Address").Value.ToString(), + Ubigeo = rs.Fields.Item("Building").Value.ToString(), + MesaPartes = int.Parse(rs.Fields.Item("MesaPartes").Value.ToString()), + TipoCobranza = rs.Fields.Item("TipoCobranza").Value.ToString() + + }); + + rs.MoveNext(); + } + + return facturas; + } + + #endregion + + #region Funciones Extras Facturas Negociables + + public static XElement CrearColumnsFacturasNegociables() + { + + var xColumns = new XElement("Columns"); + + for (var i = 0; i < ColumnasGridFacturasNegociables.Length; i++) + { + xColumns.Add(new XElement("Column", + new XAttribute("Uid", ColumnasGridFacturasNegociables[i].Nombre), + new XAttribute("Type", (int)ColumnasGridFacturasNegociables[i].Tipo), + new XAttribute("MaxLength", ColumnasGridFacturasNegociables[i].Largo) + )); + } + + return xColumns; + } + + public static XElement CrearFilasFacturasNegociables(List facturas) + { + var xRows = new XElement("Rows"); + + if (facturas != null) + { + foreach (var factura in facturas) + { + + var xRow = new XElement("Row"); + var xCells = new XElement("Cells", + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Seleccionado].Nombre), + new XElement("Value", factura.Seleccionado)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Serie].Nombre), + new XElement("Value", factura.Serie)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Correlativo].Nombre), + new XElement("Value", factura.Numero)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Numero].Nombre), + new XElement("Value", factura.DocNum)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Planilla].Nombre), + new XElement("Value", factura.Planilla)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Cliente].Nombre), + new XElement("Value", factura.Cliente)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.FechaContabilizacion].Nombre), + new XElement("Value", factura.FechaContabilizacion.ToString("yyyyMMdd"))), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.FechaVencimiento].Nombre), + new XElement("Value", factura.FechaVencimiento.ToString("yyyyMMdd"))), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Banco].Nombre), + new XElement("Value", factura.Banco)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Moneda].Nombre), + new XElement("Value", factura.Moneda)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Total].Nombre), + new XElement("Value", factura.Total)), + + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Clave].Nombre), + new XElement("Value", factura.BoeKey)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Codigo].Nombre), + new XElement("Value", factura.CardCode)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Ruc].Nombre), + new XElement("Value", factura.LicTradNum)), + + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Correo].Nombre), + new XElement("Value", factura.Correo)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Direccion].Nombre), + new XElement("Value", factura.Direccion)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Ubigeo].Nombre), + new XElement("Value", factura.Ubigeo)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Factura].Nombre), + new XElement("Value", factura.DocEntry)), + new XElement("Cell", new XElement("ColumnUid", ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Xml].Nombre), + new XElement("Value", factura.Xml)) + ); + xRow.Add(xCells); + + xRows.Add(xRow); + } + } + + + + return xRows; + } + + public static void CargarGridFacturasNegociables(SAPbouiCOM.Form form, SAPbobsCOM.Company oCompany) + { + + SAPbouiCOM.Grid grid; + SAPbouiCOM.EditTextColumn editTextColumn; + SAPbouiCOM.UserDataSource uds; + + grid = (Grid)form.Items.Item(Formulario.Items.GridFacturas).Specific; + + var facturas = ObtenerFacturasNegociables(oCompany); + + /// filtrar facturas + /// + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Cliente); + var cliente = uds.ValueEx.Trim(); + + facturas = cliente.Equals(string.Empty) ? facturas : facturas.Where(x => x.CardCode == cliente).ToList(); + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.BancosFiltro); + var banco = uds.ValueEx.Trim(); + + facturas = banco.Equals("###") ? facturas : facturas.Where(x => x.Banco == banco).ToList(); + + + /// Calcular totales + /// + + var xColumns = CrearColumnsFacturasNegociables(); + + var xRows = CrearFilasFacturasNegociables(facturas); + + var xDataTable = new XDocument(new XElement("DataTable", new XAttribute("Uid", Formulario.DataSources.DataTables.Facturas))); + xDataTable.Root.Add(xColumns); + xDataTable.Root.Add(xRows); + + try + { + form.Freeze(true); + + grid.DataTable.LoadSerializedXML(BoDataTableXmlSelect.dxs_All, xDataTable.ToString()); + + grid.CommonSetting.FixedColumnsCount = 5; + + foreach (var columna in ColumnasGridFacturasNegociables) + { + grid.Columns.Item(columna.Nombre).RightJustified = columna.RightJustified; + grid.Columns.Item(columna.Nombre).Editable = columna.Editable; + grid.Columns.Item(columna.Nombre).TitleObject.Sortable = columna.Sortable; + + + if (columna.SumType == BoColumnSumType.bst_Auto) + { + + editTextColumn = (SAPbouiCOM.EditTextColumn)grid.Columns.Item(columna.Nombre); + editTextColumn.ColumnSetting.SumType = BoColumnSumType.bst_Auto; + + } + } + + grid.RowHeaders.TitleObject.Caption = "#"; + + for (var i = 0; i < grid.Rows.Count; i++) + grid.RowHeaders.SetText(i, $"{i + 1}"); + + grid.Columns.Item(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Banco].Nombre).Type = BoGridColumnType.gct_ComboBox; + + var rs = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); + SAPbouiCOM.ComboBoxColumn comboBoxColumn; + var query = string.Empty; + + // combo box columna bancos + query = "SELECT TX.\"BankCode\", TX.\"BankName\" FROM ODSC TX"; + rs.DoQuery(query); + comboBoxColumn = (SAPbouiCOM.ComboBoxColumn)grid.Columns.Item(ColumnasGridFacturasVentas[(int)OrdenGridFacturasVentas.Banco].Nombre); + comboBoxColumn.DisplayType = BoComboDisplayType.cdt_both; + + while (comboBoxColumn.ValidValues.Count > 0) + comboBoxColumn.ValidValues.Remove(0, BoSearchKey.psk_Index); + + while (!rs.EoF) + { + comboBoxColumn.ValidValues.Add(rs.Fields.Item("BankCode").Value.ToString(), rs.Fields.Item("BankName").Value.ToString()); + rs.MoveNext(); + } + + // + + + editTextColumn = (SAPbouiCOM.EditTextColumn)grid.Columns.Item(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Clave].Nombre); + editTextColumn.LinkedObjectType = "181"; + + editTextColumn = (SAPbouiCOM.EditTextColumn)grid.Columns.Item(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Factura].Nombre); + editTextColumn.LinkedObjectType = "13"; + + editTextColumn = (SAPbouiCOM.EditTextColumn)grid.Columns.Item(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Codigo].Nombre); + editTextColumn.LinkedObjectType = "2"; + + grid.Columns.Item(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Seleccionado].Nombre).Type = BoGridColumnType.gct_CheckBox; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.CantidadSeleccionada); + uds.ValueEx = $"0"; + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.TotalSeleccionado); + uds.ValueEx = "0.00"; + + + } + catch (Exception) + { + + } + finally + { + form.Freeze(false); + } + + + } + + public static List ObtenerFacturasNegociables(SAPbobsCOM.Company oCompany) + { + var facturas = new List(); + + var query = ObtenerQuery_FacturasNegociables(); + + var emails = ObtenerEmailsContactos(oCompany); + + var rs = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); + + rs.DoQuery(query); + + while (!rs.EoF) + { + var s_docdate = rs.Fields.Item("PmntDate").Value.ToString(); + var s_docduedate = rs.Fields.Item("DueDate").Value.ToString(); + + var s_doctotal = rs.Fields.Item("BoeSum").Value.ToString(); + + var cliente = rs.Fields.Item("CardCode").Value.ToString(); + + facturas.Add( + new DataModel.Factura + { + Seleccionado = "N", + BoeKey = rs.Fields.Item("BoeKey").Value.ToString(), + DocEntry = rs.Fields.Item("DocEntry").Value.ToString(), + DocNum = rs.Fields.Item("BoeNum").Value.ToString(), + FechaContabilizacion = DateTime.ParseExact(s_docdate, "yyyyMMdd", CultureInfo.InvariantCulture), + FechaVencimiento = DateTime.ParseExact(s_docduedate, "yyyyMMdd", CultureInfo.InvariantCulture), + Moneda = rs.Fields.Item("Currency").Value.ToString(), + Total = double.Parse(s_doctotal, new CultureInfo("en-US")), + + CardCode = cliente, + Cliente = rs.Fields.Item("CardName").Value.ToString(), + LicTradNum = rs.Fields.Item("LicTradNum").Value.ToString(), + + Serie = rs.Fields.Item("FolioPref").Value.ToString(), + Numero = rs.Fields.Item("FolioNum").Value.ToString(), + + BankCode = rs.Fields.Item("DpsBankCod").Value.ToString(), + + Correo = emails.ContainsKey(cliente) ? emails[cliente] : string.Empty, + Direccion = rs.Fields.Item("Address").Value.ToString(), + Ubigeo = rs.Fields.Item("Building").Value.ToString(), + Xml = rs.Fields.Item("Xml").Value.ToString(), + Planilla = rs.Fields.Item("Planilla").Value.ToString(), + Banco = rs.Fields.Item("BankCode").Value.ToString() + + + }); + + rs.MoveNext(); + } + + return facturas; + } + + #endregion + + #region Funciones Extras + + public static Dictionary ObtenerEmailsContactos(SAPbobsCOM.Company oCompany) + { + + var emails = new Dictionary(); + + var query = ObtenerQuery_EmailsContactos(); + + var rs = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); + + rs.DoQuery(query); + + while (!rs.EoF) + { + var cc = rs.Fields.Item("CardCode").Value.ToString(); + var e = rs.Fields.Item("Email").Value.ToString(); + + if (cc.Length > 0 && !emails.ContainsKey(cc)) + { + emails.Add(cc, e); + } + + rs.MoveNext(); + } + + return emails; + } + + public static Dictionary ObtenerFechaMesaPartes(SAPbobsCOM.Company oCompany) + { + var fechas = new Dictionary(); + + var query = ObtenerQuery_FechaMesaPartes(); + + var rs = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); + + rs.DoQuery(query); + + while (!rs.EoF) + { + fechas.Add(rs.Fields.Item("DocEntry").Value.ToString(), rs.Fields.Item("Fecha").Value.ToString()); + + rs.MoveNext(); + } + + return fechas; + } + + public static string ObtenerQuery_FacturasVentas() + { + + var query = @" + SELECT + T0.""DocEntry"" + , T0.""DocNum"" + , TO_VARCHAR(T0.""DocDate"",'YYYYMMDD') ""DocDate"" + , TO_VARCHAR(T6.""DueDate"",'YYYYMMDD') ""DocDueDate"" + , TO_VARCHAR(IFNULL(T0.""U_SIS_FECPAG"",T6.""DueDate""),'YYYYMMDD') ""FechaPago"" + , IFNULL(T5.""BankCode"",'') ""BankCode"" + , T0.""Indicator"" + , T0.""FolioPref"" + , T0.""FolioNum"" + , T6.""InstlmntID"" + , T0.""Installmnt"" + , T0.""DocCur"" + , TO_VARCHAR(T6.""InsTotal"") ""DocTotal"" + , TO_VARCHAR(T6.""Paid"") ""PaidSum"" + , TO_VARCHAR(T6.""PaidToDate"") ""PaidToDate"" + , T0.""GroupNum"" + , T2.""PymntGroup"" + , T0.""U_SIS_TIPVEN"" ""TipoVenta"" + , IFNULL(T5.""E_Mail"",'') ""E_Mail"" + , IFNULL(T5.""Address"",'') ""Address"" + , T0.""CardCode"" + , T0.""CardName"" + , T0.""LicTradNum"" + , T0.""U_PGX_REPIMPXML"" ""Xml"" + , IFNULL(T5.""Building"",'') ""Building"" + , IFNULL(T0.""U_SIS_DETENT"",0) ""DetalleEntrega"" + , IFNULL(T5.""U_SIS_TIPCOB"",'') ""TipoCobranza"" + , (SELECT COUNT('A') + FROM OATC T8 + INNER JOIN ATC1 T3 ON T3.""AbsEntry"" = T8.""AbsEntry"" + WHERE T8.""AbsEntry"" = T0.""AtcEntry"" AND T3.""FileExt"" = 'pdf') ""Cargo"" + , (SELECT COUNT('A') + FROM ""@SIS_DETENT1"" T7 + WHERE T7.""DocEntry"" = T0.""U_SIS_DETENT"" AND T7.""U_SIS_ETAPA"" = 'MESA DE PARTES') ""MesaPartes"" + + FROM OINV T0 + INNER JOIN OCRD T5 ON T5.""CardCode"" = T0.""CardCode"" + INNER JOIN OCTG T2 ON T2.""GroupNum"" = T0.""GroupNum"" + INNER JOIN INV6 T6 ON T6.""DocEntry"" = T0.""DocEntry"" + WHERE T0.""CANCELED"" = 'N' + AND T0.""DocStatus"" = 'O' + AND T6.""TotalBlck"" = 0.00 + AND T6.""Status"" = 'O' + AND T0.""DocCur"" = 'SOL' + AND T0.""Indicator"" = '01' + AND T0.""GroupNum"" IN (SELECT TX.""GroupNum"" FROM OCTG TX WHERE TX.""PymntGroup"" LIKE '%negocia%')"; + + return query; + } + + public static string ObtenerQuery_FacturasNegociables() + { + + var query = @"SELECT + T0.""BoeKey"" + , T0.""BoeNum"" + , TO_VARCHAR(T0.""PmntDate"",'YYYYMMDD') ""PmntDate"" + , TO_VARCHAR(T0.""DueDate"",'YYYYMMDD') ""DueDate"" + , TO_VARCHAR(T0.""DpsBankCod"",'YYYYMMDD') ""DpsBankCod"" + , IFNULL(T0.""FolioPref"",'') ""FolioPref"" + , IFNULL(T0.""FolioNum"",0) ""FolioNum"" + , IFNULL(T5.""BankCode"",'') ""BankCode"" + , T0.""Currency"" + , T0.""BoeSum"" + , T0.""CardCode"" + , T0.""CardName"" + , IFNULL(T5.""E_Mail"",'') ""E_Mail"" + , IFNULL(T5.""Address"",'') ""Address"" + , T5.""LicTradNum"" + , IFNULL(T5.""Building"",'') ""Building"" + , T0.""PayMethCod"" + , T6.""DocEntry"" + , IFNULL(T6.""U_PGX_REPIMPXML"",'') ""Xml"" + , IFNULL(T0.""U_SIS_PLANILLA"",'') ""Planilla"" + FROM OBOE T0 + INNER JOIN OCRD T5 ON T5.""CardCode"" = T0.""CardCode"" + LEFT JOIN OINV T6 ON T6.""FolioPref"" = T0.""FolioPref"" AND T6.""FolioNum"" = T0.""FolioNum"" + WHERE T0.""PayMethCod"" LIKE '%_FN_%' + AND T0.""BoeType"" = 'I' + AND T0.""BoeStatus"" = 'G' + AND T6.""CANCELED"" = 'N' + AND LENGTH(IFNULL(T6.""FolioPref"",'')) > 0 AND IFNULL(T6.""FolioNum"",0) > 0"; + + return query; + } + + public static string ObtenerQuery_DatosAdjuntos(string docentry) + { + + var query = $@" + SELECT T3.* + FROM OATC T2 + INNER JOIN ATC1 T3 ON T3.""AbsEntry"" = T2.""AbsEntry"" + WHERE T2.""AbsEntry"" = {docentry} AND T3.""FileExt"" = 'pdf'"; + + return query; + } + + public static string ObtenerQuery_EmailsContactos() + { + var query = $@"SELECT A.""CardCode"", A.""Email"" + FROM ( + SELECT + CASE + WHEN ROW_NUMBER() OVER (PARTITION BY T0.""CardCode"" ORDER BY T0.""CardCode"") = 1 THEN 'Y' + ELSE 'N' + END ""Flag"", + T0.""CardCode"", + T0.""E_MailL"" ""Email"" + FROM OCPR T0 + WHERE T0.""EmlGrpCode"" = 'factura negociable' + + ) A + WHERE A.""Flag"" = 'Y';"; + + return query; + } + + public static string ObtenerQuery_FechaMesaPartes() + { + var query= $@"SELECT A.""Fecha"", A.""DocEntry"" + FROM ( + SELECT CASE WHEN ROW_NUMBER() OVER(PARTITION BY T0.""DocEntry"" ORDER BY T0.""DocEntry"") = 1 THEN 'Y' ELSE 'N' END ""Flag"", + TO_VARCHAR(T7.""U_SIS_FECHA"",'YYYYMMDD') ""Fecha"", + T0.""DocEntry"" + FROM OINV T0 + INNER JOIN ""@SIS_DETENT1"" T7 ON T7.""DocEntry"" = T0.""U_SIS_DETENT"" + WHERE T7.""U_SIS_ETAPA"" = 'MESA DE PARTES' ) A + WHERE A.""Flag"" = 'Y';"; + + return query; + } + + public static DataModel.DataTable DeserializarDataTable(string xmlData) + { + DataModel.DataTable dataTableSerializer = new DataModel.DataTable(); + try + { + ; + XmlSerializer serializer = new XmlSerializer(typeof(DataModel.DataTable)); + using (StringReader reader = new StringReader(xmlData)) + { + dataTableSerializer = (DataModel.DataTable)serializer.Deserialize(reader); + + } + + } + catch (Exception) + { + + } + + + return dataTableSerializer; + } + + public static void Archivo_Excel_BCP(SAPbouiCOM.Form form) + { + + SAPbouiCOM.UserDataSource uds; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.RutaCarpetas); + var ruta = uds.ValueEx; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Correo); + var correo_tagumedica = uds.ValueEx; + + //uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Serie); + //var serie_factura_negociable = uds.ValueEx; + + + SAPbouiCOM.Grid grid; + grid = (SAPbouiCOM.Grid)form.Items.Item(Formulario.Items.GridFacturas).Specific; + + var facturas = new List(); + + //var formats = new string[] { @"dd/MM/yyyy", @"d/MM/yyyy" }; + + for (var i = 0; i < grid.Rows.Count; i++) + { + var rowIndex = grid.GetDataTableRowIndex(i); + + var seleccionado = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Seleccionado].Nombre, rowIndex).ToString(); + if (seleccionado.Equals("Y")) + { + var serie = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Serie].Nombre, rowIndex).ToString(); + var correlativo = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Correlativo].Nombre, rowIndex).ToString(); + var correo = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Correo].Nombre, rowIndex).ToString(); + var direccion = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Direccion].Nombre, rowIndex).ToString(); + var total = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Total].Nombre, rowIndex).ToString(); + var ubigeo = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Ubigeo].Nombre, rowIndex).ToString(); + + + var vencimiento = DateTime.Parse(grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.FechaVencimiento].Nombre, rowIndex).ToString(), CultureInfo.DefaultThreadCurrentCulture); + + facturas.Add(new FacturaNegociableBCP + { + TipoProducto = "DLEFNC", + Moneda = "0", + NumeroCuentaCorriente = "1921153365050", + TipoComprobante = "01", + RucProveedor = "20503662869", + Serie = serie, + Numeracion = correlativo, + FechaVencimiento = vencimiento.ToString("dd/MM/yyyy"), + DepartamentoProveedor = "15", + ProvinciaProveedor = "01", + DistritoProveedor = "01", + DomicilioProveedor = "AV. MAQUINARIAS 2414 - LIMA - LIMA", + DepartamentoAdquiriente = ubigeo.Length > 1 ? ubigeo.Substring(0, 2) : "", + ProvinciaAdquiriente = ubigeo.Length > 3 ? ubigeo.Substring(2, 2) : "", + DistritoAdquiriente = ubigeo.Length > 5 ? ubigeo.Substring(4, 2) : "", + DomicilioAdquiriente = direccion, + TipoPago = "0", + NumeroCuota = "", + FechaComunicacionAdquiriente = DateTime.Now.ToString("dd/MM/yyyy"), + FechaAceptacion = "", + FechaPago = vencimiento.ToString("dd/MM/yyyy"), + ImporteNetoPendientePago = double.Parse(total, CultureInfo.DefaultThreadCurrentCulture), + ClausulaProrroga = 0, + ClausulasEspeciales = correo_tagumedica, + Observaciones = correo + + }); + } + } + + + + + var nombreArchivo = $"{DateTime.Now:yyyyMMddHHmmss}.xls"; + + var fullPath = Path.Combine(ruta, nombreArchivo); + SLDocument excel = new SLDocument(); + + var dt = new System.Data.DataTable(); + + dt.Columns.Add("TIPO DE PRODUCTO", typeof(string)); + dt.Columns.Add("MONEDA", typeof(string)); + dt.Columns.Add("NUMERO DE CUENTA CORRIENTE DE CARGO/ABONO", typeof(string)); + dt.Columns.Add("IMPORTE TOTAL PLANILLA", typeof(double)); + dt.Columns.Add("TIPO_COMPROBANTE", typeof(string)); + dt.Columns.Add("RUC_PROVEEDOR", typeof(string)); + dt.Columns.Add("SERIE", typeof(string)); + dt.Columns.Add("NUMERACION", typeof(string)); + dt.Columns.Add("FECHA_VENCIMIENTO", typeof(string)); + dt.Columns.Add("DEPARTAMENTO_PROVEEDOR", typeof(string)); + dt.Columns.Add("PROVINCIA_PROVEEDOR", typeof(string)); + dt.Columns.Add("DISTRITO_PROVEEDOR", typeof(string)); + dt.Columns.Add("DOMICILIO_PROVEEDOR", typeof(string)); + dt.Columns.Add("DEPARTAMENTO_ADQ", typeof(string)); + dt.Columns.Add("PROVINCIA_ADQ", typeof(string)); + dt.Columns.Add("DISTRITO_ADQ", typeof(string)); + dt.Columns.Add("DOMICILIO_ADQUIRIENTE", typeof(string)); + dt.Columns.Add("TIPO_PAGO", typeof(string)); + dt.Columns.Add("NRO_CUOTA", typeof(string)); + dt.Columns.Add("FECHA_COMUNICACION_ADQ", typeof(string)); + dt.Columns.Add("FECHA_ACEPTACION", typeof(string)); + dt.Columns.Add("FECHA_PAGO", typeof(string)); + dt.Columns.Add("IMPORTE_NETO_PENDIENTE_PAGO", typeof(double)); + dt.Columns.Add("CLAUSULA DE PRORROGA", typeof(int)); + dt.Columns.Add("CLAUSULAS_ESPECIALES", typeof(string)); + dt.Columns.Add("OBSERVACIONES", typeof(string)); + + for (var i = 1; i <= 24; i++) + { + dt.Columns.Add($"MONTO_NETO_CUOTA_{i}", typeof(string)); + dt.Columns.Add($"FECHA_PAGO_CUOTA_{i}", typeof(string)); + } + + + var importeTotalPlanilla = facturas.Sum(x => x.ImporteNetoPendientePago); + + + foreach (var item in facturas) + { + dt.Rows.Add(item.TipoProducto, + item.Moneda, + item.NumeroCuentaCorriente, + importeTotalPlanilla, + item.TipoComprobante, + item.RucProveedor, + item.Serie, + item.Numeracion, + item.FechaVencimiento, + item.DepartamentoProveedor, + item.ProvinciaProveedor, + item.DistritoProveedor, + item.DomicilioProveedor, + item.DepartamentoAdquiriente, + item.ProvinciaAdquiriente, + item.DistritoAdquiriente, + item.DomicilioAdquiriente, + item.TipoPago, + item.NumeroCuota, + item.FechaComunicacionAdquiriente, + item.FechaAceptacion, + item.FechaPago, + item.ImporteNetoPendientePago, + item.ClausulaProrroga, + item.ClausulasEspeciales, + item.Observaciones + ); + } + + excel.ImportDataTable(1, 1, dt, true); + + // Crear estilo + SLStyle styleDecimal = excel.CreateStyle(); + styleDecimal.FormatCode = "0.00"; + + var ultimaFila = dt.Rows.Count + 1; + + // La columna 23 es IMPORTE_NETO_PENDIENTE_PAGO + // Desde fila 2 porque fila 1 es encabezado + excel.SetCellStyle(2, 23, ultimaFila, 23, styleDecimal); + + // La columna 4 es IMPORTE TOTAL PLANILLA + // Desde fila 2 porque fila 1 es encabezado + excel.SetCellStyle(2, 4, ultimaFila, 4, styleDecimal); + + excel.SaveAs(fullPath); + } + + public static void Archivo_Excel_BBVA(SAPbouiCOM.Form form) + { + + SAPbouiCOM.UserDataSource uds; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.RutaCarpetas); + var ruta = uds.ValueEx; + + uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Correo); + var correo_tagumedica = uds.ValueEx; + + //uds = form.DataSources.UserDataSources.Item(Formulario.DataSources.UserDataSources.Serie); + //var serie_factura_negociable = uds.ValueEx; + + + SAPbouiCOM.Grid grid; + grid = (SAPbouiCOM.Grid)form.Items.Item(Formulario.Items.GridFacturas).Specific; + + var facturas = new List(); + + //string[] formats = new string[] { @"dd/MM/yyyy", @"d/MM/yyyy" }; + + for (var i = 0; i < grid.Rows.Count; i++) + { + var rowIndex = grid.GetDataTableRowIndex(i); + + var seleccionado = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Seleccionado].Nombre, rowIndex).ToString(); + if (seleccionado.Equals("Y")) + { + var serie = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Serie].Nombre, rowIndex).ToString(); + var correlativo = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Correlativo].Nombre, rowIndex).ToString(); + var correo = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Correo].Nombre, rowIndex).ToString(); + var direccion = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Direccion].Nombre, rowIndex).ToString(); + var total = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Total].Nombre, rowIndex).ToString(); + var ubigeo = grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.Ubigeo].Nombre, rowIndex).ToString(); + + + var vencimiento = DateTime.Parse(grid.DataTable.GetValue(ColumnasGridFacturasNegociables[(int)OrdenGridFacturasNegociables.FechaVencimiento].Nombre, rowIndex).ToString(), CultureInfo.DefaultThreadCurrentCulture); + + facturas.Add(new FacturaNegociableBBVA + { + TipoComprobante = "01", + RucProveedor = "20503662869", + Serie = serie, + Numeracion = correlativo, + FechaVencimiento = vencimiento.ToString("dd/MM/yyyy"), + DepartamentoProveedor = "15", + ProvinciaProveedor = "01", + DistritoProveedor = "01", + DomicilioProveedor = "AV. MAQUINARIAS 2414 - LIMA - LIMA", + DepartamentoAdquiriente = ubigeo.Length > 1 ? ubigeo.Substring(0, 2) : "", + ProvinciaAdquiriente = ubigeo.Length > 3 ? ubigeo.Substring(2, 2) : "", + DistritoAdquiriente = ubigeo.Length > 5 ? ubigeo.Substring(4, 2) : "", + DomicilioAdquiriente = direccion, + TipoPago = "0", + NumeroCuota = "", + FechaComunicacionAdquiriente = DateTime.Now.ToString("dd/MM/yyyy"), + FechaAceptacion = "", + FechaPago = vencimiento.ToString("dd/MM/yyyy"), + ImporteNetoPendientePago = double.Parse(total, CultureInfo.DefaultThreadCurrentCulture), + ClausulasEspeciales = correo_tagumedica, + Observaciones = correo + }); + } + } + + + + + var nombreArchivo = $"{DateTime.Now:yyyyMMddHHmmss}.xls"; + + var fullPath = Path.Combine(ruta, nombreArchivo); + SLDocument excel = new SLDocument(); + + var dt = new System.Data.DataTable(); + + dt.Columns.Add("TIPO_COMPROBANTE", typeof(string)); + dt.Columns.Add("RUC_PROVEEDOR", typeof(string)); + dt.Columns.Add("SERIE", typeof(string)); + dt.Columns.Add("NUMERACION", typeof(string)); + dt.Columns.Add("FECHA_VENCIMIENTO", typeof(string)); + dt.Columns.Add("DEPARTAMENTO_PROVEEDOR", typeof(string)); + dt.Columns.Add("PROVINCIA_PROVEEDOR", typeof(string)); + dt.Columns.Add("DISTRITO_PROVEEDOR", typeof(string)); + dt.Columns.Add("DOMICILIO_PROVEEDOR", typeof(string)); + dt.Columns.Add("DEPARTAMENTO_ADQ", typeof(string)); + dt.Columns.Add("PROVINCIA_ADQ", typeof(string)); + dt.Columns.Add("DISTRITO_ADQ", typeof(string)); + dt.Columns.Add("DOMICILIO_ADQUIRIENTE", typeof(string)); + dt.Columns.Add("TIPO_PAGO", typeof(string)); + dt.Columns.Add("NRO_CUOTA", typeof(string)); + dt.Columns.Add("FECHA_COMUNICACION_ADQ", typeof(string)); + dt.Columns.Add("FECHA_ACEPTACION", typeof(string)); + dt.Columns.Add("FECHA_PAGO", typeof(string)); + dt.Columns.Add("IMPORTE_NETO_PENDIENTE_PAGO", typeof(double)); + dt.Columns.Add("CLAUSULAS_ESPECIALES", typeof(string)); + dt.Columns.Add("OBSERVACIONES", typeof(string)); + + + for (var i = 1; i <= 24; i++) + { + dt.Columns.Add($"MONTO_NETO_CUOTA_{i}", typeof(string)); + dt.Columns.Add($"FECHA_PAGO_CUOTA_{i}", typeof(string)); + } + + foreach (var item in facturas) + { + dt.Rows.Add(item.TipoComprobante, + item.RucProveedor, + item.Serie, + item.Numeracion, + item.FechaVencimiento, + item.DepartamentoProveedor, + item.ProvinciaProveedor, + item.DistritoProveedor, + item.DomicilioProveedor, + item.DepartamentoAdquiriente, + item.ProvinciaAdquiriente, + item.DistritoAdquiriente, + item.DomicilioAdquiriente, + item.TipoPago, + item.NumeroCuota, + item.FechaComunicacionAdquiriente, + item.FechaAceptacion, + item.FechaPago, + item.ImporteNetoPendientePago, + item.ClausulasEspeciales, + item.Observaciones + ); + } + + excel.ImportDataTable(1, 1, dt, true); + + // Crear estilo + SLStyle styleDecimal = excel.CreateStyle(); + styleDecimal.FormatCode = "0.00"; + + // La columna 19 es IMPORTE_NETO_PENDIENTE_PAGO + // Desde fila 2 porque fila 1 es encabezado + var ultimaFila = dt.Rows.Count + 1; + + excel.SetCellStyle(2, 19, ultimaFila, 19, styleDecimal); + + excel.SaveAs(fullPath); + } + + #endregion + + } +} diff --git a/FacturaNegociable/FormularioWebBrowser.cs b/FacturaNegociable/FormularioWebBrowser.cs new file mode 100644 index 0000000..a14e768 --- /dev/null +++ b/FacturaNegociable/FormularioWebBrowser.cs @@ -0,0 +1,122 @@ +using System; +using System.Xml; + +namespace FacturaNegociable +{ + public static class FormularioWebBrowser + { + #region Formulario + public struct Formulario + { + public struct DataSources + { + public struct DBDataSources + { + + } + + public struct UserDataSources + { + public const string US = "US"; + } + + public struct DataTables + { + public const string DataTable = "DT_0"; + } + } + + public struct Items + { + public struct Item + { + public const string WebBrowser = "wb"; + } + } + } + + #endregion + + public static void FormLoad(string fullpathfile, string tittle, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool bBubbleEvent) + { + bBubbleEvent = true; + + SAPbouiCOM.FormCreationParams oFormCreationPackage; + SAPbouiCOM.Form Form; + SAPbouiCOM.Item oItem; + SAPbouiCOM.WebBrowser oWebBrowser; + + oFormCreationPackage = (SAPbouiCOM.FormCreationParams)oApplication.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams); + try + { + XmlDocument xmlForm = new XmlDocument(); + + xmlForm.Load(Archivos.ArchivoFormularioWebBrowser); + + oFormCreationPackage.XmlData = xmlForm.InnerXml; + oFormCreationPackage.UniqueID = "UF" + Funciones.Random().ToString(); + Form = oApplication.Forms.AddEx(oFormCreationPackage); + + if (tittle != string.Empty) + Form.Title = tittle; + + oItem = Form.Items.Item(Formulario.Items.Item.WebBrowser); + + oItem.Left = 5; + oItem.Top = 5; + oItem.Height = Form.ClientHeight - 5; + oItem.Width = Form.ClientWidth - 5; + + oWebBrowser = (SAPbouiCOM.WebBrowser)oItem.Specific; + + oWebBrowser.Url = fullpathfile; + + Form.Visible = true; + + } + catch (Exception e) + { + oApplication.StatusBar.SetText(e.ToString(), SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + } + + } + + public static void HandleItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent oItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool bBubbleEvent) + { + bBubbleEvent = true; + switch (oItemEvent.EventType) + { + case SAPbouiCOM.BoEventTypes.et_FORM_RESIZE: + FormResize(FormUID, ref oItemEvent, oCompany, ref oApplication, out bBubbleEvent); + break; + } + } + + public static void FormResize(string FormUID, ref SAPbouiCOM.ItemEvent oItemEvent, SAPbobsCOM.Company oCompany, ref SAPbouiCOM.Application oApplication, out bool bBubbleEvent) + { + bBubbleEvent = true; + + SAPbouiCOM.Form Form; + SAPbouiCOM.Item Item; + Form = oApplication.Forms.Item(FormUID); + + if (!oItemEvent.BeforeAction) + { + for (int i = 0; i < Form.Items.Count; i++) + { + if (Form.Items.Item(i).UniqueID == Formulario.Items.Item.WebBrowser) + { + Item = Form.Items.Item(Formulario.Items.Item.WebBrowser); + Item.Left = 5; + Item.Top = 5; + Item.Height = Form.ClientHeight - 5; + Item.Width = Form.ClientWidth - 5; + + break; + } + } + + } + } + } +} diff --git a/FacturaNegociable/Funciones.cs b/FacturaNegociable/Funciones.cs new file mode 100644 index 0000000..bf87cc9 --- /dev/null +++ b/FacturaNegociable/Funciones.cs @@ -0,0 +1,94 @@ +using SAPbouiCOM; +using System; +using System.Security; +using System.Text.RegularExpressions; + +namespace FacturaNegociable +{ + public static class Funciones + { + public static long Random() + { + long _aleatorio = -1; + long _minimo = 1; + long _maximo = 1000; + Random r = new Random(); + _aleatorio = (_minimo - _maximo) * r.Next() + _maximo; + return _aleatorio; + } + + public static void LoadComboQuery(string _query, ref SAPbouiCOM.ComboBox oComboBox, string fieldValue, string fieldDesc, SAPbobsCOM.Company oCompany) + { + SAPbouiCOM.ValidValues oValidValues; + SAPbobsCOM.Recordset oRecordset; + + oRecordset = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); + oRecordset.DoQuery(_query); + + oValidValues = oComboBox.ValidValues; + + while (oComboBox.ValidValues.Count > 0) + { + oComboBox.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index); + } + + if (string.Equals(fieldDesc, string.Empty)) + { + while (!oRecordset.EoF) + { + oValidValues.Add(oRecordset.Fields.Item(fieldValue).Value.ToString(), ""); + oRecordset.MoveNext(); + } + } + else + { + while (!oRecordset.EoF) + { + oValidValues.Add(oRecordset.Fields.Item(fieldValue).Value.ToString(), oRecordset.Fields.Item(fieldDesc).Value.ToString()); + oRecordset.MoveNext(); + } + } + } + + public static SAPbouiCOM.DataTable GetDataTableFromCLF(SAPbouiCOM.ItemEvent oEvent, SAPbouiCOM.Form oForm) + { + SAPbouiCOM.ChooseFromListEvent oChooseFromListEvent; + SAPbouiCOM.ChooseFromList oChooseFromList; + string ItemUid; + + oChooseFromListEvent = (SAPbouiCOM.ChooseFromListEvent)oEvent; + ItemUid = oChooseFromListEvent.ChooseFromListUID; + oChooseFromList = oForm.ChooseFromLists.Item(ItemUid); + + return oChooseFromListEvent.SelectedObjects; + } + + public static string CleanString(string imputText) + { + string result = string.Empty; + + //string pattern = @"\b[A-Z]\w*\b"; + + result = Regex.Replace(imputText, "[^A-Za-z0-9 _]", ""); + + return result; + } + + public static SecureString ConvertToSecureString(string password) + { + if (password == null) + throw new ArgumentNullException("password"); + + unsafe + { + fixed (char* passwordChars = password) + { + var securePassword = new SecureString(passwordChars, password.Length); + securePassword.MakeReadOnly(); + return securePassword; + } + } + } + + } +} diff --git a/FacturaNegociable/Menu.cs b/FacturaNegociable/Menu.cs new file mode 100644 index 0000000..aadba81 --- /dev/null +++ b/FacturaNegociable/Menu.cs @@ -0,0 +1,69 @@ +using SAPbouiCOM.Framework; +using System; +using System.Xml; + +namespace FacturaNegociable +{ + public class Menu + { + public void AddMenuItems() + { + try + { + RemoveMenus(); + + var menuXml = new XmlDocument(); + + menuXml.Load("menu.xml"); + + Application.SBO_Application.LoadBatchActions(menuXml.InnerXml); + + + //SAPbouiCOM.MenuItem menu = Application.SBO_Application.Menus.Item(MenuUsuario.MenuPrincipal); + //menu.Image = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "creditcard.bmp"); + } + catch (Exception) + { + + } + + } + + public void RemoveMenus() + { + SAPbouiCOM.Menus oMenus = Application.SBO_Application.Menus; + + if (oMenus.Exists(MenuUsuario.MenuFacturaNegociable)) + { + oMenus.RemoveEx(MenuUsuario.MenuFacturaNegociable); + } + + } + + public void SBO_Application_MenuEvent(ref SAPbouiCOM.MenuEvent menuEvent, out bool BubbleEvent) + { + BubbleEvent = true; + + try + { + switch (menuEvent.MenuUID) + { + case MenuUsuario.MenuFacturaNegociable: + + FormularioFacturaNegociable.FormLoad(ref menuEvent, Program.sbo_company, ref Program.sbo_application, out BubbleEvent); + + break; + + default: + break; + } + + } + catch (Exception ex) + { + Program.sbo_application.StatusBar.SetText("MenuEvent " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + } + } + + } +} diff --git a/FacturaNegociable/OpenFileDialogWrapper.cs b/FacturaNegociable/OpenFileDialogWrapper.cs new file mode 100644 index 0000000..d81db7b --- /dev/null +++ b/FacturaNegociable/OpenFileDialogWrapper.cs @@ -0,0 +1,264 @@ +using System; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Management; +using System.Threading; +using System.Windows.Forms; + +using ThreadState = System.Threading.ThreadState; + +namespace FacturaNegociable +{ + public static class OpenFileDialogWrapper + { + #region Private members + + private const string SapProcessName = "SAP Business One"; + + private static string fileName; + + private static string filter = "All files(*.*)|*.*"; + + #endregion + + /// + /// Determina el número de instancias actuales de Business One en la computadora. + /// + /// Número encontrado de instancias + public static int IsBusinessOneRunning() + { + var returnValue = 0; + + var userName = Environment.UserName; + + fileName = string.Empty; + + try + { + var processes = Process.GetProcessesByName(SapProcessName); + + for (var i = 0; i <= processes.Length - 1; i++) + { + var processUserName = GetProcessUserName(processes[i]); + if (processUserName != userName) + { + continue; + } + + returnValue++; + } + } + catch (Exception ex) + { + Program.sbo_application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + + //if (Debugger.IsAttached) + //{ + // Debugger.Break(); + //} + } + + return returnValue; + } + + /// + /// Muestra un diálogo estándar FileBrowser para obtener un nombre de archivo del usuario + /// + /// + /// The file Filter. + /// + /// + /// Nombre de archivo si está seleccionado, más cadena. Vacio + /// + public static string FindFile(string fileFilter = "") + { + string returnValue = string.Empty; + + if (!string.IsNullOrEmpty(fileFilter)) + { + filter = fileFilter; + } + + try + { + var showFolderBrowserThread = new Thread(ShowFolderBrowser); + if (showFolderBrowserThread.ThreadState == ThreadState.Unstarted) + { + showFolderBrowserThread.SetApartmentState(ApartmentState.STA); + } + + showFolderBrowserThread.Start(); + showFolderBrowserThread.Join(); + + while (showFolderBrowserThread.ThreadState == ThreadState.Running) + { + Application.DoEvents(); + } + + if (false == string.IsNullOrEmpty(fileName)) + { + returnValue = fileName; + } + } + catch (Exception ex) + { + Program.sbo_application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + + } + return returnValue; + } + + private static void ShowFolderBrowser() + { + var userName = Environment.UserName; + var openFile = new OpenFileDialog(); + + fileName = string.Empty; + + try + { + openFile.Multiselect = false; + openFile.Filter = filter; + int filterIndex = 0; + + try + { + filterIndex = 0; + } + catch (Exception) + { + + } + + openFile.FilterIndex = filterIndex; + + openFile.RestoreDirectory = true; + + /////////////////////////////// + + + Process currentProcess = Process.GetCurrentProcess(); + + int parentProcessId = -1; + + Process parentProcess = GetParent(currentProcess); + + if (parentProcess == null) + { + Program.sbo_application.StatusBar.SetText("No hay proceso padre.", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + } + else + { + parentProcessId = parentProcess.Id; + + //var myWindow = new WindowWrapper(Process.GetProcessById(parentProcessId).MainWindowHandle); + var myWindow = new WindowWrapper(parentProcess.MainWindowHandle); + + var ret = openFile.ShowDialog(myWindow); + + if (ret == DialogResult.OK) + { + fileName = openFile.FileName; + } + else + { + Application.ExitThread(); + } + } + + + /////////////////////////////// + + + //Process[] runningProcesses = Process.GetProcesses(); + + //int currentSessionID = Process.GetCurrentProcess().SessionId; + + //Program.archivoLog.EscribirLog($"Process.GetCurrentProcess().SessionId = {currentSessionID}"); + + //Process[] sameAsThisSession = runningProcesses.Where(p => p.SessionId == currentSessionID).ToArray(); + + //Program.archivoLog.EscribirLog($"sameAsThisSession Length = {sameAsThisSession.Length}"); + + //foreach (Process p in sameAsThisSession) + //{ + // Program.archivoLog.EscribirLog($"ProcessName = {p.ProcessName} | Id = {p.Id} | SessionId = {p.SessionId} | ProcessUserName = {GetProcessUserName(p)}"); + + //} + + + + } + catch (Exception ex) + { + + Program.sbo_application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + + } + finally + { + openFile.Dispose(); + GC.Collect(); + } + } + + public static Process GetParent(this Process process) + { + try + { + using (var query = new ManagementObjectSearcher( + "SELECT * " + + "FROM Win32_Process " + + "WHERE ProcessId=" + process.Id)) + { + return query + .Get() + .OfType() + .Select(p => Process.GetProcessById((int)(uint)p["ParentProcessId"])) + .FirstOrDefault(); + } + } + catch + { + return null; + } + } + + private static string GetProcessUserName(Process process) + { + var returnValue = string.Empty; + var query = string.Format( + CultureInfo.InvariantCulture, + "Select * from Win32_Process Where ProcessID = '{0}'", + process.Id); + var sq = new ObjectQuery(query); + + using (var searcher = new ManagementObjectSearcher(sq)) + { + ManagementObjectCollection processList = searcher.Get(); + if (0 == processList.Count) + { + return string.Empty; + } + + foreach (var o in processList) + { + var managementObject = (ManagementObject)o; + var args = new object[2]; + + // Invoca el método y rellena el var con el nombre de usuario y el dominio + managementObject.InvokeMethod("GetOwner", args); + + if (null != args[0]) + { + returnValue = args[0].ToString(); + break; + } + } + } + + return returnValue; + } + } +} diff --git a/FacturaNegociable/Program.cs b/FacturaNegociable/Program.cs new file mode 100644 index 0000000..14c36fd --- /dev/null +++ b/FacturaNegociable/Program.cs @@ -0,0 +1,200 @@ +using System; +using SAPbouiCOM; + +namespace FacturaNegociable +{ + static class Program + { + #region VariablesGlobales + public static System.Globalization.NumberFormatInfo oNumberFormatInfo = new System.Globalization.NumberFormatInfo(); + public static string RightClickColumn = null; + public static int RightClickRow = -1; + public static string RightClickItemUID = null; + public static bool ModalFormIsOpen = false; + + public static SAPbobsCOM.Company sbo_company; + public static SAPbouiCOM.Application sbo_application; + + public static SAPbouiCOM.ProgressBar sbo_progressbar = null; + + //public static FileLogger archivoLog = new FileLogger(); + + #endregion + + /// + /// Punto de entrada principal para la aplicación. + /// + [STAThread] + static void Main(string[] args) + { + try + { + SAPbouiCOM.Framework.Application oApp = null; + if (args.Length < 1) + { + oApp = new SAPbouiCOM.Framework.Application(); + } + else + { + oApp = new SAPbouiCOM.Framework.Application(args[0]); + } + + sbo_application = SAPbouiCOM.Framework.Application.SBO_Application; + + sbo_company = (SAPbobsCOM.Company)sbo_application.Company.GetDICompany(); + + + Program.oNumberFormatInfo.NumberDecimalSeparator = sbo_company.GetCompanyService().GetAdminInfo().DecimalSeparator; + Program.oNumberFormatInfo.NumberGroupSeparator = sbo_company.GetCompanyService().GetAdminInfo().ThousandsSeparator; + + Menu MyMenu = new Menu(); + MyMenu.AddMenuItems(); + oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent); + + SAPbouiCOM.Framework.Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent); + + SAPbouiCOM.Framework.Application.SBO_Application.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(SBO_Application_ItemEvent); + + SAPbouiCOM.Framework.Application.SBO_Application.FormDataEvent += new SAPbouiCOM._IApplicationEvents_FormDataEventEventHandler(SBO_Application_FormDataEvent); + + SAPbouiCOM.Framework.Application.SBO_Application.ReportDataEvent += new SAPbouiCOM._IApplicationEvents_ReportDataEventEventHandler(SBO_Application_ReportDataEvent); + + SAPbouiCOM.Framework.Application.SBO_Application.PrintEvent += new SAPbouiCOM._IApplicationEvents_PrintEventEventHandler(SBO_Application_PrintEvent); + + SAPbouiCOM.Framework.Application.SBO_Application.RightClickEvent += new SAPbouiCOM._IApplicationEvents_RightClickEventEventHandler(SBO_Application_RightClickEvent); + + SAPbouiCOM.Framework.Application.SBO_Application.ProgressBarEvent += new SAPbouiCOM._IApplicationEvents_ProgressBarEventEventHandler(SBO_Application_ProgressBarEvent); + + System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); + System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); + + SAPbouiCOM.Framework.Application.SBO_Application.StatusBar.SetText($"addon factura negociable {fvi.FileVersion} iniciado con éxito.", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success); + + oApp.Run(); + + } + catch (Exception ex) + { + System.Windows.Forms.MessageBox.Show(ex.Message); + } + } + + private static void SBO_Application_ProgressBarEvent(ref ProgressBarEvent pVal, out bool BubbleEvent) + { + BubbleEvent = true; + + if (pVal.EventType == BoProgressBarEventTypes.pbet_ProgressBarStopped && pVal.BeforeAction) + { + + } + } + + private static void SBO_Application_AppEvent(SAPbouiCOM.BoAppEventTypes eventType) + { + switch (eventType) + { + case SAPbouiCOM.BoAppEventTypes.aet_ShutDown: + //Exit Add-On + System.Windows.Forms.Application.Exit(); + break; + case SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged: + System.Windows.Forms.Application.Exit(); + break; + case SAPbouiCOM.BoAppEventTypes.aet_FontChanged: + break; + case SAPbouiCOM.BoAppEventTypes.aet_LanguageChanged: + System.Windows.Forms.Application.Exit(); + break; + case SAPbouiCOM.BoAppEventTypes.aet_ServerTerminition: + System.Windows.Forms.Application.Exit(); + break; + default: + break; + } + } + + private static void SBO_Application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent itemEvent, out bool BubbleEvent) + { + + BubbleEvent = true; + + try + { + switch (itemEvent.FormTypeEx) + { + + case UserFormType.FormularioFacturaNegociable: + + FormularioFacturaNegociable.HandleItemEvent(FormUID, ref itemEvent, Program.sbo_company, ref Program.sbo_application, out BubbleEvent); + + break; + case UserFormType.FormularioWebBrowser: + + FormularioWebBrowser.HandleItemEvent(FormUID, ref itemEvent, Program.sbo_company, ref Program.sbo_application, out BubbleEvent); + + break; + + default: + break; + } + + } + catch (Exception ex) + { + sbo_application.StatusBar.SetText("ItemEvent " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + } + + } + + private static void SBO_Application_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo businessObjectInfo, out bool BubbleEvent) + { + BubbleEvent = true; + try + { + switch (businessObjectInfo.FormTypeEx) + { + + default: + break; + } + } + catch (Exception ex) + { + sbo_application.StatusBar.SetText("FormDataEvent " + ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); + } + + } + + private static void SBO_Application_ReportDataEvent(ref SAPbouiCOM.ReportDataInfo reportDataInfo, out bool BubbleEvent) + { + BubbleEvent = true; + + } + + private static void SBO_Application_PrintEvent(ref SAPbouiCOM.PrintEventInfo printeventInfo, out bool BubbleEvent) + { + BubbleEvent = true; + } + + private static void SBO_Application_RightClickEvent(ref SAPbouiCOM.ContextMenuInfo eventInfo, out bool BubbleEvent) + { + BubbleEvent = true; + + //SAPbouiCOM.Form form; + + //form = Program.sbo_application.Forms.Item(eventInfo.FormUID); + + try + { + + } + catch (Exception ex) + { + Program.sbo_application.MessageBox(ex.Message); + } + + + } + } + +} diff --git a/FacturaNegociable/Properties/AssemblyInfo.cs b/FacturaNegociable/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4e0371f --- /dev/null +++ b/FacturaNegociable/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// La información general de un ensamblado se controla mediante el siguiente +// conjunto de atributos. Cambie estos valores de atributo para modificar la información +// asociada con un ensamblado. +[assembly: AssemblyTitle("FacturaNegociable 3_3_0_0")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("FacturaNegociable")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Si establece ComVisible en false, los tipos de este ensamblado no estarán visibles +// para los componentes COM. Si es necesario obtener acceso a un tipo en este ensamblado desde +// COM, establezca el atributo ComVisible en true en este tipo. +[assembly: ComVisible(false)] + +// El siguiente GUID sirve como id. de typelib si este proyecto se expone a COM. +[assembly: Guid("84776f11-d2b7-4d6e-9a21-d8af0e7bf0d9")] + +// La información de versión de un ensamblado consta de los cuatro valores siguientes: +// +// Versión principal +// Versión secundaria +// Número de compilación +// Revisión +// +// Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión +// utilizando el carácter "*", como se muestra a continuación: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("3.3.0.0")] +[assembly: AssemblyFileVersion("3.3.0.0")] diff --git a/FacturaNegociable/Properties/Resources.Designer.cs b/FacturaNegociable/Properties/Resources.Designer.cs new file mode 100644 index 0000000..f10f15a --- /dev/null +++ b/FacturaNegociable/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace FacturaNegociable.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FacturaNegociable.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/FacturaNegociable/Properties/Resources.resx b/FacturaNegociable/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/FacturaNegociable/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/FacturaNegociable/Properties/Settings.Designer.cs b/FacturaNegociable/Properties/Settings.Designer.cs new file mode 100644 index 0000000..abe03dd --- /dev/null +++ b/FacturaNegociable/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace FacturaNegociable.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.12.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/FacturaNegociable/Properties/Settings.settings b/FacturaNegociable/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/FacturaNegociable/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/FacturaNegociable/WindowWrapper.cs b/FacturaNegociable/WindowWrapper.cs new file mode 100644 index 0000000..7db5851 --- /dev/null +++ b/FacturaNegociable/WindowWrapper.cs @@ -0,0 +1,23 @@ +using System; +using System.Windows.Forms; + +namespace FacturaNegociable +{ + public class WindowWrapper : IWin32Window + { + private readonly IntPtr hwnd; + + /// + /// Inicializa una nueva instancia de la clase WindowWrapper. + /// + public WindowWrapper(IntPtr handle) + { + this.hwnd = handle; + } + + /// + /// Obtiene el control de la ventana administrada por la clase. + /// + public IntPtr Handle => this.hwnd; + } +} diff --git a/FacturaNegociable/packages.config b/FacturaNegociable/packages.config new file mode 100644 index 0000000..4965a9b --- /dev/null +++ b/FacturaNegociable/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/SolucionTagumedica.sln b/SolucionTagumedica.sln new file mode 100644 index 0000000..6083366 --- /dev/null +++ b/SolucionTagumedica.sln @@ -0,0 +1,151 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33103.184 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "netActualizacionLotes", "netActualizacionLotes\netActualizacionLotes.csproj", "{DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrearEntrega", "CrearEntrega\CrearEntrega.csproj", "{03878884-70AB-4B40-97CD-2E07C5FDBE5B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FacturaNegociable", "FacturaNegociable\FacturaNegociable.csproj", "{84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrdenImpresion", "OrdenImpresion\OrdenImpresion.csproj", "{83FFBDC1-CCA2-4CEA-8616-01944F557C73}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrearEntregaDropShip", "CrearEntregaDropShip\CrearEntregaDropShip.csproj", "{79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DescargarExportacion", "DescargarExportacion\DescargarExportacion.csproj", "{343F5617-ED8B-46F8-B2F8-A027DDB1714C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualizadorCargos", "VisualizadorCargos\VisualizadorCargos.csproj", "{B04B7461-62BB-46F4-9993-F4927841716D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|arm64 = Debug|arm64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|arm64 = Release|arm64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Debug|arm64.ActiveCfg = Debug|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Debug|arm64.Build.0 = Debug|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Debug|x64.ActiveCfg = Debug|x64 + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Debug|x64.Build.0 = Debug|x64 + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Debug|x86.ActiveCfg = Debug|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Debug|x86.Build.0 = Debug|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Release|Any CPU.Build.0 = Release|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Release|arm64.ActiveCfg = Release|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Release|arm64.Build.0 = Release|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Release|x64.ActiveCfg = Release|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Release|x64.Build.0 = Release|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Release|x86.ActiveCfg = Release|Any CPU + {DC879D0E-37CA-45D2-ACEE-9D09E3F00ADE}.Release|x86.Build.0 = Release|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Debug|arm64.ActiveCfg = Debug|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Debug|arm64.Build.0 = Debug|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Debug|x64.ActiveCfg = Debug|x64 + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Debug|x64.Build.0 = Debug|x64 + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Debug|x86.ActiveCfg = Debug|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Debug|x86.Build.0 = Debug|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Release|Any CPU.Build.0 = Release|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Release|arm64.ActiveCfg = Release|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Release|arm64.Build.0 = Release|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Release|x64.ActiveCfg = Release|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Release|x64.Build.0 = Release|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Release|x86.ActiveCfg = Release|Any CPU + {03878884-70AB-4B40-97CD-2E07C5FDBE5B}.Release|x86.Build.0 = Release|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Debug|arm64.ActiveCfg = Debug|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Debug|arm64.Build.0 = Debug|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Debug|x64.ActiveCfg = Debug|x64 + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Debug|x64.Build.0 = Debug|x64 + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Debug|x86.ActiveCfg = Debug|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Debug|x86.Build.0 = Debug|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Release|Any CPU.Build.0 = Release|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Release|arm64.ActiveCfg = Release|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Release|arm64.Build.0 = Release|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Release|x64.ActiveCfg = Release|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Release|x64.Build.0 = Release|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Release|x86.ActiveCfg = Release|Any CPU + {84776F11-D2B7-4D6E-9A21-D8AF0E7BF0D9}.Release|x86.Build.0 = Release|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Debug|arm64.ActiveCfg = Debug|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Debug|arm64.Build.0 = Debug|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Debug|x64.ActiveCfg = Debug|x64 + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Debug|x64.Build.0 = Debug|x64 + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Debug|x86.ActiveCfg = Debug|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Debug|x86.Build.0 = Debug|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Release|Any CPU.Build.0 = Release|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Release|arm64.ActiveCfg = Release|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Release|arm64.Build.0 = Release|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Release|x64.ActiveCfg = Release|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Release|x64.Build.0 = Release|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Release|x86.ActiveCfg = Release|Any CPU + {83FFBDC1-CCA2-4CEA-8616-01944F557C73}.Release|x86.Build.0 = Release|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Debug|arm64.ActiveCfg = Debug|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Debug|arm64.Build.0 = Debug|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Debug|x64.ActiveCfg = Debug|x64 + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Debug|x64.Build.0 = Debug|x64 + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Debug|x86.ActiveCfg = Debug|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Debug|x86.Build.0 = Debug|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Release|Any CPU.Build.0 = Release|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Release|arm64.ActiveCfg = Release|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Release|arm64.Build.0 = Release|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Release|x64.ActiveCfg = Release|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Release|x64.Build.0 = Release|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Release|x86.ActiveCfg = Release|Any CPU + {79AF8DD0-FBC4-4EE5-A68D-7CEBDF9748B1}.Release|x86.Build.0 = Release|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Debug|arm64.ActiveCfg = Debug|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Debug|arm64.Build.0 = Debug|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Debug|x64.ActiveCfg = Debug|x64 + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Debug|x64.Build.0 = Debug|x64 + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Debug|x86.ActiveCfg = Debug|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Debug|x86.Build.0 = Debug|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Release|Any CPU.Build.0 = Release|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Release|arm64.ActiveCfg = Release|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Release|arm64.Build.0 = Release|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Release|x64.ActiveCfg = Release|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Release|x64.Build.0 = Release|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Release|x86.ActiveCfg = Release|Any CPU + {343F5617-ED8B-46F8-B2F8-A027DDB1714C}.Release|x86.Build.0 = Release|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Debug|arm64.ActiveCfg = Debug|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Debug|arm64.Build.0 = Debug|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Debug|x64.ActiveCfg = Debug|x64 + {B04B7461-62BB-46F4-9993-F4927841716D}.Debug|x64.Build.0 = Debug|x64 + {B04B7461-62BB-46F4-9993-F4927841716D}.Debug|x86.ActiveCfg = Debug|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Debug|x86.Build.0 = Debug|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Release|Any CPU.Build.0 = Release|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Release|arm64.ActiveCfg = Release|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Release|arm64.Build.0 = Release|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Release|x64.ActiveCfg = Release|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Release|x64.Build.0 = Release|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Release|x86.ActiveCfg = Release|Any CPU + {B04B7461-62BB-46F4-9993-F4927841716D}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9B39AC3C-275D-43EB-B95E-A09683DE4E33} + EndGlobalSection +EndGlobal