Code Monkey home page Code Monkey logo

itco-sbo-addon-framework's Introduction

SAP Business One Addon Framework

Framework for SAP Business One SDK Addons

NuGet version itcompaniet MyGet Build Status

Usage UI API

Create an Windows Application Project and run SboAddonContext() from Main.

Connection to SBO will be made automatically.

static class Program
{
    [STAThread]
    static void Main()
    {
        Application.Run(new SboAddonContext());
    }
}

Form Controller

MyFormController will automaticly load Forms.MyForm.srf and create an menu item.

    public class MyFormController : FormController, IFormMenuItem
    {
        public string MenuItemTitle => "My Form";
        public string ParentMenuItemId => SboMenuItem.Finance;
    }

Usage DI API

Connect

static class Program
{
    static void Main()
    {
        // From app.config
        SboApp.DiConnectFromAppConfig();
    }
}
  <appSettings>
    <add key="Sbo:ServerName" value="SAP-SERVER"/>
    <add key="Sbo:ServerType" value="MSSQL2014"/>
    <add key="Sbo:CompanyDb" value="SBODemo"/>
    <add key="Sbo:DbUsername" value="sa"/>
    <add key="Sbo:DbPassword" value=""/>
    <add key="Sbo:Username" value="manager"/>
    <add key="Sbo:Password" value=""/>
    <add key="Sbo:LicenceService" value="SAP-SERVER:30000"/>
  </appSettings>

Setup Class

    public class MySetup : ISetup
    {
        public const string UDT_MyData = "ITCO_Mydata";
        public const string UDF_CardCode = "CardCode";
        public const string UDF_Amount = "Amount";

        public int Version => 1;

        public void Run()
        {
            UserDefinedHelper.CreateTable(UDT_MyData, "My Data")
                .CreateUDF(UDF_CardCode, "CardCode", BoFieldTypes.db_Alpha, 30)
                .CreateUDF(UDF_Amount, "Amount", BoFieldTypes.db_Float, 30, BoFldSubTypes.st_Price);

            SettingService.InitSetting<string>("my.setting.1", "My Setting 1", "value123");
            SettingService.InitSetting<int>("my.setting.2", "My Setting 2", 0);
        }
    }

Run setup

// Finds and run all ISetup classes
SetupManager.FindAndRunSetups(GetType().Assembly);
// or run manually
SetupManager.RunSetup(new MySetup());

Settings Service

var mySetting = SettingService.GetSettingByKey("itco.mysetting", 0);

Recordset Query

using (var query = new SboRecordsetQuery("SELECT [DocNum] FROM [ORDR]"))
{
    if (query.Count == 0)
        SboApp.Application.MessageBox("No Matches!");

    foreach (var row in query.Result)
    {
        var docNum = row.Item("DocNum").Value;
    }
}

Misc Helpers

var combobox = Form.GetComboBox("MyCombo");
combobox.AddComboBoxValues("SELECT CardCode, Cardname FROM OCRD");

itco-sbo-addon-framework's People

Contributors

kwestground avatar eschtenk avatar brakim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.