using Ease.Core.DataAccess; using Ease.CoreV35.DataAccess; using HRM.BO; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using static NPOI.HSSF.Util.HSSFColor; namespace HRM.DA { public class NewInvestmentDA { #region Constructor private NewInvestmentDA() { } #endregion #region Get internal static IDataReader Get(TransactionContext tc, int id) { return tc.ExecuteReader("SELECT * FROM FM_NewInvestment WHERE NewInvestmentID=%n", id); } internal static IDataReader Get(TransactionContext tc, DateTime tranMonth) { return tc.ExecuteReader("SELECT * FROM FM_NewInvestment WHERE TranMonth = %d", tranMonth); } internal static IDataReader GetByMemberID(TransactionContext tc, int MemberID) { return tc.ExecuteReader("SELECT * FROM FM_NewInvestment WHERE ApproverOne = %n OR ApproverTwo = %n", MemberID, MemberID); } internal static IDataReader GetNewInvestmentById(TransactionContext tc, int NewInvestmentId) { return tc.ExecuteReader("SELECT * FROM FM_NewInvestment Where NewInvestmentId = %n", NewInvestmentId); } internal static IDataReader GetAll(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM FM_NewInvestment order by NewInvestmentID asc"); } #endregion #region Insert internal static void Insert(TransactionContext tc, NewInvestment oNewInvestment) { string sql = SQLParser.MakeSQL("INSERT INTO FM_NewInvestment(NewInvestmentID, TranMonth, Balance, CreatedBy, CreatedDate, " + "ApproverOne, ApproverOneRemarks, ApproverOneDate, " + "ApproverTwo, ApproverTwoRemarks, ApproverTwoDate) " + "VALUES (%n, %d, %n, %n, %d, %n, %s, %d, %n, %s, %d)", oNewInvestment.ID, oNewInvestment.TranMonth, oNewInvestment.Balance, oNewInvestment.CreatedBy, oNewInvestment.CreatedDate, oNewInvestment.ApproverOne, oNewInvestment.ApproverOneRemarks, oNewInvestment.ApproverOneDate, oNewInvestment.ApproverTwo, oNewInvestment.ApproverTwoRemarks, oNewInvestment.ApproverTwoDate); tc.ExecuteNonQuery(sql); } #endregion #region Update internal static void Update(TransactionContext tc, NewInvestment oNewInvestment) { string sSQL = SQLParser.MakeSQL("UPDATE FM_NewInvestment SET " + "NewInvestmentID = %n, TranMonth = %d, Balance = %n, CreatedBy = %n, CreatedDate = %d, " + "ApproverOne = %n, ApproverOneRemarks = %s, ApproverOneDate = %d, " + "ApproverTwo = %n, ApproverTwoRemarks = %s, ApproverTwoDate = %d)", oNewInvestment.ID, oNewInvestment.TranMonth, oNewInvestment.Balance, oNewInvestment.CreatedBy, oNewInvestment.CreatedDate, oNewInvestment.ApproverOne, oNewInvestment.ApproverOneRemarks, oNewInvestment.ApproverOneDate, oNewInvestment.ApproverTwo, oNewInvestment.ApproverTwoRemarks, oNewInvestment.ApproverTwoDate); tc.ExecuteNonQuery(sSQL); } #endregion #region Delete internal static void Delete(TransactionContext tc, int id) { tc.ExecuteNonQuery("DELETE FROM FM_NewInvestment WHERE NewInvestmentID=%n", id); } #endregion #region NewInvestMentInBankDA internal static IDataReader GetNewInvestmentInBanks(TransactionContext tc, int newInvestMentID) { return tc.ExecuteReader("SELECT i.*, b.Name AS BankName FROM FM_NewInvestmentInBank AS i " + "INNER JOIN FM_BANK AS b ON i.BankID = b.BankID " + "WHERE i.NewInvestMentID = %n", newInvestMentID); } internal static void UpdateNewInvestMentInBank(TransactionContext tc, NewInvestmentInBank newInvestmentInBank) { string sql = SQLParser.MakeSQL("UPDATE FM_NewInvestmentInBank Set NewInvestmentID = %n, Amount = %n,Ratio = %n, rating = %n, " + "ThreeMonthRate = %n, SixMonthRate = %n, TwelveMonthRate = %n, ThreeYearRate = %n, FiveYearRate = %n " + "Where BankID = %n", newInvestmentInBank.NewInvestmentID, newInvestmentInBank.Amount, newInvestmentInBank.Ratio, newInvestmentInBank.RatingID, newInvestmentInBank.ThreeMonthRate, newInvestmentInBank.SixMonthRate, newInvestmentInBank.TwelveMonthRate, newInvestmentInBank.ThreeYearRate, newInvestmentInBank.FiveYearRate, newInvestmentInBank.BankID); tc.ExecuteNonQuery(sql); } internal static void InsertNewInvestMentInBank(TransactionContext tc, NewInvestmentInBank newInvestmentInBank) { string sql = SQLParser.MakeSQL("INSERT INTO FM_NewInvestmentInBank(NewInvestmentInBankID, NewInvestmentID, BankID, Amount, Ratio, RatingID, " + "ThreeMonthRate, SixMonthRate, TwelveMonthRate, ThreeYearRate, FiveYearRate) " + "VALUES (%n, %n, %n, %n, %n, %n, %n, %n, %n, %n, %n)", newInvestmentInBank.ID, newInvestmentInBank.NewInvestmentID, newInvestmentInBank.BankID, newInvestmentInBank.Amount, newInvestmentInBank.Ratio, newInvestmentInBank.RatingID, newInvestmentInBank.ThreeMonthRate, newInvestmentInBank.SixMonthRate, newInvestmentInBank.TwelveMonthRate, newInvestmentInBank.ThreeYearRate, newInvestmentInBank.FiveYearRate); tc.ExecuteNonQuery(sql); } internal static void DeleteNewInvestMentInBank(TransactionContext tc, int id) { tc.ExecuteNonQuery("DELETE FROM FM_NewInvestmentInBank WHERE NewInvestmentID=%n", id); } #endregion internal static void UpdateNewInvestmentApproval(TransactionContext tc, NewInvestment oNewInvestment) { string sSQL = SQLParser.MakeSQL("UPDATE FM_NewInvestment SET ApproverOneDate = %d, ApproverTwoDate = %d, " + "ApproverOneRemarks = %s, ApproverTwoRemarks = %s WHERE NewInvestmentID = %n", DataReader.GetNullValue(oNewInvestment.ApproverOneDate), oNewInvestment.ApproverTwoDate, oNewInvestment.ApproverOneRemarks, oNewInvestment.ApproverTwoRemarks, oNewInvestment.NewInvestmentID); tc.ExecuteNonQuery(sSQL); } } }