/// <summary> /// GetCurrentAtDate /// Calls [usp_select_CurrencyRate_Current_at_Date] /// </summary> public override CurrencyRateDetails GetCurrentAtDate(System.Int32?currencyNo, System.DateTime?datePoint) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_select_CurrencyRate_Current_at_Date", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@CurrencyNo", SqlDbType.Int).Value = currencyNo; cmd.Parameters.Add("@DatePoint", SqlDbType.DateTime).Value = datePoint; cn.Open(); DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow); if (reader.Read()) { //return GetCurrencyRateFromReader(reader); CurrencyRateDetails obj = new CurrencyRateDetails(); obj.ExchangeRate = GetReaderValue_Double(reader, "ExchangeRate", 0); return(obj); } else { return(null); } } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get CurrencyRate", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }
private static CurrencyRate PopulateFromDBDetailsObject(CurrencyRateDetails obj) { CurrencyRate objNew = new CurrencyRate(); objNew.CurrencyRateId = obj.CurrencyRateId; objNew.CurrencyNo = obj.CurrencyNo; objNew.CurrencyDate = obj.CurrencyDate; objNew.ExchangeRate = obj.ExchangeRate; objNew.UpdatedBy = obj.UpdatedBy; objNew.DLUP = obj.DLUP; objNew.RepriceOpenOrders = obj.RepriceOpenOrders; objNew.CurrencyCode = obj.CurrencyCode; return(objNew); }
//[001] code start /// <summary> /// GetListForCurrency /// Calls [usp_selectAll_ExchangeRate_for_LocalCurrency] /// </summary> public override List <CurrencyRateDetails> GetListForExchangeRate(System.Int32?localCurrencyId) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_selectAll_ExchangeRate_for_LocalCurrency", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@LocalCurrencyId", SqlDbType.Int).Value = localCurrencyId; cn.Open(); DbDataReader reader = ExecuteReader(cmd); List <CurrencyRateDetails> lst = new List <CurrencyRateDetails>(); while (reader.Read()) { CurrencyRateDetails obj = new CurrencyRateDetails(); obj.ExchangeRateId = GetReaderValue_Int32(reader, "ExchangeRateId", 0); obj.LocalCurrencyNo = GetReaderValue_Int32(reader, "LocalCurrencyNo", 0); obj.ExchangeRateDate = GetReaderValue_DateTime(reader, "ExchangeRateDate", DateTime.MinValue); obj.ExchangeRate = GetReaderValue_Double(reader, "ExchangeRate", 0); obj.UpdatedBy = GetReaderValue_NullableInt32(reader, "UpdatedBy", null); obj.DLUP = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue); obj.CurrencyCode = GetReaderValue_String(reader, "GlobalCurrencyName", ""); obj.ChangeBy = GetReaderValue_String(reader, "EmployeeName", ""); obj.ClientCurrencyCode = GetReaderValue_String(reader, "ClientLocalCurrencyCode", ""); lst.Add(obj); obj = null; } return(lst); } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get Exchange rates", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }
/// <summary> /// Get /// Calls [usp_select_CurrencyRate] /// </summary> public override CurrencyRateDetails Get(System.Int32?currencyRateId) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_select_CurrencyRate", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@CurrencyRateId", SqlDbType.Int).Value = currencyRateId; cn.Open(); DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow); if (reader.Read()) { //return GetCurrencyRateFromReader(reader); CurrencyRateDetails obj = new CurrencyRateDetails(); obj.CurrencyRateId = GetReaderValue_Int32(reader, "CurrencyRateId", 0); obj.CurrencyNo = GetReaderValue_Int32(reader, "CurrencyNo", 0); obj.CurrencyDate = GetReaderValue_DateTime(reader, "CurrencyDate", DateTime.MinValue); obj.ExchangeRate = GetReaderValue_Double(reader, "ExchangeRate", 0); obj.UpdatedBy = GetReaderValue_NullableInt32(reader, "UpdatedBy", null); obj.DLUP = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue); obj.RepriceOpenOrders = GetReaderValue_NullableBoolean(reader, "RepriceOpenOrders", null); return(obj); } else { return(null); } } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get CurrencyRate", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }