Calendar

September 2008
SunMonTueWedThuFriSat
 << < > >>
 123456
78910111213
14151617181920
21222324252627
282930    

Iserting Values Using StoredProcedure

public void InsertStored()
{
    LoginProperty loginProperty;
    OdbcConnection connection;
    Statement statement;
    Str sqlStatement,sql;
    SqlStatementExecutePermission sqlPermission;
    ;
    loginProperty = new LoginProperty();
  //  loginProperty.setServer("AGIL-SPS-DB");
  //  LoginProperty.setDatabase("Dynamics_28112007");
     loginProperty.setServer("AGIL-Ax-DB");
     LoginProperty.setDatabase("Savior_TOS");

    try
    {

        connection = new OdbcConnection(loginProperty);
        connection.ttsbegin();
        statement = connection.createStatement();
        sqlStatement =strfmt(
        "'%1','%2','%3','%4'",
        'Y',
        'Test',
        'TestName',
        '1234');
         sql=strfmt("exec dbo.Axapta_Employee %1",sqlStatement);
        sqlPermission = new SQLStatementExecutePermission(sql);
        sqlPermission.assert();
        statement.executeUpdate(sql);
        CodeAccessPermission::revertAssert();
        connection.ttscommit();
        info("Inserted Successfully");
    }
    catch (Exception::Error)
    {
        error(strFmt("Error has been occured while Inserting Data"));
    }
}

05 Sep 2008
Admin · 1 view · Leave a comment
Customer Amount Invoicing
class WI_PostingCustAmount
{
    CustInvoiceTable                custInvoiceTable;
    CustInvoiceLine                 custInvoiceLine;
}
void InvoiceBookingLine()
{

    InventPosting               inventPosting;
    Real    TotalInvoicedAmount;
    ;


   // select custInvoiceTable ;//where custInvoiceTable.RefSalesBookingRecId == _salesBookingTable.RecId && custInvoiceTable.W_SaleAdvance == NoYes::Yes;

    custInvoiceLine.ParentRecId = custInvoiceTable.RecId;
   // custInvoiceLine.Dimension[1]       = ProjTable::find(_salesBookingTable.ProjectId).Dimension[1];
  //  custInvoiceLine.Dimension[2]       = ProjTable::find(_salesBookingTable.ProjectId).Dimension[2];
  //  custInvoiceLine.Dimension[3]       = ProjTable::find(_salesBookingTable.ProjectId).Dimension[3];
    custInvoiceLine.LedgerAccount ="1002";// InventPosting::Wipro_account(InventAccountType::W_SalesBookingAdvance,custInvoiceTable.OrderAccount,custInvoiceTable.CustGroup,'');
    custInvoiceLine.TaxItemGroup = LedgerTable::find(custInvoiceLine.LedgerAccount).TaxItemGroup;
    custInvoiceLine.AmountCur = 123;
    custInvoiceLine.LineNum=1;
    custInvoiceLine.Description = "Test Transaction";
    custInvoiceLine.InvoiceTxt="Test Free Text Invoice";
    custInvoiceLine.insert();

}
void InvoiceBookingTable()
{
    ;
    custInvoiceTable.OrderAccount       ="1";
    custInvoiceTable.CustGroup          ="TCGRP" ;
   // custInvoiceTable.RefSalesBookingId  = ;

    custInvoiceTable.InvoiceDate        = systemdateget();
    custInvoiceTable.LanguageId         = CustTable::find("1").LanguageId;
    custInvoiceTable.CurrencyCode       = CustTable::find("1").Currency;

    custInvoiceTable.insert();
}
void PostInvoice()
{
    CustInvoiceTable        custInvoiceTableLocal;
    CustInvoiceLine         custInvoiceLineLocal;
    CustPostInvoiceJob      custPostInvoicejob;
    Args                    args;
    CustInvoiceJour         custinvoiceJour;
    ;
    args = New Args();
    args.record(CustInvoiceTable);
    args.parm("SalesBooking");

    try
    {
        custPostInvoiceJob::main(args);
        infolog.clear(0);
        CustInvoiceTable.reread();
        select custinvoiceJour where custinvoiceJour.InvoiceId==CustInvoiceTable.InvoiceId;
        info(strfmt(" Invoice Id %1 Posted Successfully",custinvoiceJour.InvoiceId),'',SysInfoAction_TableField::newBuffer(custinvoiceJour));
    }
    catch
    {
        ttsbegin;
        Delete_from custInvoiceTableLocal where custInvoiceTableLocal.RecId == custInvoiceTable.RecId;
        Delete_from custInvoiceLineLocal where custInvoiceLineLocal.RecId == custInvoiceLine.RecId;
        ttscommit;
        Throw error ("Did not get posted");
    }

}
static void main(Args args)
{

   W_SalesBooking  SalesBooking = New W_SalesBooking();
   ;
  SalesBooking.InvoiceBookingTable();
  SalesBooking.InvoiceBookingLine();
  SalesBooking.PostInvoice();

}
04 Sep 2008
Admin · 1 view · Leave a comment
Reading Excel Data Into Axapta

