using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using Ease.CoreV35.Model; using SpreadsheetGear; using Ease.CoreV35.Utility; using System.Windows.Forms; namespace Payroll.BO { [Serializable] public class BasicDataUploadProcess : BasicBaseObject { #region Class variable private ObjectsTemplate _categorys = new ObjectsTemplate(); private ObjectsTemplate _grades = new ObjectsTemplate(); private ObjectsTemplate _departments = new ObjectsTemplate(); private ObjectsTemplate _locations = new ObjectsTemplate(); private ObjectsTemplate _religions = new ObjectsTemplate(); private ObjectsTemplate _designations = new ObjectsTemplate(); private ObjectsTemplate _banks = new ObjectsTemplate(); private ObjectsTemplate _branches = new ObjectsTemplate(); private List _errorOrSuccessList; private ObjectsTemplate _employees = new ObjectsTemplate(); private ObjectsTemplate _incomeTaxs = new ObjectsTemplate(); private ObjectsTemplate _accessCards = new ObjectsTemplate(); #endregion Class variable private int _departmentid = 0; private int _locationid = 0; private int _categoryID = 0; private int _religionID = 0; private int _designationid = 0; private int _gradeid = 0; private int _branchid = 0; private int _bankid = 0; private int _emloyeeId = 0; private int _accessCardID = 0; public BasicDataUploadProcess() { _errorOrSuccessList = new List(); } public event ProgressStatus ProgressStatus; public event ProcessStatus ProcessStatus; private void UpdateProgressStatus(EnumProcessStatus status) { if (ProgressStatus != null) ProgressStatus(status); } private void UpdateprocessStatus(string statusString) { if (ProcessStatus != null) ProcessStatus(statusString); } public void RefreshObject() { _departments = Department.Get(); int maxID = 0; if (_departments.Count > 0) { maxID = (from detail in _departments select detail.ID.Integer).Max(); _departmentid = maxID; } _categorys = Category.Get(EnumStatus.Regardless); if (_categorys.Count > 0) { maxID = (from detail in _categorys select detail.ID.Integer).Max(); _categoryID = maxID; } _grades = Grade.Get(EnumStatus.Regardless); if (_grades.Count > 0) { maxID = (from detail in _grades select detail.ID.Integer).Max(); _gradeid = maxID; } // _grades = new ObjectsTemplate(); _locations = Location.Get(); if (_locations.Count > 0) { maxID = (from detail in _locations select detail.ID.Integer).Max(); _locationid = maxID; } _religions = Religion.Get(EnumStatus.Regardless); if (_religions.Count > 0) { maxID = (from detail in _religions select detail.ID.Integer).Max(); _religionID = maxID; } _designations = Designation.Get(EnumStatus.Regardless); if (_designations.Count > 0) { maxID = (from detail in _designations select detail.ID.Integer).Max(); _designationid = maxID; } _banks = Bank.Get(EnumStatus.Regardless); if (_banks.Count > 0) { maxID = (from detail in _banks select detail.ID.Integer).Max(); _bankid = maxID; } _branches = Branch.Get(EnumStatus.Regardless); if (_branches.Count > 0) { maxID = (from detail in _branches select detail.ID.Integer).Max(); _branchid = maxID; } SearchManager omanager = new SearchManager(EnumSearchFrom.Employee); omanager.Parameter.Remove(EnumSearchParameter.PayrollTypeID); ObjectsTemplate oemployees = omanager.Find(); if (oemployees.Count > 0) { maxID = (from detail in oemployees select detail.EmployeeID.Integer).Max(); _emloyeeId = maxID; } _accessCards = AccessCard.Get(); if (_accessCards.Count > 0) { maxID = (from detail in _accessCards select detail.ID.Integer).Max(); _accessCardID = maxID; } _accessCards = new ObjectsTemplate(); } public List ErrorOrSuccessList { get { return _errorOrSuccessList; } } public bool ProcessBasicData(DataTable uploadTable) { bool CodeautoGenerate = false; RefreshObject(); ConfigurationManager ocManager = new ConfigurationManager(); ObjectsTemplate deptConfig = ocManager.GetChilds("department", EnumConfigurationType.Logic); ObjectsTemplate deptTiers = ocManager.GetChilds(deptConfig, "tiernames"); ObjectsTemplate locConfig = ocManager.GetChilds("location", EnumConfigurationType.Logic); ObjectsTemplate locTiers = ocManager.GetChilds(locConfig, "tiernames"); Employee oemployee = new Employee(); int nRow = 0; int nIndex = 0; int count = 0; foreach (DataRow row in uploadTable.Rows) { Application.DoEvents(); _emloyeeId = _emloyeeId + 1; count++; oemployee = new Employee(); oemployee.EmployeeNo = row["Employee Code"].ToString(); oemployee.SetObjectID(_emloyeeId + 1); object[] obj = row.ItemArray; nRow = nRow + 1; //uploadStatus.Text = string.Format("Processing Basic Data... {0}/{1}", index, uploadTable.Rows.Count); //uploadStatus.Refresh(); /// /// Process category whether it is already in the system or new category /// #region Category upload //Category oCategory = null; //CodeautoGenerate = ConfigurationManager.GetBoolValue("category", "codeautogenerate", EnumConfigurationType.Logic); //if (CodeautoGenerate == false) // oCategory = _categorys.Find(delegate(Category item) { return item.Code == row["Category Code"].ToString(); }); //else // oCategory = _categorys.Find(delegate(Category item) { return item.Name == row["Category Name"].ToString(); }); //if (oCategory == null) //{ // oCategory = new Category(); // oCategory.Name = row["Category Name"].ToString(); // oCategory.Status = EnumStatus.Active; // if (CodeautoGenerate == false) // oCategory.Code = row["Category Code"].ToString(); // _categoryID = _categoryID + 1; // oemployee.CategoryID = ID.FromInteger(_categoryID); // oCategory.SetObjectID(_categoryID); // _categorys.Add(oCategory); //} //else //{ // oemployee.CategoryID = oCategory.ID; //} #endregion Category upload /// /// Process grade whether it is already in the system or new grade /// /// #region Grade upload Grade ograde = null; CodeautoGenerate = ConfigurationManager.GetBoolValue("grade", "codeautogenerate", EnumConfigurationType.Logic); if (CodeautoGenerate == false) ograde = _grades.Find(delegate(Grade item) { return item.Code == row["Grade Code"].ToString(); }); else ograde = _grades.Find(delegate(Grade item) { return item.Name == row["Grade Name"].ToString(); }); if (ograde == null) { ograde = new Grade(); ograde.Status = EnumStatus.Active; ograde.GradeSegmentID = ID.FromInteger(1); ograde.HasPayscale = ConfigurationManager.GetBoolValue("grade", "payscaleapplicable ", EnumConfigurationType.Logic); ograde.HasGrossConcept = ConfigurationManager.GetBoolValue("grade", "grossapplicable", EnumConfigurationType.Logic); ograde.Name = row["Grade Name"].ToString().Trim(); ograde.PayrollTypeID = SystemInformation.CurrentSysInfo.PayrollTypeID; if (CodeautoGenerate == false) ograde.Code = row["Grade Code"].ToString().Trim(); _gradeid = _gradeid + 1; oemployee.GradeID = ID.FromInteger(_gradeid); ograde.SetObjectID(_gradeid); _grades.Add(ograde); if (Grade.Get(ograde.Code) != null) _errorOrSuccessList.Add(UploadErrorOrSuccess.Create("Grade", nRow, "Grade already exist in other payroll type.")); } else { oemployee.GradeID = ograde.ID; } #endregion Grade upload /// /// Process Department whether it is already in the system or new location /// #region Department int nparentid = 0; ID tempid = ID.FromInteger(0); nIndex = 0; foreach (Configaration oconfig in deptTiers) { string sValue = oconfig.ConAttributes.GetAttributeValue("tier"); if (sValue == "") continue; nIndex = nIndex + 1; if (row[oconfig.Value + " Name"].ToString() == "") continue; Department odepartment = null; CodeautoGenerate = ConfigurationManager.GetBoolValue("department", "codeautogenerate", EnumConfigurationType.Logic); if (CodeautoGenerate == false) { if (nIndex > 1) odepartment = _departments.Find(delegate(Department item) { return item.Code == row[oconfig.Value + " Code"].ToString().Trim() && item.Tier == nIndex && item.ParentID.Integer == nparentid; }); else odepartment = _departments.Find(delegate(Department item) { return item.Code == row[oconfig.Value + " Code"].ToString().Trim() && item.Tier == nIndex; }); } else { if (nIndex > 1) odepartment = _departments.Find(delegate(Department item) { return item.Name == row[oconfig.Value + " Name"].ToString().Trim() && item.Tier == nIndex && item.ParentID.Integer == nparentid; }); else odepartment = _departments.Find(delegate(Department item) { return item.Name == row[oconfig.Value + " Name"].ToString().Trim() && item.Tier == nIndex; }); } if (odepartment == null) { odepartment = new Department(); odepartment.Name = row[oconfig.Value + " Name"].ToString().Trim(); odepartment.Tier = nIndex; odepartment.Status = EnumStatus.Active; if (CodeautoGenerate == false) { odepartment.Code = row[oconfig.Value + " Code"].ToString().Trim(); if (odepartment.Code == "") _errorOrSuccessList.Add(UploadErrorOrSuccess.Create(oconfig.Value + " Code", nRow, oconfig.Value + " Code can't be empty")); } if (nIndex > 1) odepartment.ParentID = ID.FromInteger(nparentid); _departmentid = _departmentid + 1; nparentid = _departmentid; oemployee.DepartmentID = ID.FromInteger(_departmentid); odepartment.SetObjectID(_departmentid); _departments.Add(odepartment); } else { nparentid = odepartment.ID.Integer; oemployee.DepartmentID = odepartment.ID; } //if (nIndex > 1) odepartment.ParentID = ID.FromInteger(nparentid); //nparentid = odepartment.ID.Integer; } #endregion /// /// Process location whether it is already in the system or new location /// #region Location //nparentid = 0; //nIndex = 0; //foreach (Configaration oconfig in locConfig) //{ // string sValue = oconfig.ConAttributes.GetAttributeValue("tier"); // if (sValue == "") continue; // nIndex = nIndex + 1; // if (row[oconfig.Value + " Name"].ToString() == "") continue; // Location olocation = null; // CodeautoGenerate = ConfigurationManager.GetBoolValue("location", "codeautogenerate", EnumConfigurationType.Logic); // //if (CodeautoGenerate == false) // //{ // // if (nIndex > 1) // // { // // olocation = _locations.Find(delegate(Location item) { return item.Code == row[oconfig.Value + " Code"].ToString().Trim() && item.Tier == nIndex && item.ParentID.Integer == nparentid; }); // // } // // else // // { // // olocation = _locations.Find(delegate(Location item) { return item.Code == row[oconfig.Value + " Code"].ToString().Trim() && item.Tier == nIndex; }); // // } // //} // //else // //{ // // if (nIndex > 1) // // { // // olocation = _locations.Find(delegate(Location item) { return item.Name == row[oconfig.Value + " Name"].ToString().Trim() && item.Tier == nIndex && item.ParentID.Integer == nparentid; }); // // } // // else // // { // // olocation = _locations.Find(delegate(Location item) { return item.Name == row[oconfig.Value + " Name"].ToString().Trim() && item.Tier == nIndex; }); // // } // //} // //if (olocation == null) // //{ // // olocation = new Location(); // // olocation.Name = row[oconfig.Value + " Name"].ToString().Trim(); // // olocation.Tier = nIndex; // // olocation.Status = EnumStatus.Active; // // if (olocation.Name == "") // // _errorOrSuccessList.Add(UploadErrorOrSuccess.Create(oconfig.Value + " Name", nRow, oconfig.Value + " Name can't be empty")); // // if (CodeautoGenerate == false) // // { // // olocation.Code = row[oconfig.Value + " Code"].ToString().Trim(); // // if (olocation.Code == "") // // _errorOrSuccessList.Add(UploadErrorOrSuccess.Create(oconfig.Value + " Code", nRow, oconfig.Value + " Code can't be empty")); // // } // // if (nIndex > 1) olocation.ParentID = ID.FromInteger(nparentid); // // _locationid = _locationid + 1; // // nparentid = _locationid; // // oemployee.LocationID = ID.FromInteger(_locationid); // // olocation.SetObjectID(_locationid); // // _locations.Add(olocation); // //} // //else // //{ // // nparentid = olocation.ID.Integer; // // oemployee.LocationID = olocation.ID; // //} //} #endregion /// /// Process religion whether it is already in the system or new religion /// #region Religion upload Religion oreligion = null; CodeautoGenerate = ConfigurationManager.GetBoolValue("religion", "codeautogenerate", EnumConfigurationType.Logic); if (CodeautoGenerate == false) oreligion = _religions.Find(delegate(Religion item) { return item.Code == row["Religion Code"].ToString().Trim(); }); else oreligion = _religions.Find(delegate(Religion item) { return item.Name == row["Religion Name"].ToString().Trim(); }); if (oreligion == null) { oreligion = new Religion(); oreligion.Name = row["Religion Name"].ToString().Trim(); if (CodeautoGenerate == false) { oreligion.Code = row["Religion Name"].ToString().Trim(); } _religionID = _religionID + 1; oemployee.ReligionID = ID.FromInteger(_religionID); oreligion.SetObjectID(_religionID); _religions.Add(oreligion); } else { oemployee.ReligionID = oreligion.ID; } #endregion Religion upload /// /// Process designation whether it is already in the system or new designation /// #region Designation upload Designation odesignation = null; CodeautoGenerate = ConfigurationManager.GetBoolValue("designation", "codeautogenerate", EnumConfigurationType.Logic); if (CodeautoGenerate == false) odesignation = _designations.Find(delegate(Designation item) { return item.Code == row["Designation Code"].ToString().Trim(); }); else odesignation = _designations.Find(delegate(Designation item) { return item.Name == row["Designation Name"].ToString().Trim(); }); if (odesignation == null) { odesignation = new Designation(); odesignation.Name = row["Designation Name"].ToString().Trim(); if (CodeautoGenerate == false) odesignation.Code = row["Designation Code"].ToString().Trim(); _designationid = _designationid + 1; oemployee.DesignationID = ID.FromInteger(_designationid); odesignation.SetObjectID(_designationid); odesignation.Status = EnumStatus.Active; _designations.Add(odesignation); } else { oemployee.DesignationID = odesignation.ID; } #endregion Designation upload #region Bank & Branch upload if (row["Salary Bank Name"].ToString().Trim() != "") { Bank obank = null; CodeautoGenerate = ConfigurationManager.GetBoolValue("bank", "codeautogenerate", EnumConfigurationType.Logic); if (CodeautoGenerate == false) { obank = _banks.Where(x => x.Code.ToUpper().Trim() == row["Salary Bank Code"].ToString().ToUpper().Trim()) .FirstOrDefault(); } else { obank = _banks.Where(x => x.Name.ToUpper().Trim() == row["Salary Bank Name"].ToString().ToUpper().Trim()) .FirstOrDefault(); } if (obank == null) { obank = new Bank(); obank.Name = row["Salary Bank Name"].ToString().Trim(); if (CodeautoGenerate == false) obank.Code = row["Salary Bank Code"].ToString().Trim(); _bankid = _bankid + 1; obank.SetObjectID(_bankid); _banks.Add(obank); } if (row["Salary Branch Name"].ToString() != "") { Branch oBranch = null; CodeautoGenerate = ConfigurationManager.GetBoolValue("branch", "codeautogenerate", EnumConfigurationType.Logic); if (CodeautoGenerate == false) { oBranch = _branches.Where(item=> item.Code.ToUpper().Trim() == row["Salary Branch Code"].ToString().ToUpper().Trim() && item.BankID.Integer == obank.ID.Integer) .FirstOrDefault(); } else { oBranch = _branches.Where(item => item.Name.ToUpper().Trim() == row["Salary Branch Name"].ToString().ToUpper().Trim() && item.BankID.Integer == obank.ID.Integer) .FirstOrDefault(); } if (oBranch == null) { oBranch = new Branch(); oBranch.Name = row["Salary Branch Name"].ToString().Trim(); if (CodeautoGenerate == false) oBranch.Code = row["Salary Branch Code"].ToString().Trim(); _branchid = _branchid + 1; oBranch.BankID = obank.ID; oBranch.SetObjectID(_branchid); oemployee.BranchID = ID.FromInteger(_branchid); _branches.Add(oBranch); } else { oemployee.BranchID = oBranch.ID; } } } //bool isOPISeparateAcountApplicable = ConfigurationManager.GetBoolValue("opi", "separateaccount", EnumConfigurationType.Logic); //if (isOPISeparateAcountApplicable) //{ // if (row["OPI Bank Name"].ToString() != "") // { // Bank obank = null; // CodeautoGenerate = ConfigurationManager.GetBoolValue("bank", "codeautogenerate", EnumConfigurationType.Logic); // if (CodeautoGenerate == false) // { // obank = _banks.Where(x => // x.Code.ToUpper().Trim() == row["OPI Bank Code"].ToString().ToUpper().Trim()) // .FirstOrDefault(); // } // else // { // obank = _banks.Where(x => // x.Name.ToUpper().Trim() == row["OPI Bank Name"].ToString().ToUpper().Trim()) // .FirstOrDefault(); // } // if (obank == null) // { // obank = new Bank(); // obank.Name = row["OPI Bank Name"].ToString().Trim(); // if (CodeautoGenerate == false) // obank.Code = row["OPI Bank Code"].ToString().Trim(); // _bankid = _bankid + 1; // obank.SetObjectID(_bankid); // _banks.Add(obank); // } // if (row["OPI Branch Name"].ToString() != "") // { // Branch oBranch = null; // CodeautoGenerate = ConfigurationManager.GetBoolValue("branch", "codeautogenerate", EnumConfigurationType.Logic); // if (CodeautoGenerate == false) // { // oBranch = _branches.Where(item => // item.Code.ToUpper().Trim() == row["OPI Branch Code"].ToString().ToUpper().Trim() // && item.BankID.Integer == obank.ID.Integer) // .FirstOrDefault(); // } // else // { // oBranch = _branches.Where(item => // item.Name.ToUpper().Trim() == row["OPI Branch Name"].ToString().ToUpper().Trim() // && item.BankID.Integer == obank.ID.Integer) // .FirstOrDefault(); // } // if (oBranch == null) // { // oBranch = new Branch(); // oBranch.Name = row["OPI Branch Name"].ToString().Trim(); // if (CodeautoGenerate == false) // oBranch.Code = row["OPI Branch Code"].ToString().Trim(); // _branchid = _branchid + 1; // oBranch.BankID = obank.ID; // oBranch.SetObjectID(_branchid); // oemployee.OutPayBranchID = ID.FromInteger(_branchid); // _branches.Add(oBranch); // } // else // { // oemployee.OutPayBranchID = oBranch.ID; // } // } //} //} #endregion Bank & Branch upload _employees.Add(oemployee); } return true; } private BasicCodeItem ExistingItem(object ItemByCode, object ItemByName) { if (ItemByCode != null) return BasicCodeItem.Code; else return BasicCodeItem.Name; } public void Save() { try { foreach (Employee item in _employees) { item.PayrollTypeID = SystemInformation.CurrentSysInfo.PayrollTypeID; } RegularDataUpload.Save(_categorys, _grades, _departments, _locations, _religions, _designations, _banks, _branches, _employees, _accessCards); } catch (Exception ex) { throw new ServiceException(ex.Message); } } #region Save Tax Data public void SaveTaxData() { try { IncomeTax.Save(_incomeTaxs, EnumIncomeTaxDataFrom.ProcessTempData); } catch (Exception ex) { throw new ServiceException(ex.Message); } } #endregion public void ImportEmpBasicInfoRegularly (DataTable odataTable) { Employee oemployee = null; #region Refresh Objects if (ProcessBasicData(odataTable) == false) return; int nRow = 0; try { foreach (DataRow dr in odataTable.Rows) { Application.DoEvents(); nRow = nRow + 1; oemployee = _employees.Find(delegate(Employee emp) { return emp.EmployeeNo == dr["Employee Code"].ToString(); }); if (oemployee == null) throw new ServiceException("Employee not found in the collection; employeeNo:" + dr["Employee Code"].ToString()); oemployee.Name = dr["Employee Name"].ToString().Trim(); oemployee.FatherName = dr["Father's Name"].ToString().Trim(); oemployee.BirthDate = Convert.ToDateTime(dr["Date of Birth"]); oemployee.JoiningDate = Convert.ToDateTime(dr["Date of Joining"]); //For Novartis Discontinue Employee Upload and Fund Management Data Issue //oemployee.Status = EnumEmployeeStatus.Discontinued; oemployee.Gender = (dr["Gender"].ToString().Trim().ToUpper() == "M") ? EnumGender.Male : EnumGender.Female; oemployee.MaritalStatus = (dr["Marital Status"].ToString().Trim().ToUpper() == "MARRIED") ? EnumMaritalStatus.Married : EnumMaritalStatus.UnMarried; //oemployee.TaxCircle = dr["Tax Circle"].ToString() != string.Empty ? (EnumTaxCircle)Enum.Parse(typeof(EnumTaxCircle), dr["Tax Circle"].ToString(), true) : EnumTaxCircle.Employee; oemployee.TaxCircle = dr["Tax Circle"].ToString().Trim(); oemployee.TinNo = dr["TIN"].ToString().Trim(); if (dr["Confirmation Date"].ToString() != "") oemployee.ConfirDate = Convert.ToDateTime(dr["Confirmation Date"]); if (oemployee.ConfirDate != DateTime.MinValue) oemployee.IsConfirmed = true; if (dr["PF Membership"].ToString().ToUpper().Trim() == "Y") oemployee.PFMemberType = EnumPFMembershipType.Live; oemployee.ForeignExPat = dr["Is Foreign Expatriate"].ToString() != string.Empty ? (dr["Is Foreign Expatriate"].ToString() == "YES" ? true : false) : false; //Refresh Employee Grade Salary if (oemployee.GradeID != null) { Grade ograde = _grades.GetItem(oemployee.GradeID); oemployee.EmployeeGradeSalary.SetObjectID(oemployee.ID.Integer); oemployee.EmployeeGradeSalary.GradeID = oemployee.GradeID; oemployee.EmployeeGradeSalary.GradeSalaryTypeID = ID.FromInteger(1); if (ograde.HasGrossConcept == true) oemployee.EmployeeGradeSalary.GrossSalary = dr["Gross Salary"].ToString() != string.Empty ? Convert.ToDouble(dr["Gross Salary"]) : 0.0; oemployee.EmployeeGradeSalary.BasicSalary = dr["Basic Salary"].ToString() != string.Empty ? Convert.ToDouble(dr["Basic Salary"]) : 0.0; oemployee.BasicSalary = oemployee.EmployeeGradeSalary.BasicSalary; oemployee.GrossSalary = oemployee.EmployeeGradeSalary.GrossSalary; oemployee.EmployeeGradeSalary.EffectDate = oemployee.JoiningDate; oemployee.EmployeeGradeSalary.EmployeeID = oemployee.ID; ObjectsTemplate itemsToSave = oemployee.EmployeeGradeSalary.process(); oemployee.EmployeeGradeSalarys = new ObjectsTemplate(); foreach (EmployeeGradeSalary item in itemsToSave) { oemployee.EmployeeGradeSalarys.Add(item); } } //Refresh Employee Posting oemployee.EmployeePosting.EffectDate = oemployee.JoiningDate; oemployee.EmployeePosting.SetObjectID(oemployee.ID.Integer); oemployee.EmployeePosting.DepartmentID = oemployee.DepartmentID; oemployee.EmployeePosting.LocationID = oemployee.LocationID; oemployee.EmployeePosting.DesignationID = oemployee.DesignationID; //Refresh Emloyee Bank Account if (oemployee.BranchID != null) { if (dr["Salary Account Number"].ToString() != "") { oemployee.AccountNo = dr["Salary Account Number"].ToString(); // oemployee.EmployeeBankAccount.SetObjectID(oemployee.ID.Integer); oemployee.PaymentMode = EnumPaymentMode.BankTransfer; oemployee.EmployeeBankAccount.EffectDate = oemployee.JoiningDate; oemployee.EmployeeBankAccount.BranchID = oemployee.BranchID; oemployee.EmployeeBankAccount.AccountType = EnumBankAccountType.SalaryAccount; oemployee.EmployeeBankAccount.AccountNo = dr["Salary Account Number"].ToString(); } else _errorOrSuccessList.Add(UploadErrorOrSuccess.Create("Salary Account Number", nRow, "'Salary Account Number' Column not found for the employee No:" + oemployee.EmployeeNo, oemployee.EmployeeNo, oemployee.Name)); } if(oemployee.OutPayBranchID!=null) { if (dr["OPI Account Number"].ToString() != "") { oemployee.OutPayAccountNo = dr["OPI Account Number"].ToString(); // oemployee.EmployeeOPIBankAccount.SetObjectID(oemployee.ID.Integer); oemployee.OutPayPaymentMode = EnumPaymentMode.BankTransfer; oemployee.EmployeeOPIBankAccount.EffectDate = oemployee.JoiningDate; oemployee.EmployeeOPIBankAccount.BranchID = oemployee.OutPayBranchID; oemployee.EmployeeOPIBankAccount.AccountType = EnumBankAccountType.OutPayAccount; oemployee.EmployeeOPIBankAccount.AccountNo = dr["OPI Account Number"].ToString(); } else _errorOrSuccessList.Add(UploadErrorOrSuccess.Create("OPI Account Number", nRow, "'OPI Account Number' Column not found for the employee No:" + oemployee.EmployeeNo, oemployee.EmployeeNo, oemployee.Name)); } if (dr["PROXID"].ToString() != "") { _accessCardID = _accessCardID + 1; oemployee.CardID = ID.FromInteger(_accessCardID); AccessCard ocard = new AccessCard(); ocard.SetObjectID(_accessCardID); ocard.CardNumber = dr["PROXID"].ToString(); ocard.TypeID = ID.FromInteger(1); ocard.Status = EnumCardStatus.Attached; ocard.CardOperation.EmployeeID = oemployee.ID; ocard.CardOperation.CardID = ocard.ID; ocard.CardOperation.AssignDate = oemployee.JoiningDate; _accessCards.Add(ocard); } } } catch (Exception ex) { throw new ServiceException("Error occered on row:" + nRow + " Reason:" + ex.Message); } #endregion } public void ImportEmpBasicInfo(DataTable odataTable) { Employee oemployee = null; #region Refresh Objects if (ProcessBasicData(odataTable) == false) return; int nRow = 0; try { foreach (DataRow dr in odataTable.Rows) { Application.DoEvents(); nRow = nRow + 1; oemployee = _employees.Find(delegate(Employee emp) { return emp.EmployeeNo == dr["Employee Code"].ToString(); }); if (oemployee == null) throw new ServiceException("Employee not found in the collection; employeeNo:" + dr["Employee Code"].ToString()); oemployee.Name = dr["Employee Name"].ToString().Trim(); oemployee.FatherName = dr["Father's Name"].ToString().Trim(); oemployee.BirthDate = Convert.ToDateTime(dr["Date of Birth"]); oemployee.JoiningDate = Convert.ToDateTime(dr["Date of Joining"]); //For Novartis Discontinue Employee Upload and Fund Management Data Issue //oemployee.Status = EnumEmployeeStatus.Discontinued; if ((dr["Gender"].ToString().Trim().ToUpper() == "MALE") || (dr["Gender"].ToString().Trim().ToUpper() == "M")) { oemployee.Gender = EnumGender.Male; } else { oemployee.Gender = EnumGender.Female; } //oemployee.Gender = ((dr["Gender"].ToString().Trim().ToUpper() == "M") || (dr["Gender"].ToString().Trim().ToUpper() == "Male")) ? EnumGender.Male : EnumGender.Female; oemployee.MaritalStatus = (dr["Marital Status"].ToString().Trim().ToUpper() == "MARRIED") ? EnumMaritalStatus.Married : EnumMaritalStatus.UnMarried; //oemployee.TaxCircle = dr["Tax Circle"].ToString() != string.Empty ? (EnumTaxCircle)Enum.Parse(typeof(EnumTaxCircle), dr["Tax Circle"].ToString(), true) : EnumTaxCircle.Employee; oemployee.TaxCircle = dr["Tax Circle"].ToString().Trim(); oemployee.TinNo = dr["TIN"].ToString().Trim(); if (dr["Confirmation Date"].ToString() != "") oemployee.ConfirDate = Convert.ToDateTime(dr["Confirmation Date"]); if (oemployee.ConfirDate != DateTime.MinValue) oemployee.IsConfirmed = true; //if (dr["PF Membership"].ToString().ToUpper().Trim() == "Y") // oemployee.PFMemberType = EnumPFMembershipType.Live; //oemployee.ForeignExPat = dr["Is Foreign Expatriate"].ToString() != string.Empty ? (dr["Is Foreign Expatriate"].ToString() == "YES" ? true : false) : false; oemployee.MobileNo = dr["Mobile No"].ToString().Trim(); oemployee.EmailAddress = dr["Email Address"].ToString().Trim(); //Refresh Employee Grade Salary if (oemployee.GradeID != null) { Grade ograde = _grades.GetItem(oemployee.GradeID); oemployee.EmployeeGradeSalary.SetObjectID(oemployee.ID.Integer); oemployee.EmployeeGradeSalary.GradeID = oemployee.GradeID; oemployee.EmployeeGradeSalary.GradeSalaryTypeID = ID.FromInteger(1); if (ograde.HasGrossConcept == true) oemployee.EmployeeGradeSalary.GrossSalary = dr["Gross Salary"].ToString() != string.Empty ? Convert.ToDouble(dr["Gross Salary"]) : 0.0; oemployee.EmployeeGradeSalary.BasicSalary = dr["Basic Salary"].ToString() != string.Empty ? Convert.ToDouble(dr["Basic Salary"]) : 0.0; oemployee.BasicSalary = oemployee.EmployeeGradeSalary.BasicSalary; oemployee.GrossSalary = oemployee.EmployeeGradeSalary.GrossSalary; oemployee.EmployeeGradeSalary.EffectDate = oemployee.JoiningDate; oemployee.EmployeeGradeSalarys = new ObjectsTemplate(); oemployee.EmployeeGradeSalarys.Add(oemployee.EmployeeGradeSalary); } //Refresh Employee Posting oemployee.EmployeePosting.EffectDate = oemployee.JoiningDate; oemployee.EmployeePosting.SetObjectID(oemployee.ID.Integer); oemployee.EmployeePosting.DepartmentID = oemployee.DepartmentID; oemployee.EmployeePosting.LocationID =ID.FromInteger(1); oemployee.EmployeePosting.DesignationID = oemployee.DesignationID; //Refresh Emloyee Bank Account if (oemployee.BranchID != null) { if (dr["Salary Account Number"].ToString() != "") { oemployee.AccountNo = dr["Salary Account Number"].ToString(); // oemployee.EmployeeBankAccount.SetObjectID(oemployee.ID.Integer); oemployee.PaymentMode = EnumPaymentMode.BankTransfer; oemployee.EmployeeBankAccount.EffectDate = oemployee.JoiningDate; oemployee.EmployeeBankAccount.BranchID = oemployee.BranchID; oemployee.EmployeeBankAccount.AccountType = EnumBankAccountType.SalaryAccount; oemployee.EmployeeBankAccount.AccountNo = dr["Salary Account Number"].ToString(); } else _errorOrSuccessList.Add(UploadErrorOrSuccess.Create("Salary Account Number", nRow, "'Salary Account Number' Column not found for the employee No:" + oemployee.EmployeeNo, oemployee.EmployeeNo, oemployee.Name)); } //if(oemployee.OutPayBranchID!=null) //{ // if (dr["OPI Account Number"].ToString() != "") // { // oemployee.OutPayAccountNo = dr["OPI Account Number"].ToString(); // // oemployee.EmployeeOPIBankAccount.SetObjectID(oemployee.ID.Integer); // oemployee.OutPayPaymentMode = EnumPaymentMode.BankTransfer; // oemployee.EmployeeOPIBankAccount.EffectDate = oemployee.JoiningDate; // oemployee.EmployeeOPIBankAccount.BranchID = oemployee.OutPayBranchID; // oemployee.EmployeeOPIBankAccount.AccountType = EnumBankAccountType.OutPayAccount; // oemployee.EmployeeOPIBankAccount.AccountNo = dr["OPI Account Number"].ToString(); // } // else // _errorOrSuccessList.Add(UploadErrorOrSuccess.Create("OPI Account Number", nRow, "'OPI Account Number' Column not found for the employee No:" + oemployee.EmployeeNo, oemployee.EmployeeNo, oemployee.Name)); //} //if (dr["PROXID"].ToString() != "") //{ // _accessCardID = _accessCardID + 1; // oemployee.CardID = ID.FromInteger(_accessCardID); // AccessCard ocard = new AccessCard(); // ocard.SetObjectID(_accessCardID); // ocard.CardNumber = dr["PROXID"].ToString(); // ocard.TypeID = ID.FromInteger(1); // ocard.Status = EnumCardStatus.Attached; // ocard.CardOperation.EmployeeID = oemployee.ID; // ocard.CardOperation.CardID = ocard.ID; // ocard.CardOperation.AssignDate = oemployee.JoiningDate; // _accessCards.Add(ocard); //} } } catch (Exception ex) { throw new ServiceException("Error occered on row:" + nRow + " Reason:" + ex.Message); } #endregion } public void ImportTaxAdjustmentData(DataTable odataTable, DataUploadColumnDefinition columnDefinition) { ObjectsTemplate oTaxMergeMasters = new ObjectsTemplate(); oTaxMergeMasters = TaxMergeMaster.GetbyTaxParameter(SystemInformation.CurrentSysInfo.TaxParamID); Employee oemployee = null; IncomeTax oIncomeTax = null; TaxMergeMaster oTaxMergeMaster = null; _employees = Employee.Get(); ObjectsTemplate processItems = ProcessItem.Get(); #region Refresh Objects int nRow = 0; ObjectsTemplate savedData = IncomeTax.Get(EnumIncomeTaxDataFrom.ProcessTempData); try { foreach (DataRow dr in odataTable.Rows) { nRow = nRow + 1; oemployee = _employees.Find(delegate(Employee emp) { return emp.EmployeeNo == dr["Employee No"].ToString(); });//Employee.Get(dr["Employee Code"].ToString()); if (oemployee == null) { _errorOrSuccessList.Add(UploadErrorOrSuccess.Create("Employee Code", nRow, "Employee Code not found: " + dr["Employee No"].ToString())); continue; } for (int i = 1; i < odataTable.Columns.Count; i++) { oIncomeTax = TaxMergeMaster.Extract(oTaxMergeMasters, EnumTaxMergeType.TaxAdjustItem, columnDefinition.SelectedItemOneID.Integer); if (oIncomeTax == null) { _errorOrSuccessList.Add(UploadErrorOrSuccess.Create(odataTable.Columns[i].ColumnName, nRow, "Tax head grouping net yet created for the selected item", oemployee.EmployeeNo, oemployee.Name)); continue; } ProcessItem pitem = processItems.Find(delegate(ProcessItem item) { return item.ItemCode == (int)oIncomeTax.ItemGroup; }); if (pitem == null) { _errorOrSuccessList.Add(UploadErrorOrSuccess.Create(odataTable.Columns[i].ColumnName, nRow, " Tax process item code not found in the process collection; Item Code:" + oTaxMergeMaster.ItemGroup.ToString(), oemployee.EmployeeNo, oemployee.Name)); continue; } oIncomeTax.EmployeeID = oemployee.ID; double nAmount = 0; if (double.TryParse(dr[odataTable.Columns[i].ColumnName].ToString(), out nAmount) == false) { _errorOrSuccessList.Add(UploadErrorOrSuccess.Create(odataTable.Columns[i].ColumnName, nRow, odataTable.Columns[i].ColumnName + " contains Invalid value:" + dr[odataTable.Columns[i].ColumnName].ToString(), oemployee.EmployeeNo, oemployee.Name)); continue; } IncomeTax oNewItem = IncomeTax.Get(savedData, oemployee.ID, oIncomeTax.ItemGroup, oIncomeTax.ItemID); //.Get(savedData, oemployee.ID, oTaxMergeMaster.ItemGroup, oTaxMergeMaster.ItemID); if (oNewItem != null) oIncomeTax = oNewItem; else { oIncomeTax.Side = (EnumIncomeTaxSide)pitem.ItemGroup; oIncomeTax.Position = pitem.Position; } // if (oIncomeTax == null) oIncomeTax = new IncomeTax(); oIncomeTax.EmployeeID = oemployee.ID; oIncomeTax.PreviousAmount = oIncomeTax.PreviousAmount + nAmount; if (oIncomeTax.PreviousAmount != 0) _incomeTaxs.Add(oIncomeTax); } } } catch (Exception ex) { throw new ServiceException("Error occered on row:" + nRow + " Reason:" + ex.Message); } #endregion } public void ImportTaxDataInfo(DataTable odataTable) { ObjectsTemplate oTaxMergeMasters = new ObjectsTemplate(); oTaxMergeMasters = TaxMergeMaster.GetbyTaxParameter(SystemInformation.CurrentSysInfo.TaxParamID); Employee oemployee = null; IncomeTax oIncomeTax = null; TaxMergeMaster oTaxMergeMaster = null; _employees = Employee.Get(); ObjectsTemplate processItems = ProcessItem.Get(); #region Refresh Objects int nRow = 0; ObjectsTemplate savedData = IncomeTax.Get(EnumIncomeTaxDataFrom.ProcessTempData); try { foreach (DataRow dr in odataTable.Rows) { nRow = nRow + 1; oemployee = _employees.Find(delegate(Employee emp) { return emp.EmployeeNo == dr["Employee Code"].ToString(); });//Employee.Get(dr["Employee Code"].ToString()); if (oemployee == null) { // _errorOrSuccessList.Add(UploadErrorOrSuccess.Create("Employee Code", nRow, "Employee Code not found: " + dr["Employee Code"].ToString())); continue; } for (int i = 1; i < odataTable.Columns.Count; i++) { oIncomeTax = new IncomeTax(); oTaxMergeMaster = oTaxMergeMasters.Find(delegate(TaxMergeMaster taxMerge) { return taxMerge.Description == odataTable.Columns[i].ColumnName; }); if (oTaxMergeMaster == null) { _errorOrSuccessList.Add(UploadErrorOrSuccess.Create(odataTable.Columns[i].ColumnName, nRow, odataTable.Columns[i].ColumnName + " not found in the tax head groping", oemployee.EmployeeNo, oemployee.Name)); continue; } ProcessItem pitem = processItems.Find(delegate(ProcessItem item) { return item.ItemCode == (int)oTaxMergeMaster.ItemGroup; }); if (pitem == null) { _errorOrSuccessList.Add(UploadErrorOrSuccess.Create(odataTable.Columns[i].ColumnName, nRow, " Tax process item code not found in the process collection; Item Code:" + oTaxMergeMaster.ItemGroup.ToString(), oemployee.EmployeeNo, oemployee.Name)); continue; } if (oTaxMergeMaster != null) { oIncomeTax.EmployeeID = oemployee.ID; double nAmount = 0; if (double.TryParse(dr[odataTable.Columns[i].ColumnName].ToString(), out nAmount) == false) { _errorOrSuccessList.Add(UploadErrorOrSuccess.Create(odataTable.Columns[i].ColumnName, nRow, odataTable.Columns[i].ColumnName + " contains Invalid value:" + dr[odataTable.Columns[i].ColumnName].ToString(), oemployee.EmployeeNo, oemployee.Name)); continue; } oIncomeTax = IncomeTax.Get(savedData, oemployee.ID, oTaxMergeMaster.ItemGroup, oTaxMergeMaster.ItemID); if (oIncomeTax == null) oIncomeTax = new IncomeTax(); oIncomeTax.EmployeeID = oemployee.ID; oIncomeTax.ItemGroup = oTaxMergeMaster.ItemGroup; oIncomeTax.ItemID = oTaxMergeMaster.ItemID; oIncomeTax.PreviousAmount = oIncomeTax.PreviousAmount + nAmount; oIncomeTax.Description = oTaxMergeMaster.Description; oIncomeTax.Side = (EnumIncomeTaxSide)pitem.ItemGroup; oIncomeTax.Position = pitem.Position; if (oIncomeTax.PreviousAmount != 0) _incomeTaxs.Add(oIncomeTax); } else _errorOrSuccessList.Add(UploadErrorOrSuccess.Create(odataTable.Columns[i].ColumnName, nRow, "Column not found in tax setup", oemployee.EmployeeNo, oemployee.Name)); } } } catch (Exception ex) { throw new ServiceException("Error occered on row:" + nRow + " Reason:" + ex.Message); } #endregion } } }