Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(EVE_Central.Model.Market_History model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Market_History set ");
            strSql.Append("typeID=SQL2012typeID,");
            strSql.Append("volume=SQL2012volume,");
            strSql.Append("orderCount=SQL2012orderCount,");
            strSql.Append("lowPrice=SQL2012lowPrice,");
            strSql.Append("highPrice=SQL2012highPrice,");
            strSql.Append("avgPrice=SQL2012avgPrice,");
            strSql.Append("date=SQL2012date");
            strSql.Append(" where id=SQL2012id");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012typeID",     SqlDbType.Int,       4),
                new SqlParameter("SQL2012volume",     SqlDbType.BigInt,    8),
                new SqlParameter("SQL2012orderCount", SqlDbType.BigInt,    8),
                new SqlParameter("SQL2012lowPrice",   SqlDbType.Float,     8),
                new SqlParameter("SQL2012highPrice",  SqlDbType.Float,     8),
                new SqlParameter("SQL2012avgPrice",   SqlDbType.Float,     8),
                new SqlParameter("SQL2012date",       SqlDbType.DateTime),
                new SqlParameter("SQL2012id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.typeID;
            parameters[1].Value = model.volume;
            parameters[2].Value = model.orderCount;
            parameters[3].Value = model.lowPrice;
            parameters[4].Value = model.highPrice;
            parameters[5].Value = model.avgPrice;
            parameters[6].Value = model.date;
            parameters[7].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public EVE_Central.Model.Market_History DataRowToModel(DataRow row)
 {
     EVE_Central.Model.Market_History model = new EVE_Central.Model.Market_History();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["typeID"] != null && row["typeID"].ToString() != "")
         {
             model.typeID = int.Parse(row["typeID"].ToString());
         }
         if (row["volume"] != null && row["volume"].ToString() != "")
         {
             model.volume = long.Parse(row["volume"].ToString());
         }
         if (row["orderCount"] != null && row["orderCount"].ToString() != "")
         {
             model.orderCount = long.Parse(row["orderCount"].ToString());
         }
         if (row["lowPrice"] != null && row["lowPrice"].ToString() != "")
         {
             model.lowPrice = decimal.Parse(row["lowPrice"].ToString());
         }
         if (row["highPrice"] != null && row["highPrice"].ToString() != "")
         {
             model.highPrice = decimal.Parse(row["highPrice"].ToString());
         }
         if (row["avgPrice"] != null && row["avgPrice"].ToString() != "")
         {
             model.avgPrice = decimal.Parse(row["avgPrice"].ToString());
         }
         if (row["date"] != null && row["date"].ToString() != "")
         {
             model.date = DateTime.Parse(row["date"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(EVE_Central.Model.Market_History model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Market_History(");
            strSql.Append("typeID,volume,orderCount,lowPrice,highPrice,avgPrice,date)");
            strSql.Append(" values (");
            strSql.Append("SQL2012typeID,SQL2012volume,SQL2012orderCount,SQL2012lowPrice,SQL2012highPrice,SQL2012avgPrice,SQL2012date)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012typeID",     SqlDbType.Int,    4),
                new SqlParameter("SQL2012volume",     SqlDbType.BigInt, 8),
                new SqlParameter("SQL2012orderCount", SqlDbType.BigInt, 8),
                new SqlParameter("SQL2012lowPrice",   SqlDbType.Float,  8),
                new SqlParameter("SQL2012highPrice",  SqlDbType.Float,  8),
                new SqlParameter("SQL2012avgPrice",   SqlDbType.Float,  8),
                new SqlParameter("SQL2012date",       SqlDbType.DateTime)
            };
            parameters[0].Value = model.typeID;
            parameters[1].Value = model.volume;
            parameters[2].Value = model.orderCount;
            parameters[3].Value = model.lowPrice;
            parameters[4].Value = model.highPrice;
            parameters[5].Value = model.avgPrice;
            parameters[6].Value = model.date;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public EVE_Central.Model.Market_History GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,typeID,volume,orderCount,lowPrice,highPrice,avgPrice,date from Market_History ");
            strSql.Append(" where id=SQL2012id");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            EVE_Central.Model.Market_History model = new EVE_Central.Model.Market_History();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(EVE_Central.Model.Market_History model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(EVE_Central.Model.Market_History model)
 {
     return(dal.Add(model));
 }