using Ease.Core.Model; using Payroll.BO; using System; using System.Collections.Generic; using System.Data; using System.Linq; using static System.Net.Mime.MediaTypeNames; namespace HRM.BO { public class BasicDataUploadProcess : BasicBaseObject { #region Class variable private List _categorys = new List(); private List _grades = new List(); private List _departments = new List(); private List _locations = new List(); private List _religions = new List(); private List _designations = new List(); private List _banks = new List(); private List _branches = new List(); // private List _subcategorys = new List(); private List _errorOrSuccessList; private List _employees = new List(); private List _incomeTaxs = new List(); private List _accessCards = new List(); #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; private int _payrollTypeID = 0; public BasicDataUploadProcess() { _errorOrSuccessList = new List(); } //public void RefreshObject() //{ // _departments = Department.Get(); // if (_departments.Count > 0) // { // _departmentid = _departments.Max(x => x.ID.Integer); // } // _categorys = Category.Get(EnumStatus.Regardless); // _categoryID = Category.GetMaxID(); // _grades = Grade.Get(EnumStatus.Regardless); // _gradeid = Grade.GetMaxGradeID(); // _locations = Location.Get(); // if (_locations.Count > 0) // { // _locationid = _locations.Max(x => x.ID.Integer); // } // _religions = Religion.Get(EnumStatus.Regardless); // if (_religions.Count > 0) // { // _religionID = _religions.Max(x => x.ID.Integer); // } // _designations = Designation.Get(EnumStatus.Regardless); // _designationid = Designation.GetMaxID(); // _banks = Bank.Get(EnumStatus.Regardless); // if (_banks.Count > 0) // { // _bankid = _banks.Max(x => x.ID.Integer); // } // _branches = Branch.Get(EnumStatus.Regardless); // if (_branches.Count > 0) // { // _branchid = _branches.Max(x => x.ID.Integer); // } // SearchManager omanager = new SearchManager(EnumSearchFrom.Employee); // omanager.Parameter.Remove(EnumSearchParameter.PayrollTypeID); // List oemployees = omanager.Find(); // if (oemployees.Count > 0) // { // _emloyeeId = oemployees.Max(x => x.EmployeeID.Integer); // } // _accessCards = AccessCard.Get(); // if (_accessCards.Count > 0) // { // _accessCardID = _accessCards.Max(x => x.ID.Integer); // } //} //public void RefreshObject() //{ // // MiscellaneousService ms = new MiscellaneousService(); // _departments = Department.Get(_payrollTypeID); // _departmentid = Miscellaneous.Service.GetNextID("Department", "DepartmentID", ""); // //_categorys = Category.Get(EnumStatus.Regardless); // //_categoryID = Category.GetMaxID(); // _categorys = Category.Get(EnumStatus.Regardless); // _categoryID = Miscellaneous.Service.GetNextID("Category", "CategoryID", ""); // _subcategorys = SubCategory.GetSubCategories(EnumStatus.Regardless); // _subcategoryID = Miscellaneous.Service.GetNextID("SubCategory", "SubCategoryID", ""); // //_subcategorys = SubCategory.Get(EnumStatus.Regardless); // //_subcategoryID = SubCategory.GetMaxID(); // _grades = Grade.Get(EnumStatus.Regardless); // _gradeid = Miscellaneous.Service.GetNextID("Grades", "GradeID", ""); // _locations = Location.GetLocations(); // _locationid = Miscellaneous.Service.GetNextID("Location", "LocationID", ""); // _religions = Religion.Get(EnumStatus.Regardless); // _religionID = Miscellaneous.Service.GetNextID("Religion", "ReligionID", ""); // _designations = Designation.Get(EnumStatus.Regardless); // _designationid = Miscellaneous.Service.GetNextID("Designation", "DesignationID", ""); // //_designationid = Designation.GetMaxID(); // _banks = Bank.GetBanks(EnumStatus.Regardless); // _bankid = Miscellaneous.Service.GetNextID("Banks", "BankID", ""); // _branches = Branch.GetBranches(EnumStatus.Regardless); // _branchid = Miscellaneous.Service.GetNextID("BRANCHES", "BranchID", ""); ; // SearchManager omanager = new SearchManager(EnumSearchFrom.Employee); // omanager.Parameter.Remove(EnumSearchParameter.PayrollTypeID); // List oemployees = omanager.Find(); // if (oemployees.Count > 0) // { // _emloyeeId = oemployees.Max(x => x.EmployeeID.Integer); // } // //_accessCards = AccessCard.Get(); // //if (_accessCards.Count > 0) // //{ // // _accessCardID = _accessCards.Max(x => x.ID.Integer); // //} //} //public void RefreshObject2() //{ // int maxID = 0; // _categorys = Category.Get(EnumStatus.Regardless); // if (_categorys.Count > 0) // { // maxID = (from detail in _categorys // select detail.ID.Integer).Max(); // _categoryID = maxID; // } //} public List ErrorOrSuccessList { get { return _errorOrSuccessList; } } //public bool ProcessBasicData2(DataTable uploadTable) //{ // bool CodeautoGenerate = false; // RefreshObject2(); // 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 No"].ToString(); // oemployee.SetObjectID(_emloyeeId + 1); // object[] obj = row.ItemArray; // nRow = nRow + 1; // #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"].ToString(); }); // if (oCategory == null) // { // oCategory = new Category(); // oCategory.Name = row["Category"].ToString(); // oCategory.Status = EnumStatus.Active; // if (CodeautoGenerate == false) // oCategory.Code = row["Category Code"].ToString(); // _categoryID = _categoryID + 1; // oemployee.CategoryID = (_categoryID); // oCategory.SetObjectID(_categoryID); // _categorys.Add(oCategory); // } // else // { // oemployee.CategoryID = oCategory.ID; // } // #endregion Category upload // #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"].ToString().Trim(); }); // if (oreligion == null) // { // oreligion = new Religion(); // oreligion.Name = row["Religion"].ToString().Trim(); // if (CodeautoGenerate == false) // { // oreligion.Code = row["Religion"].ToString().Trim(); // } // _religionID = _religionID + 1; // oemployee.ReligionID = (_religionID); // oreligion.SetObjectID(_religionID); // _religions.Add(oreligion); // } // else // { // oemployee.ReligionID = oreligion.ID; // } // #endregion Religion upload // _employees.Add(oemployee); // } // return true; //} //public bool ProcessBasicData(DataTable uploadTable) //{ // bool CodeautoGenerate = false; // RefreshObject(); // ConfigurationManager ocManager = new ConfigurationManager(); // List deptConfig = ocManager.GetChilds("department", EnumConfigurationType.Logic); // List deptTiers = ocManager.GetChilds(deptConfig, "tiernames"); // List locConfig = ocManager.GetChilds("location", EnumConfigurationType.Logic); // List 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 No"].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 = (_categoryID); // oCategory.SetObjectID(_categoryID); // oCategory.WagesType = EnumWagesType.Monthly; // _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 = (1); // ograde.HasPayscale = ConfigurationManager.GetBoolValue("grade", "payscaleapplicable ", EnumConfigurationType.Logic); // ograde.HasGrossConcept = ConfigurationManager.GetBoolValue("grade", "grossapplicable", EnumConfigurationType.Logic); // ograde.Name = row["Grade Name"].ToString().Trim(); // if (CodeautoGenerate == false) // ograde.Code = row["Grade Code"].ToString().Trim(); // _gradeid = _gradeid + 1; // oemployee.GradeID = (_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; // int tempid = (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 = (nparentid); // _departmentid = _departmentid + 1; // nparentid = _departmentid; // oemployee.DepartmentID = (_departmentid); // odepartment.SetObjectID(_departmentid); // _departments.Add(odepartment); // } // else // { // nparentid = odepartment.ID.Integer; // oemployee.DepartmentID = odepartment.ID; // } // //if (nIndex > 1) odepartment.ParentID = (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 = (nparentid); // _locationid = _locationid + 1; // nparentid = _locationid; // oemployee.LocationID = (_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 = (_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 = (_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); // CodeautoGenerate = true; // 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 = (_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 = (_branchid); // _branches.Add(oBranch); // } // else // { // oemployee.OutPayBranchID = oBranch.ID; // } // } // } // } // #endregion Bank & Branch upload // _employees.Add(oemployee); // } // return true; //} //public bool ProcessBasicDataDepartment(DataTable uploadTable) //{ // bool CodeautoGenerate = false; // RefreshObject(); // List emps = Employee.GetAllEmps(); // ConfigurationManager ocManager = new ConfigurationManager(); // List deptConfig = ocManager.GetChilds("department", EnumConfigurationType.Logic); // List deptTiers = ocManager.GetChilds(deptConfig, "tiernames"); // List locConfig = ocManager.GetChilds("location", EnumConfigurationType.Logic); // List 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++; // Employee oemployee = emps.Find(x => x.EmployeeNo == row["Employee No"].ToString()); // if (oemployee == null) // continue; // //oemployee.EmployeeNo = row["Employee No"].ToString(); // //oemployee.SetObjectID(_emloyeeId + 1); // object[] obj = row.ItemArray; // nRow = nRow + 1; // /// // /// Process Department whether it is already in the system or new location // /// // #region Department // int nparentid = 0; // int tempid = (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 = (nparentid); // _departmentid = _departmentid + 1; // nparentid = _departmentid; // oemployee.DepartmentID = (_departmentid); // odepartment.SetObjectID(_departmentid); // _departments.Add(odepartment); // } // else // { // nparentid = odepartment.ID.Integer; // oemployee.DepartmentID = odepartment.ID; // } // //if (nIndex > 1) odepartment.ParentID = (nparentid); // //nparentid = odepartment.ID.Integer; // } // #endregion // _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); // new SystemDataUpload().SaveOrganogram(_employees, _designations); // new SystemDataUpload().ImportPosting(_employees); // } // catch (Exception ex) // { // throw new ServiceException(ex.Message); // } //} //public void SaveDept() //{ // try // { // RegularDataUpload.Save2(_departments, _employees); // } // 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 ImportEmpBasicInfo(DataTable odataTable,int payrollTypeID) //{ // Employee oemployee = null; // this._payrollTypeID = payrollTypeID; // #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 No"].ToString(); }); // if (oemployee == null) throw new ServiceException("Employee not found in the collection; employeeNo:" + dr["Employee No"].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"]); // // oemployee.LineManagerNo = dr["Line Manager ID"].ToString() != string.Empty ? dr["Line Manager ID"].ToString() : null; // //For Novartis Discontinue Employee Upload and Fund Management Data Issue // //oemployee.Status = EnumEmployeeStatus.Discontinued; // oemployee.Gender = (dr["Gender"].ToString().Trim() == "Male" || dr["Gender"].ToString().Trim() == "M" || dr["Gender"].ToString().Trim() == "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; // //Refresh Employee Grade Salary // if (oemployee.GradeID != null) // { // Grade ograde = new Grade//_grades.GetItem(oemployee.GradeID); // oemployee.EmployeeGradeSalary.SetObjectID(oemployee.ID.Integer); // oemployee.EmployeeGradeSalary.GradeID = oemployee.GradeID; // oemployee.EmployeeGradeSalary.GradeSalaryTypeID = (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; // } // //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 = (_accessCardID); // AccessCard ocard = new AccessCard(); // ocard.SetObjectID(_accessCardID); // ocard.CardNumber = dr["PROXID"].ToString(); // ocard.TypeID = (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 ImportDeptInfo(DataTable odataTable) //{ // Employee oemployee = null; // #region Refresh Objects // if (ProcessBasicDataDepartment(odataTable) == false) return; // int nRow = 0; // try // { // foreach (DataRow dr in odataTable.Rows) // { // Application.DoEvents(); // nRow = nRow + 1; // //if (nRow == 1098) // // nRow = nRow; // oemployee = _employees.Find(delegate(Employee emp) { return emp.EmployeeNo == dr["Employee No"].ToString(); }); // if (oemployee == null) continue; // //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; // } // } // catch (Exception ex) // { // throw new ServiceException("Error occered on row:" + nRow + " Reason:" + ex.Message); // } // #endregion //} //public void ImportTaxAdjustmentData(DataTable odataTable, DataUploadColumnDefinition columnDefinition) //{ // List oTaxMergeMasters = new List(); // oTaxMergeMasters = TaxMergeMaster.GetbyTaxParameter(SystemInformation.CurrentSysInfo.TaxParamID); // Employee oemployee = null; // IncomeTax oIncomeTax = null; // TaxMergeMaster oTaxMergeMaster = null; // _employees = Employee.GetWithDiscontinue(); // List processItems = ProcessItem.Get(); // #region Refresh Objects // int nRow = 0; // List 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 ImportWPPFAllowance(DataTable odataTable, DataUploadColumnDefinition columnDefinition) //{ // List oTaxMergeMasters = new List(); // oTaxMergeMasters = TaxMergeMaster.GetbyTaxParameter(SystemInformation.CurrentSysInfo.TaxParamID); // Employee oemployee = null; // IncomeTax oIncomeTax = null; // TaxMergeMaster oTaxMergeMaster = null; // _employees = Employee.GetWithDiscontinue(); // List processItems = ProcessItem.Get(); // #region Refresh Objects // int nRow = 0; // List 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.NONE, (int)EnumIncomeTaxItemGroup.WPPF_Allowance); // 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; // } // oIncomeTax.EmployeeID = oemployee.ID; // oIncomeTax.PreviousAmount = oIncomeTax.PreviousAmount + nAmount; // if (oIncomeTax.PreviousAmount != 0) // { // _incomeTaxs.Add(oIncomeTax); // IncomeTax wppfExp = new IncomeTax(); // wppfExp.EmployeeID = oIncomeTax.EmployeeID; // wppfExp.Side =EnumIncomeTaxSide.Dec_SalaryIncome; // wppfExp.ItemGroup = EnumIncomeTaxItemGroup.WPPF_Examption; // wppfExp.ItemID = (int)EnumIncomeTaxItemGroup.WPPF_Examption; // wppfExp.Description = "WPPF Examption"; // wppfExp.Position = 49; // if (oIncomeTax.PreviousAmount <= 50000) // wppfExp.PreviousAmount = oIncomeTax.PreviousAmount; // else wppfExp.PreviousAmount = 50000; // _incomeTaxs.Add(wppfExp); // } // } // } // } // catch (Exception ex) // { // throw new ServiceException("Error occered on row:" + nRow + " Reason:" + ex.Message); // } // #endregion //} //public void ImportTaxDataInfo(DataTable odataTable) //{ // List oTaxMergeMasters = new List(); // oTaxMergeMasters = TaxMergeMaster.GetbyTaxParameter(SystemInformation.CurrentSysInfo.TaxParamID); // Employee oemployee = null; // IncomeTax oIncomeTax = null; // TaxMergeMaster oTaxMergeMaster = null; // _employees = Employee.GetAllEmps(); // List processItems = ProcessItem.Get(); // #region Refresh Objects // int nRow = 0; // List 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 //} } }