using System; using System.Text; using System.Data; using System.Data.SqlClient; using System.Collections; using System.Collections.Generic; using System.Configuration; using Ease.CoreV35.Model; namespace Payroll.BO { [Serializable] public class ConfigReader { private string[] items = null; private ObjectsTemplate _SetupDetails = null; private int _totalType = 0; List _sTypes = null; List _sqlRelationtoEmp = null; List _nTypes = null; public ObjectsTemplate Details { get { return _SetupDetails; } } public List Types { get { return _sTypes; } } public List EnumTypes { get { return _nTypes; } } public List SQLRelationToEmp { get { return _sqlRelationtoEmp; } } public int TotalTypes { get { return _totalType; } } public static List GetTotalTypes(string sType) { List nTypes = new List(); // string value = System.Configuration.ConfigurationManager.AppSettings[sType]; string[] items = sType.Split(','); if (items != null && items.Length > 0) { foreach (string item in items) { switch (item.ToLower().Trim()) { case "grade": nTypes.Add(EnmSetupManagerTranType.Grade); break; case "location": nTypes.Add(EnmSetupManagerTranType.Location); break; case "category": nTypes.Add(EnmSetupManagerTranType.Category); break; case "designation": nTypes.Add(EnmSetupManagerTranType.Designation); break; } } } return nTypes; } public ConfigReader(string sType) { items = sType.Split(','); SetupDetail detail = null; _sTypes = new List(); _nTypes = new List(); _sqlRelationtoEmp = new List(); if (items != null && items.Length > 0) { _SetupDetails = new ObjectsTemplate(); foreach (string item in items) { switch (item.ToLower().Trim()) { case "grade": _sTypes.Add("Grade"); _nTypes.Add(EnmSetupManagerTranType.Grade); _totalType++; _sqlRelationtoEmp.Add(" SD.TranType=1 AND E.GradeID= SD.TranID"); ObjectsTemplate oGrades = Grade.Get(EnumStatus.Active); //Grades oGrades = Grades.Get(); foreach (Grade grade in oGrades) { detail = new SetupDetail(); detail.Code = grade.Code; detail.Name = grade.Name; detail.IsSelected = false; detail.TranID = grade.ID; detail.TranType = EnmSetupManagerTranType.Grade; _SetupDetails.Add(detail); } break; case "location": _totalType++; _sTypes.Add("Location"); _nTypes.Add(EnmSetupManagerTranType.Location); _sqlRelationtoEmp.Add(" SD.TranType=2 AND E.LocationID= SD.TranID"); ObjectsTemplate oLocations = Location.GetParents(EnumStatus.Active); //Locations oLocations = Locations.GetLocation(); foreach (Location olocation in oLocations) { //if (olocation.Tier == 1) continue; detail = new SetupDetail(); detail.Code = olocation.Code; detail.Name = olocation.Name; detail.IsSelected = false; detail.TranID = olocation.ID; detail.TranType = EnmSetupManagerTranType.Location; _SetupDetails.Add(detail); } break; case "category": _sTypes.Add("Category"); _nTypes.Add(EnmSetupManagerTranType.Category); _totalType++; _sqlRelationtoEmp.Add(" SD.TranType=3 AND E.CategoryID= SD.TranID"); ObjectsTemplate oCategorys = Category.Get(EnumStatus.Active); //Categories oCategorys = Categories.Get(); foreach (Category ocat in oCategorys) { detail = new SetupDetail(); detail.Code = ocat.Code; detail.Name = ocat.Name; detail.IsSelected = false; detail.TranID = ocat.ID; detail.TranType = EnmSetupManagerTranType.Category; _SetupDetails.Add(detail); } break; case "designation": _sTypes.Add("Designation"); _nTypes.Add(EnmSetupManagerTranType.Designation); _totalType++; _sqlRelationtoEmp.Add(" SD.TranType=4 AND E.DesignationID= SD.TranID"); ObjectsTemplate oDesignations = Designation.Get(EnumStatus.Active); //Designations oDesignations = Designations.Get(); foreach (Designation oDesg in oDesignations) { detail = new SetupDetail(); detail.Code = oDesg.Code; detail.Name = oDesg.Name; detail.IsSelected = false; detail.TranID = oDesg.ID; detail.TranType = EnmSetupManagerTranType.Designation; _SetupDetails.Add(detail); } break; } } } } } }