118 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			118 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.Data;
 | 
						|
using Ease.Core.DataAccess;
 | 
						|
using HRM.BO;
 | 
						|
 | 
						|
 | 
						|
namespace HRM.DA
 | 
						|
{
 | 
						|
    public class AssetDA
 | 
						|
    {
 | 
						|
        #region Constructor
 | 
						|
 | 
						|
        private AssetDA()
 | 
						|
        {
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
 | 
						|
        #region Get
 | 
						|
 | 
						|
        internal static IDataReader Get(TransactionContext tc, int id)
 | 
						|
        {
 | 
						|
            return tc.ExecuteReader("SELECT * FROM Asset WHERE AssetID=%n", id);
 | 
						|
        }
 | 
						|
 | 
						|
        internal static IDataReader Get(TransactionContext tc)
 | 
						|
        {
 | 
						|
            return tc.ExecuteReader("SELECT * FROM Asset order by AssetId asc");
 | 
						|
        }
 | 
						|
 | 
						|
        internal static IDataReader Get(TransactionContext tc, Employee oEmployee, EnumAssetInventoryType assetType,
 | 
						|
            bool defaultItem)
 | 
						|
        {
 | 
						|
            return tc.ExecuteReader(
 | 
						|
                "SELECT * FROM Asset where (AssignUserNo1=%s OR AssignUserNo2=%s) AND AssetType=%n AND DefaultItem=%b",
 | 
						|
                oEmployee.EmployeeNo, oEmployee.EmployeeNo, assetType, defaultItem);
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        internal static IDataReader Get(TransactionContext tc, Employee oEmployee)
 | 
						|
        {
 | 
						|
            return tc.ExecuteReader("SELECT * FROM Asset where (AssignUserNo1=%s OR AssignUserNo2=%s) ",
 | 
						|
                oEmployee.EmployeeNo, oEmployee.EmployeeNo);
 | 
						|
        }
 | 
						|
 | 
						|
        internal static IDataReader Get(TransactionContext tc, EnumAssetInventoryType assetType)
 | 
						|
        {
 | 
						|
            return tc.ExecuteReader("SELECT * FROM Asset where AssetType=%n",
 | 
						|
                assetType);
 | 
						|
        }
 | 
						|
 | 
						|
        internal static IDataReader GetLineManagerItem(TransactionContext tc)
 | 
						|
        {
 | 
						|
            return tc.ExecuteReader("SELECT * FROM Asset where IsLinemanager=%b ", true
 | 
						|
            );
 | 
						|
        }
 | 
						|
 | 
						|
        internal static IDataReader Get(TransactionContext tc, string name)
 | 
						|
        {
 | 
						|
            return tc.ExecuteReader("SELECT * FROM Asset WHERE Name=%s", name);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Insert
 | 
						|
 | 
						|
        internal static void Insert(TransactionContext tc, Asset oAsset)
 | 
						|
        {
 | 
						|
            string sql = SQLParser.MakeSQL("INSERT INTO Asset(AssetID, Code, Name, Description," +
 | 
						|
                                           "BuyTime, Remarks, IsUsing,BuyPrice,Section,AssignUserNo1,AssignUserNo2,IsLinemanager,CreatedBy, CreationDate, AssetType, DefaultItem,AssignEmployeeNo1,AssignEmployeeNo2,IsSerailItem,AssetCategoryId,WarrentyDays)" +
 | 
						|
                                           "VALUES(%n, %s, %s, %s, %d, %s, %n,%n, %s, %s, %s,%b,%n,%d,%n,%b,%n,%n,%b,%n,%n)",
 | 
						|
                oAsset.ID, oAsset.Code, oAsset.Name, oAsset.Description,
 | 
						|
                oAsset.BuyTime, oAsset.Remarks, Convert.ToInt32(oAsset.IsUsing),
 | 
						|
                oAsset.BuyPrice, oAsset.Section, oAsset.AssignUserNo1, oAsset.AssignUserNo2, oAsset.IsLinemanager,
 | 
						|
                DataReader.GetNullValue(oAsset.CreatedBy),
 | 
						|
                DataReader.GetNullValue(oAsset.CreatedDate), oAsset.AssetType, oAsset.DefaultItem,oAsset.AssignEmployeeNo1,oAsset.AssignEmployeeNo2,oAsset.IsSerailItem,oAsset.AssetCategoryId,oAsset.WarrentyDays);
 | 
						|
            tc.ExecuteNonQuery(sql);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
 | 
						|
        #region Update
 | 
						|
 | 
						|
        internal static void Update(TransactionContext tc, Asset oAsset)
 | 
						|
        {
 | 
						|
            string sSQL = SQLParser.MakeSQL("UPDATE Asset SET Code=%s,Name=%s,Description=%s," +
 | 
						|
                                            " BuyTime=%d,Remarks=%s,IsUsing=%n,BuyPrice=%n,Section=%s,AssignUserNo1=%s,AssignUserNo2=%s,IsLinemanager=%b," +
 | 
						|
                                            " ModifiedBy=%n,ModifiedDate=%d, AssetType=%n, DefaultItem=%b,AssetCategoryId=%n,WarrentyDays=%n,IsSerailItem=%b WHERE AssetID=%n",
 | 
						|
                oAsset.Code, oAsset.Name, oAsset.Description, oAsset.BuyTime,
 | 
						|
                oAsset.Remarks, oAsset.IsUsing, oAsset.BuyPrice, oAsset.Section, oAsset.AssignUserNo1,
 | 
						|
                oAsset.AssignUserNo2, oAsset.IsLinemanager,
 | 
						|
                DataReader.GetNullValue(oAsset.ModifiedBy),
 | 
						|
                DataReader.GetNullValue(oAsset.ModifiedDate), oAsset.AssetType, oAsset.DefaultItem, oAsset.AssetCategoryId,oAsset.WarrentyDays, oAsset.IsSerailItem,
 | 
						|
                oAsset.ID);
 | 
						|
            tc.ExecuteNonQuery(sSQL);
 | 
						|
        }
 | 
						|
 | 
						|
        internal static void UpdateAssetSpecification(TransactionContext tc, AssetSerial oAssetserial)
 | 
						|
        {
 | 
						|
            string sSQL = SQLParser.MakeSQL("UPDATE Asset SET Description=%s where assetid=%n", oAssetserial.Specification,
 | 
						|
                oAssetserial.AssetId);
 | 
						|
            tc.ExecuteNonQuery(sSQL);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Delete
 | 
						|
 | 
						|
        internal static void Delete(TransactionContext tc, int id)
 | 
						|
        {
 | 
						|
            tc.ExecuteNonQuery("DELETE FROM Asset WHERE AssetID=%n", id);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
} |