Example #1
0
        /// <summary>
        /// Metodo para conectarse a la Aplicacion SBO que se esta ejecutando (UIAPI)
        /// </summary>
        private void ObtenerAplicacion()
        {
            try
            {
                string               strConexion   = "";                 //variable que almacena el codigo de identificacion de conexion con SBO
                string[]             strArgumentos = new string[4];
                SAPbouiCOM.SboGuiApi oSboGuiApi    = null;               //Variable para obtener la instacia activa de SBO

                oSboGuiApi    = new SAPbouiCOM.SboGuiApi();              //Instancia nueva para la gestion de la conexion
                strArgumentos = System.Environment.GetCommandLineArgs(); //obtenemos el codigo de conexion del entorno configurado en "Propiedades -> Depurar -> Argumentos de la linea de comandos"

                if (strArgumentos.Length > 0)
                {
                    if (strArgumentos.Length > 1)
                    {
                        //Verificamos que la aplicacion se este ejecutando en un ambiente SBO
                        if (strArgumentos[0].LastIndexOf("\\") > 0)
                        {
                            strConexion = strArgumentos[1];
                        }
                        else
                        {
                            strConexion = strArgumentos[0];
                        }
                    }
                    else
                    {
                        //Verificamos que la aplicacion se este ejecutando en un ambiente SBO
                        if (strArgumentos[0].LastIndexOf("\\") > -1)
                        {
                            strConexion = strArgumentos[0];
                        }
                        else
                        {
                            Comunes.Msj_Appl.Errores(1, ""); //mensaje de erro por no tener SBO activo
                        }
                    }
                }
                else
                {
                    Comunes.Msj_Appl.Errores(1, "");        //mensaje de erro por no tener SBO activo
                }
                oSboGuiApi.Connect(strConexion);            //Establecemos la conexion
                m_SBO_Appl = oSboGuiApi.GetApplication(-1); //Asignamos la conexion a la aplicacion
            }
            catch (Exception ex)
            {
                Comunes.Msj_Appl.Errores(-2, ex.Message);
            }
        }
Example #2
0
        public override void CreateForm(SAPbouiCOM.Application SboApp, string strXml, SAPbobsCOM.Company cmp, string frmId)
        {
            base.CreateForm(SboApp, strXml, cmp, frmId);

            oForm.EnableMenu("1282", false);  // Add New Record
            oForm.EnableMenu("1288", false);  // Next Record
            oForm.EnableMenu("1289", false);  // Pevious Record
            oForm.EnableMenu("1290", false);  // First Record
            oForm.EnableMenu("1291", false);  // Last record
            oForm.EnableMenu("1281", false);  // Find record
            oForm.Settings.MatrixUID = "mtCA";
            oForm.Settings.Enabled   = true;
            InitiallizeForm();
        }
Example #3
0
 public ListaSolicitud()
 {
     cont     = 1;
     app      = null;
     oCompany = null;
     forma    = null;
     oForm    = null;
     filas    = new List <int>();
     colUID   = "";
     colUID1  = "";
     row      = 0;
     formUID  = "";
     smf      = false;
 }
