static void Main(string[] args) { try { Application oApp = null; if (args.Length < 1) { oApp = new Application(); } else { oApp = new Application(args[0]); } Menu MyMenu = new Menu(); MyMenu.AddMenuItems(); DIApplication.DIConnect((SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany()); oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent); Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent); //Initialize Tables UIApplication.ShowSuccess(string.Format("Inicializar las tablas")); CyCServiceFactory lObjCyCServiceFactory = new CyCServiceFactory(); lObjCyCServiceFactory.GetSetupService().InitializeTables(); UIApplication.ShowSuccess(string.Format("Addon de compras iniciado correctamente")); oApp.Run(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
static void Main(string[] args) { try { Application oApp = null; if (args.Length < 1) { oApp = new Application(); } else { oApp = new Application(args[0]); } LogService.Filename("AddOnFinances"); DIApplication.DIConnect((SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany()); Menu MyMenu = new Menu(); MyMenu.AddMenuItems(); oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent); Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent); Application.SBO_Application.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(SBO_Application_ItemEvent); UIApplication.ShowSuccess(string.Format("Addon Finanzas iniciado correctamente")); LogService.WriteSuccess(string.Format("Addon Finanzas iniciado correctamente")); oApp.Run(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
private void btnCreate_ClickAfter(object sboObject, SBOItemEventArg pVal) { try { IList <string> lLstStrCreateJounalEntry = mObjPaymentServiceFactory.CreateDocument().CreateDocument(mLstJournalEntryDTO); if (lLstStrCreateJounalEntry.Count() == 0) { UIApplication.ShowMessageBox("Guardado correcto"); UIApplication.ShowSuccess("Creación de asiento realizado correctamente"); LogService.WriteSuccess("Creación de asiento realizado correctamente"); try { UIAPIRawForm.Freeze(true); DtMatrixAuctions.Rows.Clear(); List <PaymentDTO> lLstPaymentDTO = mObjPaymentServiceFactory.GetPaymentService().GetPayments(mStrAuctionId, mIntSignature).ToList(); FillMatrix(lLstPaymentDTO); mtxAuction.LoadFromDataSource(); mLstJournalEntryDTO = new List <JournalEntryDTO>(); } catch (Exception ex) { UIApplication.ShowError("frmPayment (btnCreate_ClickAfter) " + ex.Message); LogService.WriteError("frmPayment (btnCreate_ClickAfter) " + ex.Message); LogService.WriteError(ex); } finally { UIAPIRawForm.Freeze(false); } } else { string lStrMessage = string.Format(" \n{0}", string.Join("\n", lLstStrCreateJounalEntry.Select(x => string.Format("{0}", x)).ToArray())); UIApplication.ShowMessageBox("Error al crear el asiento: " + lStrMessage); } } catch (Exception ex) { UIApplication.ShowError("frmPayment (btnCreate_ClickAfter) " + ex.Message); LogService.WriteError("frmPayment (btnCreate_ClickAfter) " + ex.Message); LogService.WriteError(ex); } }
private void Button0_ClickBefore(object sboObject, SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; try { if (UIApplication.GetApplication().MessageBox("¿Desea procesar los preliminares y convertirlos a facturas?", 2, "Si", "No", "") != 1) { return; } string lStrInvoiceProcessorPath = new QueryManager().GetValue("U_VALUE", "Name", "GLO_InvoiceProcessorAppPath", "[@UG_Config]"); if (string.IsNullOrEmpty(lStrInvoiceProcessorPath)) { UIApplication.ShowError("Agregue un valor en la configuración para el campo GLO_InvoiceProcessorAppPath"); return; } if (!System.IO.File.Exists(lStrInvoiceProcessorPath)) { UIApplication.ShowError("No existe la ruta de la aplicación asignada en la configuración en el campo GLO_InvoiceProcessorAppPath"); return; } UIApplication.GetApplication().Forms.ActiveForm.Freeze(true); using (var lObjProcess = new Process()) { lObjProcess.StartInfo.FileName = lStrInvoiceProcessorPath; lObjProcess.StartInfo.Arguments = "-v -s -a"; lObjProcess.Start(); lObjProcess.WaitForExit(); //proc.Close(); } UIApplication.ShowSuccess("La aplicación se estará ejecutando en paralelo, quede atento a la consola o al log"); } catch (Exception ex) { UIApplication.ShowMessageBox(string.Format("Error al procesar los preliminares: {0}", ex.Message)); } finally { UIApplication.GetApplication().Forms.ActiveForm.Freeze(false); } }
private bool LoadMtxHeader(string pStrWhsRequesting) { bool lBolVerify = false; try { string lStrQuery = mObjReceptionTransferDAO.SearchWhsTransit(pStrWhsRequesting); if (lStrQuery != "") { this.UIAPIRawForm.DataSources.DataTables.Item("DT_Header").ExecuteQuery(lStrQuery); if (this.UIAPIRawForm.DataSources.DataTables.Item("DT_Header").IsEmpty) { mtxHeader.Clear(); UIApplication.ShowSuccess(string.Format("No hay trasferencias pendientes para {0}", mStrWhsCode)); lBolVerify = false; } else { mtxHeader.Columns.Item("Col_0").DataBind.Bind("DT_Header", "DocEntry"); mtxHeader.Columns.Item("Col_1").DataBind.Bind("DT_Header", "DocNum"); mtxHeader.Columns.Item("Col_2").DataBind.Bind("DT_Header", "DocDate"); mtxHeader.Columns.Item("Col_3").DataBind.Bind("DT_Header", "JrnlMemo"); mtxHeader.Columns.Item("Col_4").DataBind.Bind("DT_Header", "U_PL_WhsReq"); //'almacen solicita' mtxHeader.Columns.Item("Col_5").DataBind.Bind("DT_Header", "Filler"); //'de alamcen' mtxHeader.Columns.Item("Col_6").DataBind.Bind("DT_Header", "ToWhsCode"); //'almacen destino' mtxHeader.LoadFromDataSource(); lBolVerify = true; } } } catch (Exception ex) { UIApplication.ShowError(string.Format("ItemEventException: {0}", ex.Message)); } finally { //MemoryUtility.ReleaseComObject(lObjRecordSet); //this.UIAPIRawForm.Freeze(false); } return(lBolVerify); }
static void Main(string[] args) { try { Application oApp = null; if (args.Length < 1) { oApp = new Application(); } else { oApp = new Application(args[0]); } LogService.Filename("AddOnMaquinaria"); Menu MyMenu = new Menu(); MyMenu.AddMenuItems(); oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent); Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent); //Using Utilities DIApplication.. DIApplication.DIConnect((SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany()); //Initialize Tables UIApplication.ShowSuccess("Inicializando tablas"); MachinerySeviceFactory lObjMachinerySeviceFactory = new MachinerySeviceFactory(); lObjMachinerySeviceFactory.GetSetupService().InitializeTables(); UIApplication.ShowSuccess("Addon de Maquinaria iniciado correctamente"); LogService.WriteSuccess(string.Format("Addon de Maquinaria iniciado correctamente")); oApp.Run(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
static void Main(string[] args) { try { Application oApp = null; if (args.Length < 1) { oApp = new Application(); } else { oApp = new Application(args[0]); } DIApplication.DIConnect((SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany()); //BatchNameCua batchNameCua = new BatchNameCua(); Menu MyMenu = new Menu(); MyMenu.AddMenuItems(); oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent); Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent); //Using Utilities DIApplication.. //DIApplication.DIConnect((SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany()); UIApplication.ShowSuccess(string.Format("Inicializar las tablas")); Services.SetupService lObjSetupService = new Services.SetupService(); lObjSetupService.InitializeTables(); UIApplication.ShowSuccess(string.Format("Addon de cuarentenaria iniciado correctamente")); oApp.Run(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
static void Main(string[] args) { try { Application oApp = null; if (args.Length < 1) { oApp = new Application(); } else { oApp = new Application(args[0]); } LogService.Filename("AddonTransportes"); DIApplication.DIConnect((SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany()); Menu MyMenu = new Menu(); Freights lObjFreights = new Freights(); MyMenu.AddMenuItems(); oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent); Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent); //Initialize Tables UIApplication.ShowSuccess(string.Format("Inicializar las tablas")); TransportServiceFactory mObjServiceFactory = new TransportServiceFactory(); mObjServiceFactory.GetSetUpService().InitializeTables(); UIApplication.ShowSuccess(string.Format("Addon de transportes 1.0.18 iniciado correctamente")); LogService.WriteSuccess("Addon de transportes 1.0.18 iniciado correctamente"); oApp.Run(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
static void Main(string[] args) { try { Application oApp = null; if (args.Length < 1) { oApp = new Application(); } else { oApp = new Application(args[0]); } LogService.Filename("AddOnCompras"); Menu MyMenu = new Menu(); MyMenu.AddMenuItems(); oApp.RegisterMenuEventHandler(MyMenu.SBO_Application_MenuEvent); DIApplication.DIConnect((SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany()); Application.SBO_Application.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent); //TestXML(); //Initialize Tables UIApplication.ShowSuccess(string.Format("Inicializar las tablas")); PurchasesServiceFactory lObjFoodProductionFactory = new PurchasesServiceFactory(); lObjFoodProductionFactory.GetSetupService().InitializeTables(); UIApplication.ShowSuccess(string.Format("AddonCompras 1.2.69 iniciado correctamente")); LogService.WriteSuccess(string.Format("AddonCompras 1.2.69 iniciado correctamente")); oApp.Run(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); System.Windows.Forms.Application.Exit(); } }
private void CreateJournalEntry() { try { if (cboAcct.Selected == null) { UIApplication.ShowError("Seleccione una cuenta"); return; } string lStrBankAccountNum = cboAcct.Selected.Value; if (string.IsNullOrEmpty(lStrBankAccountNum)) { UIApplication.ShowError("Seleccione una cuenta"); return; } string lStrBankAccountCode = mObjTransportServiceFactory.GetBankService().GetBankAccount(lStrBankAccountNum).GLAccount; string lStrFolio = txtFolio.Value; string lStrReference = txtReference.Value; string lStrCmsDriverAcct = new QueryManager().GetValue("U_VALUE", "Name", "TR_ACC_LIQCHOF", "[@UG_Config]"); string lStrFilePath = string.Empty; if (string.IsNullOrEmpty(lStrFolio)) { UIApplication.ShowError("Seleccione un folio de comisión"); return; } if (string.IsNullOrEmpty(lStrBankAccountCode)) { UIApplication.ShowError(string.Format("No se encontró la cuenta para la cuenta bancaria {0}", lStrBankAccountNum)); return; } if (string.IsNullOrEmpty(lStrCmsDriverAcct)) { UIApplication.ShowError("Agregue un valor en la configuración para el campo TR_ACC_LIQCHOF"); return; } if (dtCommissions.Rows.Count == 0) { UIApplication.ShowError("No puede crear la comisión sin líneas"); return; } if (!string.IsNullOrEmpty(mStrFilePath)) { //mObjTransportServiceFactory.GetAttachmentDI().AttachFile(mStrFilePath); lStrFilePath = AttatchFile(mStrFilePath); } SAPbobsCOM.JournalEntries lObjJournalEntry = (SAPbobsCOM.JournalEntries)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries); lObjJournalEntry.TransactionCode = "TRPG"; lObjJournalEntry.Reference = lStrFolio; lObjJournalEntry.Reference2 = lStrReference; lObjJournalEntry.ReferenceDate = DateTime.Now; lObjJournalEntry.TaxDate = DateTime.Now; lObjJournalEntry.DueDate = DateTime.Now; for (int i = 0; i < dtCommissions.Rows.Count; i++) { string lStrEmpId = dtCommissions.GetValue("EmpId", i).ToString(); string lStrEmployee = dtCommissions.GetValue("EmpNm", i).ToString(); double lDblImport = double.Parse(dtCommissions.GetValue("Import", i).ToString()); string lStrFolioLine = dtCommissions.GetValue("FolioCms", i).ToString(); string lStrAcctLine = dtCommissions.GetValue("Acct", i).ToString(); lObjJournalEntry.Lines.SetCurrentLine(lObjJournalEntry.Lines.Count - 1); lObjJournalEntry.Lines.TaxDate = DateTime.Now; lObjJournalEntry.Lines.AccountCode = lStrCmsDriverAcct; lObjJournalEntry.Lines.Debit = lDblImport; lObjJournalEntry.Lines.Credit = 0; lObjJournalEntry.Lines.CostingCode = "TR_TRANS"; lObjJournalEntry.Lines.UserFields.Fields.Item("U_GLO_TypeAux").Value = "2"; lObjJournalEntry.Lines.UserFields.Fields.Item("U_GLO_Auxiliar").Value = lStrEmpId; //code empleado lObjJournalEntry.Lines.UserFields.Fields.Item("U_GLO_CodeMov").Value = lStrFolio; lObjJournalEntry.Lines.UserFields.Fields.Item("U_GLO_File").Value = lStrFilePath; lObjJournalEntry.Lines.Add(); lObjJournalEntry.Lines.SetCurrentLine(lObjJournalEntry.Lines.Count - 1); lObjJournalEntry.Lines.TaxDate = DateTime.Now; lObjJournalEntry.Lines.AccountCode = lStrBankAccountCode; lObjJournalEntry.Lines.Debit = 0; lObjJournalEntry.Lines.Credit = lDblImport; lObjJournalEntry.Lines.CostingCode = "TR_TRANS"; lObjJournalEntry.Lines.UserFields.Fields.Item("U_GLO_TypeAux").Value = "2"; lObjJournalEntry.Lines.UserFields.Fields.Item("U_GLO_Auxiliar").Value = lStrEmpId; //code empleado lObjJournalEntry.Lines.UserFields.Fields.Item("U_GLO_CodeMov").Value = lStrFolio; lObjJournalEntry.Lines.UserFields.Fields.Item("U_GLO_File").Value = lStrFilePath; lObjJournalEntry.Lines.Add(); } if (lObjJournalEntry.Add() != 0) { string lStrLastError = DIApplication.Company.GetLastErrorDescription(); UIApplication.ShowMessageBox(string.Format("Error al generar el asiento de la comisión: {0}", DIApplication.Company.GetLastErrorDescription())); } else { int lIntDocEntry = int.Parse(DIApplication.Company.GetNewObjectKey()); LogUtility.WriteSuccess(String.Format("[frmDriversCommissions - CreateJournalEntry] Comisión creada correctamente con el DocEntry {0} para el Folio: {1}", lIntDocEntry, lStrFolio)); Commissions lObjCommission = mObjTransportServiceFactory.GetCommissionService().GetCommission(lStrFolio); lObjCommission.HasDriverCms = "Y"; if (mObjTransportServiceFactory.GetCommissionService().UpdateCommission(lObjCommission) != 0) { throw new Exception(string.Format("Error al modificar el estatus de la comisión {0}", lStrFolio)); } //SaveCommissionsRecords(lIntDocEntry); ClearControls(); UIApplication.ShowSuccess(string.Format("Comisión creada correctamente con el número de documento: {0}", lIntDocEntry)); } } catch (Exception lObjException) { LogUtility.WriteError(String.Format("[frmDriversCommissions - CreateJournalEntry] Error al crear el asiento contable: {0}", lObjException.Message)); throw new Exception(string.Format("Error al crear el asiento contable: {0}", lObjException.Message)); } finally { } }
private void CreateStockTransfer() { try { if (string.IsNullOrEmpty(txtRiseFolio.Value)) { UIApplication.ShowError("No se seleccionó una subida"); return; } if (dtItems.Rows.Count <= 0) { UIApplication.ShowError("Sin artículos para dar salida"); return; } SAPbobsCOM.StockTransfer lObjStockTransfer = (SAPbobsCOM.StockTransfer)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer); lObjStockTransfer.FromWarehouse = "MQHEOBRA"; lObjStockTransfer.ToWarehouse = "MQHE"; lObjStockTransfer.UserFields.Fields.Item("U_MQ_Rise").Value = txtRiseFolio.Value; for (int i = 0; i < dtItems.Rows.Count; i++) { string lStrItemCode = dtItems.GetValue("ItemCode", i).ToString(); double lDblQuantity = double.Parse(dtItems.GetValue("Qty", i).ToString()); if (lDblQuantity <= 0) { UIApplication.ShowError(string.Format("No puede dar entrada al artículo {0} si la cantidad es menor o igual a 0", lStrItemCode)); return; } lObjStockTransfer.Lines.SetCurrentLine(i); lObjStockTransfer.Lines.ItemCode = lStrItemCode; lObjStockTransfer.Lines.FromWarehouseCode = "MQHEOBRA"; lObjStockTransfer.Lines.WarehouseCode = "MQHE"; lObjStockTransfer.Lines.Quantity = lDblQuantity; lObjStockTransfer.Lines.Add(); } if (lObjStockTransfer.Add() != 0) { string lStrLastError = DIApplication.Company.GetLastErrorDescription(); UIApplication.ShowMessageBox(string.Format("Error al generar la entrada de consumibles: {0}", DIApplication.Company.GetLastErrorDescription())); } else { int lIntDocEntry = int.Parse(DIApplication.Company.GetNewObjectKey()); LogUtility.WriteSuccess(string.Format("[frmStockTransfer - CreateStockTransfer] StockTransfer creado correctamente con el DocEntry {0} para la Subida: {1}", lIntDocEntry, txtRiseFolio.Value)); mObjMachineryServiceFactory.GetRiseService().MarkRiseAsStockTransfer(int.Parse(txtRiseFolio.Value)); ClearControls(); UIApplication.ShowSuccess("Entrada de mercancía creada correctamente"); } } catch (Exception lObjException) { LogUtility.WriteError(string.Format("[frmStockTransfer - CreateStockTransfer] Error al crear la entrada de consumibles: {0}", lObjException.Message)); throw new Exception(string.Format("Error al crear la entrada de consumibles: {0}", lObjException.Message)); } }
/// <summary> /// Lee los campos del xml /// <summary> public PurchaseXMLDTO ReadXML(string pStrFileName) { XmlTextReader reader = new XmlTextReader(pStrFileName); XDocument lObjDoc = XDocument.Load(pStrFileName); XNamespace cfdiNamespace = lObjDoc.Root.Name.Namespace; XElement lElementAdenda = lObjDoc.Root.Element(cfdiNamespace + "Addenda"); if (lElementAdenda != null) { lObjDoc.Root.Element(cfdiNamespace + "Addenda").Remove(); } List <string> lLstStrSchemas = GetXmlSchemas(lObjDoc); LogService.WriteInfo("Obtencion de esquemas correctamente"); //DownloadSchema(lLstStrSchemas); List <string> lStrLstXML = new List <string>();//lStrValidateSchema(lObjDoc, lLstStrSchemas); // PurchaseXMLDTO lObjXML = new PurchaseXMLDTO(); string lStrField = string.Empty; if (lStrLstXML.Count == 0) { try { XNamespace cfdi; cfdi = lObjDoc.Root.Name.Namespace; XNamespace tfd = @"http://www.sat.gob.mx/TimbreFiscalDigital"; lStrField = "Complemento " + " " + "TimbreFiscalDigital" + " UUID "; lObjXML.FolioFiscal = lObjDoc.Root.Element(cfdi + "Complemento").Element(tfd + "TimbreFiscalDigital").Attribute("UUID").Value; lStrField = "Receptor " + " " + "Rfc"; lObjXML.RFCReceptor = lObjDoc.Root.Element(cfdi + "Receptor").Attribute("Rfc").Value; string lStrRFC = mObjPurchasesServiceFactory.GetPurchaseXmlService().GetRFC(); if (lStrRFC != lObjXML.RFCReceptor) { SAPbouiCOM.Framework.Application.SBO_Application.MessageBox("RFC de receptor incorrecto"); lObjXML = null; } else { if (string.IsNullOrEmpty(lObjXML.FolioFiscal)) { lStrLstXML.Add("El folio fiscal no existe en el xml"); } else { if (ValidateUUID(lObjXML.FolioFiscal)) { lStrLstXML.Add(" El folio fiscal ya existe en la base de datos"); } else { UIApplication.ShowSuccess(string.Format("XML válido")); lStrField = "Comprobante" + " " + "Folio"; XAttribute lObjAttribute = lObjDoc.Element(cfdi + "Comprobante").Attribute("Folio"); if (lObjAttribute != null) { lObjXML.ReferenceFolio = lObjDoc.Element(cfdi + "Comprobante").Attribute("Folio").Value; } lStrField = "Emisor " + " " + "Rfc"; lObjXML.RFCProvider = lObjDoc.Root.Element(cfdi + "Emisor").Attribute("Rfc").Value; lStrField = "Emisor" + " " + "Nombre"; lObjXML.BPName = lObjDoc.Root.Element(cfdi + "Emisor").Attribute("Nombre").Value; lStrField = "Comprobante" + " " + "Fecha"; lObjXML.Date = lObjDoc.Element(cfdi + "Comprobante").Attribute("Fecha").Value; lStrField = "Comprobante" + " " + "SubTotal"; lObjXML.SubTotal = lObjDoc.Element(cfdi + "Comprobante").Attribute("SubTotal").Value; lStrField = "Comprobante" + " " + "Total"; lObjXML.Total = lObjDoc.Element(cfdi + "Comprobante").Attribute("Total").Value; lStrField = "Conceptos"; IEnumerable <XElement> lLstConcepts = lObjDoc.Root.Element(cfdi + "Conceptos").Elements(); List <ConceptsXMLDTO> lLstConceptsXMLDTO = new List <ConceptsXMLDTO>(); foreach (XElement lObjElements in lLstConcepts) { ConceptsXMLDTO lObjConcepts = new ConceptsXMLDTO(); lStrField = "Conceptos" + "//" + "ClaveProdServ"; lObjConcepts.ClassificationCode = lObjElements.Attribute("ClaveProdServ").Value; lStrField = "Conceptos" + "//" + "Cantidad"; lObjConcepts.Quantity = lObjElements.Attribute("Cantidad").Value; // lStrField = "Conceptos" + "//" + "ClaveProdServ"; //lObjConcepts.CodeItmProd = lObjElements.Attribute("ClaveProdServ").Value; lStrField = "Conceptos" + "//" + "ClaveUnidad"; lObjConcepts.UnitType = lObjElements.Attribute("ClaveUnidad").Value; lStrField = "Conceptos" + "//" + "Descripcion"; lObjConcepts.Description = lObjElements.Attribute("Descripcion").Value; lStrField = "Conceptos" + "//" + "Importe"; lObjConcepts.Amount = lObjElements.Attribute("Importe").Value; //lObjConcepts.NoIdentification = lObjElements.Attribute("NoIdentificacion").Value != null ? lObjElements.Attribute("NoIdentificacion").Value : ""; lStrField = "Conceptos" + "//" + "Unidad"; lObjConcepts.Unit = (string)lObjElements.Attribute("Unidad"); lStrField = "Conceptos" + "//" + "ValorUnitario"; lObjConcepts.UnitPrice = lObjElements.Attribute("ValorUnitario").Value; XAttribute lObjDiscount = lObjElements.Attribute("Descuento"); if (lObjDiscount != null) { lStrField = "Conceptos" + "//" + "Descuento"; lObjConcepts.Discount = lObjDiscount.Value; //lObjConcepts.Amount = (Convert.ToDecimal(lObjConcepts.Amount) - Convert.ToDecimal(lObjConcepts.Discount)).ToString(); } if (lObjElements.HasElements) { XElement lObjHasTax = lObjElements.Element(cfdi + "Impuestos"); if (lObjHasTax != null) { XElement lObjHasTraslate = lObjElements.Element(cfdi + "Impuestos").Element(cfdi + "Traslados"); if (lObjHasTraslate != null) { lStrField = "Conceptos//Impuestos" + "//" + "Traslados"; IEnumerable <XElement> lLstTaxesXml = lObjElements.Element(cfdi + "Impuestos").Elements(cfdi + "Traslados").Elements(); List <TaxesXMLDTO> lLstTaxes = new List <TaxesXMLDTO>(); foreach (XElement lObjTax in lLstTaxesXml) { TaxesXMLDTO lObjTaxes = new TaxesXMLDTO(); lStrField = "Conceptos//Impuestos//Traslados" + "//" + "Importe"; lObjTaxes.Amount = (string)lObjTax.Attribute("Importe"); if (string.IsNullOrEmpty(lObjTaxes.Amount)) { lObjTaxes.Amount = "0"; } if (Convert.ToDouble(lObjTaxes.Amount) > 0) { lStrField = "Conceptos//Impuestos//Traslados" + "//" + "TasaOCuota"; lObjTaxes.Rate = (string)lObjTax.Attribute("TasaOCuota"); if (string.IsNullOrEmpty(lObjTaxes.Rate)) { lObjTaxes.Rate = ""; } //lObjTaxes.Rate = lObjTax.Attribute("TasaOCuota").Value; lStrField = "Conceptos//Impuestos//Traslados" + "//" + "Importe"; lObjTaxes.Amount = (string)lObjTax.Attribute("Importe"); if (string.IsNullOrEmpty(lObjTaxes.Amount)) { lObjTaxes.Amount = ""; } lStrField = "Conceptos//Impuestos//Traslados" + "//" + "Base"; lObjTaxes.Base = lObjTax.Attribute("Base").Value; lStrField = "Conceptos//Impuestos//Traslados" + "//" + "Impuesto"; lObjTaxes.Tax = lObjTax.Attribute("Impuesto").Value; lStrField = "Conceptos//Impuestos//Traslados" + "//" + "TipoFactor"; lObjTaxes.TypeFactor = lObjTax.Attribute("TipoFactor").Value; lLstTaxes.Add(lObjTaxes); decimal lDecAmount = Convert.ToDecimal(lObjConcepts.Amount) - Convert.ToDecimal(lObjConcepts.Discount); decimal lDecAmount1 = lDecAmount + Convert.ToDecimal(0.01); decimal lDecAmount01 = lDecAmount - Convert.ToDecimal(0.01); decimal lDecBase = Convert.ToDecimal(lObjTaxes.Base); //if(lObjTaxes.Tax == "002" && (lDecAmount != lDecBase && lDecAmount1 != lDecBase && lDecAmount01 != lDecBase)) { if (lObjTaxes.Tax == "002" && !((lDecAmount1 >= lDecBase && lDecAmount <= lDecBase) || (lDecAmount01 <= lDecBase && lDecAmount01 >= lDecBase))) { if (Convert.ToDouble(lObjTaxes.Amount) > 0) { lObjConcepts.Amount = (Convert.ToDecimal(lObjTaxes.Base) + Convert.ToDecimal(lObjConcepts.Discount)).ToString(); //lObjConcepts.Amount = lObjTaxes.Base; lObjConcepts.UnitPrice = Convert.ToDecimal((((Convert.ToDouble(lObjTaxes.Base) + Convert.ToDouble(lObjConcepts.Discount)) / Convert.ToDouble(lObjConcepts.Quantity)))).ToString(); lLstTaxes.Add(AddIeps(lDecAmount, Convert.ToDouble(lObjTaxes.Base))); } } } } lObjConcepts.LstTaxes = lLstTaxes; } XElement lObjHasWht = lObjElements.Element(cfdi + "Impuestos").Element(cfdi + "Retenciones"); if (lObjHasWht != null) { //Retenciones lStrField = "Conceptos//Impuestos//Retenciones"; IEnumerable <XElement> lXmlWithholdingTax = lObjElements.Element(cfdi + "Impuestos").Elements(cfdi + "Retenciones").Elements(); List <TaxesXMLDTO> lLstWithholdingTax = new List <TaxesXMLDTO>(); foreach (XElement lObjTax in lXmlWithholdingTax) { TaxesXMLDTO lObjTaxes = new TaxesXMLDTO(); lStrField = "Conceptos//Impuestos//Retenciones" + "//" + "TasaOCuota"; lObjTaxes.Rate = lObjTax.Attribute("TasaOCuota").Value; lStrField = "Conceptos//Impuestos//Retenciones" + "//" + "Importe"; lObjTaxes.Amount = lObjTax.Attribute("Importe").Value; lStrField = "Conceptos//Impuestos//Retenciones" + "//" + "Impuesto"; lObjTaxes.Tax = lObjTax.Attribute("Impuesto").Value; lStrField = "Conceptos//Impuestos//Retenciones" + "//" + "TipoFactor"; lObjTaxes.TypeFactor = lObjTax.Attribute("TipoFactor").Value; // lObjTaxes.Base = lObjTax.Attribute("Base").Value != null ? lObjTax.Attribute("Base").Value : ""; lLstWithholdingTax.Add(lObjTaxes); } lObjConcepts.LstWithholdingTax = lLstWithholdingTax; } } } lLstConceptsXMLDTO.Add(lObjConcepts); } lObjXML.ConceptLines = lLstConceptsXMLDTO; List <SchemaDTO> lLstSchemaName = GetSchemasName(lObjDoc); if (lLstSchemaName.Where(x => x.Key == "implocal").Count() > 0) { XNamespace XNSimplocal = lLstSchemaName.Where(x => x.Key == "implocal").FirstOrDefault().Value; lStrField = "Conceptos//ImpuestosLocales//TotaldeTraslados"; XElement lXElement = lObjDoc.Root.Element(cfdi + "Complemento"); IEnumerable <XElement> XImpLoc = lXElement.Descendants();//.Element(XNSimplocal + "ImpuestosLocales"); IEnumerable <XAttribute> xLstAtr = XImpLoc.Attributes(); XAttribute xAtr = xLstAtr.Where(x => x.Name == "TotaldeTraslados").FirstOrDefault(); if (xAtr != null) { TaxesXMLDTO lObjTaxesXMLDTO = AddLocalTax(Convert.ToDecimal(xAtr.Value), 0.02); lObjXML.LstLocalTax = new List <TaxesXMLDTO>(); lObjXML.LstLocalTax.Add(lObjTaxesXMLDTO); } } } XElement lObjImpuestos = lObjDoc.Root.Element(cfdi + "Impuestos"); if (lObjImpuestos != null) { lStrField = "Impuestos" + " " + "TotalImpuestosTrasladados"; XAttribute lObjTotalTraslados = lObjImpuestos.Attribute("TotalImpuestosTrasladados"); if (lObjTotalTraslados != null) { lObjXML.TaxesTransfers = lObjDoc.Root.Element(cfdi + "Impuestos").Attribute("TotalImpuestosTrasladados").Value; } lStrField = "Impuestos//Retenciones"; IEnumerable <XElement> lLstXMLWithholdingTaxDoc = lObjDoc.Root.Element(cfdi + "Impuestos").Elements(cfdi + "Retenciones").Elements(); List <TaxesXMLDTO> lLstWithholdingTaxDoc = new List <TaxesXMLDTO>(); foreach (XElement lObjTax in lLstXMLWithholdingTaxDoc) { TaxesXMLDTO lObjTaxes = new TaxesXMLDTO(); lStrField = "Impuestos//Retenciones" + "//" + "Importe"; lObjTaxes.Amount = lObjTax.Attribute("Importe").Value; lStrField = "Impuestos//Retenciones" + "//" + "Importe"; lObjTaxes.Tax = lObjTax.Attribute("Impuesto").Value; // lObjTaxes.Base = lObjTax.Attribute("Base").Value != null ? lObjTax.Attribute("Base").Value : ""; lLstWithholdingTaxDoc.Add(lObjTaxes); lStrField = string.Empty; } lObjXML.WithholdingTax = lLstWithholdingTaxDoc; } } //} } } catch (Exception ex) { lObjXML = null; lStrLstXML.Add(lStrField); LogService.WriteError("ReadXMLService (ReadXML) " + ex.Message + ": " + lStrField); LogService.WriteError(ex); } } if (lStrLstXML.Count > 0) { lObjXML = null; string lStrMessage = string.Format("Error en {0}:\n{1}", (lStrLstXML.Count == 1 ? "el siguiente campo" : "los siguientes campos " + lStrField), string.Join("\n", lStrLstXML.Select(x => string.Format("-{0}", x)).ToArray())); SAPbouiCOM.Framework.Application.SBO_Application.MessageBox(lStrMessage); LogService.WriteError("ReadXMLService (ReadXML) " + lStrMessage); } return(lObjXML); }
private void btnPayments_ClickBefore(object sboObject, SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; Form lObjPaymentForm = null; Form lObjPaymentFormUDF = null; Form lObjAccountForm = null; try { if (mIntRowSelected > 0) { StatusEnum lEnmStatus = (StatusEnum)int.Parse(DtMatrix.GetValue("C_Status", mIntRowSelected - 1).ToString()); string lStrFolio = DtMatrix.GetValue("C_Folio", mIntRowSelected - 1).ToString(); string lStrEmpCode = DtMatrix.GetValue("C_Employe", mIntRowSelected - 1).ToString(); string lStrArea = DtMatrix.GetValue("C_Area", mIntRowSelected - 1).ToString(); double lDblImport = double.Parse(DtMatrix.GetValue("C_Amount", mIntRowSelected - 1).ToString()); string lStrEmpName = mObjPurchasesServiceFactory.GetPurchaseService().GetEmpName(lStrEmpCode); string lStrLineAccount = mObjPurchasesServiceFactory.GetPurchaseReceiptsService().GetAccountRefund(lStrArea); //string lStrChkAcct = mObjPurchasesServiceFactory.GetPurchaseReceiptsService().GetAccountInConfig("GLO_CTAREEMBCHEQ"); string lStrChkAcct = cbAccount.Value; // Dictionary<string, string> lStrBankInfo = mObjPurchasesServiceFactory.GetPurchaseReceiptsService().GetBankInfo(lStrChkAcct); Dictionary <string, string> lStrBankInfo = new Dictionary <string, string>(); lStrBankInfo.Add(cbAccount.Value, cbBank.Selected.Description); if (lEnmStatus != StatusEnum.Authorized_Ope_Admon) { UIApplication.ShowError("El reembolso seleccionado no está autorizado"); return; } string lStrValidation = ValidatePaymentsFields(lStrFolio, lStrEmpCode, lStrArea, lDblImport, lStrChkAcct, lStrBankInfo, lStrLineAccount); if (!string.IsNullOrEmpty(lStrValidation)) { UIApplication.ShowMessageBox(lStrValidation); return; } if (mObjPurchasesServiceFactory.GetPurchaseReceiptsService().ExistsPayment(lStrEmpCode, lStrFolio, lStrArea)) /*string lStrDocEntry = DtMatrix.GetValue("C_DocEntry", mIntRowSelected - 1).ToString(); * if (mObjPurchasesServiceFactory.GetPurchaseReceiptsService().ExistsPayment(lStrDocEntry))*/ { UIApplication.ShowError("Ya existe un pago para el reembolso seleccionado"); return; } this.UIAPIRawForm.Freeze(true); UIApplication.GetApplication().ActivateMenuItem("2818"); if (!UIApplication.GetApplication().Menus.Item("6913").Checked) { UIApplication.GetApplication().ActivateMenuItem("6913");//2050 } lObjPaymentForm = UIApplication.GetApplication().Forms.GetForm("426", -1); lObjPaymentFormUDF = UIApplication.GetApplication().Forms.GetForm("-426", -1); lObjPaymentForm.Freeze(true); lObjPaymentFormUDF.Freeze(true); SAPbouiCOM.EditText txtDocDate = ((SAPbouiCOM.EditText)lObjPaymentForm.Items.Item("10").Specific); txtDocDate.Value = DateTime.Now.ToString("yyyyMMdd"); SAPbouiCOM.OptionBtn optionBtnAccount = ((SAPbouiCOM.OptionBtn)lObjPaymentForm.Items.Item("58").Specific); optionBtnAccount.Selected = true; SAPbouiCOM.ComboBox cboPymtType = ((SAPbouiCOM.ComboBox)lObjPaymentFormUDF.Items.Item("U_GLO_PaymentType").Specific); cboPymtType.Select("GLREM", SAPbouiCOM.BoSearchKey.psk_ByValue); SAPbouiCOM.EditText txtCodeMov = ((SAPbouiCOM.EditText)lObjPaymentFormUDF.Items.Item("U_GLO_CodeMov").Specific); txtCodeMov.Value = lStrFolio; SAPbouiCOM.ComboBox txtCostCenter = ((SAPbouiCOM.ComboBox)lObjPaymentFormUDF.Items.Item("U_GLO_CostCenter").Specific); txtCostCenter.Select(lStrArea, SAPbouiCOM.BoSearchKey.psk_ByValue); SAPbouiCOM.ComboBox cboAuxiliarType = ((SAPbouiCOM.ComboBox)lObjPaymentFormUDF.Items.Item("U_FZ_AuxiliarType").Specific); cboAuxiliarType.Select("2", SAPbouiCOM.BoSearchKey.psk_ByValue); SAPbouiCOM.EditText txtName = ((SAPbouiCOM.EditText)lObjPaymentForm.Items.Item("10000166").Specific); txtName.Value = lStrEmpName; SAPbouiCOM.EditText txtAuxiliar = ((SAPbouiCOM.EditText)lObjPaymentFormUDF.Items.Item("U_FZ_Auxiliar").Specific); txtAuxiliar.Value = lStrEmpCode; SAPbouiCOM.Button btnBank = ((SAPbouiCOM.Button)lObjPaymentForm.Items.Item("234000001").Specific); btnBank.Item.Click(); lObjAccountForm = UIApplication.GetApplication().Forms.GetForm("196", -1); lObjAccountForm.Freeze(true); SAPbouiCOM.Folder folderCheck = ((SAPbouiCOM.Folder)lObjAccountForm.Items.Item("3").Specific); folderCheck.Item.Click(); SAPbouiCOM.Matrix mtxCheck = ((SAPbouiCOM.Matrix)lObjAccountForm.Items.Item("28").Specific); ((SAPbouiCOM.EditText)mtxCheck.Columns.Item("7").Cells.Item(1).Specific).Value = lDblImport.ToString(); ComboBox cb = ((SAPbouiCOM.ComboBox)mtxCheck.Columns.Item("2").Cells.Item(1).Specific); string ss = lStrBankInfo[lStrBankInfo.Keys.ElementAt(0)]; //lStrBankInfo.ElementAt(0); ((SAPbouiCOM.ComboBox)mtxCheck.Columns.Item("2").Cells.Item(1).Specific).Select(lStrBankInfo[lStrBankInfo.Keys.ElementAt(0)], SAPbouiCOM.BoSearchKey.psk_ByValue); //Banco ((SAPbouiCOM.ComboBox)mtxCheck.Columns.Item("4").Cells.Item(1).Specific).Select(lStrBankInfo.Keys.ElementAt(0), SAPbouiCOM.BoSearchKey.psk_ByValue); //Cuenta? SAPbouiCOM.Button btnOk = ((SAPbouiCOM.Button)lObjAccountForm.Items.Item("1").Specific); btnOk.Item.Click(); SAPbouiCOM.Matrix mtxPayment = ((SAPbouiCOM.Matrix)lObjPaymentForm.Items.Item("71").Specific); mtxPayment.AddRow(); ((SAPbouiCOM.EditText)mtxPayment.Columns.Item("5").Cells.Item(1).Specific).Value = lDblImport.ToString(); ((SAPbouiCOM.EditText)mtxPayment.Columns.Item("8").Cells.Item(1).Specific).Value = lStrLineAccount; //cuenta de mayor } else { UIApplication.ShowMessageBox("Favor de seleccionar un registro"); } lObjPaymentFormUDF.Freeze(false); this.UIAPIRawForm.Freeze(false); if (lObjPaymentForm != null) { lObjPaymentForm.Freeze(false); } if (lObjAccountForm != null) { lObjPaymentFormUDF.Freeze(false); } if (this.UIAPIRawForm != null) { this.UIAPIRawForm.Freeze(false); } // if (lObjAccountForm. ==) lObjAccountForm.Freeze(false); UIApplication.ShowSuccess("Carga de pago terminada"); } catch (Exception ex) { LogService.WriteError("frmSearchRefunds (btnPayments_ClickBefore) " + ex.Message); LogService.WriteError(ex); UIApplication.ShowMessageBox(string.Format("Error al abrir pantalla de pagos: {0}", ex.Message)); } finally { if (lObjPaymentFormUDF != null) { lObjPaymentFormUDF.Freeze(false); } this.UIAPIRawForm.Freeze(false); } }
static void Main(string[] pArrStrArgs) { try { LogService.Filename("FoodProduction"); LogService.WriteInfo("Inicio del addon 1.2.56"); Application lObjApplication = null; if (pArrStrArgs.Length < 1) { lObjApplication = new Application(); } else { lObjApplication = new Application(pArrStrArgs[0]); } //Prepare menu MenuManager lObjMenuManager = new MenuManager(); lObjMenuManager.Initialize(); //Prepare filters EventManager lObjEventManager = new EventManager(); UIApplication.GetApplication().SetFilter(lObjEventManager.GetItemEventFiltersByMenu(lObjMenuManager.Menu)); UIApplication.ShowSuccess(string.Format("Menu manager")); //Add menu events lObjApplication.RegisterMenuEventHandler(lObjMenuManager.GetApplicationMenuEvent); LogService.WriteSuccess("Registro del menú"); UIApplication.ShowSuccess(string.Format("Registro del menu")); //Add application events UIApplication.GetApplication().AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(GetApplicationAppEvent); DIApplication.DIConnect((SAPbobsCOM.Company)Application.SBO_Application.Company.GetDICompany()); UIApplication.ShowSuccess(string.Format("DI Connect")); //Bascula ConnectRemoteAccess(); //Initialize Tables UIApplication.ShowSuccess(string.Format("Inicializar las tablas")); SetupService mObjSetupService; mObjSetupService = new SetupService(); mObjSetupService.InitializeTables(); UIApplication.ShowSuccess(string.Format("Addon Iniciado correctamente")); LogService.WriteSuccess("[AddOn FoodProduction 1.2.55 STARTED]"); //Ticket instance = (Ticket)Activator.CreateInstance(typeof(Ticket)); //Init application lObjApplication.Run(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); LogService.WriteError("[ERROR]" + ex.Message); } }
private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; try { //SAPbobsCOM.Documents lObjInvoice2 = (SAPbobsCOM.Documents)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices); //lObjInvoice2.DocDate = DateTime.Now; //lObjInvoice2.DocDueDate = DateTime.Now; //lObjInvoice2.CardCode = "CL00000001"; //lObjInvoice2.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items; //lObjInvoice2.Lines.SetCurrentLine(0); //lObjInvoice2.Lines.ItemCode = "A00000001"; //lObjInvoice2.Lines.Quantity = 1; //lObjInvoice2.Lines.UnitPrice = 10; //lObjInvoice2.Lines.TaxCode = "V0"; //lObjInvoice2.Lines.AccountCode = "4010020002000"; //lObjInvoice2.Lines.WarehouseCode = "CRHE"; //lObjInvoice2.Lines.Add(); ////lObjInvoice2.GetByKey(191); ////string lStrXmlOriginalInvoice = lObjInvoice2.GetAsXML(); ////lStrXmlOriginalInvoice = ""; //////Intialize a new invoice through your xml ////DIApplication.Company.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode; ////DIApplication.Company.XMLAsString = true; ////lObjInvoice2 = (SAPbobsCOM.Documents)DIApplication.Company.GetBusinessObjectFromXML(lStrXmlOriginalInvoice, 0); //if (lObjInvoice2.Add() != 0) //{ // string lStrLastError = DIApplication.Company.GetLastErrorDescription(); //} //else //{ // int lIntDocEntry = int.Parse(DIApplication.Company.GetNewObjectKey()); //} if (!(sboObject as SAPbouiCOM.Button).Item.Enabled) { return; } (sboObject as SAPbouiCOM.Button).Item.Enabled = false; SAPbobsCOM.Documents lObjInvoice = (SAPbobsCOM.Documents)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices); lObjInvoice.CardCode = mEdtCardCode.Value; lObjInvoice.DocObjectCode = SAPbobsCOM.BoObjectTypes.oInvoices; if (mEdtDate.Value != "") { lObjInvoice.DocDate = this.GetDataSourceValue <DateTime>("UD_Date"); } if (mEdtDueDate.Value != "") { lObjInvoice.DocDueDate = this.GetDataSourceValue <DateTime>("UD_DueDate"); } lObjInvoice.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items; if (mEdtSeries.Value != "") { lObjInvoice.Series = Convert.ToInt32(mEdtSeries.Value); } if (mEdtPaymentMethod.Value != "") { lObjInvoice.PaymentMethod = mEdtPaymentMethod.Value; } if (mEdtPaymentGroup.Value != "") { lObjInvoice.PaymentGroupCode = Convert.ToInt32(mEdtPaymentGroup.Value); } lObjInvoice.UserFields.Fields.Item("U_B1SYS_MainUsage").Value = "P01"; lObjInvoice.Lines.SetCurrentLine(0); lObjInvoice.Lines.ItemCode = mEdtItemCode.Value; lObjInvoice.Lines.Quantity = this.GetDataSourceValue <int>("UD_Qty"); lObjInvoice.Lines.UnitPrice = this.GetDataSourceValue <double>("UD_Price"); lObjInvoice.Lines.TaxCode = mEdtItemTax.Value; if (mEdtItemWarehouse.Value != "") { lObjInvoice.Lines.WarehouseCode = mEdtItemWarehouse.Value; } if (mEdtItemCosting.Value != "") { //lObjInvoice.Lines.COGSCostingCode = mEdtItemCosting.Value; lObjInvoice.Lines.CostingCode = mEdtItemCosting.Value; } lObjInvoice.Lines.Add(); if (mCmbEdocType.Value != "") { lObjInvoice.EDocGenerationType = SAPbobsCOM.EDocGenerationTypeEnum.edocGenerate; //(SAPbobsCOM.EDocGenerationTypeEnum)Convert.ToInt32(mCmbEdocType.Value); } if (mEdtEdocFormat.Value != "") { lObjInvoice.EDocExportFormat = Convert.ToInt32(mEdtEdocFormat.Value); } int lLongErr = lObjInvoice.Add(); string lStrErrMsg; if (lLongErr != 0) { DIApplication.Company.GetLastError(out lLongErr, out lStrErrMsg); UIApplication.ShowError(lStrErrMsg); } else { string lStrLastDoc = DIApplication.Company.GetNewObjectKey().ToString(); UIApplication.ShowSuccess(String.Format("Documento {0} creado", lStrLastDoc)); } (sboObject as SAPbouiCOM.Button).Item.Enabled = true; } catch (Exception e) { Console.WriteLine(e); } finally { (sboObject as SAPbouiCOM.Button).Item.Enabled = true; } }