Ejemplo n.º 1
0
        /// <summary>按条件更新数据
        ///
        /// </summary>
        public bool UpdateByCond(string str_set, string cond)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [user] set " + str_set + " ");
            strSql.Append(" where " + cond);
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            return(h.ExecuteNonQuery());
        }
Ejemplo n.º 2
0
        /// <summary>删除一条数据
        ///
        /// </summary>
        public bool Delete(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from [user] ");
            strSql.Append(" where id=@id ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            h.AddParameter("@id", id);
            return(h.ExecuteNonQuery());
        }
Ejemplo n.º 3
0
        /// <summary>根据条件删除数据
        ///
        /// </summary>
        public bool DeleteByCond(string cond)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from [user] ");
            if (!string.IsNullOrEmpty(cond))
            {
                strSql.Append(" where " + cond);
            }
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            return(h.ExecuteNonQuery());
        }
Ejemplo n.º 4
0
        /// <summary>更新一条数据
        ///
        /// </summary>
        public bool Update(mhqNetAPP.Model.User model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [user] set ");
            strSql.Append("[creatdate]=@creatdate, [username]=@username, [password]=@password, [face]=@face, [usertype]=@usertype, [phone]=@phone, [qq]=@qq, [email]=@email, [remark]=@remark  ");
            strSql.Append(" where id=@id ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            if (model.id == null)
            {
                h.AddParameter("@id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@id", model.id);
            }
            if (model.creatdate == null)
            {
                h.AddParameter("@creatdate", DBNull.Value);
            }
            else
            {
                h.AddParameter("@creatdate", model.creatdate);
            }
            if (model.username == null)
            {
                h.AddParameter("@username", DBNull.Value);
            }
            else
            {
                h.AddParameter("@username", model.username);
            }
            if (model.password == null)
            {
                h.AddParameter("@password", DBNull.Value);
            }
            else
            {
                h.AddParameter("@password", model.password);
            }
            if (model.face == null)
            {
                h.AddParameter("@face", DBNull.Value);
            }
            else
            {
                h.AddParameter("@face", model.face);
            }
            if (model.usertype == null)
            {
                h.AddParameter("@usertype", DBNull.Value);
            }
            else
            {
                h.AddParameter("@usertype", model.usertype);
            }
            if (model.phone == null)
            {
                h.AddParameter("@phone", DBNull.Value);
            }
            else
            {
                h.AddParameter("@phone", model.phone);
            }
            if (model.qq == null)
            {
                h.AddParameter("@qq", DBNull.Value);
            }
            else
            {
                h.AddParameter("@qq", model.qq);
            }
            if (model.email == null)
            {
                h.AddParameter("@email", DBNull.Value);
            }
            else
            {
                h.AddParameter("@email", model.email);
            }
            if (model.remark == null)
            {
                h.AddParameter("@remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@remark", model.remark);
            }

            return(h.ExecuteNonQuery());
        }