static void CreatePO(Args _args)
{
NumberSeq numseq;
PurchTable purchTable;
PurchLine purchLine;
PurchFormLetter purchFormLetter;
Dialog dialog;
DialogField dialogField;
int i,j;
CCADOConnection adoConnection;
CCADOCommand adoCommand;
CCADORecordSet adoRecordSet;
CCADOFields adoFields;
CCADOField adoField;
;
adoConnection = new CCADOConnection();
adoRecordSet = new CCADORecordSet();
adoConnection.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= 'c:\\file.xls' ;Extended Properties='Excel 8.0;HDR=No;IMEX=1'");
adoCommand = new CCADOCommand();
adoCommand.activeConnection(adoConnection);
adoCommand.commandText(@"SELECT * FROM [SHEET1$]");
ttsbegin;
numseq = NumberSeq::newGetNumFromCode(PurchParameters::numRefPurchId().NumberSequence,true);
//initialize purchase order values
purchTable.initValue();
purchTable.PurchId = numseq.num();
purchTable.OrderAccount = '1002';
purchTable.initFromVendTable();
if(!purchTable.validateWrite())
{
throw Exception::Error;
}
purchTable.insert();
//Inserting Purchase Lines
adoRecordSet = adoCommand.execute();
while(!adoRecordSet.EOF())
{
adoFields = adoRecordSet.fields();
i=0;
while(i<adoFields.count()-1)
{
purchLine.clear();
purchLine.PurchId = purchTable.PurchId;
purchline.ItemId = adoFields.itemIdx(i).value();
i++;
purchline.PurchQty = adoFields.itemIdx(i).value();
purchLine.createLine(true,true,true,true,true,false);
}
adoRecordSet.recordSet().moveNext();
}
//invoiceing the entries using purchFormLetter Class
purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.update(purchTable,"Inv_"+purchTable.PurchId,systemdateget());
if (PurchTable::find(purchTable.PurchId).DocumentStatus == DocumentStatus::Invoice)
{
info(strfmt("Posted invoiced journal for purchase order %1",purchTable.PurchId));
}
}
{
NumberSeq numseq;
PurchTable purchTable;
PurchLine purchLine;
PurchFormLetter purchFormLetter;
Dialog dialog;
DialogField dialogField;
int i,j;
CCADOConnection adoConnection;
CCADOCommand adoCommand;
CCADORecordSet adoRecordSet;
CCADOFields adoFields;
CCADOField adoField;
;
adoConnection = new CCADOConnection();
adoRecordSet = new CCADORecordSet();
adoConnection.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= 'c:\\file.xls' ;Extended Properties='Excel 8.0;HDR=No;IMEX=1'");
adoCommand = new CCADOCommand();
adoCommand.activeConnection(adoConnection);
adoCommand.commandText(@"SELECT * FROM [SHEET1$]");
ttsbegin;
numseq = NumberSeq::newGetNumFromCode(PurchParameters::numRefPurchId().NumberSequence,true);
//initialize purchase order values
purchTable.initValue();
purchTable.PurchId = numseq.num();
purchTable.OrderAccount = '1002';
purchTable.initFromVendTable();
if(!purchTable.validateWrite())
{
throw Exception::Error;
}
purchTable.insert();
//Inserting Purchase Lines
adoRecordSet = adoCommand.execute();
while(!adoRecordSet.EOF())
{
adoFields = adoRecordSet.fields();
i=0;
while(i<adoFields.count()-1)
{
purchLine.clear();
purchLine.PurchId = purchTable.PurchId;
purchline.ItemId = adoFields.itemIdx(i).value();
i++;
purchline.PurchQty = adoFields.itemIdx(i).value();
purchLine.createLine(true,true,true,true,true,false);
}
adoRecordSet.recordSet().moveNext();
}
//invoiceing the entries using purchFormLetter Class
purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.update(purchTable,"Inv_"+purchTable.PurchId,systemdateget());
if (PurchTable::find(purchTable.PurchId).DocumentStatus == DocumentStatus::Invoice)
{
info(strfmt("Posted invoiced journal for purchase order %1",purchTable.PurchId));
}
}
No comments:
Post a Comment