//Excluir tabela de usuário
        public bool fExcluirTabela(string cTable)
        {
            GC.Collect();
            //SBO_Application.StatusBar.SetText("Removendo tabela [" + cTable + "]", SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);
            SAPbobsCOM.UserTablesMD objUserTablesMD;
            objUserTablesMD           = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
            objUserTablesMD.TableName = cTable;
            objUserTablesMD.GetByKey(cTable);

            CodErroDB = objUserTablesMD.Remove();
            if (CodErroDB != 0)
            {
                oCompany.GetLastError(out CodErroDB, out string MsgErroDB);
                //SBO_Application.MessageBox("Erro ao remover tabela [" + cTable + "]. Motivo: " + MsgErroDB + "....");
                System.Runtime.InteropServices.Marshal.ReleaseComObject(objUserTablesMD);
                objUserTablesMD = null;
                return(false);
            }
            else
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(objUserTablesMD);
                objUserTablesMD = null;
                return(true);
            }
        }
コード例 #2
0
ファイル: BD.cs プロジェクト: szarblewskiout/SapFramework
        internal static int DeleteTabela(string nomeTabela)
        {
            int intRetCode = -1;

            SAPbobsCOM.UserTablesMD objUserTablesMD = null;

            try
            {
                //instancia objeto para deletar tabela
                objUserTablesMD = (UserTablesMD)B1AppDomain.Company.GetBusinessObject(BoObjectTypes.oUserTables);
                if (objUserTablesMD.GetByKey(nomeTabela))
                {
                    //deleta tabela
                    intRetCode = objUserTablesMD.Remove();
                    //verifica e retorna erro
                    if (intRetCode != 0 && intRetCode != -2035)
                    {
                        B1Exception.throwException("MetaData.CriaCampos: ", new Exception(B1AppDomain.Company.GetLastErrorDescription()));
                    }
                }
                else
                {
                    B1AppDomain.Application.SetStatusBarMessage("Tabela não localizada no sistema :: " + nomeTabela, BoMessageTime.bmt_Short, true);
                }
            }
            catch (Exception ex)
            {
                B1Exception.throwException("Erro ao Deletar Tabela :: " + nomeTabela + " - ", ex);
            }



            return(intRetCode);
        }
コード例 #3
0
        public void CreateUserTable(string UserTableName, string UserTableDesc, SAPbobsCOM.BoUTBTableType UserTableType)
        {
            FindColumns        = new GenericModel();
            FindColumns.Fields = new Dictionary <string, object>();
            Log.AppendLine();
            Log.AppendLine(UserTableName);
            Log.AppendFormat("Criação/Atualização da tabela de usuário {0}: ", UserTableName);

            SAPbobsCOM.UserTablesMD oUserTableMD = (SAPbobsCOM.UserTablesMD)SBOApp.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
            // Remove a arroba do usertable Name
            UserTableName = UserTableName.Replace("@", "");

            bool bUpdate = oUserTableMD.GetByKey(UserTableName);

            oUserTableMD.TableName        = UserTableName;
            oUserTableMD.TableDescription = UserTableDesc;
            oUserTableMD.TableType        = UserTableType;

            if (bUpdate)
            {
                //CodErro = oUserTableMD.Update();
                CodErro = 0;
            }
            else
            {
                CodErro = oUserTableMD.Add();
            }
            this.ValidateAction();

            Marshal.ReleaseComObject(oUserTableMD);
            oUserTableMD = null;
        }
コード例 #4
0
ファイル: Table.cs プロジェクト: xavl369/UGRS
        /// <summary> Gets user table. </summary>
        /// <remarks> Ranaya, 02/05/2017. </remarks>
        /// <returns> The user table. </returns>

        public UserTablesMD GetUserTable()
        {
            SAPbobsCOM.UserTablesMD lObjUserTable = null;
            lObjUserTable = (SAPbobsCOM.UserTablesMD)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);

            lObjUserTable.TableName        = GetAttributes().Name;
            lObjUserTable.TableDescription = GetAttributes().Description;
            lObjUserTable.TableType        = GetAttributes().Type;

            return(lObjUserTable);
        }
        //Criar tabela de usuário

        private void AddUserTable(string Name, string Description, SAPbobsCOM.BoUTBTableType Type)
        {
            ////****************************************//**********************************
            // The UserTablesMD represents a meta-data object which allows us
            // to add\remove tables, change a table name etc.
            ////*********************//*********************//**********************************
            GC.Collect();
            SAPbobsCOM.UserTablesMD oUserTablesMD = null;
            ////*********************//*********************//**********************************
            // In any meta-data operation there should be no other object "alive"
            // but the meta-data object, otherwise the operation will fail.
            // This restriction is intended to prevent a collisions
            ////*********************//*********************//**********************************
            // the meta-data object needs to be initialized with a
            // regular UserTables object
            oUserTablesMD = ((SAPbobsCOM.UserTablesMD)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)));
            ////*********************//*****************************
            // when adding user tables or fields to the SBO DB
            // use a prefix identifying your partner name space
            // this will prevent collisions between different
            // partners add-ons
            // SAP's name space prefix is "BE_"
            ////*********************//*****************************
            // set the table parameters
            oUserTablesMD.TableName        = Name;
            oUserTablesMD.TableDescription = Description;
            oUserTablesMD.TableType        = Type;
            // Add the table
            // This action add an empty table with 2 default fields
            // 'Code' and 'Name' which serve as the key
            // in order to add your own User Fields
            // see the AddUserFields.frm in this project
            // a privat, user defined, key may be added
            // see AddPrivateKey.frm in this project
            CodErroDB = oUserTablesMD.Add();
            // check for errors in the process
            if (CodErroDB != 0)
            {
                if (CodErroDB == -1)
                {
                }
                else
                {
                    oCompany.GetLastError(out CodErroDB, out MsgErroDB);
                    // SBO_Application.StatusBar.SetText("Erro ao criar Tabela [" + Name + "] --> [" + Description + "] - " + MsgErroDB + "!", SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                }
            }
            else
            {
                // SBO_Application.StatusBar.SetText("Tabela [" + Name + "] --> [" + Description + "] - Criada com Sucesso!", SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
            }
            oUserTablesMD = null;
            GC.Collect(); // Release the handle to the table
        }
コード例 #6
0
        public bool AddTable(string TableName, string TableDescription, SAPbobsCOM.BoUTBTableType TableType)
        {
            bool outResult = false;

            try
            {
                SAPbobsCOM.UserTablesMD v_UserTableMD = default(SAPbobsCOM.UserTablesMD);

                GC.Collect();
                if (!TableExists(TableName))
                {
                    oApplication.StatusBar.SetText("Creating Table " + TableName + " ...................", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);
                    v_UserTableMD                  = (SAPbobsCOM.UserTablesMD)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
                    v_UserTableMD.TableName        = TableName;
                    v_UserTableMD.TableDescription = TableDescription;
                    v_UserTableMD.TableType        = TableType;
                    v_RetVal = v_UserTableMD.Add();
                    if (v_RetVal != 0)
                    {
                        oCompany.GetLastError(out v_ErrCode, out v_ErrMsg);
                        oApplication.StatusBar.SetText("Failed to Create Table " + TableName + v_ErrCode + " " + v_ErrMsg, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(v_UserTableMD);
                        v_UserTableMD = null;
                        GC.Collect();
                        return(false);
                    }
                    else
                    {
                        oApplication.StatusBar.SetText("[@" + TableName + "] - " + TableDescription + " created successfully!!!", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(v_UserTableMD);
                        v_UserTableMD = null;
                        outResult     = true;
                        GC.Collect();
                        return(true);
                    }
                }
                else
                {
                    GC.Collect();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                oApplication.StatusBar.SetText("Failed to Add Table : " + ex.Message);
            }
            finally
            {
            }
            return(outResult);
        }
コード例 #7
0
        public void RemoveUserTable(string UserTableName)
        {
            Log.AppendFormat("Remoção da tabela de usuário {0}: ", UserTableName);
            SAPbobsCOM.UserTablesMD oUserTableMD = (SAPbobsCOM.UserTablesMD)SBOApp.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);

            // Remove a arroba do usertable Name
            UserTableName = UserTableName.Replace("@", "");

            if (oUserTableMD.GetByKey(UserTableName))
            {
                CodErro = oUserTableMD.Remove();
                this.ValidateAction();
            }
            else
            {
                CodErro = 0;
                MsgErro = "";
                Log.AppendLine("OK");
            }
            Marshal.ReleaseComObject(oUserTableMD);
            oUserTableMD = null;
        }
コード例 #8
0
ファイル: BD.cs プロジェクト: szarblewskiout/SapFramework
        internal static int AddTabela(string nomeTabela, string descricao, BoUTBTableType tipoTabela)
        {
            int intRetCode = -1;

            SAPbobsCOM.UserTablesMD objUserTablesMD = null;

            try
            {
                //instancia objeto para criar tabela
                objUserTablesMD = (UserTablesMD)B1AppDomain.Company.GetBusinessObject(BoObjectTypes.oUserTables);

                //seta propriedades
                objUserTablesMD.TableName        = nomeTabela;
                objUserTablesMD.TableDescription = descricao;
                objUserTablesMD.TableType        = tipoTabela;

                //adiciona tabela
                intRetCode = objUserTablesMD.Add();
                //verifica e retorna erro
                if (intRetCode != 0 && intRetCode != -2035)
                {
                    B1Exception.throwException("MetaData.CriaCampos: ", new Exception(B1AppDomain.Company.GetLastErrorDescription()));
                }

                //mata objeto para reutilizar senao trava
                //Marshal.FinalReleaseComObject(objUserTablesMD);
                //objUserTablesMD = null;
                //GC.Collect();
                Objects.LimpaMemoria(objUserTablesMD);
            }
            catch (Exception ex)
            {
                B1Exception.throwException("Erro ao Criar Tabela :: " + nomeTabela + " - ", ex);
            }

            return(intRetCode);
        }
コード例 #9
0
        public bool TableExists(string TableName)
        {
            bool outResult = false;

            try
            {
                SAPbobsCOM.UserTablesMD oTables = default(SAPbobsCOM.UserTablesMD);
                bool oFlag = false;

                oTables = (SAPbobsCOM.UserTablesMD)oDiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
                oFlag   = oTables.GetByKey(TableName);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oTables);
                outResult = oFlag;
                return(oFlag);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to Table Exists : " + ex.Message);
            }
            finally
            {
            }
            return(outResult);
        }