Ejemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.stock_k_lineInfo GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, stock_code, stock_name, update_time, open, preClose, highest, lowest, deal_vol, deal_price, fprice  ");
            strSql.Append("  from c_stock_k_line ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;


            Model.stock_k_lineInfo model = new Model.stock_k_lineInfo();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.stock_k_lineInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update c_stock_k_line set ");

            strSql.Append(" stock_code = @stock_code , ");
            strSql.Append(" stock_name = @stock_name , ");
            strSql.Append(" update_time = @update_time , ");
            strSql.Append(" open = @open , ");
            strSql.Append(" preClose = @preClose , ");
            strSql.Append(" highest = @highest , ");
            strSql.Append(" lowest = @lowest , ");
            strSql.Append(" deal_vol = @deal_vol , ");
            strSql.Append(" deal_price = @deal_price , ");
            strSql.Append(" fprice = @fprice  ");
            strSql.Append(" where id=@id ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@stock_code",  MySqlDbType.VarChar,   12),
                new MySqlParameter("@stock_name",  MySqlDbType.VarChar,   32),
                new MySqlParameter("@update_time", MySqlDbType.DateTime),
                new MySqlParameter("@open",        MySqlDbType.Decimal,   13),
                new MySqlParameter("@preClose",    MySqlDbType.Decimal,   13),
                new MySqlParameter("@highest",     MySqlDbType.Decimal,   13),
                new MySqlParameter("@lowest",      MySqlDbType.Decimal,   13),
                new MySqlParameter("@deal_vol",    MySqlDbType.Int32,     11),
                new MySqlParameter("@deal_price",  MySqlDbType.Decimal,   13),
                new MySqlParameter("@fprice",      MySqlDbType.Decimal,   13),

                new MySqlParameter("@id",          MySqlDbType.Int32, 11)
            };
            parameters[0].Value  = model.stock_code;
            parameters[1].Value  = model.stock_name;
            parameters[2].Value  = model.update_time;
            parameters[3].Value  = model.open;
            parameters[4].Value  = model.preClose;
            parameters[5].Value  = model.highest;
            parameters[6].Value  = model.lowest;
            parameters[7].Value  = model.deal_vol;
            parameters[8].Value  = model.deal_price;
            parameters[9].Value  = model.fprice;
            parameters[10].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 将对象转换为实体
 /// </summary>
 public Model.stock_k_lineInfo DataRowToModel(DataRow row)
 {
     Model.stock_k_lineInfo model = new Model.stock_k_lineInfo();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         model.stock_code = row["stock_code"].ToString();
         model.stock_name = row["stock_name"].ToString();
         if (row["update_time"] != null && row["update_time"].ToString() != "")
         {
             model.update_time = DateTime.Parse(row["update_time"].ToString());
         }
         if (row["open"] != null && row["open"].ToString() != "")
         {
             model.open = decimal.Parse(row["open"].ToString());
         }
         if (row["preClose"] != null && row["preClose"].ToString() != "")
         {
             model.preClose = decimal.Parse(row["preClose"].ToString());
         }
         if (row["highest"] != null && row["highest"].ToString() != "")
         {
             model.highest = decimal.Parse(row["highest"].ToString());
         }
         if (row["lowest"] != null && row["lowest"].ToString() != "")
         {
             model.lowest = decimal.Parse(row["lowest"].ToString());
         }
         if (row["deal_vol"] != null && row["deal_vol"].ToString() != "")
         {
             model.deal_vol = int.Parse(row["deal_vol"].ToString());
         }
         if (row["deal_price"] != null && row["deal_price"].ToString() != "")
         {
             model.deal_price = decimal.Parse(row["deal_price"].ToString());
         }
         if (row["fprice"] != null && row["fprice"].ToString() != "")
         {
             model.fprice = decimal.Parse(row["fprice"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.stock_k_lineInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into c_stock_k_line(");
            strSql.Append("stock_code,stock_name,update_time,open,preClose,highest,lowest,deal_vol,deal_price,fprice");
            strSql.Append(") values (");
            strSql.Append("@stock_code,@stock_name,@update_time,@open,@preClose,@highest,@lowest,@deal_vol,@deal_price,@fprice");
            strSql.Append("); Select LAST_INSERT_ID() ");

            MySqlParameter[] parameters =
            {
                new MySqlParameter("@stock_code",  MySqlDbType.VarChar,   12),
                new MySqlParameter("@stock_name",  MySqlDbType.VarChar,   32),
                new MySqlParameter("@update_time", MySqlDbType.DateTime),
                new MySqlParameter("@open",        MySqlDbType.Decimal,   13),
                new MySqlParameter("@preClose",    MySqlDbType.Decimal,   13),
                new MySqlParameter("@highest",     MySqlDbType.Decimal,   13),
                new MySqlParameter("@lowest",      MySqlDbType.Decimal,   13),
                new MySqlParameter("@deal_vol",    MySqlDbType.Int32,     11),
                new MySqlParameter("@deal_price",  MySqlDbType.Decimal,   13),
                new MySqlParameter("@fprice",      MySqlDbType.Decimal, 13)
            };

            parameters[0].Value = model.stock_code;
            parameters[1].Value = model.stock_name;
            parameters[2].Value = model.update_time;
            parameters[3].Value = model.open;
            parameters[4].Value = model.preClose;
            parameters[5].Value = model.highest;
            parameters[6].Value = model.lowest;
            parameters[7].Value = model.deal_vol;
            parameters[8].Value = model.deal_price;
            parameters[9].Value = model.fprice;
            int rows = Convert.ToInt32(DbHelperMySQL.GetSingle(strSql.ToString(), parameters));

            return(rows);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.stock_k_lineInfo GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, stock_code, stock_name, update_time, open, preClose, highest, lowest, deal_vol, deal_price, fprice  ");
            strSql.Append("  from c_stock_k_line ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" limit 0,1");
            Model.stock_k_lineInfo model = new Model.stock_k_lineInfo();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }