示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DriveMgr.Model.Button model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tbButton set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Code=@Code,");
            strSql.Append("Icon=@Icon,");
            strSql.Append("Sort=@Sort,");
            strSql.Append("AddDate=@AddDate,");
            strSql.Append("Description=@Description");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",        SqlDbType.VarChar,    50),
                new SqlParameter("@Code",        SqlDbType.VarChar,    50),
                new SqlParameter("@Icon",        SqlDbType.VarChar,    50),
                new SqlParameter("@Sort",        SqlDbType.Int,         4),
                new SqlParameter("@AddDate",     SqlDbType.DateTime),
                new SqlParameter("@Description", SqlDbType.VarChar,   100),
                new SqlParameter("@Id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Code;
            parameters[2].Value = model.Icon;
            parameters[3].Value = model.Sort;
            parameters[4].Value = model.AddDate;
            parameters[5].Value = model.Description;
            parameters[6].Value = model.Id;

            int rows = DriveMgr.Common.SqlHelper.ExecuteNonQuery(DriveMgr.Common.SqlHelper.connStr, CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DriveMgr.Model.Button model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tbButton(");
            strSql.Append("Name,Code,Icon,Sort,AddDate,Description)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Code,@Icon,@Sort,@AddDate,@Description)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",        SqlDbType.VarChar,   50),
                new SqlParameter("@Code",        SqlDbType.VarChar,   50),
                new SqlParameter("@Icon",        SqlDbType.VarChar,   50),
                new SqlParameter("@Sort",        SqlDbType.Int,        4),
                new SqlParameter("@AddDate",     SqlDbType.DateTime),
                new SqlParameter("@Description", SqlDbType.VarChar, 100)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Code;
            parameters[2].Value = model.Icon;
            parameters[3].Value = model.Sort;
            parameters[4].Value = model.AddDate;
            parameters[5].Value = model.Description;

            int rows = Convert.ToInt32(DriveMgr.Common.SqlHelper.ExecuteScalar(DriveMgr.Common.SqlHelper.connStr, CommandType.Text, strSql.ToString(), parameters));

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(DriveMgr.Model.Button model)
 {
     return(dal.Update(model));
 }
示例#4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(DriveMgr.Model.Button model)
 {
     return(dal.Add(model));
 }