Wednesday, 15 December 2010

How to open TIF Image files in Dynamics AX

Today I’m going to discuss about one of another important feature in Dynamics AX. As well as the Other Programming languages, Axapta is supporting ActiveX object handling.
ActiveX control is a small program, which contains set of instruction & functions. Sometimes it’s called as add-ons.

Generally we can create an image viewer using this ActiveX object. In standard AX is coming with “Microsoft Web Browser” class for handling the Image Viewer ActiveX Control. But this viewer is accepting limited image file formats such as .JPG, GIF…

So I’m going to explain, powerful image viewer ActiveX control which supports a lot of popular image file extension, including TIFF, MNG, JNG,  BMP, GIF, ICO, JPEG,  PCX, PNG, PSD, WMF, WBMP, TGA, PGX, RAS, PNM.

That image Viewer ActiveX Control & Type Library is coming with Microsoft Office Package. That Is called “Microsoft Office Document Imaging 2003 (MODI)” model.

Step 1: When ActiveX control is placed in your PC, we have to get those files in to the Axapta using Wrapper Class. That can be done as follows,

Tools \ Development Tools \ Wizards \ COM Class Wrapper Wizard & go “Next”

Step 2:  select the “Microsoft Office Document Imaging 12.0 Type Library”. & click “Next”

Step 3: Enter an element mask. That will be appended to the front of the all elements generated by Wizard. In my example I’ve chosen “INDMODI”. & click “Next”.

Step 4: Create a new form & add ActiveX Control by right click on the design
In the ActiveX browser select the “Microsoft Office Document Imaging Viewer Control 12.0”.

Step 5: we need to specify the image path to open the file. For that add following code to the form


//Declaring Variable
public class FormRun extends ObjectRun
{
    INDMODIDocument    modiDocument;
}

//Initialize the Image path
public void init()
{
   ;
    super();
    activex.filename("Z:\\Images\\TestImage.gfd");
}


public void run()
{
    try
    {
        if(activeX.document())
        {
            modiDocument = new UKMODIDocument(activeX.document());
            super();
        }
    }
    catch (Exception::Error)
    {
        activeX.filename('');
    }
}


//Clear the Memory & Buffer
public void close()
{
    super();
    modiDocument.Close();
    activex.filename('');
}


Wednesday, 8 December 2010

Retrieve External Data using ODBC connection in Dynamics AX

When I’m flying in Dynamics AX world, I found most of the AX users are struggling to handle data from out source (External source such as MS-Access Database, Oracle Database, etc....).

In below I’m going to explain, how we can connect to the External Database using ODBC(Open Database Connectivity) Connection & retrieve data from that DB.

First we have to create a ODBC Datasource which has connected our Database. In my Example i have used DS as my Datasource name.

server static void GetShippingTrans(CustTable custTable)
{

     // Variable Declaration
LoginProperty lP;
OdbcConnection con;
Statement st;
ResultSet rS;
Str sqlS;
str databaseName = "Test"; 
MyShippingTrans trans;
SqlStatementExecutePermission sqlPermission;
;

// Initialize new Login Property
lP= new LoginProperty();

// Set DSN to the Login Property
lP.setDSN(DS);

//Set the correct DataBase to retrieve Data (May have more than one Database in that DSN)
lP.setDatabase(databaseName);

try
{

 //Create ODBC Connection by using Login Property
con= new OdbcConnection(lP);
st= con.createStatement();

//SQL Statement to select the Records from the Table
sqlS = StrFmt("SELECT %1, %2, %3 FROM Customer WHERE " +
"Customer.id = '%4',"Name", "DOB", "Height", custTable.CustId );

//Create a permission to execute SQL Statement
sqlPermission = new SQLStatementExecutePermission(sqlS);
sqlPermission.assert();

//Execute SQL Statement & retrieve the result set
            rS = st.executeQuery(sqlS);

while (rs.next())
{
            //Manipulate retrieved data.......
                     info(strFmt("Cust Name :%1    DOB : %2    Hieght : %3 "
                     ,rs.getString(1), rs.getDate(2), rs.getReal(3)));
}
CodeAccessPermission::revertAssert();
}
catch (Exception::Error)
{
            error(strFmt("Error accessing Customer database"));
}
}


I hope, now everyone has an idea about retrieving data from external data base & manipulating those fetched data.

Friday, 3 December 2010

Microsoft SQL Shedule Backup

Step 1: Open Object explorer in SQL and select “Management” ---> Maintenance Plans

Step 2: Create a new maintenance plan for Shedule Backup

Step 3: A new window pops up and asking for the name of the plan.


Step 4: Once entered, another new window opens


Step 5:  On the Top Left corner (Marked by red color box), from the Maintenance Plan Tasks, select “Back up Database Task”.


Step 6: Drag and drop “Back up Database Task” to Design part


Step 7:  Double click the Box and a window opens as follows:


Step 8: Select the Database to be taken back up


Step 9: Select the folder where the database has to be taken back up  and also enter the frequency when the database back up has to take place.