// To create Employee thorugh X++
private void createEmployee(System.Data.SqlClient.SqlDataReader dr1)
{
CompanyInfo companyInfo;
HcmEmploymentRecId newEmploymentRecId;
ValidFromDateTime employmentStartDateTime;
ValidToDateTime employmentEndDateTime;
HcmWorker newHcmWorker;
DirPerson dirPerson;
DirPersonName dirPersonName;
HcmEmploymentType hcmEmploymentType = HcmEmploymentType::Employee;
NumberSeq numberSeqPersonnelNum;
HcmPersonPrivateDetails HcmPersonPrivateDetails;
HcmEmployment hcmEmployment;
HcmWorkerTitle hcmWorkerTitle;
DirParty dirparty;
DirPartyContactInfoView contactView;
HcmPersonDetails persondetails;
HcmPersonIdentificationNumber hcmPersonIdentificationNumber;
utcdatetime _validFrom = DateTimeUtil::utcNow();
Struct struct;
container ledgerDimension;
DimensionDefault DimensionDefault;
int k;
TransDate HireDate,DOB;
HcmPersonID Employeecode;
str FirstName,Title,MobilePhone,email,MaritalStatus,NationalityCode,NationalityName,PaymentMode,MiddleName,LastName;
str DepartmentCode,DepartmentName,SubDivisionCode,SubDivisionName,DivisionCode,DivisionName ,SectorCode, SectorName;
str DesignationCode,DesignationName,SponsorCode,SponsorDesc,MOLNo,PASSPORTNUMBER,Gender,BloodGroup,ReligionCategory,EmployeeCategory,Emiratization;
;
Employeecode = dr1.get_Item('Employeecode'); FirstName = dr1.get_Item('FirstName'); MiddleName = dr1.get_Item('Middlename'); LastName = dr1.get_Item('Lastname');
Title = dr1.get_Item('Title'); MobilePhone = dr1.get_Item('MobilePhone');
email = dr1.get_Item('email'); DOB = dr1.get_Item('DOB');
MaritalStatus = dr1.get_Item('MaritalStatus'); NationalityCode = dr1.get_Item('NationalityCode');
NationalityName = dr1.get_Item('NationalityName'); HireDate = dr1.get_Item('HireDate');
PaymentMode = dr1.get_Item('PaymentMode'); DepartmentCode = dr1.get_Item('DepartmentCode');
DepartmentName = dr1.get_Item('DepartmentName'); //SubDivisionCode = dr1.get_Item('SubDivisionCode');
// SubDivisionName = dr1.get_Item('SubDivisionName'); // DivisionCode = dr1.get_Item('DivisionCode');
// DivisionName = dr1.get_Item('DivisionName'); // SectorCode = dr1.get_Item('SectorCode');
// SectorName = dr1.get_Item('SectorName'); DesignationCode = dr1.get_Item('DesignationCode');
DesignationName = dr1.get_Item('DesignationName'); //SponsorCode = dr1.get_Item('SponsorCode');
SponsorDesc = dr1.get_Item('SponsorName');
MOLNo = dr1.get_Item('MOLNo');
PASSPORTNUMBER = dr1.get_Item('PASSPORTNUMBER');
Gender = dr1.get_Item('Gender');
BloodGroup = dr1.get_Item('BloodGroup');
ReligionCategory = dr1.get_Item('ReligionCategory');
EmployeeCategory = dr1.get_Item('EmployeeCategory');
Emiratization = dr1.get_Item('Emiratization');
companyInfo = companyInfo::find();
newHcmWorker = HcmWorker::findByPersonnelNumber(Employeecode);
if(! newHcmWorker)
{
employmentStartDateTime = datetobeginUtcDateTime(HireDate, DateTimeUtil::getUserPreferredTimeZone());
employmentEndDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::maxValue(), DateTimeUtil::getUserPreferredTimeZone());
dirPersonName.FirstName = FirstName;
dirPersonName.MiddleName = Middlename;
dirPersonName.LastName = LastName;
newHcmWorker = HcmWorker::find(HcmWorkerTransition::newCreateHcmWorker(dirPersonName
, Employeecode
, companyInfo.RecId
, hcmEmploymentType
, employmentStartDateTime
, employmentEndDateTime));
}
else
{
dirPersonName = DirPersonName::find(newHcmWorker.Person,true);
dirPersonName.FirstName = FirstName;
dirPersonName.MiddleName = Middlename;
dirPersonName.LastName = LastName;
dirPersonName.update();
}
hcmPersonPrivateDetails = HcmPersonPrivateDetails::findByPerson(newHcmWorker.Person,true);
hcmPersonPrivateDetails.initValue();
hcmPersonPrivateDetails.Person = dirPersonName.Person;
hcmPersonPrivateDetails.BirthDate = DOB;
hcmPersonPrivateDetails.Gender = SQLIntegration::convGender(Gender);
hcmPersonPrivateDetails.CitizenshipCountryRegion = NationalityCode;
hcmPersonPrivateDetails.BloodGroup = SQLIntegration::convBlood(BloodGroup);
hcmPersonPrivateDetails.ReligionCategory = SQLIntegration::convReligion(ReligionCategory);
hcmPersonPrivateDetails.EmployeeCategory = SQLIntegration::convEmployeeCategory(EmployeeCategory);
hcmPersonPrivateDetails.Emiratization = SQLIntegration::convEmiratization(Emiratization);
if(hcmPersonPrivateDetails)
hcmPersonPrivateDetails.update();
else
hcmPersonPrivateDetails.insert();
persondetails = HcmPersonDetails::findByPerson(newHcmWorker.Person);
persondetails.initValue();
persondetails.Person = dirPersonName.Person;
persondetails.MaritalStatus = SQLIntegration::convMarital(MaritalStatus);
persondetails.ValidFrom = DateTimeUtil::utcNow();
persondetails.ValidTo = DateTimeUtil::maxValue();
//if (persondetails)
//{
//persondetails.selectForUpdate(true);
//persondetails.update();
//}
//else
//{
persondetails.insert();
//}
hcmWorkerTitle = HcmWorkerTitle::findByWorker(newHcmWorker.RecId);
hcmWorkerTitle.initValue();
hcmWorkerTitle.Worker = newHcmWorker.RecId;
hcmWorkerTitle.Title = HcmTitle::findByTitle(DesignationCode).RecId;
hcmWorkerTitle.ValidFrom = DateTimeUtil::utcNow();
hcmWorkerTitle.ValidTo = DateTimeUtil::maxValue();
//if(hcmWorkerTitle)
//{
//hcmWorkerTitle.selectForUpdate(true);
//hcmWorkerTitle.update();
//}
//else
//{
hcmWorkerTitle.insert();
//}
hcmPersonIdentificationNumber = HcmPersonIdentificationNumber::findByPersonAndType(newHcmWorker.RecId,HcmIdentificationType::findByIdentificationType("SponsorCode").RecId);
hcmPersonIdentificationNumber.Person = dirPersonName.Person;
hcmPersonIdentificationNumber.IdentificationType = HcmIdentificationType::findByIdentificationType("SponsorCode").RecId;
hcmPersonIdentificationNumber.IdentificationNumber = SponsorCode;
hcmPersonIdentificationNumber.Description = SponsorDesc;
if(hcmPersonIdentificationNumber)
{
hcmPersonIdentificationNumber.selectForUpdate(true);
hcmPersonIdentificationNumber.update();
}
else
{
hcmPersonIdentificationNumber.insert();
}
hcmPersonIdentificationNumber.clear();
hcmPersonIdentificationNumber = HcmPersonIdentificationNumber::findByPersonAndType(newHcmWorker.RecId,HcmIdentificationType..
private void createEmployee(System.Data.SqlClient.SqlDataReader dr1)
{
CompanyInfo companyInfo;
HcmEmploymentRecId newEmploymentRecId;
ValidFromDateTime employmentStartDateTime;
ValidToDateTime employmentEndDateTime;
HcmWorker newHcmWorker;
DirPerson dirPerson;
DirPersonName dirPersonName;
HcmEmploymentType hcmEmploymentType = HcmEmploymentType::Employee;
NumberSeq numberSeqPersonnelNum;
HcmPersonPrivateDetails HcmPersonPrivateDetails;
HcmEmployment hcmEmployment;
HcmWorkerTitle hcmWorkerTitle;
DirParty dirparty;
DirPartyContactInfoView contactView;
HcmPersonDetails persondetails;
HcmPersonIdentificationNumber hcmPersonIdentificationNumber;
utcdatetime _validFrom = DateTimeUtil::utcNow();
Struct struct;
container ledgerDimension;
DimensionDefault DimensionDefault;
int k;
TransDate HireDate,DOB;
HcmPersonID Employeecode;
str FirstName,Title,MobilePhone,email,MaritalStatus,NationalityCode,NationalityName,PaymentMode,MiddleName,LastName;
str DepartmentCode,DepartmentName,SubDivisionCode,SubDivisionName,DivisionCode,DivisionName ,SectorCode, SectorName;
str DesignationCode,DesignationName,SponsorCode,SponsorDesc,MOLNo,PASSPORTNUMBER,Gender,BloodGroup,ReligionCategory,EmployeeCategory,Emiratization;
;
Employeecode = dr1.get_Item('Employeecode'); FirstName = dr1.get_Item('FirstName'); MiddleName = dr1.get_Item('Middlename'); LastName = dr1.get_Item('Lastname');
Title = dr1.get_Item('Title'); MobilePhone = dr1.get_Item('MobilePhone');
email = dr1.get_Item('email'); DOB = dr1.get_Item('DOB');
MaritalStatus = dr1.get_Item('MaritalStatus'); NationalityCode = dr1.get_Item('NationalityCode');
NationalityName = dr1.get_Item('NationalityName'); HireDate = dr1.get_Item('HireDate');
PaymentMode = dr1.get_Item('PaymentMode'); DepartmentCode = dr1.get_Item('DepartmentCode');
DepartmentName = dr1.get_Item('DepartmentName'); //SubDivisionCode = dr1.get_Item('SubDivisionCode');
// SubDivisionName = dr1.get_Item('SubDivisionName'); // DivisionCode = dr1.get_Item('DivisionCode');
// DivisionName = dr1.get_Item('DivisionName'); // SectorCode = dr1.get_Item('SectorCode');
// SectorName = dr1.get_Item('SectorName'); DesignationCode = dr1.get_Item('DesignationCode');
DesignationName = dr1.get_Item('DesignationName'); //SponsorCode = dr1.get_Item('SponsorCode');
SponsorDesc = dr1.get_Item('SponsorName');
MOLNo = dr1.get_Item('MOLNo');
PASSPORTNUMBER = dr1.get_Item('PASSPORTNUMBER');
Gender = dr1.get_Item('Gender');
BloodGroup = dr1.get_Item('BloodGroup');
ReligionCategory = dr1.get_Item('ReligionCategory');
EmployeeCategory = dr1.get_Item('EmployeeCategory');
Emiratization = dr1.get_Item('Emiratization');
companyInfo = companyInfo::find();
newHcmWorker = HcmWorker::findByPersonnelNumber(Employeecode);
if(! newHcmWorker)
{
employmentStartDateTime = datetobeginUtcDateTime(HireDate, DateTimeUtil::getUserPreferredTimeZone());
employmentEndDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::maxValue(), DateTimeUtil::getUserPreferredTimeZone());
dirPersonName.FirstName = FirstName;
dirPersonName.MiddleName = Middlename;
dirPersonName.LastName = LastName;
newHcmWorker = HcmWorker::find(HcmWorkerTransition::newCreateHcmWorker(dirPersonName
, Employeecode
, companyInfo.RecId
, hcmEmploymentType
, employmentStartDateTime
, employmentEndDateTime));
}
else
{
dirPersonName = DirPersonName::find(newHcmWorker.Person,true);
dirPersonName.FirstName = FirstName;
dirPersonName.MiddleName = Middlename;
dirPersonName.LastName = LastName;
dirPersonName.update();
}
hcmPersonPrivateDetails = HcmPersonPrivateDetails::findByPerson(newHcmWorker.Person,true);
hcmPersonPrivateDetails.initValue();
hcmPersonPrivateDetails.Person = dirPersonName.Person;
hcmPersonPrivateDetails.BirthDate = DOB;
hcmPersonPrivateDetails.Gender = SQLIntegration::convGender(Gender);
hcmPersonPrivateDetails.CitizenshipCountryRegion = NationalityCode;
hcmPersonPrivateDetails.BloodGroup = SQLIntegration::convBlood(BloodGroup);
hcmPersonPrivateDetails.ReligionCategory = SQLIntegration::convReligion(ReligionCategory);
hcmPersonPrivateDetails.EmployeeCategory = SQLIntegration::convEmployeeCategory(EmployeeCategory);
hcmPersonPrivateDetails.Emiratization = SQLIntegration::convEmiratization(Emiratization);
if(hcmPersonPrivateDetails)
hcmPersonPrivateDetails.update();
else
hcmPersonPrivateDetails.insert();
persondetails = HcmPersonDetails::findByPerson(newHcmWorker.Person);
persondetails.initValue();
persondetails.Person = dirPersonName.Person;
persondetails.MaritalStatus = SQLIntegration::convMarital(MaritalStatus);
persondetails.ValidFrom = DateTimeUtil::utcNow();
persondetails.ValidTo = DateTimeUtil::maxValue();
//if (persondetails)
//{
//persondetails.selectForUpdate(true);
//persondetails.update();
//}
//else
//{
persondetails.insert();
//}
hcmWorkerTitle = HcmWorkerTitle::findByWorker(newHcmWorker.RecId);
hcmWorkerTitle.initValue();
hcmWorkerTitle.Worker = newHcmWorker.RecId;
hcmWorkerTitle.Title = HcmTitle::findByTitle(DesignationCode).RecId;
hcmWorkerTitle.ValidFrom = DateTimeUtil::utcNow();
hcmWorkerTitle.ValidTo = DateTimeUtil::maxValue();
//if(hcmWorkerTitle)
//{
//hcmWorkerTitle.selectForUpdate(true);
//hcmWorkerTitle.update();
//}
//else
//{
hcmWorkerTitle.insert();
//}
hcmPersonIdentificationNumber = HcmPersonIdentificationNumber::findByPersonAndType(newHcmWorker.RecId,HcmIdentificationType::findByIdentificationType("SponsorCode").RecId);
hcmPersonIdentificationNumber.Person = dirPersonName.Person;
hcmPersonIdentificationNumber.IdentificationType = HcmIdentificationType::findByIdentificationType("SponsorCode").RecId;
hcmPersonIdentificationNumber.IdentificationNumber = SponsorCode;
hcmPersonIdentificationNumber.Description = SponsorDesc;
if(hcmPersonIdentificationNumber)
{
hcmPersonIdentificationNumber.selectForUpdate(true);
hcmPersonIdentificationNumber.update();
}
else
{
hcmPersonIdentificationNumber.insert();
}
hcmPersonIdentificationNumber.clear();
hcmPersonIdentificationNumber = HcmPersonIdentificationNumber::findByPersonAndType(newHcmWorker.RecId,HcmIdentificationType..
No comments:
Post a Comment