using System; using Payroll.BO; using System.Data; using System.Linq; using Ease.CoreV35.Model; using System.Data.SqlClient; using Ease.CoreV35.DataAccess; using System.Collections.Generic; using Ease.CoreV35.DataAccess.SQL; namespace Payroll.Service { #region Class InstitutionDA internal class InstitutionDA { #region constructor public InstitutionDA() { } #endregion #region insert function internal static void Insert(TransactionContext tc, Institution item) { tc.ExecuteNonQuery("INSERT INTO INSTITUTION(INSTITUTIONID, CODE, NAME, TYPE, EducationTypeID, SEQUENCENO, STATUS, CREATEDBY, CREATIONDATE)" + "VALUES(%n, %s, %s, %n, %n, %n, %n, %n, %d)", item.ID.Integer, item.Code, item.Name, item.Type, item.EducationTypeID.Integer, item.Sequence, item.Status, item.CreatedBy.Integer, item.CreatedDate); } #endregion #region update function internal static void Update(TransactionContext tc, Institution item) { tc.ExecuteNonQuery("UPDATE INSTITUTION SET code=%s, name=%s, type=%n, EducationTypeID=%n, sequencenO=%n, status=%n, modifiedby=%n, modifieddate=%d" + "WHERE INSTITUTIONID=%n", item.Code, item.Name, item.Type, item.EducationTypeID.Integer, item.Sequence, item.Status, item.ModifiedBy.Integer, item.ModifiedDate, item.ID.Integer); } #endregion #region Get function internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM INSTITUTION"); } internal static IDataReader Get(TransactionContext tc, EnumStatus status) { if (status == EnumStatus.Regardless) { return tc.ExecuteReader("SELECT * FROM INSTITUTION Order By SequenceNo"); } else { return tc.ExecuteReader("SELECT * FROM INSTITUTION Where Status=%n Order By SequenceNo", status); } } internal static IDataReader Get(TransactionContext tc, ID nID) { return tc.ExecuteReader("SELECT * FROM INSTITUTION WHERE INSTITUTIONID=%n", nID.Integer); } internal static IDataReader Get(TransactionContext tc, string sCode) { return tc.ExecuteReader("SELECT * FROM INSTITUTION WHERE Code=%s", sCode); } internal static IDataReader GetByInstituteType(TransactionContext tc, EnmInstituteType type) { return tc.ExecuteReader("SELECT * FROM INSTITUTION Where Type=%n Order By SequenceNo", type); } #endregion #region Delete function internal static void Delete(TransactionContext tc, ID nID) { tc.ExecuteNonQuery("DELETE FROM [INSTITUTION] WHERE INSTITUTIONID=%n", nID.Integer); } internal static bool IsExists(TransactionContext tc, string Code) { Object obj = tc.ExecuteScalar("Select Count(*) From [INSTITUTION] where Code = %s", Code); return Convert.ToInt32(obj) > 0; } #endregion } #endregion }