static void Test(Args _args)
{
  SysExcelApplication excel;
    SysExcelWorkbooks books;
    SysExcelWorkbook book;
    SysExcelWorkSheets sheets;
    SysExcelWorkSheet sheet;
    str _filepath = "C:\\Documents and Settings\\dineshsharma\\Desktop\\Naresh.xls";

    loginProperty       loginProperty  = new LoginProperty();
    ODBCConnection      odbcConnection;
    Statement           sql;
    ResultSet           resultSet;
    str                 sqlstr = "select name,age from [Sheet1$]";

    ;

   // super();

    try{

        excel = SysExcelApplication::construct();

        books = excel.workbooks();
        books.open(_filepath);

        sheets=excel.worksheets();
        sheet=sheets.itemFromNum(1);

        loginProperty.setDSN('NareshExcel'); // (Name of your ODBC configuration)

        odbcConnection = new ODBCConnection(loginProperty);
        sql  = odbcConnection.createStatement();
        resultSet = sql.executeQuery(sqlstr);

        // select data from excel and input fields into our table
        while(resultSet.next())
        {
         //  satishTable.StudId=resultSet.getString(1);
           //satishTable.Name=resultSet.getString(2);
           //satishTable.Age=resultSet.getInt(3);
           info(resultSet.getString(1)+resultSet.getString(2));
        }

        resultSet.close();
        books.close();
    }

    catch {
        books.close();
    }


}

