EchoTex_Payroll/HRM.BO/Common/DataUploadColumnDefinition.cs

313 lines
7.5 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using Ease.Core.Model;
using Payroll.BO;
using System;
using System.Collections.Generic;
using System.Data;
namespace HRM.BO
{
public class DataUploadColumnDefinition : ColumnDefinationException
{
#region Declarations
public DataUploadColumnDefinition()
{
_sheetName = string.Empty;
_columnName = new List<string>();
_SheetCollection = new List<string>();
_dataType = new List<string>();
_allowNull = new List<string>();
_itemOneCombo = null;
_itemTwoCombo = null;
_itemThreeDate = null;
_selectedItemOneID = (0);
_selectedItemTwoID = (0);
_selectedItemOneText = String.Empty;
//_itemThreeSelectedDate = DateTime.Today;
}
#endregion
#region Property
public int uploadID { get; set; }
public int? uploadItemID { get; set; }
#region Property SheetName : String
private string _sheetName;
public string SheetName
{
get { return _sheetName; }
set { _sheetName = value; }
}
public string getColumnNames()
{
string scolName = "";
foreach (string col in this._columnName)
{
scolName = scolName + col + ", ";
}
if (scolName.Length > 2)
scolName = scolName.Substring(0, scolName.Length - 2);
return scolName;
}
#endregion
#region Property SheetCollection : Collection
private List<string> _SheetCollection;
public List<string> SheetCollection
{
get { return _SheetCollection; }
set { _SheetCollection = value; }
}
#endregion
#region Property ColumnName : Collection
private List<string> _columnName;
public List<string> ColumnName
{
get { return _columnName; }
set { _columnName = value; }
}
#endregion
#region Property DataType : Collection
private List<string> _dataType;
public List<string> DataType
{
get { return _dataType; }
set { _dataType = value; }
}
#endregion
#region Property AllowNull : Collection
private List<string> _allowNull;
public List<string> AllowNull
{
get { return _allowNull; }
set { _allowNull = value; }
}
#endregion
#region Property Item One : string
private string _itemOneComboText;
public string ItemOneComboText
{
get { return _itemOneComboText; }
set { _itemOneComboText = value; }
}
#endregion
#region Property Item One : Collection
private Dictionary<int, string> _itemOneCombo;
public Dictionary<int, string> ItemOneComboData
{
get { return _itemOneCombo; }
set { _itemOneCombo = value; }
}
#endregion
#region Property Item One Selected Value : ID
private int _selectedItemOneID;
public int SelectedItemOneID
{
get { return _selectedItemOneID; }
set { _selectedItemOneID = value; }
}
#endregion
#region Property Item One Selected Text : ID
private string _selectedItemOneText;
public string SelectedItemOneText
{
get { return _selectedItemOneText; }
set { _selectedItemOneText = value; }
}
#endregion
#region Property Item Two Text : string
private string _itemTwoComboText;
public string ItemTwoComboText
{
get { return _itemTwoComboText; }
set { _itemTwoComboText = value; }
}
#endregion
#region Property Item Two : Collection
private Dictionary<int, string> _itemTwoCombo;
public Dictionary<int, string> ItemTwoComboData
{
get { return _itemTwoCombo; }
set { _itemTwoCombo = value; }
}
#endregion
#region Property Item Two Selected Value : ID
private int _selectedItemTwoID;
public int SelectedItemTwoID
{
get { return _selectedItemTwoID; }
set { _selectedItemTwoID = value; }
}
#endregion
#region Property Item Three Text : string
private string _itemThreeDateText;
public string ItemThreeDateText
{
get { return _itemThreeDateText; }
set { _itemThreeDateText = value; }
}
#endregion
#region Property Item Three : Collection
private DateTime? _itemThreeDate;
public DateTime? ItemThreeDateData
{
get { return _itemThreeDate; }
set { _itemThreeDate = value; }
}
#endregion
#region Property Item Three Selected Value: DateTime
private DateTime? _itemThreeSelectedDate;
public DateTime? ItemThreeSelectedDate
{
get { return _itemThreeSelectedDate; }
set { _itemThreeSelectedDate = value; }
}
#endregion
#region Property From Text : string
private string _formText;
public string FormText
{
get { return _formText; }
set { _formText = value; }
}
#endregion
#region Property Item One Selected Value : ID
private int _payrollTypeID;
public int PayrollTypeID
{
get { return _payrollTypeID; }
set { _payrollTypeID = value; }
}
#endregion
#endregion
public void Add(string fieldName, string dataType, string allowNull)
{
this.ColumnName.Add(fieldName);
this.DataType.Add(dataType);
this.AllowNull.Add(allowNull);
}
public bool IsAllowNull(string scolumnName)
{
int nIndex = 0;
foreach (string col in this._columnName)
{
if (col.ToUpper().Trim() == scolumnName.ToUpper().Trim())
{
if (this.AllowNull[nIndex].ToUpper() == "YES") return true;
else return false;
}
nIndex = nIndex + 1;
}
throw new ServiceException("Column:" + scolumnName + " is not exist in the sheet:" + this.SheetName);
return false;
}
public int getColumnIndex(string scolumnName)
{
int index = 0;
foreach (string col in this._columnName)
{
if (col.ToUpper().Trim() == scolumnName.ToUpper().Trim()) return index;
index = index + 1;
}
throw new ServiceException("Column not exist in the collection.");
return -1;
}
public string GetColumnDataType(string scolumnName)
{
int nIndex = 0;
foreach (string col in this._columnName)
{
if (col.ToUpper().Trim() == scolumnName.ToUpper().Trim())
return this.DataType[nIndex].ToUpper();
nIndex = nIndex + 1;
}
throw new ServiceException("Column not exist in the collection.");
return "";
}
}
public interface IDataUploadColumnDefinition
{
DataUploadColumnDefinition GetColumnDefinition(int uploadId ,int? itemid, int payrolltypeID);
}
}