Exemplo n.º 1
0
        /// <summary>
        /// Inserir stop start da ordem na tabela tbStopStartOrder
        /// </summary>
        /// <param name="pOrdem"></param>
        /// <returns></returns>
        public virtual int EnviarOrdemStop(AutomacaoOrdensInfo pOrdem)
        {
            SqlCommand command = new SqlCommand();

            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
            conn.ConnectionString = Conn;
            conn.Open();

            try
            {
                command.Connection  = conn;
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.CommandText = "PRC_INS_ORDEM_STOP_OMS";

                SqlParameter OutParameter = new SqlParameter();
                OutParameter.Direction     = ParameterDirection.Output;
                OutParameter.ParameterName = "@StopStartID";
                OutParameter.Size          = 32;

                command.Parameters.Add(OutParameter);
                command.Parameters.AddWithValue("@OrdTypeID", pOrdem.OrdTypeID);
                command.Parameters.AddWithValue("@StopStartStatusID", pOrdem.StopStartStatusID);
                command.Parameters.AddWithValue("@Symbol", pOrdem.Symbol);
                command.Parameters.AddWithValue("@OrderQty", pOrdem.OrderQty);
                command.Parameters.AddWithValue("@Account", pOrdem.Account);
                //command.Parameters.AddWithValue("@RegisterTime",           pOrdem.RegisterTime);
                command.Parameters.AddWithValue("@ExpireDate", pOrdem.ExpireDate);
                command.Parameters.AddWithValue("@ExecutionTime", pOrdem.ExecutionTime);
                command.Parameters.AddWithValue("@ReferencePrice", pOrdem.ReferencePrice);
                command.Parameters.AddWithValue("@StartPriceValue", pOrdem.StartPriceValue);
                command.Parameters.AddWithValue("@SendStartPrice", pOrdem.SendStartPrice);
                command.Parameters.AddWithValue("@StopGainValuePrice", pOrdem.StopGainValuePrice);
                command.Parameters.AddWithValue("@SendStopGainPrice", pOrdem.SendStopGainPrice);
                command.Parameters.AddWithValue("@StopLossValuePrice", pOrdem.StopLossValuePrice);
                command.Parameters.AddWithValue("@SendStopLossValuePrice", pOrdem.SendStopLossValuePrice);
                command.Parameters.AddWithValue("@InitialMovelPrice", pOrdem.InitialMovelPrice);
                command.Parameters.AddWithValue("@AdjustmentMovelPrice", pOrdem.AdjustmentMovelPrice);
                command.Parameters.AddWithValue("@StopStartTipoEnum", (int)pOrdem.IdStopStartTipo);
                command.Parameters.AddWithValue("@PortaControle", pOrdem.ControlePorta);

                command.ExecuteNonQuery();

                int id_stopstart = int.Parse(command.Parameters["@StopStartID"].Value.ToString());

                return(id_stopstart);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("{0}{1}", "EnviarOrdemStop: ", ex.Message));
            }
            finally
            {
                conn.Close();
                conn.Dispose();

                command.Connection.Close();
                command.Dispose();
                command = null;
            }
        }
