CEL_Payroll/Payroll.BO/Basic/SystemInformation.cs
2024-09-17 14:30:13 +06:00

500 lines
14 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35;
using Ease.CoreV35.Model;
using Ease.CoreV35.Caching;
using System.Data.Linq.Mapping;
using Ease.CoreV35.Utility;
using System.Data;
namespace Payroll.BO
{
public interface IworkflowInterface
{
string ObjectDescription { get; }
ID SetupID { get; }
ID ObjectID { get; }
}
#region SystemInformation
[Serializable]
public class SystemInformation : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(SystemInformation));
#endregion
#region Constructor
public SystemInformation()
{
_code = string.Empty;
_name = string.Empty;
_corporateAddress = string.Empty;
_factoryAddress = string.Empty;
_telephoneNo = string.Empty;
_email = string.Empty;
_webAddress = string.Empty;
_systemStartDate = DateTime.MinValue;
_taxYearEndDate = DateTime.MinValue;
_nextPayProcessDate = DateTime.MinValue;
_maxYearOfService = 0;
_pFContriStaff = 0;
_pFContriCompany = 0;
_pFInterest = 0;
_taxParamID = null;
_oTFilePath = string.Empty;
_pFYearEndDate = DateTime.MinValue;
}
#endregion
#region Properties
private static SystemInformation _currentSysInfo;
#region Code : string
private string _code;
public string Code
{
get { return _code; }
set
{
base.OnPropertyChange<string>("Code", _code, value);
_code = value;
}
}
#endregion
#region name : string
private string _name;
public string name
{
get { return _name; }
set
{
base.OnPropertyChange<string>("name", _name, value);
_name = value;
}
}
#endregion
#region corporateAddress : string
private string _corporateAddress;
public string corporateAddress
{
get { return _corporateAddress; }
set
{
base.OnPropertyChange<string>("corporateAddress", _corporateAddress, value);
_corporateAddress = value;
}
}
#endregion
#region factoryAddress : string
private string _factoryAddress;
public string factoryAddress
{
get { return _factoryAddress; }
set
{
base.OnPropertyChange<string>("factoryAddress", _factoryAddress, value);
_factoryAddress = value;
}
}
#endregion
#region TelephoneNo : string
private string _telephoneNo;
public string TelephoneNo
{
get { return _telephoneNo; }
set
{
base.OnPropertyChange<string>("telephoneNo", _telephoneNo, value);
_telephoneNo = value;
}
}
#endregion
#region email : string
private string _email;
public string email
{
get { return _email; }
set
{
base.OnPropertyChange<string>("email", _email, value);
_email = value;
}
}
#endregion
#region webAddress : string
private string _webAddress;
public string webAddress
{
get { return _webAddress; }
set
{
base.OnPropertyChange<string>("webAddress", _webAddress, value);
_webAddress = value;
}
}
#endregion
#region systemStartDate : DateTime
private DateTime _systemStartDate;
public DateTime systemStartDate
{
get { return _systemStartDate; }
set
{
base.OnPropertyChange<DateTime>("systemStartDate", _systemStartDate, value);
_systemStartDate = value;
}
}
#endregion
#region taxYearEndDate : DateTime
private DateTime _taxYearEndDate;
public DateTime TaxYearEndDate
{
get { return _taxYearEndDate; }
set
{
base.OnPropertyChange<DateTime>("taxYearEndDate", _taxYearEndDate, value);
_taxYearEndDate = value;
}
}
#endregion
#region nextPayProcessDate : DateTime
private DateTime _nextPayProcessDate;
public DateTime NextPayProcessDate
{
get { return _nextPayProcessDate; }
set
{
base.OnPropertyChange<DateTime>("nextPayProcessDate", _nextPayProcessDate, value);
_nextPayProcessDate = value;
}
}
public DateTime LastPayProcessDate
{
get { return Global.DateFunctions.LastDateOfMonth(_nextPayProcessDate.AddMonths(-1)); }
}
#endregion
#region maxYearOfService : int
private int _maxYearOfService;
public int maxYearOfService
{
get { return _maxYearOfService; }
set
{
base.OnPropertyChange<int>("maxYearOfService", _maxYearOfService, value);
_maxYearOfService = value;
}
}
#endregion
#region pFContriStaff : double
private double _pFContriStaff;
public double pFContriStaff
{
get { return _pFContriStaff; }
set
{
base.OnPropertyChange<double>("pFContriStaff", _pFContriStaff, value);
_pFContriStaff = value;
}
}
#endregion
#region pFContriCompany : double
private double _pFContriCompany;
public double pFContriCompany
{
get { return _pFContriCompany; }
set
{
base.OnPropertyChange<double>("pFContriCompany", _pFContriCompany, value);
_pFContriCompany = value;
}
}
#endregion
#region pFInterest : double
private double _pFInterest;
public double pFInterest
{
get { return _pFInterest; }
set
{
base.OnPropertyChange<double>("pFInterest", _pFInterest, value);
_pFInterest = value;
}
}
#endregion
#region taxParamID : int
private ID _taxParamID;
public ID TaxParamID
{
get { return _taxParamID; }
set
{
base.OnPropertyChange<ID>("taxParamID", _taxParamID, value);
_taxParamID = value;
}
}
#endregion
#region oTFilePath : string
private string _oTFilePath;
public string oTFilePath
{
get { return _oTFilePath; }
set
{
base.OnPropertyChange<string>("oTFilePath", _oTFilePath, value);
_oTFilePath = value;
}
}
#endregion
#region pFYearEndDate : DateTime
private DateTime _pFYearEndDate;
public DateTime PFYearEndDate
{
get { return _pFYearEndDate; }
set
{
base.OnPropertyChange<DateTime>("pFYearEndDate", _pFYearEndDate, value);
_pFYearEndDate = value;
}
}
#endregion
#region PayrollTypeID : Int
private ID _logInPayrollTypeID;
public ID PayrollTypeID
{
get { return _logInPayrollTypeID; }
set
{
_logInPayrollTypeID = value;
}
}
#endregion
#region PayrollTypeID : Int
public static SystemInformation CurrentSysInfo
{
get
{
if (_currentSysInfo == null)
{
_currentSysInfo = SystemInformation.Get();
}
return _currentSysInfo;
}
set
{
_currentSysInfo = null;
}
}
#endregion
#region Service Factory ISystemInformationService : ISystemInformationService
internal static ISystemInformationService Service
{
get { return Services.Factory.CreateService<ISystemInformationService>(typeof(ISystemInformationService)); }
}
#endregion
#endregion
#region Functions
public static SystemInformation Get()
{
SystemInformation oSystemInformation = null;
#region Cache Header
oSystemInformation = (SystemInformation)_cache["Get"];
if (oSystemInformation != null)
return oSystemInformation;
#endregion
oSystemInformation = SystemInformation.Service.Get();
MergeWithLogInPayrollType(oSystemInformation);
_currentSysInfo = oSystemInformation;
#region Cache Footer
_cache.Add(oSystemInformation, "Get");
#endregion
return oSystemInformation;
}
public static DateTime GetServerDate()
{
return Service.GetServerDate();
}
private static void MergeWithLogInPayrollType(SystemInformation systemInfo)
{
if (User.CurrentUser == null) return;
if (User.CurrentUser.UserType != EnumSystemType.Web)
if (User.CurrentUser.LogInMode != EnumUserLogInMode.Normal) return;
PayrollType pType = PayrollType.Get(User.CurrentUser.LogInPayrollTypeID);
systemInfo.NextPayProcessDate = pType.NextPayProcessDate;
systemInfo.TaxParamID = pType.TaxParamID;
systemInfo.PFYearEndDate = pType.PFYearEndDate;
systemInfo.TaxYearEndDate = pType.TaxYearEndDate;
systemInfo.PayrollTypeID = User.CurrentUser.LogInPayrollTypeID;
//_currentSysInfo.NextPayProcessDate = pType.NextPayProcessDate;
//_currentSysInfo.TaxParamID = pType.TaxParamID;
//_currentSysInfo.PFYearEndDate = pType.PFYearEndDate;
//_currentSysInfo.TaxYearEndDate = pType.TaxYearEndDate;
//_currentSysInfo.LogInPayrollTypeID = User.CurrentUser.LogInPayrollTypeID;
}
public void Update()
{
SystemInformation.Service.Update(this);
}
public void Save(HardPasswordSetup oItem)
{
SystemInformation.Service.Save(oItem);
}
public void UpdCurrYerTaxParamter(ID nTaxYearId)
{
SystemInformation.Service.UpdCurrYerTaxParamter(nTaxYearId, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
public string GetConnectionString()
{
return SystemInformation.Service.GetConnectionString();
}
public HardPasswordSetup GetPasswordSetup()
{
DataTable ds = null;
HardPasswordSetup oItem = new HardPasswordSetup();
try
{
ds = Service.GetPasswordSetup();
if (ds != null && ds.Rows.Count > 0)
{
foreach (DataRow dr in ds.Rows)
{
oItem.MaxLength = Convert.ToInt16(dr["MaxLength"]);
oItem.MinLength = Convert.ToInt16(dr["MinLength"]);
oItem.PasswordExpireNotificationDays = Convert.ToInt16(dr["PasswordExpireNotificationDays"]);
oItem.PasswordExpireDays = Convert.ToInt16(dr["PasswordExpireDays"]);
oItem.ContainLowercase = Convert.ToBoolean(dr["ContainLowercase"]);
oItem.ContainNumber = Convert.ToBoolean(dr["ContainNumber"]);
oItem.ContainSpecialCharacter = Convert.ToBoolean(dr["ContainSpecialCharacter"]);
oItem.ContainUppercase = Convert.ToBoolean(dr["ContainUppercase"]);
oItem.ContainLetter = Convert.ToBoolean(dr["ContainLetter"]);
oItem.UserPasswordSame = Convert.ToBoolean(dr["UserPasswordSame"]);
}
}
}
catch (Exception e)
{
throw new Exception(e.Message, e);
}
return oItem;
}
public static string GetDatabaseName()
{
return SystemInformation.Service.GetDatabaseName();
}
#endregion
}
#endregion
public class HardPasswordSetup
{
public int MaxLength { get; set; }
public int MinLength { get; set; }
public bool ContainUppercase { get; set; }
public bool ContainLowercase { get; set; }
public bool ContainSpecialCharacter { get; set; }
public bool ContainNumber { get; set; }
public bool ContainLetter { get; set; }
public bool UserPasswordSame { get; set; }
public int PasswordExpireNotificationDays { get; set; }
public int PasswordExpireDays { get; set; }
}
#region ISystemInformation Service
public interface ISystemInformationService
{
SystemInformation Get();
ID Update(SystemInformation item);
DateTime GetServerDate();
string GetConnectionString();
void UpdCurrYerTaxParamter(ID taxParameterID, ID PayrollTypeID);
string GetDatabaseName();
DataTable GetPasswordSetup();
void Save(HardPasswordSetup oItem);
}
#endregion
}