Esempio n. 1
0
        public void Insert()
        {
            Axapta       ax;
            AxaptaRecord axRecord;

            try
            {
                ax = new Axapta();
                ax.Logon(null, null, null, null);
                using (axRecord = ax.CreateAxaptaRecord(TABLE_NAME))
                {
                    ax.TTSBegin();

                    axRecord.Call("ESS_WriteValues",
                                  this.LeaveApplicationType,
                                  this.EmplId,
                                  this.RequestedBy,
                                  this.ScheduledLeaveDate,
                                  this.ScheduledReturnDate,
                                  this.ApprovalStatus,
                                  this.ExitVisaType,
                                  this.Comments,
                                  this.CommentsApproval);
                    axRecord.Insert();
                    ax.TTSCommit();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Axapta Ax = new Axapta();

            Ax.Logon(null, null, null, null);
            string className  = "ZFS_TestXML";
            string methodName = "getResultTable";
            string paramList  = null;

            AxaptaObject axObj = Ax.CreateAxaptaObject(className);
            AxaptaRecord ret   = null;

            if (paramList != null)
            {
                ret = (AxaptaRecord)axObj.Call(methodName, paramList);
            }
            else
            {
                ret = (AxaptaRecord)axObj.Call(methodName);
            }

            while (ret.Found)
            {
                ret.get_Field(2);
            }

            axObj.Dispose();
        }
Esempio n. 3
0
        public void Update()
        {
            Axapta       ax;
            AxaptaRecord axRecord;

            try
            {
                ax = new Axapta();
                ax.Logon(null, null, null, null);
                using (axRecord = ax.CreateAxaptaRecord(TABLE_NAME))
                {
                    string sql = string.Format("select forupdate * from %1 where %1.{0} == '{1}'", APPLICATION_ID, this.ApplicationId);
                    axRecord.ExecuteStmt(sql);
                    if (axRecord.Found)
                    {
                        ax.TTSBegin();
                        axRecord.set_Field(LEAVE_APP_TYPE, this.LeaveApplicationType);
                        axRecord.set_Field(SCH_LEAVE_DATE, this.ScheduledLeaveDate);
                        axRecord.set_Field(SCH_RETURN_DATE, this.ScheduledReturnDate);
                        axRecord.set_Field(APPROVAL_STATUS, this.ApprovalStatus);
                        axRecord.set_Field(EXIT_VISA_TYPE, this.ExitVisaType);
                        axRecord.set_Field(COMMENTS, this.Comments);
                        axRecord.set_Field(COMMENTS_APPROVAL, this.CommentsApproval);
                        axRecord.Update();
                        ax.TTSCommit();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
        }
Esempio n. 4
0
    static void Main(string[] args)
    {
        // Create the .NET Business Connector objects.
        Axapta ax;
        AxaptaRecord axRecord;
        string tableName = "LabX_ResultTable";

        // The Table field names for calls to
        // the AxRecord.get_field method.
        string strSampleField = "SampleID";
        string strDescriptionField = "Description";

        // The output variables for calls to the
        // AxRecord.get_Field method.
        object fieldSampleId, fieldDescription;

        try
        {
            // Login to Microsoft Dynamics AX.
            ax = new Axapta();
            ax.Logon(null, null, null, null);

            // Create a query using the AxaptaRecord class
            // for the StateAddress table.
            using (axRecord = ax.CreateAxaptaRecord(tableName))
            {

                // Execute the query on the table.
                axRecord.ExecuteStmt("select * from %1");
                // Create output with a title and column headings
                // for the returned records.
                Console.WriteLine("List of selected records from {0}",
                    tableName);
                Console.WriteLine("{0}\t{1}", strSampleField, strDescriptionField);

                // Loop through the set of retrieved records.
                while (axRecord.Found)
                {
                    // Retrieve the record data for the specified fields.
                    fieldSampleId = axRecord.get_Field(strSampleField);
                    fieldDescription = axRecord.get_Field(strDescriptionField);

                    // Display the retrieved data.
                    Console.WriteLine(fieldSampleId + "\t" + fieldDescription);

                    // Advance to the next row.
                    axRecord.Next();
                }
            }
        }

        catch (Exception e)
        {
            Console.WriteLine("Error encountered: {0}", e.Message);
            // Take other error action as needed.
        }

        Console.Read();
    }
Esempio n. 5
0
    static void Main(string[] args)
    {
        // Create the .NET Business Connector objects.
        Axapta       ax;
        AxaptaRecord axRecord;
        string       tableName = "LabX_ResultTable";

        // The Table field names for calls to
        // the AxRecord.get_field method.
        string strSampleField      = "SampleID";
        string strDescriptionField = "Description";

        // The output variables for calls to the
        // AxRecord.get_Field method.
        object fieldSampleId, fieldDescription;

        try
        {
            // Login to Microsoft Dynamics AX.
            ax = new Axapta();
            ax.Logon(null, null, null, null);

            // Create a query using the AxaptaRecord class
            // for the StateAddress table.
            using (axRecord = ax.CreateAxaptaRecord(tableName))
            {
                // Execute the query on the table.
                axRecord.ExecuteStmt("select * from %1");
                // Create output with a title and column headings
                // for the returned records.
                Console.WriteLine("List of selected records from {0}",
                                  tableName);
                Console.WriteLine("{0}\t{1}", strSampleField, strDescriptionField);

                // Loop through the set of retrieved records.
                while (axRecord.Found)
                {
                    // Retrieve the record data for the specified fields.
                    fieldSampleId    = axRecord.get_Field(strSampleField);
                    fieldDescription = axRecord.get_Field(strDescriptionField);

                    // Display the retrieved data.
                    Console.WriteLine(fieldSampleId + "\t" + fieldDescription);

                    // Advance to the next row.
                    axRecord.Next();
                }
            }
        }

        catch (Exception e)
        {
            Console.WriteLine("Error encountered: {0}", e.Message);
            // Take other error action as needed.
        }

        Console.Read();
    }
Esempio n. 6
0
        public static List <LeaveApp> GetLeaveApps()
        {
            var          leaveApps = new List <LeaveApp>();
            Axapta       ax;
            AxaptaRecord axRecord;

            try
            {
                // Login to Microsoft Dynamics AX.
                ax = new Axapta();
                ax.Logon(null, null, null, null);

                // Create a query using the AxaptaRecord class
                using (axRecord = ax.CreateAxaptaRecord(TABLE_NAME))
                {
                    // Execute the query on the table.
                    axRecord.ExecuteStmt("select * from %1 ");

                    while (axRecord.Found)
                    {
                        var leaveApp = new LeaveApp()
                        {
                            ApplicationId        = axRecord.get_Field(APPLICATION_ID).ToString(),
                            CreatedDateTime      = (DateTime)axRecord.get_Field(CREATE_DATETIME),
                            LeaveApplicationType = axRecord.get_Field(LEAVE_APP_TYPE).ToString(),
                            DefaultLeaveCode     = axRecord.get_Field(LEAVE_CODE).ToString(),
                            EmplId              = axRecord.get_Field(EMPLOYEE_ID).ToString(),
                            RequestedBy         = (long)axRecord.get_Field(REQUESTED_BY),
                            ScheduledLeaveDate  = (DateTime)axRecord.get_Field(SCH_LEAVE_DATE),
                            ScheduledReturnDate = (DateTime)axRecord.get_Field(SCH_RETURN_DATE),
                            Days             = (int)axRecord.get_Field(DAYS),
                            ApprovalStatus   = axRecord.get_Field(APPROVAL_STATUS).ToString(),
                            ExitVisaType     = axRecord.get_Field(EXIT_VISA_TYPE).ToString(),
                            Comments         = axRecord.get_Field(COMMENTS).ToString(),
                            CommentsApproval = axRecord.get_Field(COMMENTS_APPROVAL).ToString()
                        };
                        leaveApps.Add(leaveApp);
                        axRecord.Next();
                    }
                    return(leaveApps);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error encountered: {0}", ex.Message);
                throw;
            }
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            // Create the .NET Business Connector objects.
            Axapta ax;
            string sID = "@SYS21669";
            object o;
            bool b;

            try
            {
                // Login to Microsoft Dynamics Ax.
                ax = new Axapta();
                ax.Logon(null, null, null, null);

            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred in object creation or Axapta logon: {0}", e.Message);
                return;
            }

            // Logon was successful.
            try
            {
                // Call a static class method.
                // In this example, call SysLabel::labelId2String2
                // to determine the label string for a particular label ID.
                o = ax.CallStaticClassMethod("SysLabel", "labelId2String2", sID);
            }
            catch (Exception e)
            {
                Console.WriteLine("An error has been encountered during CallStaticClassMethod: {0}", e.Message);
                b = ax.Logoff();
                return;
            }

            // Display the returned string.
            Console.WriteLine("The label string for {0} is {1}.", sID, o.ToString());

            // Log off from Microsoft Dynamics AX.
            b = ax.Logoff();
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            // Create the .NET Business Connector objects.
            Axapta ax;
            string sID = "@SYS21669";
            object o;
            bool   b;

            try
            {
                // Login to Microsoft Dynamics Ax.
                ax = new Axapta();
                ax.Logon(null, null, null, null);
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occurred in object creation or Axapta logon: {0}", e.Message);
                return;
            }

            // Logon was successful.
            try
            {
                // Call a static class method.
                // In this example, call SysLabel::labelId2String2
                // to determine the label string for a particular label ID.
                o = ax.CallStaticClassMethod("SysLabel", "labelId2String2", sID);
            }
            catch (Exception e)
            {
                Console.WriteLine("An error has been encountered during CallStaticClassMethod: {0}", e.Message);
                b = ax.Logoff();
                return;
            }

            // Display the returned string.
            Console.WriteLine("The label string for {0} is {1}.", sID, o.ToString());

            // Log off from Microsoft Dynamics AX.
            b = ax.Logoff();
        }
Esempio n. 9
0
        public static Employee GetEmployee(string personnelNumber)
        {
            Axapta       ax;
            AxaptaRecord axRecord;

            try
            {
                // Login to Microsoft Dynamics AX.
                ax = new Axapta();
                ax.Logon(null, null, null, null);

                // Create a query using the AxaptaRecord class
                // for the StateAddress table.
                using (axRecord = ax.CreateAxaptaRecord(TABLE_NAME))
                {
                    // Execute the query on the table.
                    axRecord.ExecuteStmt(string.Format("select * from %1 where %1.PersonnelNumber == '{0}'", personnelNumber));

                    if (axRecord.Found)
                    {
                        var emp = new Employee()
                        {
                            PersonnelNumber = axRecord.get_Field(PERSONNEL_NUMBER).ToString(),
                            Worker          = (long)axRecord.get_Field(WORKER),
                            EmplCompany     = axRecord.Company,
                            Name            = axRecord.Call("name").ToString()
                        };
                        return(emp);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error encountered: {0}", ex.Message);
                return(null);
            }
        }
Esempio n. 10
0
        }                                       // AX Company for create Employee Leaves
        #endregion

        #region Methods
        public static List <Employee> GetEmployees(string _supervisor = "")
        {
            var          employees = new List <Employee>();
            Axapta       ax;
            AxaptaRecord axRecord;

            try
            {
                // Login to Microsoft Dynamics AX.
                ax = new Axapta();
                ax.Logon(null, null, null, null);

                // Create a query using the AxaptaRecord class
                // for the StateAddress table.
                using (axRecord = ax.CreateAxaptaRecord(TABLE_NAME))
                {
                    // Execute the query on the table.
                    axRecord.ExecuteStmt("select * from %1 ");

                    while (axRecord.Found)
                    {
                        var emp = new Employee()
                        {
                            PersonnelNumber = axRecord.get_Field(PERSONNEL_NUMBER).ToString(),
                            Worker          = (long)axRecord.get_Field(WORKER),
                            EmplCompany     = axRecord.Company,
                            Name            = axRecord.Call("name").ToString()
                        };
                        employees.Add(emp);
                        axRecord.Next();
                    }
                    return(employees);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error encountered: {0}", ex.Message);
                throw;
            }
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            Axapta Ax = new Axapta();
            Ax.Logon(null, null, null, null);
            string className = "ZFS_TestXML";
            string methodName = "getResultTable";
            string paramList = null;

            AxaptaObject axObj = Ax.CreateAxaptaObject(className);
            AxaptaRecord ret = null;
            if (paramList != null)
                ret = (AxaptaRecord)axObj.Call(methodName, paramList);
            else
                ret = (AxaptaRecord)axObj.Call(methodName);

            while (ret.Found)
            {
                ret.get_Field(2);
            }

            axObj.Dispose();
        }