CEL_Payroll/Payroll.BO/SetupManager/ConfigReader.cs

188 lines
7.4 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
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<SetupDetail> _SetupDetails = null;
private int _totalType = 0;
List<string> _sTypes = null;
List<string> _sqlRelationtoEmp = null;
List<EnmSetupManagerTranType> _nTypes = null;
public ObjectsTemplate<SetupDetail> Details
{
get
{
return _SetupDetails;
}
}
public List<string> Types
{
get
{
return _sTypes;
}
}
public List<EnmSetupManagerTranType> EnumTypes
{
get
{
return _nTypes;
}
}
public List<string> SQLRelationToEmp
{
get
{
return _sqlRelationtoEmp;
}
}
public int TotalTypes
{
get
{
return _totalType;
}
}
public static List<EnmSetupManagerTranType> GetTotalTypes(string sType)
{
List<EnmSetupManagerTranType> nTypes = new List<EnmSetupManagerTranType>();
// 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<string>();
_nTypes = new List<EnmSetupManagerTranType>();
_sqlRelationtoEmp = new List<string>();
if (items != null && items.Length > 0)
{
_SetupDetails = new ObjectsTemplate<SetupDetail>();
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<Grade> 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<Location> 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<Category> 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<Designation> 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;
}
}
}
}
}
}