Example #4
0
        public static string CreateUDT(string tableName, string tableDesc, SAPbobsCOM.BoUTBTableType tableType)
        {
            oApp     = (SAPbouiCOM.Application)Application.SBO_Application;
            oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany();
            SAPbobsCOM.UserTablesMD oUdtMD = null;
            SAPbobsCOM.UserFieldsMD oUdtCA = null;
            tableName = "Prueba";
            try
            {
                oUdtMD = (SAPbobsCOM.UserTablesMD)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
                if (oUdtMD.GetByKey(tableName) == false)
                {
                    oUdtMD.TableName        = tableName;
                    oUdtMD.TableDescription = tableName;
                    oUdtMD.TableType        = tableType;



                    // oUdtCA.Mandatory = "tYes";

                    int lRetCode;
                    lRetCode = oUdtMD.Add();
                    oUdtCA.Add();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD);
                    oUdtMD = null;
                    GC.Collect();
                    if ((lRetCode != 0))
                    {
                        if ((lRetCode == -2035))
                        {
                            return("-2035");
                        }

                        return(oCompany.GetLastErrorDescription());
                    }


                    return("");
                }
                else
                {
                    return("");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Example #5
0
        private void OnCustomInitialize()
        {
            //busca la conexion de la empresa actual
            oApp     = (SAPbouiCOM.Application)Application.SBO_Application;
            oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany();



            oForm = oApp.Forms.Item("actsecc");
            ////  Muestra el formulario
            oForm.Visible = true;

            //aca creo el data source manualmente , es decir desde el cuadro de herramientas

            oForm.DataSources.UserDataSources.Item("actprec");
            SAPbouiCOM.EditText oEdit = (SAPbouiCOM.EditText)oForm.Items.Item("txtprase").Specific;
            oEdit.DataBind.SetBound(true, "", "actprec");

            //busca con recorset los datos y los muestros en los textboxes
            SAPbobsCOM.Recordset oRecordset   = ((SAPbobsCOM.Recordset)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)));
            SAPbouiCOM.EditText  oEditStatus  = EditText1;
            SAPbouiCOM.EditText  oEditStatus2 = EditText2;
            SAPbouiCOM.EditText  oEditStatus3 = EditText3;
            SAPbouiCOM.EditText  oEditStatus4 = EditText4;
            //oApp.SetStatusBarMessage("El dato es..." + EditText0.Value);
            string SqlCad1 = "SELECT T0.U_NombreSEC AS 'NOMBRE',T0.U_SupraSeccionSEC as 'codsupra',T1.U_NombreSS AS [SUPRA-SECCIÓN] ,T0.U_PrecioSEC AS 'PRECIO' FROM [@SECCIONESCOL] AS T0 LEFT JOIN [@SUPRASECCIONESCOL] AS T1 ON T0.U_SupraSeccionSEC=T1.U_CodigoSS where T0.U_CodigoSEC='" + sValorGrid2 + "'";

            // oApp.SetStatusBarMessage("El dato es " + SqlCad1);
            oRecordset.DoQuery(SqlCad1);
            string  Extraerdequery  = oRecordset.Fields.Item("NOMBRE").Value.ToString();
            string  Extraerdequery2 = oRecordset.Fields.Item("codsupra").Value.ToString();
            string  Extraerdequery3 = oRecordset.Fields.Item("SUPRA-SECCIÓN").Value.ToString();
            string  Extraerdequery4 = oRecordset.Fields.Item("PRECIO").Value.ToString();
            decimal precio          = Convert.ToDecimal(Extraerdequery4);

            //oApp.SetStatusBarMessage("El dato es " + precio );

            oEditStatus.Value  = Extraerdequery;
            oEditStatus2.Value = Extraerdequery2;
            oEditStatus3.Value = Extraerdequery3;
            oEditStatus4.Value = Extraerdequery4;


            CleanComboBox(ComboBox0);
            string SqlCad = ("SELECT U_CodigoSS AS 'Código',U_NombreSS AS 'Nombre' FROM  [@SUPRASECCIONESCOL]");

            // oApp.SetStatusBarMessage("El dato es " + SqlCad );
            LoadComboQueryRecordset(SqlCad, ComboBox0, "Código", "Nombre", oCompany);
        }
