Ejemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.t_goods DataRowToModel(DataRow row)
 {
     Maticsoft.Model.t_goods model = new Maticsoft.Model.t_goods();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["topType"] != null)
         {
             model.topType = row["topType"].ToString();
         }
         if (row["type"] != null)
         {
             model.type = row["type"].ToString();
         }
         if (row["goodsName"] != null)
         {
             model.goodsName = row["goodsName"].ToString();
         }
         if (row["minPrice"] != null && row["minPrice"].ToString() != "")
         {
             model.minPrice = decimal.Parse(row["minPrice"].ToString());
         }
         if (row["maxPrice"] != null && row["maxPrice"].ToString() != "")
         {
             model.maxPrice = decimal.Parse(row["maxPrice"].ToString());
         }
         if (row["sell_min_price"] != null && row["sell_min_price"].ToString() != "")
         {
             model.sell_min_price = decimal.Parse(row["sell_min_price"].ToString());
         }
         if (row["sell_max_price"] != null && row["sell_max_price"].ToString() != "")
         {
             model.sell_max_price = decimal.Parse(row["sell_max_price"].ToString());
         }
         if (row["describe"] != null)
         {
             model.describe = row["describe"].ToString();
         }
         if (row["status"] != null && row["status"].ToString() != "")
         {
             model.status = int.Parse(row["status"].ToString());
         }
         if (row["createTime"] != null && row["createTime"].ToString() != "")
         {
             model.createTime = DateTime.Parse(row["createTime"].ToString());
         }
         if (row["updateTime"] != null && row["updateTime"].ToString() != "")
         {
             model.updateTime = DateTime.Parse(row["updateTime"].ToString());
         }
         if (row["url"] != null)
         {
             model.url = row["url"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.t_goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_goods set ");
            strSql.Append("topType=@topType,");
            strSql.Append("type=@type,");
            strSql.Append("goodsName=@goodsName,");
            strSql.Append("minPrice=@minPrice,");
            strSql.Append("maxPrice=@maxPrice,");
            strSql.Append("sell_min_price=@sell_min_price,");
            strSql.Append("sell_max_price=@sell_max_price,");
            strSql.Append("describe=@describe,");
            strSql.Append("status=@status,");
            strSql.Append("createTime=@createTime,");
            strSql.Append("updateTime=@updateTime,");
            strSql.Append("url=@url");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@topType",        MySqlDbType.VarChar,   255),
                new MySqlParameter("@type",           MySqlDbType.VarChar,   255),
                new MySqlParameter("@goodsName",      MySqlDbType.VarChar,   255),
                new MySqlParameter("@minPrice",       MySqlDbType.Decimal,    10),
                new MySqlParameter("@maxPrice",       MySqlDbType.Decimal,    10),
                new MySqlParameter("@sell_min_price", MySqlDbType.Decimal,    10),
                new MySqlParameter("@sell_max_price", MySqlDbType.Decimal,    10),
                new MySqlParameter("@describe",       MySqlDbType.VarChar,   255),
                new MySqlParameter("@status",         MySqlDbType.Int32,      11),
                new MySqlParameter("@createTime",     MySqlDbType.DateTime),
                new MySqlParameter("@updateTime",     MySqlDbType.DateTime),
                new MySqlParameter("@url",            MySqlDbType.VarChar,   255),
                new MySqlParameter("@id",             MySqlDbType.Int32, 11)
            };
            parameters[0].Value  = model.topType;
            parameters[1].Value  = model.type;
            parameters[2].Value  = model.goodsName;
            parameters[3].Value  = model.minPrice;
            parameters[4].Value  = model.maxPrice;
            parameters[5].Value  = model.sell_min_price;
            parameters[6].Value  = model.sell_max_price;
            parameters[7].Value  = model.describe;
            parameters[8].Value  = model.status;
            parameters[9].Value  = model.createTime;
            parameters[10].Value = model.updateTime;
            parameters[11].Value = model.url;
            parameters[12].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 bool Add(Maticsoft.Model.t_goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_goods(");
            strSql.Append("topType,type,goodsName,minPrice,maxPrice,sell_min_price,sell_max_price,describe,status,createTime,updateTime,url)");
            strSql.Append(" values (");
            strSql.Append("@topType,@type,@goodsName,@minPrice,@maxPrice,@sell_min_price,@sell_max_price,@describe,@status,@createTime,@updateTime,@url)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@topType",        MySqlDbType.VarChar,   255),
                new MySqlParameter("@type",           MySqlDbType.VarChar,   255),
                new MySqlParameter("@goodsName",      MySqlDbType.VarChar,   255),
                new MySqlParameter("@minPrice",       MySqlDbType.Decimal,    10),
                new MySqlParameter("@maxPrice",       MySqlDbType.Decimal,    10),
                new MySqlParameter("@sell_min_price", MySqlDbType.Decimal,    10),
                new MySqlParameter("@sell_max_price", MySqlDbType.Decimal,    10),
                new MySqlParameter("@describe",       MySqlDbType.VarChar,   255),
                new MySqlParameter("@status",         MySqlDbType.Int32,      11),
                new MySqlParameter("@createTime",     MySqlDbType.DateTime),
                new MySqlParameter("@updateTime",     MySqlDbType.DateTime),
                new MySqlParameter("@url",            MySqlDbType.VarChar, 255)
            };
            parameters[0].Value  = model.topType;
            parameters[1].Value  = model.type;
            parameters[2].Value  = model.goodsName;
            parameters[3].Value  = model.minPrice;
            parameters[4].Value  = model.maxPrice;
            parameters[5].Value  = model.sell_min_price;
            parameters[6].Value  = model.sell_max_price;
            parameters[7].Value  = model.describe;
            parameters[8].Value  = model.status;
            parameters[9].Value  = model.createTime;
            parameters[10].Value = model.updateTime;
            parameters[11].Value = model.url;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.t_goods GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,topType,type,goodsName,minPrice,maxPrice,sell_min_price,sell_max_price,describe,status,createTime,updateTime,url from t_goods ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

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

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