Пример #1
0
        /// <summary>
        /// 获取买价的点差额
        /// </summary>
        /// <returns>返回点差额</returns>
        public static ProductRealPrice GetProductRealPrice()
        {
            SqlConnection sqlconn = null;
            SqlCommand sqlcmd = null;
            SqlDataReader sqldr = null;
            ProductRealPrice prc = new ProductRealPrice();
            try
            {
                sqlconn = new SqlConnection(SqlConnectionString);
                sqlconn.Open();
                sqlcmd = sqlconn.CreateCommand();
                sqlcmd.CommandText = "select distinct goodscode,pricecode,lowerprice from Trade_Product";

                //SqlParameter p_pcode = new SqlParameter();
                //p_pcode.ParameterName = "@pricecode";
                //p_pcode.DbType = DbType.String;
                //p_pcode.Value = priceCode;
                //sqlcmd.Parameters.Add(p_pcode);
                string goodscode = string.Empty;
                sqldr = sqlcmd.ExecuteReader();
                while (sqldr.Read())
                {
                    goodscode = sqldr["goodscode"].ToString();
                    switch (goodscode)
                    {
                        case ComFunction.AUFlg:
                            if (prc.aub_price < ComFunction.dzero)
                            {
                                prc.aub_price = Convert.ToInt32(sqldr["lowerprice"]);
                            }
                            break;
                        case ComFunction.AGFlg:
                            if (prc.agb_price < ComFunction.dzero)
                            {
                                prc.agb_price = Convert.ToInt32(sqldr["lowerprice"]);
                            }
                            break;
                        case ComFunction.PTFlg:
                            if (prc.ptb_price < ComFunction.dzero)
                            {
                                prc.ptb_price = Convert.ToInt32(sqldr["lowerprice"]);
                            }
                            break;
                        case ComFunction.PDFlg:
                            if (prc.pdb_price < ComFunction.dzero)
                            {
                                prc.pdb_price = Convert.ToInt32(sqldr["lowerprice"]);
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if (null != sqlconn)
                {
                    sqlconn.Close();
                }
                if (null != sqldr)
                {
                    sqldr.Close();
                }
            }
            return prc;
        }
Пример #2
0
 /// <summary>
 /// 获取实时卖价和买价
 /// </summary>
 /// <returns>获取实际价格(黄金,白银,铂金,钯金)</returns>
 public ProductRealPrice GetProductRealPrice()
 {
     TradeClient tc = new TradeClient();
     ProductRealPrice PRealPrice = new ProductRealPrice();
     try
     {
         PRealPrice = ComFunction.GetProductRealPrice();
         PRealPrice.au_realprice = tc.GetRealprice("XAUUSD");
         PRealPrice.ag_realprice = tc.GetRealprice("XAGUSD");
         PRealPrice.pt_realprice = tc.GetRealprice("XPTUSD");
         PRealPrice.pd_realprice = tc.GetRealprice("XPDUSD");
         PRealPrice.agb_price = PRealPrice.ag_realprice - PRealPrice.agb_price;
         PRealPrice.aub_price = PRealPrice.au_realprice - PRealPrice.aub_price;
         PRealPrice.ptb_price = PRealPrice.pt_realprice - PRealPrice.ptb_price;
         PRealPrice.pdb_price = PRealPrice.pd_realprice - PRealPrice.pdb_price;
     }
     catch (Exception ex)
     {
         tc.Abort();
         ComFunction.WriteErr(ex);
     }
     return PRealPrice;
 }