send etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
send etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

7 Temmuz 2017 Cuma

AX 2012 - Send data from server class to form with TempDB

If you try to send data from server class to form with TempDB by parameter you'll see no data will be came. You may select In Memory table or use linkPhysicalTableInstance method to link two TempDB table:

Class:

public static server void populateData(MyTempTable _tmp)
{
MyTempTable tmp;
...
...
tmp.linkPhysicalTableInstance(_tmp);
...
...
return;
}

Form:


MyClass::populateData(MyTempTable);
MyTempTable_DS.research();
MyTempTable_DS.refresh();

8 Ekim 2015 Perşembe

Axapta - Send and receive dataset

I took this code part from Fatih Demirci's developments.

Send dataset:
 

    System.Data.DataTable               dataTable;
    System.Data.DataColumnCollection    dataTableColumns;
    System.Data.DataRowCollection       DataRowCollection;
    System.Data.DataRow                 tmpRow;
    System.Data.DataSet dataset = new System.Data.DataSet();
    System.Data.DataTableCollection     dataTableCollection;


    dataTable = new System.Data.DataTable();
    dataTableColumns = dataTable.get_Columns();

//Describe lines
    dataTableColumns.Add("ACCOUNTNO", System.Type::GetType("System.String"));
    dataTableColumns.Add("ITEMNO", System.Type::GetType("System.String"));
    dataTableColumns.Add("TOACCOUNTNUM", System.Type::GetType("System.String"));
    dataTableColumns.Add("RETURNREASONIDD", System.Type::GetType("System.String"));
    dataTableColumns.Add("QUANTITY", System.Type::GetType("System.Double"));
    dataTableColumns.Add("DESCRIPTION", System.Type::GetType("System.String"));
//bir satır al
    DataRowCollection = dataTable.get_Rows();
        tmpRow = dataTable.NewRow();
//fill lines
    tmpRow.set_Item("ACCOUNTNO","MU_014600");
    tmpRow.set_Item("ITEMNO","200.05.01.0306");
    tmpRow.set_Item("TOACCOUNTNUM","MU_014600");
    tmpRow.set_Item("RETURNREASONIDD","");
    tmpRow.set_Item("QUANTITY",11);
    tmpRow.set_Item("DESCRIPTION","");

    DataRowCollection.Add(tmpRow);

     dataTable.AcceptChanges();
//At this time if opposite side needs data table, it's ready

//In the other case if wants dataset, tie to dataset
     dataTableCollection     = dataSet.get_Tables();
     dataTableCollection.Add(datatable);
//now dataset ready too


Receive dataset:

    System.Data.DataTable               dataTable;
    System.Data.DataTableCollection     dataTableCollection;
    System.Data.DataColumnCollection    dataColumnCollection;
    System.Data.DataRowCollection       dataRowCollection;
    System.Data.DataRow                 dataRow;
    System.Data.DataColumn              dataColumn;
    System.Data.DataTable               returnData;
;


        dataTableCollection     = dataSet.get_Tables();
        totalTable              = dataTableCollection.get_Count();
        for(i = 0; i < totalTable; i ++)
        {
            dataTable               = dataTableCollection.get_Item(i);
            dataColumnCollection    = dataTable.get_Columns();
            DataRowCollection       = dataTable.get_Rows();
            totalRow                = dataRowCollection.get_Count();
            totalCol                = dataColumnCollection.get_Count();
            for( j = 0; j < totalRow; j ++)
            {
                dataRow         = dataRowCollection.get_Item(j);
                custAccount     = dataRow.get_Item("ACCOUNTNO");
                itemId          = dataRow.get_Item("ITEMNO");
                toCustAccount   = dataRow.get_Item("TOACCOUNTNUM");
                strtext         = dataRow.get_Item("RETURNREASONIDD");
                krc_DefectiveId = str2int64(strtext);
                strtext         = dataRow.get_Item("QUANTITY");
                _b2bdesc        = dataRow.get_Item("DESCRIPTION");
...

6 Ocak 2014 Pazartesi

AXAPTA - Send email

private void SendMail2(str _FileName,Str60 _Subject,Notes _Body)
{

   str Toaddress;
   System.Net.Mail.MailMessage Msg =  new System.Net.Mail.MailMessage();
   System.Net.Mail.MailAddress fromMail;
   System.Net.Mail.MailAddressCollection toadrr;
   System.Net.Mail.SmtpClient smCL = new System.Net.Mail.SmtpClient();
   System.Net.NetworkCredential credential;
   str          bodygrd,sSmtpServer;
   CLRObject   exc;
   CLRObject   innerExc;
   CLRObject   clrExcMessage;
   str         strError;
   SysEmailParameters EmailParm;
   str pass;
   System.Net.Mail.AttachmentCollection  mailAttachementCollection;
   System.Net.Mail.Attachment            mailAttachment;
;

toaddress="test@hotmail.com";


    EmailParm = SysEmailParameters::find();
    pass = SysEmailParameters::password();
    credential = new System.Net.NetworkCredential(EmailParm.SMTPUserName,pass);
    fromMail = new System.Net.Mail.MailAddress(EmailParm.SMTPUserName);
    new InteropPermission(InteropKind::ClrInterop).assert();
  try
  {
    Msg.set_From(fromMail);
    toadrr = Msg.get_To();
    toadrr.Add(new System.Net.Mail.MailAddress(toaddress));
    Msg.set_Subject(_Subject);
    Msg.set_Body(_body);
    Msg.set_IsBodyHtml(true);
    sSmtpServer =  EmailParm.SMTPRelayServerName;
    smCL.set_Host(sSmtpServer);
    mailAttachementCollection = msg.get_Attachments();
        mailAttachment = new System.Net.Mail.Attachment(_fileName);
        mailAttachementCollection.Add(mailAttachment);
    smCL.set_Port(EmailParm.SMTPPortNumber);
    smCL.set_EnableSsl(true);
    smCL.set_Credentials(credential);
    smCL.Send(Msg);
  }     catch( Exception::CLRError )
                   {
                        exc = CLRInterop::getLastException();
                        if( exc )
                        {
                           clrExcMessage = exc.get_Message();
                           innerExc = exc.get_InnerException();
                           while(innerExc != null)
                           {
                              clrExcMessage = innerExc.get_Message();
                              innerExc = innerExc.get_InnerException();
                           }
                           strError = CLRInterop::getAnyTypeForObject( clrExcMessage );
                           throw error(strError);
                        }
                   }
}