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

            strSql.Append("update ecs_brand_percentage set ");
            strSql.Append("bp_brand_id=@bp_brand_id,");
            strSql.Append("bp_brand_name=@bp_brand_name,");
            strSql.Append("bp_percentage=@bp_percentage,");
            strSql.Append("bp_year=@bp_year");
            strSql.Append(" where bp_id=@bp_id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@bp_brand_id",   MySqlDbType.Int32,    10),
                new MySqlParameter("@bp_brand_name", MySqlDbType.VarChar, 100),
                new MySqlParameter("@bp_percentage", MySqlDbType.Float,    10),
                new MySqlParameter("@bp_year",       MySqlDbType.VarChar,   4),
                new MySqlParameter("@bp_id",         MySqlDbType.Int32, 10)
            };
            parameters[0].Value = model.bp_brand_id;
            parameters[1].Value = model.bp_brand_name;
            parameters[2].Value = model.bp_percentage;
            parameters[3].Value = model.bp_year;
            parameters[4].Value = model.bp_id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XHD.Model.ecs_brand_percentage DataRowToModel(DataRow row)
 {
     XHD.Model.ecs_brand_percentage model = new XHD.Model.ecs_brand_percentage();
     if (row != null)
     {
         if (row["bp_id"] != null && row["bp_id"].ToString() != "")
         {
             model.bp_id = int.Parse(row["bp_id"].ToString());
         }
         if (row["bp_brand_id"] != null && row["bp_brand_id"].ToString() != "")
         {
             model.bp_brand_id = int.Parse(row["bp_brand_id"].ToString());
         }
         if (row["bp_brand_name"] != null)
         {
             model.bp_brand_name = row["bp_brand_name"].ToString();
         }
         if (row["bp_percentage"] != null && row["bp_percentage"].ToString() != "")
         {
             model.bp_percentage = decimal.Parse(row["bp_percentage"].ToString());
         }
         if (row["bp_year"] != null)
         {
             model.bp_year = row["bp_year"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(XHD.Model.ecs_brand_percentage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ecs_brand_percentage(");
            strSql.Append("bp_brand_id,bp_brand_name,bp_percentage,bp_year)");
            strSql.Append(" values (");
            strSql.Append("@bp_brand_id,@bp_brand_name,@bp_percentage,@bp_year)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@bp_brand_id",   MySqlDbType.Int32,    10),
                new MySqlParameter("@bp_brand_name", MySqlDbType.VarChar, 100),
                new MySqlParameter("@bp_percentage", MySqlDbType.Float,    10),
                new MySqlParameter("@bp_year",       MySqlDbType.VarChar, 4)
            };
            parameters[0].Value = model.bp_brand_id;
            parameters[1].Value = model.bp_brand_name;
            parameters[2].Value = model.bp_percentage;
            parameters[3].Value = model.bp_year;

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

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

            strSql.Append("select bp_id,bp_brand_id,bp_brand_name,bp_percentage,bp_year from ecs_brand_percentage ");
            strSql.Append(" where bp_id=@bp_id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@bp_id", MySqlDbType.Int32)
            };
            parameters[0].Value = bp_id;

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

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