Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DTcms.Model.StoreMode model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update StoreMode set ");


            strSql.Append(" Name = @Name , ");
            strSql.Append(" Remark = @Remark  ");
            strSql.Append(" where Id=@Id  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",     SqlDbType.Int,       4),
                new SqlParameter("@Name",   SqlDbType.VarChar, 254),
                new SqlParameter("@Remark", SqlDbType.VarChar, 254)
            };

            parameters[0].Value = model.Id;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Remark;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DTcms.Model.StoreMode GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, Name, Remark  ");
            strSql.Append("  from StoreMode ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.Name   = ds.Tables[0].Rows[0]["Name"].ToString();
                model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DTcms.Model.StoreMode model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into StoreMode(");
            strSql.Append("Name,Remark");
            strSql.Append(") values (");
            strSql.Append("@Name,@Remark");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",   SqlDbType.VarChar, 254),
                new SqlParameter("@Remark", SqlDbType.VarChar, 254)
            };


            parameters[0].Value = model.Name;
            parameters[1].Value = model.Remark;
            return(DbHelperSQL.ExecuteSql(strSql.ToString(), parameters) > 0);
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DTcms.Model.StoreMode GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Id, Name, Remark  ");
            strSql.Append("  from StoreMode ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)			};
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();

                return model;
            }
            else
            {
                return null;
            }
        }