08 Aug 2008
Admin · 11 views · Leave a comment
Posting Invent Profit & Loss Journal from .net
using System;
using Microsoft.Dynamics.BusinessConnectorNet;
namespace ProfitLossPostingAppl
{
      class AxProfitLossPostingEngine
     {
         static void Main(string[] args)
          {
                Axapta ax = new Axapta(); // company name, language, object server, configuration
          / / this uses Windows Authentication 
               ax.Logon("cmul", null, "localhost", null);
               try
              {
                    // Start a transaction
                     ax.TTSBegin();
                   // AxaptaRecord is a class that allows to work with Tables in AX
                   AxaptaRecord header = ax.CreateAxaptaRecord("InventJournalTable");
                   AxaptaRecord journalName = ax.CreateAxaptaRecord("InventJournalName");
                   AxaptaRecord line = ax.CreateAxaptaRecord("InventJournalTrans");
                   AxaptaRecord inventTable = ax.CreateAxaptaRecord("InventTable");
                   AxaptaRecord warehouse = ax.CreateAxaptaRecord("InventDim");
                  // You can call static table methods using the following syntax
                  journalName = ax.CallStaticRecordMethod("InventJournalName", "find", "IPL") as AxaptaRecord;
                  // There is a set of predefined methods on the AxaptaRecord class, like the clear(), initValue, DML operations, etc. header.Clear();
                header.InitValue();
               // You can call table object methods as well, not only static
                header.Call("initFromInventJournalName", journalName);
                 header.Insert();
                 line.Clear();
                 line.InitValue();
                 line.Call("initFromInventJournalTable", header);
               // You cannot use table fields directly as in X++. Instead you have set/get methods
               line.set_Field("itemId", "B-R14");
        // Instead of using static table methods (like find) you can execute a direct SQL statement and receive the result in the AxaptaRecord object
        inventTable.ExecuteStmt("select * from %1 where %1.ItemId == 'B-R14'");
    // If you receive more that one record you can iterate through them using Next (as in AX)
              line.Call("initFromInventTable", inventTable);
              line.set_Field("Qty", 160.0);
              warehouse.Clear();
               warehouse.set_Field("InventLocationId", "MW");
               warehouse = ax.CallStaticRecordMethod("InventDim", "findOrCreate", warehouse) asAxaptaRecord;         line.set_Field("InventDimId", warehouse.get_Field("inventDimId"));
           line.Insert();
     // Notice AxaptaRecord is passed by reference here
      ax.CallStaticRecordMethod("InventJournalTable", "initTotal", header);
     header.Update();
     ax.TTSCommit();
// You can call static class methods the same way you call table static methods, but using a different method on Axapta class // So in case you wrote the posting in X++, you would be able to call it, passing the JournalId as the argument // int numOfLinesPosted = (int)ax.CallStaticClassMethod("DEV_ProfitLossEngine", "postProfitLossJournal", header.get_Field("JournalId")); // Or, you can use the AxaptaObject class to accomplish the same from C# // You can initialize a new class using the Axapta class method // AxaptaObject journalCheckPost = ax.CreateAxaptaObject("InventJournalCheckPost"); // Or using a static method, if that suites your needs better // Notice here that an object of type AxaptaRecord is passed into a method that expects InventJournalTable as the argument AxaptaObject journalCheckPost = ax.CallStaticClassMethod("InventJournalCheckPost", "newPostJournal", header) as AxaptaObject; // You can object methods the same way you would on a table journalCheckPost.Call("parmShowInfoResult", false); journalCheckPost.Call("parmThrowCheckFailed", true); journalCheckPost.Call("parmTransferErrors", false); journalCheckPost.Call("run"); int numOfLinesPosted = (int)journalCheckPost.Call("numOfPostedLines"); Console.WriteLine(String.Format("{0} line(s) have been successfully posted", numOfLinesPosted)); Console.WriteLine("JournalId is " + header.get_Field("JournalId")); Console.WriteLine("Press any key to continue ..."); ax.Logoff(); } catch (Exception ex) { ax.TTSAbort(); ax.Logoff(); Console.WriteLine(ex.Message); } Console.ReadKey(); } }}
07 Aug 2008
Admin · 18 views · Leave a comment
Photo Opening using HTML

void showImage()
{
    #WinAPI

    str       html;
    str       tempdir;
    str       imgName;
    str       filename;
    BinData   bin;
    container image;
    Docuvalue docuvalue;
    DocuRef   docuref;
    str path;
    ;
    select docuref where docuref.Name==WI_PhotoUpload_ImageRef.valueStr();
    select docuvalue where docuvalue.RecId==docuref.ValueRecId;
    // Render the image associated with the current as HTML in the IE browser control
    try
    {
            path=DocuParameters::find().ArchivePath+"/"+docuvalue.Name+'.'+docuvalue.FileType;
            html = '<html><body>' +
                   '<img src="' +path+ '" border=2 width=100% height=100%>' +
                  '</body></html>';

            graph.documentHTML(html);
    }

    catch (Exception::Warning)
    {
        error(strfmt("An Error has been occured as showing photo"));
    }
}

06 Aug 2008
Admin · 11 views · Leave a comment

1, 2, 3, 4, 5, 6  Next page