254 lines
12 KiB
C#
254 lines
12 KiB
C#
|
using System;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Data;
|
|||
|
//using EaseFAS.BO;
|
|||
|
using System.Xml;
|
|||
|
using System.IO;
|
|||
|
using System.Reflection;
|
|||
|
using Ease.Core.Model;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
|
|||
|
namespace HRM.BO
|
|||
|
{
|
|||
|
#region ConfigHelper
|
|||
|
public class ConfigHelper
|
|||
|
{
|
|||
|
#region Constructor ConfigHelper
|
|||
|
public ConfigHelper()
|
|||
|
{
|
|||
|
TranTypeID = 0;
|
|||
|
TranTypeName = string.Empty;
|
|||
|
CategoryID = 0;
|
|||
|
CategoryName = string.Empty;
|
|||
|
FundTypeID = 0;
|
|||
|
Effect =EnumTranEffect.Increase;
|
|||
|
TranElementItems = new List<int> ();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Property
|
|||
|
|
|||
|
#region TranTypeID
|
|||
|
public int TranTypeID { get; set; }
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region TranTypeName
|
|||
|
public string TranTypeName { get; set; }
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region CategoryID
|
|||
|
public int CategoryID { get; set; }
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region CategoryName
|
|||
|
public string CategoryName { get; set; }
|
|||
|
#endregion
|
|||
|
|
|||
|
#region FundTypeID
|
|||
|
public int FundTypeID { get; set; }
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Effect
|
|||
|
public EnumTranEffect Effect { get; set; }
|
|||
|
#endregion
|
|||
|
|
|||
|
#region TranElementItems
|
|||
|
public List<int> TranElementItems { get; set; }
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region GetCofiguration
|
|||
|
//public static ConfigHelper GetConfig(string tranTypeID)
|
|||
|
//{
|
|||
|
// try
|
|||
|
// {
|
|||
|
// ConfigHelper oConfigHelper = new ConfigHelper();
|
|||
|
// XmlTextReader reader = null;
|
|||
|
// if (File.Exists(@Application.StartupPath + @"\TranConfig.xml"))
|
|||
|
// {
|
|||
|
// reader = new XmlTextReader(@Application.StartupPath + @"\TranConfig.xml");
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// byte[] xml = Encoding.ASCII.GetBytes(XML.TranConfig);
|
|||
|
// File.WriteAllBytes(Application.StartupPath + @"\TranConfig.xml", xml);
|
|||
|
// reader = new XmlTextReader(@Application.StartupPath + @"\TranConfig.xml");
|
|||
|
// //MessageBox.Show("XML file not found", "XML File", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
// //return oConfigHelper = null;
|
|||
|
// }
|
|||
|
// XmlDocument oxmlDocument = new XmlDocument();
|
|||
|
// oxmlDocument.Load(reader);
|
|||
|
|
|||
|
// XmlNodeList xmlNodes = oxmlDocument.DocumentElement.ChildNodes; //oxmlDocument.GetElementById(nTranID).ChildNodes;//GetElementById(nTranID)
|
|||
|
// foreach (XmlNode oNode in xmlNodes)
|
|||
|
// {
|
|||
|
// if (oNode.Attributes["ID"].InnerText == tranTypeID)
|
|||
|
// {
|
|||
|
// switch (oNode.Name)
|
|||
|
// {
|
|||
|
// case "TranType":
|
|||
|
|
|||
|
// foreach (XmlAttribute oAttribute in oNode.Attributes)
|
|||
|
// {
|
|||
|
// switch (oAttribute.Name)
|
|||
|
// {
|
|||
|
// case "ID":
|
|||
|
// oConfigHelper.TranTypeID = Convert.ToInt32(oAttribute.InnerText);
|
|||
|
// break;
|
|||
|
// case "Name":
|
|||
|
// oConfigHelper.TranTypeName = oAttribute.InnerText;
|
|||
|
// break;
|
|||
|
// case "CategoryID":
|
|||
|
// oConfigHelper.CategoryID = Convert.ToInt32(oAttribute.InnerText);
|
|||
|
// break;
|
|||
|
// case "CategoryName":
|
|||
|
// oConfigHelper.CategoryName = oAttribute.InnerText;
|
|||
|
// break;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// break;
|
|||
|
// }
|
|||
|
// foreach (XmlNode oChild in oNode.ChildNodes)
|
|||
|
// {
|
|||
|
// switch (oChild.Name)
|
|||
|
// {
|
|||
|
// case "Effect":
|
|||
|
// oConfigHelper.Effect = (EnumTranEffect)Convert.ToInt32(oChild.InnerText);
|
|||
|
// break;
|
|||
|
// case "FundTypeID":
|
|||
|
// oConfigHelper.FundTypeID = Convert.ToInt32(oChild.InnerText);
|
|||
|
// break;
|
|||
|
// case "TranElement":
|
|||
|
// foreach (XmlNode tranItem in oChild.ChildNodes)
|
|||
|
// oConfigHelper.TranElementItems.Add(Convert.ToInt32(tranItem.InnerText));
|
|||
|
// break;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// return oConfigHelper;
|
|||
|
// }
|
|||
|
// catch (ServiceException e)
|
|||
|
// {
|
|||
|
// throw new ServiceException(e.Message, e);
|
|||
|
// }
|
|||
|
//}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update Transaction Using TranConfig
|
|||
|
//public static void UploadTranType(TransactionContext tc, string tranTypeID, int projectID, int MemberID, double amount)
|
|||
|
//{
|
|||
|
// try
|
|||
|
// {
|
|||
|
// ConfigHelper oConfigHelper = new ConfigHelper();
|
|||
|
// XmlTextReader reader = null;
|
|||
|
// if (File.Exists(@Application.StartupPath + @"\TranConfig.xml"))
|
|||
|
// {
|
|||
|
// reader = new XmlTextReader(@Application.StartupPath + @"\TranConfig.xml");
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// byte[] xml = Encoding.ASCII.GetBytes(XML.TranConfig);
|
|||
|
// File.WriteAllBytes(Application.StartupPath + @"\TranConfig.xml", xml);
|
|||
|
// reader = new XmlTextReader(@Application.StartupPath + @"\TranConfig.xml");
|
|||
|
// //MessageBox.Show("XML file not found", "XML File", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
// //return oConfigHelper = null;
|
|||
|
// }
|
|||
|
// XmlDocument oxmlDocument = new XmlDocument();
|
|||
|
// oxmlDocument.Load(reader);
|
|||
|
|
|||
|
// XmlNodeList xmlNodes = oxmlDocument.DocumentElement.ChildNodes; //oxmlDocument.GetElementById(nTranID).ChildNodes;//GetElementById(nTranID)
|
|||
|
// foreach (XmlNode oNode in xmlNodes)
|
|||
|
// {
|
|||
|
// if (oNode.Attributes["ID"].InnerText == tranTypeID)
|
|||
|
// {
|
|||
|
// switch (oNode.Name)
|
|||
|
// {
|
|||
|
// case "TranType":
|
|||
|
|
|||
|
// foreach (XmlAttribute oAttribute in oNode.Attributes)
|
|||
|
// {
|
|||
|
// switch (oAttribute.Name)
|
|||
|
// {
|
|||
|
// case "ID":
|
|||
|
// oConfigHelper.TranTypeID = Convert.ToInt32(oAttribute.InnerText);
|
|||
|
// break;
|
|||
|
// case "Name":
|
|||
|
// oConfigHelper.TranTypeName = oAttribute.InnerText;
|
|||
|
// break;
|
|||
|
// case "CategoryID":
|
|||
|
// oConfigHelper.CategoryID = Convert.ToInt32(oAttribute.InnerText);
|
|||
|
// break;
|
|||
|
// case "CategoryName":
|
|||
|
// oConfigHelper.CategoryName = oAttribute.InnerText;
|
|||
|
// break;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// break;
|
|||
|
// }
|
|||
|
// foreach (XmlNode oChild in oNode.ChildNodes)
|
|||
|
// {
|
|||
|
// switch (oChild.Name)
|
|||
|
// {
|
|||
|
// case "Effect":
|
|||
|
// oConfigHelper.Effect = (EnumTranEffect)Convert.ToInt32(oChild.InnerText);
|
|||
|
// break;
|
|||
|
// case "FundTypeID":
|
|||
|
// oConfigHelper.FundTypeID = Convert.ToInt32(oChild.InnerText);
|
|||
|
// break;
|
|||
|
// case "TranElement":
|
|||
|
// foreach (XmlNode tranItem in oChild.ChildNodes)
|
|||
|
// {
|
|||
|
// TranElement tranElement = new TranElement();
|
|||
|
// if (tranItem.InnerText != "")
|
|||
|
// {
|
|||
|
// int i = Convert.ToInt32(tranItem.InnerText);
|
|||
|
// tranElement = tranElement.Get(ID.FromInteger(i));
|
|||
|
// }
|
|||
|
// string st = string.Empty;
|
|||
|
// if (tranElement != null)
|
|||
|
// {
|
|||
|
// if (oConfigHelper.Effect == EnumTranEffect.Increase)
|
|||
|
// {
|
|||
|
// if (tranElement.Source != "" && tranElement.Name != "" && amount >= 0 && projectID >= 0 && MemberID != 0 && oConfigHelper.FundTypeID >= 0)
|
|||
|
// st = "Update " + tranElement.Source + " SET " + tranElement.Name + "=" + tranElement.Name + "+" + amount + " Where ProjectID=" + projectID + " AND MembersID=" + MemberID + " AND FundTypeID=" + oConfigHelper.FundTypeID;
|
|||
|
// //oConfigHelper.TranElementItems.Add(Convert.ToInt32(tranItem.InnerText));
|
|||
|
// }
|
|||
|
// else if (oConfigHelper.Effect == EnumTranEffect.Decrease)
|
|||
|
// {
|
|||
|
// if (tranElement.Source != "" && tranElement.Name != "" && amount >= 0 && projectID >= 0 && MemberID != 0 && oConfigHelper.FundTypeID >= 0)
|
|||
|
// st = "Update " + tranElement.Source + " SET " + tranElement.Name + "=" + tranElement.Name + "-" + amount + " Where ProjectID=" + projectID + " AND MembersID=" + MemberID + " AND FundTypeID=" + oConfigHelper.FundTypeID;
|
|||
|
// //oConfigHelper.TranElementItems.Add(Convert.ToInt32(tranItem.InnerText));
|
|||
|
// }
|
|||
|
// if (st != string.Empty)
|
|||
|
// {
|
|||
|
|
|||
|
// tc.ExecuteNonQuery(st);
|
|||
|
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// break;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// // return oConfigHelper;
|
|||
|
// }
|
|||
|
// catch (ServiceException e)
|
|||
|
// {
|
|||
|
// throw new ServiceException(e.Message, e);
|
|||
|
// }
|
|||
|
//}
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|