Exemplo n.º 2
0
        public virtual AutomacaoOrdensInfo SelecionaOrdemStopStart(int pIdStartStop)
        {
            SqlCommand command = new SqlCommand();

            AutomacaoOrdensInfo _TOrdem = new AutomacaoOrdensInfo();

            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
            conn.ConnectionString = Conn;
            conn.Open();

            try
            {
                command.Connection  = conn;
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.CommandText = "prc_sel_stopstart";

                command.Parameters.AddWithValue("@StopStartID", pIdStartStop);

                DataTable      dtDados = new DataTable();
                SqlDataAdapter da      = new SqlDataAdapter(command);
                da.Fill(dtDados);

                if (dtDados.Rows.Count > 0)
                {
                    _TOrdem                        = new AutomacaoOrdensInfo();
                    _TOrdem.Account                = int.Parse(dtDados.Rows[0]["Account"].ToString());
                    _TOrdem.StopStartID            = int.Parse(dtDados.Rows[0]["StopStartID"].ToString());
                    _TOrdem.Symbol                 = dtDados.Rows[0]["Symbol"].ToString();
                    _TOrdem.IdStopStartTipo        = (StopStartTipoEnum)dtDados.Rows[0]["StopStartTipoEnum"];
                    _TOrdem.OrdTypeID              = int.Parse(dtDados.Rows[0]["OrdTypeID"].ToString());
                    _TOrdem.IdBolsa                = Conversao.ToInt(dtDados.Rows[0]["id_Bolsa"].ToString());
                    _TOrdem.InitialMovelPrice      = Conversao.ToDecimal(dtDados.Rows[0]["InitialMovelPrice"]);
                    _TOrdem.OrderQty               = int.Parse(dtDados.Rows[0]["OrderQty"].ToString());
                    _TOrdem.ReferencePrice         = Conversao.ToDecimal(dtDados.Rows[0]["ReferencePrice"]);
                    _TOrdem.SendStartPrice         = Conversao.ToDecimal(dtDados.Rows[0]["SendStartPrice"]);
                    _TOrdem.SendStopGainPrice      = Conversao.ToDecimal(dtDados.Rows[0]["SendStopGainPrice"]);
                    _TOrdem.SendStopLossValuePrice = Conversao.ToDecimal(dtDados.Rows[0]["SendStopLossValuePrice"]);
                    _TOrdem.StartPriceValue        = Conversao.ToDecimal(dtDados.Rows[0]["StartPriceValue"]);
                    _TOrdem.StopGainValuePrice     = Conversao.ToDecimal(dtDados.Rows[0]["StopGainValuePrice"]);
                    _TOrdem.StopLossValuePrice     = Conversao.ToDecimal(dtDados.Rows[0]["StopLossValuePrice"]);
                    _TOrdem.StopStartStatusID      = int.Parse(dtDados.Rows[0]["StopStartStatusID"].ToString());
                    _TOrdem.RegisterTime           = Conversao.ToDateTime(dtDados.Rows[0]["RegisterTime"]);
                    _TOrdem.ExecutionTime          = Conversao.ToDateTime(dtDados.Rows[0]["ExecutionTime"]);
                    _TOrdem.ExpireDate             = Conversao.ToDateTime(dtDados.Rows[0]["ExpireDate"]);
                }

                return(_TOrdem);
            }
            finally
            {
                conn.Close();
                conn.Dispose();

                command.Connection.Close();
                command.Dispose();
                command = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Seleciona o Stop/Start
        /// </summary>
        /// <param name="id_startstop">Id do Stop/Start</param>
        /// <returns>Retorna uma entidade do tipo AutomacaoOrdensInfo</returns>
        public virtual AutomacaoOrdensInfo ListarOrdemStopStartResumido(int id_startstop)
        {
            SqlCommand command = new SqlCommand();

            AutomacaoOrdensInfo _TOrdem = new AutomacaoOrdensInfo();



            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
            conn.ConnectionString = Conn;
            conn.Open();

            try
            {
                command.Connection  = conn;
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.CommandText = "prc_sel_stopstart";

                command.Parameters.AddWithValue("@StopStartID", id_startstop);

                DataTable      dtDados = new DataTable();
                SqlDataAdapter da      = new SqlDataAdapter(command);
                da.Fill(dtDados);

                if (dtDados.Rows.Count > 0)
                {
                    _TOrdem.Account       = int.Parse(dtDados.Rows[0]["Account"].ToString());
                    _TOrdem.StopStartID   = int.Parse(dtDados.Rows[0]["StopStartID"].ToString());
                    _TOrdem.Symbol        = dtDados.Rows[0]["Symbol"].ToString();
                    _TOrdem.ControlePorta = dtDados.Rows[0]["PortaControle"].ToString();
                }

                return(_TOrdem);
            }
            finally
            {
                conn.Close();
                conn.Dispose();

                command.Connection.Close();
                command.Dispose();
                command = null;
            }
        }