public static bool CheckUDOExists(string UDOName)
        {
            SAPbobsCOM.Company SBO_Company = Conexion.oCompany;

            SAPbobsCOM.UserObjectsMD oUdtMD = null /* TODO Change to default(_) if this is not a reference type */;
            bool ret = false;

            try
            {
                oUdtMD = (SAPbobsCOM.UserObjectsMD)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);

                if (oUdtMD.GetByKey(UDOName))
                {
                    ret = true;
                }
                else
                {
                    ret = false;
                }
            }
            catch (Exception)
            {
                ret = false;
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD);
                oUdtMD = null /* TODO Change to default(_) if this is not a reference type */;
                GC.Collect();
            }

            return(ret);
        }
        public static string CreateUdo(string udoCode, string udoDescription, string headerTable, string chidlTable, int position, int fatherMenuId)
        {
            SAPbobsCOM.UserObjectsMD udo = (SAPbobsCOM.UserObjectsMD)DiManager.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);
            bool updateFlag = udo.GetByKey(udoCode);

            udo.Code                  = udoCode;
            udo.Name                  = udoDescription;
            udo.ObjectType            = BoUDOObjType.boud_Document;
            udo.TableName             = headerTable;
            udo.ChildTables.TableName = chidlTable;
            udo.ChildTables.Add();


            udo.CanCancel            = BoYesNoEnum.tNO;
            udo.CanClose             = BoYesNoEnum.tYES;
            udo.CanDelete            = BoYesNoEnum.tNO;
            udo.CanFind              = BoYesNoEnum.tYES;
            udo.MenuCaption          = udoDescription;
            udo.CanCreateDefaultForm = BoYesNoEnum.tYES;
            udo.EnableEnhancedForm   = BoYesNoEnum.tYES;
            udo.MenuItem             = BoYesNoEnum.tYES;
            udo.Position             = position;
            udo.FatherMenuID         = fatherMenuId;
            udo.MenuUID              = udoCode;

            udo.FormColumns.FormColumnAlias       = "DocEntry";
            udo.FormColumns.FormColumnDescription = "DocEntry";
            udo.FormColumns.Add();



            return(updateFlag ? udo.Update() != 0 ? Company.GetLastErrorDescription() : string.Empty : udo.Add() != 0 ? Company.GetLastErrorDescription() : string.Empty);
        }
Exemplo n.º 3
0
        public bool UDOExists(string code)
        {
            bool outResult = false;

            try
            {
                SAPbobsCOM.UserObjectsMD v_UDOMD = default(SAPbobsCOM.UserObjectsMD);
                bool v_ReturnCode = false;

                GC.Collect();
                v_UDOMD      = (SAPbobsCOM.UserObjectsMD)oDiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);
                v_ReturnCode = v_UDOMD.GetByKey(code);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(v_UDOMD);
                v_UDOMD   = null;
                outResult = v_ReturnCode;
                return(v_ReturnCode);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to UDO Exists : " + ex.Message);
            }
            finally
            {
            }
            return(outResult);
        }
        public void RemoveUserObject(string ObjectName)
        {
            Log.AppendFormat("Remoção do Objeto de usuário {0}", ObjectName);

            SAPbobsCOM.UserObjectsMD UserObjectsMD = (SAPbobsCOM.UserObjectsMD)SBOApp.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);

            bool bUpdate = UserObjectsMD.GetByKey(ObjectName);

            CodErro = 0;
            if (bUpdate)
            {
                CodErro = UserObjectsMD.Remove();
            }
            this.ValidateAction();

            Marshal.ReleaseComObject(UserObjectsMD);
            UserObjectsMD = null;
        }
Exemplo n.º 5
0
        internal static int DeleteUdo(Tabelas tabela)
        {
            int intRetCode = -1;

            SAPbobsCOM.UserObjectsMD oUserObjectMD = null;


            if (oUserObjectMD.GetByKey(tabela.Udos.TableName))
            {
                intRetCode = oUserObjectMD.Remove();

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

            return(intRetCode);
        }
        public void AddChildTableToUserObject(string ObjectName, string ChildTableName)
        {
            // se não preenchido um table name separado, usa o mesmo do objeto

            Log.AppendFormat("Inserção de tabela filha ({0}) ao objeto {1}: ", ChildTableName, ObjectName);

            SAPbobsCOM.UserObjectsMD UserObjectsMD = (SAPbobsCOM.UserObjectsMD)SBOApp.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);

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

            bool bUpdate = UserObjectsMD.GetByKey(ObjectName);

            bool JaAdicionada = false;

            for (int i = 0; i < UserObjectsMD.ChildTables.Count; i++)
            {
                UserObjectsMD.ChildTables.SetCurrentLine(i);
                if (ChildTableName == UserObjectsMD.ChildTables.TableName)
                {
                    JaAdicionada = true;
                    break;
                }
            }

            if (!JaAdicionada)
            {
                UserObjectsMD.ChildTables.Add();
                UserObjectsMD.ChildTables.TableName = ChildTableName;
            }

            CodErro = UserObjectsMD.Update();
            this.ValidateAction();

            Marshal.ReleaseComObject(UserObjectsMD);
            UserObjectsMD = null;
        }
        public static void CreateUDO(string tableName, SAPbobsCOM.BoUDOObjType objtype)
        {
            SAPbobsCOM.UserObjectsMD oUdtMD = null /* TODO Change to default(_) if this is not a reference type */; // ‘
            string errmsg = "";

            try
            {
                SAPbobsCOM.Company SBO_Company = Conexion.oCompany;

                oUdtMD = (SAPbobsCOM.UserObjectsMD)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);
                if (oUdtMD.GetByKey(tableName) == false)
                {
                    oUdtMD.Code      = tableName;
                    oUdtMD.Name      = tableName;
                    oUdtMD.TableName = tableName;

                    oUdtMD.ObjectType = objtype;

                    oUdtMD.CanCancel            = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUdtMD.CanClose             = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUdtMD.CanDelete            = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUdtMD.CanFind              = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUdtMD.CanLog               = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUdtMD.ManageSeries         = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUdtMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUdtMD.CanYearTransfer      = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUdtMD.EnableEnhancedForm   = SAPbobsCOM.BoYesNoEnum.tYES;
                    oUdtMD.MenuItem             = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUdtMD.UseUniqueFormType    = SAPbobsCOM.BoYesNoEnum.tNO;
                    oUdtMD.Position             = 1;
                    oUdtMD.FatherMenuID         = 2048;
                    //oUdtMD.LogTableName = "";
                    if (objtype == SAPbobsCOM.BoUDOObjType.boud_MasterData)
                    {
                        oUdtMD.FormColumns.FormColumnAlias = "Code";
                        oUdtMD.FormColumns.Add();
                    }
                    else
                    {
                        oUdtMD.FormColumns.FormColumnAlias = "DocEntry";
                        oUdtMD.FormColumns.Add();
                    }

                    int lRetCode;
                    lRetCode = oUdtMD.Add();

                    if ((lRetCode != 0))
                    {
                        if ((lRetCode == -2035))
                        {
                            errmsg = "-2035";
                        }
                        errmsg = SBO_Company.GetLastErrorDescription();
                    }

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdtMD);
                    oUdtMD = null /* TODO Change to default(_) if this is not a reference type */;
                    GC.Collect();
                    errmsg = "";
                }
                else
                {
                    errmsg = "";
                }
            }
            catch (Exception)
            {
            }
        }
        public void CreateUserObject(string ObjectName, string ObjectDesc, string TableName, SAPbobsCOM.BoUDOObjType ObjectType, bool CanLog, bool CanYearTransfer, bool CanCancel, bool CanClose, bool CanCreateDefaultForm, bool CanDelete, bool CanFind, int FatherMenuId, int menuPosition, GenericModel findColumns)
        {
            // se não preenchido um table name separado, usa o mesmo do objeto
            if (String.IsNullOrEmpty(TableName))
            {
                TableName = ObjectName;
            }

            Log.AppendFormat("Criação/Atualização do Objeto de usuário {0}", ObjectName);

            SAPbobsCOM.UserObjectsMD UserObjectsMD = (SAPbobsCOM.UserObjectsMD)SBOApp.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);

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

            bool bUpdate = UserObjectsMD.GetByKey(ObjectName);

            UserObjectsMD.Code       = ObjectName;
            UserObjectsMD.Name       = ObjectDesc;
            UserObjectsMD.ObjectType = ObjectType;
            UserObjectsMD.TableName  = TableName;

            //UserObjectsMD.CanArchive = GetSapBoolean(CanArchive);
            UserObjectsMD.CanCancel            = GetSapBoolean(CanCancel);
            UserObjectsMD.CanClose             = GetSapBoolean(CanClose);
            UserObjectsMD.CanCreateDefaultForm = GetSapBoolean(CanCreateDefaultForm);
            UserObjectsMD.CanDelete            = GetSapBoolean(CanDelete);
            UserObjectsMD.CanFind         = GetSapBoolean(CanFind);
            UserObjectsMD.CanLog          = GetSapBoolean(CanLog);
            UserObjectsMD.CanYearTransfer = GetSapBoolean(CanYearTransfer);

            if (CanCreateDefaultForm)
            {
                UserObjectsMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES;
                UserObjectsMD.CanCancel            = GetSapBoolean(CanCancel);
                UserObjectsMD.CanClose             = GetSapBoolean(CanClose);
                UserObjectsMD.CanDelete            = GetSapBoolean(CanDelete);
                UserObjectsMD.CanFind           = GetSapBoolean(CanFind);
                UserObjectsMD.ExtensionName     = "";
                UserObjectsMD.OverwriteDllfile  = SAPbobsCOM.BoYesNoEnum.tYES;
                UserObjectsMD.UseUniqueFormType = SAPbobsCOM.BoYesNoEnum.tYES;
                UserObjectsMD.ManageSeries      = SAPbobsCOM.BoYesNoEnum.tYES;

                UserObjectsMD.FormColumns.FormColumnAlias       = "Code";
                UserObjectsMD.FormColumns.FormColumnDescription = "Código";
                UserObjectsMD.FormColumns.Add();

                UserObjectsMD.FormColumns.FormColumnAlias       = "Name";
                UserObjectsMD.FormColumns.FormColumnDescription = "Descrição";
                UserObjectsMD.FormColumns.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
                UserObjectsMD.FormColumns.Add();

                UserObjectsMD.FindColumns.ColumnAlias       = "Code";
                UserObjectsMD.FindColumns.ColumnDescription = "Código";
                UserObjectsMD.FindColumns.Add();

                UserObjectsMD.FindColumns.ColumnAlias       = "Name";
                UserObjectsMD.FindColumns.ColumnDescription = "Descrição";
                UserObjectsMD.FindColumns.Add();

                if (findColumns != null)
                {
                    FindColumns = findColumns;
                }

                if (FindColumns != null && FindColumns.Fields != null)
                {
                    foreach (KeyValuePair <string, object> pair in FindColumns.Fields)
                    {
                        UserObjectsMD.FindColumns.ColumnAlias       = pair.Key;
                        UserObjectsMD.FindColumns.ColumnDescription = pair.Value.ToString();
                        UserObjectsMD.FindColumns.Add();
                    }
                }

                UserObjectsMD.FatherMenuID = FatherMenuId;
                UserObjectsMD.Position     = menuPosition;
                UserObjectsMD.MenuItem     = SAPbobsCOM.BoYesNoEnum.tYES;
                UserObjectsMD.MenuUID      = ObjectName;
                UserObjectsMD.MenuCaption  = ObjectDesc;
            }

            if (bUpdate)
            {
                //CodErro = UserObjectsMD.Update();
            }
            else
            {
                CodErro = UserObjectsMD.Add();
            }

            this.ValidateAction();

            Marshal.ReleaseComObject(UserObjectsMD);
            UserObjectsMD      = null;
            FindColumns        = new GenericModel();
            FindColumns.Fields = new Dictionary <string, object>();
        }