Example #6
0
        public override void CreateForm(SAPbouiCOM.Application SboApp, string strXml, SAPbobsCOM.Company cmp, string frmId)
        {
            base.CreateForm(SboApp, strXml, cmp, frmId);

            oForm.EnableMenu("1282", false);  // Add New Record
            oForm.EnableMenu("1288", false);  // Next Record
            oForm.EnableMenu("1289", false);  // Pevious Record
            oForm.EnableMenu("1290", false);  // First Record
            oForm.EnableMenu("1291", false);  // Last record
            oForm.EnableMenu("1281", false);  // Find record
            AllRules.Columns.Add("RULE");
            InitiallizeForm();

            oForm.Items.Item("btUpd").Visible = false;
        }
 public PreCarga(SAPbobsCOM.Company oCmpn, SAPbouiCOM.Application SBO_App)
 {
     oCompany = oCmpn;
     if (oCompany.Connected == true)
     {
         //PreCarga Lista Docuemntos DIAN
         //ListaInter();
         //PreCarga Configuracion de Interfaces
         //cfgInter();
     }
     else
     {
         //No hay conexión con SAP B1
     }
 }
 private static void Disconnect()
 {
     try
     {
         if (_diCompany.Connected)
         {
             _diCompany.Disconnect();
         }
     }
     finally
     {
         _diCompany   = null;
         _application = null;
     }
 }
        /// <summary>
        /// Set existing DI and/or UI Api Connection
        /// </summary>
        /// <param name="diCompany">SAPbobsCOM.Company</param>
        /// <param name="application">SAPbouiCOM.Application</param>
        /// <param name="loggingEnabled">Is SBO Common Logging enabled</param>
        public static void SetApiConnection(
            SAPbobsCOM.Company diCompany, SAPbouiCOM.Application application = null, bool loggingEnabled = true)
        {
            _diCompany = diCompany;

            if (application != null)
            {
                _application = application;
            }

            if (loggingEnabled)
            {
                SboAppLogger.Enable();
            }
        }
Example #10
0
        public static void Conectar_Aplicacion()
        {
            SAPbouiCOM.SboGuiApi SboGuiApi = new SAPbouiCOM.SboGuiApi();
            oCompany = new SAPbobsCOM.Company();
            SboGuiApi.Connect("0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056");
            oApplication = SboGuiApi.GetApplication();
            oCompany     = (SAPbobsCOM.Company)oApplication.Company.GetDICompany();

            oSBObob = (SAPbobsCOM.SBObob)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);

            sCodUsuActual     = oCompany.UserSignature.ToString();
            sNomUsuActual     = Funciones.Current_User_Name();
            sAliasUsuActual   = oCompany.UserName;
            sCurrentCompanyDB = oCompany.CompanyDB;
        }
Example #11
0
        public static void TransferItemsProcess(SAPbouiCOM.Application oApp, string referenceNumber, List <SelectedBatchDataSources> issueBatchDSList, List <SelectedBatchDataSources> receiptBatchDSList, List <TransferItem> issueItemsList, List <TransferItem> receiptItemsList)
        {
            try
            {
                B1Helper.DiCompany.StartTransaction();

                Task t1 = Task.Run(delegate()
                {
                    foreach (var tItem in issueItemsList)
                    {
                        B1Helper.CreateTransferGoodsIssue(oApp, referenceNumber, tItem.IssueItemCode, Convert.ToDouble(tItem.Quantity), tItem.FromWhs);
                    }
                });

                Task t2 = Task.Run(delegate()
                {
                    foreach (var ds in issueBatchDSList)
                    {
                        B1Helper.CreateTransferGoodsIssue(oApp, referenceNumber, ds.ItemCode, Convert.ToDouble(ds.Quantity), ds.WhsCode, ds.SelectedBatches);
                    }
                });

                Task t3 = Task.Run(delegate()
                {
                    foreach (var ds in receiptBatchDSList)
                    {
                        B1Helper.CreateTransferGoodsReceipt(oApp, referenceNumber, ds.ItemCode, Convert.ToDouble(ds.Quantity), ds.WhsCode, (ds.AddAmount / ds.Quantity) + ds.AvgPrice, ds.SelectedBatches);
                    }
                });
                Task t4 = Task.Run(delegate()
                {
                    foreach (var receiptItem in receiptItemsList)
                    {
                        B1Helper.CreateTransferGoodsReceipt(oApp, referenceNumber, receiptItem.ReceiptItemCode, Convert.ToDouble(receiptItem.Quantity), receiptItem.ToWhs, receiptItem.AvgCost + (receiptItem.AddCost / receiptItem.Quantity));
                    }
                });

                Task.WaitAll(t1, t2, t3, t4);
                B1Helper.DiCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
            }
            catch (Exception ex)
            {
                var id = Convert.ToInt32(referenceNumber);
                Utilities.LogException(ex);
                B1Helper.DeleteRecord(id);
                B1Helper.DiCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
            }
        }
