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)
            {
            }
        }
Ejemplo n.º 2
0
        public bool registerUDO(string UDOCode, string UDOName, SAPbobsCOM.BoUDOObjType UDOType, string[,] findAliasNDescription, string parentTableName, string childTable1 = "", string childTable2 = "", string childTable3 = "", string childTable4 = "", SAPbobsCOM.BoYesNoEnum LogOption = SAPbobsCOM.BoYesNoEnum.tNO, string MenuId = "", int parrentId = 0)
        {
            bool functionReturnValue = false;

            try
            {
                bool actionSuccess = false;
                SAPbobsCOM.UserObjectsMD v_udoMD = default(SAPbobsCOM.UserObjectsMD);

                functionReturnValue          = false;
                v_udoMD                      = (SAPbobsCOM.UserObjectsMD)oDiCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);
                v_udoMD.CanCancel            = SAPbobsCOM.BoYesNoEnum.tYES;
                v_udoMD.CanClose             = SAPbobsCOM.BoYesNoEnum.tYES;
                v_udoMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tNO;
                v_udoMD.CanDelete            = SAPbobsCOM.BoYesNoEnum.tYES;
                v_udoMD.CanFind              = SAPbobsCOM.BoYesNoEnum.tYES;
                v_udoMD.CanLog               = SAPbobsCOM.BoYesNoEnum.tNO;
                v_udoMD.CanYearTransfer      = SAPbobsCOM.BoYesNoEnum.tYES;
                v_udoMD.ManageSeries         = SAPbobsCOM.BoYesNoEnum.tYES;
                if (!string.IsNullOrEmpty(MenuId))
                {
                    v_udoMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES;
                    //v_udoMD.RebuildEnhancedForm = SAPbobsCOM.BoYesNoEnum.tYES
                    v_udoMD.MenuItem = SAPbobsCOM.BoYesNoEnum.tYES;

                    v_udoMD.MenuUID     = MenuId;
                    v_udoMD.MenuCaption = UDOName;
                    // v_udoMD.EnableEnhancedForm = SAPbobsCOM.BoYesNoEnum.tYES
                    v_udoMD.FatherMenuID = parrentId;
                    v_udoMD.Position     = 2;
                }

                v_udoMD.Code      = UDOCode;
                v_udoMD.Name      = UDOName;
                v_udoMD.TableName = parentTableName;
                if (LogOption == SAPbobsCOM.BoYesNoEnum.tYES)
                {
                    v_udoMD.CanLog       = SAPbobsCOM.BoYesNoEnum.tYES;
                    v_udoMD.LogTableName = "A" + parentTableName;
                }
                v_udoMD.ObjectType = UDOType;
                for (Int16 i = 0; i <= findAliasNDescription.GetLength(0) - 1; i++)
                {
                    if (i > 0)
                    {
                        v_udoMD.FindColumns.Add();
                    }
                    v_udoMD.FindColumns.ColumnAlias       = findAliasNDescription[i, 0];
                    v_udoMD.FindColumns.ColumnDescription = findAliasNDescription[i, 1];
                }
                if (!string.IsNullOrEmpty(childTable1))
                {
                    v_udoMD.ChildTables.TableName = childTable1;
                    v_udoMD.ChildTables.Add();
                }
                if (!string.IsNullOrEmpty(childTable2))
                {
                    v_udoMD.ChildTables.TableName = childTable2;
                    v_udoMD.ChildTables.Add();
                }
                if (!string.IsNullOrEmpty(childTable3))
                {
                    v_udoMD.ChildTables.TableName = childTable3;
                    v_udoMD.ChildTables.Add();
                }
                if (!string.IsNullOrEmpty(childTable4))
                {
                    v_udoMD.ChildTables.TableName = childTable4;
                    v_udoMD.ChildTables.Add();
                }
                if (v_udoMD.Add() == 0)
                {
                    functionReturnValue = true;
                }
                else
                {
                    throw new Exception("Failed to Register UDO >" + UDOCode + ">" + UDOName + " >" + oDiCompany.GetLastErrorDescription());
                    functionReturnValue = false;
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(v_udoMD);
                v_udoMD = null;
                GC.Collect();
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to UDO Register : " + ex.Message);
            }
            finally
            {
            }
            return(functionReturnValue);
        }
 public void CreateUserObject(string ObjectName, string ObjectDesc, string TableName, SAPbobsCOM.BoUDOObjType ObjectType, bool CanLog, bool CanYearTransfer, GenericModel findColumns)
 {
     this.CreateUserObject(ObjectName, ObjectDesc, TableName, ObjectType, CanLog, CanYearTransfer, false, false, false, true, true, 0, 0, findColumns);
 }
        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>();
        }
 public void CreateUserObject(string ObjectName, string ObjectDesc, string TableName, SAPbobsCOM.BoUDOObjType ObjectType, bool CanLog, bool CanYearTransfer)
 {
     this.CreateUserObject(ObjectName, ObjectDesc, TableName, ObjectType, CanLog, CanYearTransfer, false, false, false, true, true, 0, 0, null);
 }