/*
*	©Copyright 2002,2003, Microsoft Corporation
*	Microsoft Confidential.
*	Written by Sergey Vasilevskiy, 2002-2003.
*/
#pragma once

#include "stdafx.h"

//calculate absolute value
template <typename T>
T abs(T val)
{
	if (val > 0)
		return val;
	else
		return (-1)*val;
}

class CTradeOrderDB : public CTxnHarnessDBBase, public TPCE::CTradeOrderDBInterface
{	
	SQLHSTMT				m_hstmtFrame1;
	SQLHSTMT				m_hstmtFrame2;
	SQLHSTMT				m_hstmtFrame3;
	SQLHSTMT				m_hstmtFrame4;

	//stored procs input/output parameters for binding
	TPCE::TTradeOrderFrame1Input	Frame1Input;
	TPCE::TTradeOrderFrame1Output	Frame1Output;
	TPCE::TTradeOrderFrame2Input	Frame2Input;
	TPCE::TTradeOrderFrame2Output	Frame2Output;
	TPCE::TTradeOrderFrame3Input	Frame3Input;
	TPCE::TTradeOrderFrame3Output	Frame3Output;
	TPCE::TTradeOrderFrame4Input	Frame4Input;
	TPCE::TTradeOrderFrame4Output	Frame4Output;

	SQLINTEGER	    m_Frame3_CO_NAME_Ind;	//indicator variable for Frame3
	SQLINTEGER	    m_Frame3_SYMBOL_Ind;	//indicator variable for Frame3

public:
	CTradeOrderDB(CDBConnection *pDBConn);
	~CTradeOrderDB();
	
	void DoTradeOrderFrame1(const TPCE::TTradeOrderFrame1Input* pFrame1Input, 
                            TPCE::PTradeOrderFrame1Output       pFrame1Output);

	void DoTradeOrderFrame2(const TPCE::TTradeOrderFrame2Input* pFrame2Input, 
                            TPCE::PTradeOrderFrame2Output       pFrame2Output);

	void DoTradeOrderFrame3(const TPCE::TTradeOrderFrame3Input* pFrame3Input, 
                            TPCE::PTradeOrderFrame3Output       pFrame3Output);

	void DoTradeOrderFrame4(const TPCE::TTradeOrderFrame4Input* pFrame4Input, 
                            TPCE::PTradeOrderFrame4Output       pFrame4Output);

	void DoTradeOrderFrame5();
	void DoTradeOrderFrame6();

	// Function to pass any exception thrown inside
	// database class frame implementation
	// back into the database class
	void Cleanup(void* pException);
};
