Ejemplo n.º 1
0
        void SwitchCompanyWindow_OpenBeforeOriginal(object sender, System.ComponentModel.CancelEventArgs e)
        {
            List <string> users;
            TableError    err;

            Dynamics.Application CompilerApp = new Dynamics.Application();
            string CompilerMessage           = "";
            int    CompilerError             = 0;

            // Execute SanScript in Dynamics GP
            CompilerError = CompilerApp.ExecuteSanscript(Dexterity.CompanySwitchScript, out CompilerMessage);
            if (CompilerError != 0)
            {
                MessageBox.Show(CompilerMessage);
            }

            users = new List <string>();
            users.Clear();

            err = ActivityTable.GetFirst();
            while (err == TableError.NoError)
            {
                users.Add(ActivityTable.UserId.Value);
                err = ActivityTable.GetNext();
            }
            ActivityTable.Close();

            //create string scrolling procedure here to display all user activity, otherwise Status is limited to 62 char
            foreach (string str in users.ToArray())
            {
                //userActivity += str + ",";
                SwitchCompanyWindow.LocalStatus.Value += str + ",";
            }
        }
Ejemplo n.º 2
0
        void OpenPOInquiry(object sender, EventArgs e)
        {
            //sanscript
            //OpenWindow("PO1400200",2,2) of form POP_Inquiry_PO_Entry;
            //sample continuum from Mariano Gomez http://dynamicsgpblogster.blogspot.com/2013/08/accessing-microsoft-dynamics-gp-default.html
            try
            {
                Dynamics.Application gpApp = (Dynamics.Application)Activator.CreateInstance(Type.GetTypeFromProgID("Dynamics.Application"));
                if (gpApp == null)
                {
                    return;
                }
                else
                {
                    string passthrough_code = "";
                    string compile_err;
                    int    error_code;
                    //this sanscript will save the Open PO
                    passthrough_code += @"run script 'Save Button' of window POP_PO_Entry of form POP_PO_Entry;";
                    //this will open Inquiry
                    passthrough_code += @"OpenWindow(""" + POPPOEntryWindow.PoNumber.Value + @""",2,2) of form POP_Inquiry_PO_Entry;";

                    //not needed in my case, and it will auto adapt to the alternate/modified setup
                    //gpApp.CurrentProductID = 0;

                    error_code = gpApp.ExecuteSanscript(passthrough_code, out compile_err);
                    return;
                }
            }
            catch
            {
                //MessageBox.Show("Failed to initialize gpApp");
                return;
            }
        }