Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(hm.Model.ed_productAttrValue model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ed_productAttrValue(");
            strSql.Append("productId,attributeId,attributeValue)");
            strSql.Append(" values (");
            strSql.Append("@productId,@attributeId,@attributeValue)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@productId",      OleDbType.Integer, 4),
                new OleDbParameter("@attributeId",    OleDbType.Integer, 4),
                new OleDbParameter("@attributeValue", OleDbType.VarChar, 255)
            };
            parameters[0].Value = model.productId;
            parameters[1].Value = model.attributeId;
            parameters[2].Value = model.attributeValue;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(hm.Model.ed_productAttrValue model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ed_productAttrValue set ");
            strSql.Append("productId=@productId,");
            strSql.Append("attributeId=@attributeId,");
            strSql.Append("attributeValue=@attributeValue");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@productId",      OleDbType.Integer,   4),
                new OleDbParameter("@attributeId",    OleDbType.Integer,   4),
                new OleDbParameter("@attributeValue", OleDbType.VarChar, 255),
                new OleDbParameter("@ID",             OleDbType.Integer, 4)
            };
            parameters[0].Value = model.productId;
            parameters[1].Value = model.attributeId;
            parameters[2].Value = model.attributeValue;
            parameters[3].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public hm.Model.ed_productAttrValue GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,productId,attributeId,attributeValue from ed_productAttrValue ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@ID", OleDbType.Integer, 4)
            };
            parameters[0].Value = ID;

            hm.Model.ed_productAttrValue model = new hm.Model.ed_productAttrValue();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["productId"] != null && ds.Tables[0].Rows[0]["productId"].ToString() != "")
                {
                    model.productId = int.Parse(ds.Tables[0].Rows[0]["productId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["attributeId"] != null && ds.Tables[0].Rows[0]["attributeId"].ToString() != "")
                {
                    model.attributeId = int.Parse(ds.Tables[0].Rows[0]["attributeId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["attributeValue"] != null && ds.Tables[0].Rows[0]["attributeValue"].ToString() != "")
                {
                    model.attributeValue = ds.Tables[0].Rows[0]["attributeValue"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }