コード例 #1
0
        public static CrudeFinancialCurrencyData FetchByFinancialCurrencyTypeCodeActive(
            string financialCurrencyTypeCode,
            string againstFinancialCurrencyTypeCode
            )
        {
            var data = new CrudeFinancialCurrencyData();

            string sql = @" 
                select top 1 financial_currency_id, financial_currency_type_rcd, financial_currency_type_code, financial_currency_type_name, financial_currency_against_financial_currency_type_rcd, valid_from_date_time, valid_until_date_time, amount, equals_amount, decimal_count, user_id, date_time
                from financial_currency as fc
                where fc.financial_currency_type_code = @financial_currency_type_code
				  and fc.financial_currency_against_financial_currency_type_rcd = @against_financial_currency_type_code
                  and fc.valid_until_date_time  is null
                  ";

            using (var conn = new SqlConnection(Conn.ConnectionString)) {
                conn.Open();
                SqlCommand command = new SqlCommand(sql, conn);
                command.Parameters.Add("@financial_currency_type_code", SqlDbType.NVarChar).Value         = financialCurrencyTypeCode;
                command.Parameters.Add("@against_financial_currency_type_code", SqlDbType.NVarChar).Value = againstFinancialCurrencyTypeCode;

                Logging     log    = Logging.PerformanceTimeStart("SolutionNorSolutionPort.DataAccessLayer.Financial.FetchByFinancialCurrencyTypeCodeActive");
                IDataReader reader = command.ExecuteReader(CommandBehavior.SingleRow);
                log.PerformanceTimeStop(sql, command);

                if (reader.Read())
                {
                    data.Populate(reader);
                }
            }

            return(data);
        }
コード例 #2
0
ファイル: FinancialSearch.cs プロジェクト: jacov/nor-port
        /// <summary>Get Currency Conversion</summary>
        /// <cardinality>One</cardinality>
        /// <generatelayer>DataAccessLayer</generatelayer>
        public static CrudeFinancialCurrencyData GetCurrencyConversion(
            Guid financialCurrencyId,
            Guid againstFinancialCurrencyId,
            DateTime currencyDateTime
            )
        {
            string sql = @" 
                    select 
	                    top 1 fc.*
                    from financial_currency	as fc
                    where fc.financial_currency_type_rcd = (
		                    select fc2.financial_currency_type_rcd 
		                    from financial_currency	as fc2 
		                    where fc2.financial_currency_id = @financial_currency_id
	                    )
	                    and fc.financial_currency_against_financial_currency_type_rcd = (
		                    select fc2.financial_currency_type_rcd 
		                    from financial_currency	as fc2 
		                    where fc2.financial_currency_id = @financial_currency_against_financial_currency_id
	                    )
                        and @currency_date_time >= fc.valid_from_date_time and (@currency_date_time <= fc.valid_until_date_time or fc.valid_until_date_time is null)
                        ";

            using (var conn = new SqlConnection(Conn.ConnectionString)) {
                conn.Open();
                conn.BeginTransaction(IsolationLevel.ReadUncommitted).Commit();

                var data = new CrudeFinancialCurrencyData();

                using (var command = new SqlCommand(sql, conn)) {
                    command.Parameters.Add("@financial_currency_id", SqlDbType.UniqueIdentifier).Value = financialCurrencyId;
                    command.Parameters.Add("@financial_currency_against_financial_currency_id", SqlDbType.UniqueIdentifier).Value = againstFinancialCurrencyId;
                    command.Parameters.Add("@currency_date_time", SqlDbType.DateTime).Value = currencyDateTime;

                    Logging     log    = Logging.PerformanceTimeStart("SolutionNorSolutionPort.DataAccessLayer.FinancialSearch.GetCurrencyConversion");
                    IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                    log.PerformanceTimeStop(sql, command);

                    if (reader.Read())
                    {
                        data.Populate(reader);
                    }

                    reader.Close();
                }

                return(data);
            }
        }