Example #12
0
 /// <summary>
 /// Initialize components. Called by framework after form created.
 /// </summary>
 public override void OnInitializeComponent()
 {
     //     oApp = (SAPbouiCOM.Application)Application.SBO_Application;
     //     oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany();
     oApp           = (SAPbouiCOM.Application)Application.SBO_Application;
     oCompany       = (SAPbobsCOM.Company)oApp.Company.GetDICompany();
     this.ComboBox0 = ((SAPbouiCOM.ComboBox)(this.GetItem("cb_Pred1").Specific));
     this.ComboBox0.ComboSelectAfter += new SAPbouiCOM._IComboBoxEvents_ComboSelectAfterEventHandler(this.ComboBox0_ComboSelectAfter);
     this.EditText4            = ((SAPbouiCOM.EditText)(this.GetItem("txt_Cred").Specific));
     this.EditText5            = ((SAPbouiCOM.EditText)(this.GetItem("txt_Pred1").Specific));
     this.EditText6            = ((SAPbouiCOM.EditText)(this.GetItem("txt_Pred2").Specific));
     this.Button2              = ((SAPbouiCOM.Button)(this.GetItem("1").Specific));
     this.Button2.ClickBefore += new SAPbouiCOM._IButtonEvents_ClickBeforeEventHandler(this.Button2_ClickBefore);
     this.EditText7            = ((SAPbouiCOM.EditText)(this.GetItem("txt_nmed").Specific));
     this.OnCustomInitialize();
 }
Example #13
0
        private void UIAPILog(LoggingEvent loggingEvent, SAPbouiCOM.Application app, string asm)
        {
            string msg = String.Format("{0}: {1}", asm, loggingEvent.RenderedMessage);

            if (loggingEvent.Level == Level.Alert)
            {
                if (!SilentMode)
                {
                    app.StatusBar.SetText(msg, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_None);
                }
            }
            else if (loggingEvent.Level == Level.Info || loggingEvent.Level == Level.Debug)
            {
                if (!SilentMode)
                {
                    app.StatusBar.SetText(msg, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
                }
            }
            else if (loggingEvent.Level == Level.Warn)
            {
                if (!SilentMode)
                {
                    app.StatusBar.SetText(msg, SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);
                }
            }
            else
            {
                app.StatusBar.SetText(msg, SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
            }

            if (loggingEvent.ExceptionObject != null)
            {
                var traceForm = ContainerManager.Container.Resolve <ExceptionTrace>();
                if (traceForm.UIAPIRawForm != null)
                // if it's an error on Dover Boot, B1SResourceManager may not have XML form on hand.
                {
                    traceForm.ex = loggingEvent.ExceptionObject;
                    traceForm.Show();
                }
                else
                {
                    app.MessageBox(string.Format("{0}\n\n{1}",
                                                 loggingEvent.ExceptionObject.Message, loggingEvent.ExceptionObject.StackTrace));
                }
            }
        }
Example #14
0
        private void SetApplication()
        {
            SAPbouiCOM.SboGuiApi sboGuiApi;
            string sConnectionString;

            sboGuiApi = new SAPbouiCOM.SboGuiApi();

            // by following the steps specified above, the following
            // statment should be suficient for either development or run mode
            sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";

            // connect to a running SBO Application
            sboGuiApi.Connect(sConnectionString);

            // get an initialized application object
            SBO_Application = sboGuiApi.GetApplication(-1);
        }
Example #15
0
        /// <summary>
        /// Establece la aplicación
        /// </summary>
        private void EstablecerAplicacion()
        {
            SAPbouiCOM.SboGuiApi _oSboGuiApi;
            string _oConnectionString;

            _oSboGuiApi = new SAPbouiCOM.SboGuiApi();
            try
            {
                _oConnectionString = Environment.GetCommandLineArgs().GetValue(1).ToString();
                _oSboGuiApi.Connect(_oConnectionString);
                SBO_Application = _oSboGuiApi.GetApplication();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #16
0
        private void SetApplication()
        {
            SAPbouiCOM.SboGuiApi SboGuiApi = null;
            string sConnectionString       = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";

            try
            {
                sConnectionString = Environment.GetCommandLineArgs().GetValue(1).ToString();
            }
            catch { }

            SboGuiApi = new SAPbouiCOM.SboGuiApi();
            //   sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1));

            SboGuiApi.Connect(sConnectionString);
            oApplication = SboGuiApi.GetApplication(-1);
        }
        /// <summary>
        /// Connect UI and DI API
        /// </summary>
        /// <param name="connectionString">Connection String from SBO Main Application</param>
        /// <param name="loggingEnabled">Is SBO Common Logging enabled</param>
        public static void Connect(string connectionString = null, bool loggingEnabled = true)
        {
            //connectionString = DebugConnectionString;
            if (connectionString == null)
            {
                connectionString = Environment.GetCommandLineArgs().Length > 1 ?
                                   Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)) : string.Empty;
            }

            var sboGuiApi = new SAPbouiCOM.SboGuiApi();

            _diCompany = new SAPbobsCOM.Company();

            try
            {
                sboGuiApi.Connect(connectionString);
                _application = sboGuiApi.GetApplication();

                var contextCookie             = _diCompany.GetContextCookie();
                var diCompanyConnectionString = _application.Company.GetConnectionContext(contextCookie);

                var responseCode = _diCompany.SetSboLoginContext(diCompanyConnectionString);


                ErrorHelper.HandleErrorWithException(responseCode, "DI API Could not Set Sbo Login Context", _diCompany);

                var connectResponse = _diCompany.Connect();
                ErrorHelper.HandleErrorWithException(connectResponse, $"DI API Could not connect.", _diCompany);

                if (loggingEnabled)
                {
                    SboAppLogger.Enable();
                }

                var assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
                Logger.Info($"{assemblyName} connected");

                SetAppEvents();
            }
            catch (Exception ex)
            {
                Logger.Error($"SboApp UI Connect Error: {ex.Message}", ex);
                throw;
            }
        }
Example #18
0
 private void OnCustomInitialize()
 {
     this.oApp     = (SAPbouiCOM.Application)SAPbouiCOM.Framework.Application.SBO_Application;
     this.oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany();
     //Create Connection SQL
     SAPbobsCOM.Recordset oR_RecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     oR_RecordSet.DoQuery("Select * from [@ADDONCFG]");
     if (oR_RecordSet.RecordCount > 0)
     {
         string uid = oR_RecordSet.Fields.Item("Code").Value.ToString();
         string pwd = oR_RecordSet.Fields.Item("Name").Value.ToString();
         conn = new SqlConnection(string.Format("Data Source={0}; Initial Catalog={1}; User id={2}; Password={3};", oCompany.Server, oCompany.CompanyDB, uid, pwd));
     }
     else
     {
         oApp.MessageBox("Can't connect DB !");
     }
 }
Example #19
0
        internal static void removeTable(UserTablesMD ut, string name, SAPbouiCOM.Application app,
                                         SAPbobsCOM.Company company)
        {
            int    ret;
            string errMsg;

            if (ut.GetByKey(name))
            {
                ret = ut.Remove();
                if (ret != 0)
                {
                    company.GetLastError(out ret, out errMsg);
                    app.SetStatusBarMessage("Error removing table " + name, SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    throw new Exception(errMsg);
                }
                app.StatusBar.SetSystemMessage("Removed table " + name,
                                               SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
            }
        }
Example #20
0
        public void conectarGuiApi(ref SAPbouiCOM.Application app)
        {
            try
            {
                SAPbouiCOM.SboGuiApi conn = new SAPbouiCOM.SboGuiApi();
                //string cadena = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1));
                string cadena = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";
                //string cadena = "";

                conn.Connect(cadena);
                conn.AddonIdentifier = "5645523035496D706C656D656E746174696F6E3A5331343030393633343339891936B4434B1E01D7DD48DAB7C6A050FD7D3F35";
                app = conn.GetApplication(-1);
            }
            catch (Exception e)
            {
                app.StatusBar.SetText("config_method_conectarGuiApi " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short,
                                      SAPbouiCOM.BoStatusBarMessageType.smt_Error);
            }
        }
Example #21
0
        private void OnCustomInitialize()
        {
            oApp     = (SAPbouiCOM.Application)Application.SBO_Application;
            oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany();

            oForm = oApp.Forms.Item("supra_sec");

            Grid0.Columns.Item("Código").TitleObject.Sortable = true;
            Grid0.DataTable.Rows.Add(1);

            for (int i = 1; i <= this.Grid0.DataTable.Rows.Count; i += 1)
            {
                if (i < this.Grid0.DataTable.Rows.Count)
                {
                    Grid0.Rows.SelectedRows.Add(i);
                }
            }
            RowNumberGrid(Grid0);
        }
Example #22
0
        internal static void removeUDO(UserObjectsMD uo, string name,
                                       SAPbouiCOM.Application app, SAPbobsCOM.Company company)
        {
            int    ret;
            string errMsg;

            if (uo.GetByKey(name))
            {
                ret = uo.Remove();
                if (ret != 0)
                {
                    company.GetLastError(out ret, out errMsg);
                    app.SetStatusBarMessage(string.Format("Error removing object {0}", name),
                                            SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    throw new Exception(errMsg);
                }
                app.StatusBar.SetSystemMessage(string.Format("Removed field {0}", name),
                                               SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
            }
        }
Example #23
0
        public static int CreateTransferGoodsReceipt(SAPbouiCOM.Application oApplication, string reference, string itemCode, double itemQuantity, string whsCode, double totalCost, System.Data.DataTable batchesTable)
        {
            var goodsReceipt = DiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry) as SAPbobsCOM.Documents;

            try
            {
                goodsReceipt.DocType             = SAPbobsCOM.BoDocumentTypes.dDocument_Items;
                goodsReceipt.Lines.ItemCode      = itemCode;
                goodsReceipt.Lines.Quantity      = itemQuantity;
                goodsReceipt.Lines.WarehouseCode = whsCode;
                goodsReceipt.Lines.UnitPrice     = totalCost;
                goodsReceipt.Reference2          = reference;
                if (batchesTable != null)
                {
                    for (int i = 0; i < batchesTable.Rows.Count; i++)
                    {
                        goodsReceipt.Lines.BatchNumbers.Quantity    = Convert.ToDouble(batchesTable.Rows[i]["Selected Qty"]);
                        goodsReceipt.Lines.BatchNumbers.BatchNumber = batchesTable.Rows[i]["Batch"].ToString();
                        goodsReceipt.Lines.BatchNumbers.SetCurrentLine(i);
                        goodsReceipt.Lines.BatchNumbers.Add();
                    }
                }
                if (goodsReceipt.Add() != 0)
                {
                    Utilities.GetErrorMessage();
                    return(0);
                }
                else
                {
                    return(goodsReceipt.DocEntry);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
            finally
            {
                goodsReceipt.ReleaseObject();
            }
        }
Example #24
0
        public Operations()
        {
            SAPbouiCOM.EventFilters objFilterCollection = null;
            SAPbouiCOM.EventFilter  objFilter           = null;
            try
            {
                objApplication      = T1.B1.MainObject.Instance.B1Application;
                objFilterCollection = objApplication.GetFilter();
                objFilterCollection.Reset();

                //objFilter = objFilterCollection.Add(SAPbouiCOM.BoEventTypes.et_MENU_CLICK);

                //objFilter = objFilterCollection.Add(SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED);
                //objFilter.AddEx(B1.BPImpairment.InteractionId.Default.frmBPFilteringFormType);
                //objFilter.AddEx(B1.BPImpairment.InteractionId.Default.frmBPResultFormType);
                //objFilter.AddEx(B1.InventoryImpairment.InteractionId.Default.frmItemFilteringFormType);
                //objFilter.AddEx(B1.InventoryImpairment.InteractionId.Default.frmItemResultFormType);

                //objFilter = objFilterCollection.Add(SAPbouiCOM.BoEventTypes.et_COMBO_SELECT);
                //objFilter.AddEx(B1.FSNotes.InteractionId.Default.fsNotesFormType);

                //objFilter = objFilterCollection.Add(SAPbouiCOM.BoEventTypes.et_PRINT_LAYOUT_KEY);
                //objFilter.AddEx(B1.FSNotes.InteractionId.Default.fsNotesFormType);

                objFilter = objFilterCollection.Add(SAPbouiCOM.BoEventTypes.et_ALL_EVENTS);



                objStatus = true;

                T1.B1.MainObject.Instance.B1Application = objApplication;
            }
            catch (COMException comEx)
            {
                _Logger.Error("", comEx);
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }
        }
Example #25
0
        internal static void removeField(UserFieldsMD uf, string tableName, int fieldID,
                                         SAPbouiCOM.Application app, SAPbobsCOM.Company company)
        {
            int    ret;
            string errMsg;

            if (uf.GetByKey(tableName, fieldID))
            {
                ret = uf.Remove();
                if (ret != 0)
                {
                    company.GetLastError(out ret, out errMsg);
                    app.SetStatusBarMessage(string.Format("Error removing field {0}-{1}",
                                                          tableName, fieldID), SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    throw new Exception(errMsg);
                }
                app.StatusBar.SetSystemMessage(string.Format("Removed field {0}-{1}",
                                                             tableName, fieldID),
                                               SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
            }
        }
 private void OnCustomInitialize()
 {
     oApp     = (SAPbouiCOM.Application)Application.SBO_Application;
     oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany();
     // Grid0.Columns.Item("CODSUPRA").Visible = false;
     oForm = oApp.Forms.Item("secci");
     Grid0.Columns.Item("Código").TitleObject.Sortable = true;
     Grid0.DataTable.Rows.Add(1);
     gridreco();
     //selecciona la ultima linea
     for (int i = 1; i <= this.Grid0.DataTable.Rows.Count; i += 1)
     {
         if (i < this.Grid0.DataTable.Rows.Count)
         {
             Grid0.Rows.SelectedRows.Add(i);
         }
     }
     gridset();
     //numerar la grilla
     RowNumberGrid(Grid0);
 }
Example #27
0
        public SAPbouiCOM.Form createForm(SAPbobsCOM.Company company, SAPbouiCOM.Application application, string resource, string formName)
        {
            SAPbouiCOM.Form mForm = null;

            try
            {
                SAPbouiCOM.FormCreationParams fCreationParams = application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams);
                fCreationParams.XmlData  = resource;
                fCreationParams.FormType = formName;
                fCreationParams.UniqueID = formName + DateTime.Now.ToString("hhmmss");

                mForm = application.Forms.AddEx(fCreationParams);
                mForm.Settings.Enabled = true;
            }
            catch (Exception ex)
            {
                StatusMessageError("Error creando formulario " + formName + ". Excepción :" + ex.Message);
            }

            return(mForm);
        }
Example #28
0
        private static void ConectarComSAP()
        {
            SAPConnection.SBOApplicationHandler applicationHandler = null;
            applicationHandler += Dialogs.RecebeSBOApplication;
            applicationHandler += Menu.RecebeSBOApplication;
            applicationHandler += applicationParam => _sBOApplication = applicationParam;

            SAPConnection.CompanyHandler companyHandler = null;
            companyHandler += companyParam => _company = companyParam;
            companyHandler += Database.RecebeCompany;

            try
            {
                SAPConnection.Connect(applicationHandler, companyHandler);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
                System.Windows.Forms.Application.Exit();
            }
        }
Example #29
0
        private void OnCustomInitialize()
        {
            oApp     = (SAPbouiCOM.Application)Application.SBO_Application;
            oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany();
            oForm    = oApp.Forms.Item("edimatr");
            //Start();
            oMatrix = ((SAPbouiCOM.Matrix)(oForm.Items.Item("Item_2").Specific));

            oDBDataSource = oForm.DataSources.DBDataSources.Item("@EDICIONESCOL");

            // Ready Matrix to populate data

            oMatrix.Clear();

            oMatrix.AutoResizeColumns();

            // Querying the DB Data source

            oDBDataSource.Query();

            // setting the user data source data

            oMatrix.LoadFromDataSource();

            oMatrix.AutoResizeColumns();

            //int i;
            //for (i = 1; i <= oMatrix.RowCount - 1; i++) ;

            //{

            //    SAPbouiCOM.EditText cellID = (SAPbouiCOM.EditText)oMatrix.GetCellSpecific("numer", i);

            //    cellID.String = i.ToString();

            //}


            oForm.Visible = true;
        }
        internal FormLinkedButtonHelper(SAPbouiCOM.Application pApplication)
        {
            try
            {
                SboForm = pApplication.Forms.Item(strFormName);
            }
            catch (Exception)
            {
                SboForm = null;
            }

            if (SboForm == null)
            {
                SboForm = pApplication.Forms.Add(strFormName, SAPbouiCOM.BoFormTypes.ft_Floating, 0);
            }

            SAPbouiCOM.Item textItm = null;

            try
            {
                textItm = SboForm.Items.Item(strTextItem);
            }
            catch (Exception)
            {
                textItm = null;
            }

            if (textItm == null)
            {
                textItm = SboForm.Items.Add(strTextItem, SAPbouiCOM.BoFormItemTypes.it_EDIT);

                var linkedItem = SboForm.Items.Add(strLindkedtem, SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON);
                //var editText = (SAPbouiCOM.EditText)textItm.Specific;
                //var linkedButton = (SAPbouiCOM.LinkedButton)linkedItem.Specific;

                linkedItem.LinkTo = textItm.UniqueID;
                textItm.LinkTo    = linkedItem.UniqueID;
            }
        }
Example #31
0
 public LicenseVerifyAddin(LicenseDAO licenseDAO, SAPbouiCOM.Application sapApp)
 {
     this.licenseDAO = licenseDAO;
     this.sapApp = sapApp;
 }
Example #32
0
        private void SetApplication()
        {
            SAPbouiCOM.SboGuiApi SboGuiApi = null;
            string sConnectionString = null;
            SboGuiApi = new SAPbouiCOM.SboGuiApi();
            sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";
            try
            {
                SboGuiApi.Connect(sConnectionString);
            }

            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                System.Environment.Exit(0);
            }

            SBO_Application = SboGuiApi.GetApplication(-1);
        }
Example #33
0
        private void SetApplication()
        {
            SAPbouiCOM.SboGuiApi SboGuiApi = null;
            string sConnectionString = null;

            SboGuiApi = new SAPbouiCOM.SboGuiApi();

            sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1));
            SboGuiApi.Connect(sConnectionString);
            SBO_Application = SboGuiApi.GetApplication(-1);
        }
Example #34
0
 public void setSBOApplication(SAPbouiCOM.Application SBO_Application)
 {
     this.SBO_Application = SBO_Application;
 }