static server void CopiarCliente(CustTable _CustTable)
{
CustTable newCusttable;
DirPartyTable DirPartyTable;
DirPartyPostalAddressView DirPartyPostalAddressView;
DirPartyPostalAddressView DirPartyPostalAddressViewNew;
LogisticsPostalAddressView LogisticsPostalAddressView;
#define.F('F')
#define.R('R')
DirParty DirParty;
DirParty DirPartyOld;
DirPartyContactInfoView DirPartyContactInfoView;
DirPartyContactInfoView DirPartyContactInfoViewNew;
LogisticsElectronicAddress LogisticsElectronicAddress;
;
if(_CustTable)
{
try
{
ttsBegin;
newCusttable.clear();
newCusttable.data(_CustTable);
newCusttable.Party =0;
newCusttable.initFromCustGroup(CustGroup::find(_CustTable.CustGroup));
newCusttable.AccountNum =strReplace(_CustTable.AccountNum,#F,#R) ;
newCusttable.insert();
///////
DirParty =DirParty::constructFromPartyRecId(newCusttable.Party);
DirPartyOld =DirParty::constructFromPartyRecId(_CustTable.Party);
//////Agregar nombre
DirPartyTable =DirPartyTable::findRec(newCusttable.Party,true);
DirPartyTable.initFromDirParty(DirPartyOld);
ttsBegin;
DirPartyTable.update();
ttsCommit;
///agregar direcciones
while select * from DirPartyPostalAddressView
where DirPartyPostalAddressView.Party==_CustTable.Party
{
///inicializar la vista con la direccion
LogisticsPostalAddressView.initFromPartyPostalAddressView(DirPartyPostalAddressView);
///inicializar la direccion
DirPartyPostalAddressViewNew.initFromPostalAddressView(LogisticsPostalAddressView);
//insertar la direccion
DirParty.createOrUpdatePostalAddress(DirPartyPostalAddressViewNew);
}
DirParty =DirParty::constructFromPartyRecId(newCusttable.Party);
///agregar Contacto
while select * from DirPartyContactInfoView
where DirPartyContactInfoView.Party==_CustTable.Party
{
///inicializar la vista con la direccion
LogisticsElectronicAddress=LogisticsElectronicAddress::findRecId(DirPartyContactInfoView.ElectronicAddress);
DirPartyContactInfoViewNew.Locator = LogisticsElectronicAddress.Locator;
DirPartyContactInfoViewNew.Type = LogisticsElectronicAddress.Type;
DirPartyContactInfoViewNew.LocatorExtension = LogisticsElectronicAddress.LocatorExtension;
DirPartyContactInfoViewNew.CountryRegionCode = LogisticsElectronicAddress.CountryRegionCode;
DirPartyContactInfoViewNew.IsPrimary = LogisticsElectronicAddress.IsPrimary;
DirPartyContactInfoViewNew.IsPrivate = LogisticsElectronicAddress.IsPrivate;
DirPartyContactInfoViewNew.IsMobilePhone = LogisticsElectronicAddress.IsMobilePhone;
DirPartyContactInfoViewNew.IsInstantMessage = LogisticsElectronicAddress.IsInstantMessage;
//DirPartyContactInfoViewNew.LocationName = LogisticsElectronicAddress.LocationName;
//LogisticsElectronicAddress =LogisticsElectronicAddress::findRecId(DirPartyContactInfoView.ElectronicAddress);
//DirPartyContactInfoViewNew.initFromElectronicAddress(LogisticsElectronicAddress);
//insertar la direccion
DirParty.createOrUpdateContactInfo(DirPartyContactInfoViewNew);
}
ttsCommit;
}
catch
{
throw(error("Error"));
}
}
}
No hay comentarios:
Publicar un comentario