Beispiel #1
0
 /// <summary>
 /// 增加积分及检查升级
 /// </summary>
 /// <param name="user_id">用户ID</param>
 /// <param name="user_name">用户名</param>
 /// <param name="value">积分值可为正负</param>
 /// <param name="remark">备注</param>
 /// <param name="is_upgrade">是否检查升级</param>
 public int Add(int user_id, string user_name, int value, string remark, bool is_upgrade)
 {
     Model.users.user_point_log model = new Model.users.user_point_log();
     model.user_id = user_id;
     model.user_name = user_name;
     model.value = value;
     model.remark = remark;
     int result = dal.Add(model, is_upgrade);
     if (is_upgrade && value > 0 && result > 0)
     {
         new BLL.users.users().Upgrade(user_id);
     }
     return result;
 }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.users.user_point_log model, bool is_upgrade)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "user_point_log(");
            strSql.Append("user_id,user_name,value,remark,add_time)");
            strSql.Append(" values (");
            strSql.Append("@user_id,@user_name,@value,@remark,@add_time)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id",     SqlDbType.Int,         4),
                new SqlParameter("@user_name",   SqlDbType.NVarChar,  100),
                new SqlParameter("@value",       SqlDbType.Int,         4),
                new SqlParameter("@remark",      SqlDbType.NVarChar,  500),
                new SqlParameter("@add_time",    SqlDbType.DateTime),
                new SqlParameter("@ReturnValue", SqlDbType.Int)
            };
            parameters[0].Value     = model.user_id;
            parameters[1].Value     = model.user_name;
            parameters[2].Value     = model.value;
            parameters[3].Value     = model.remark;
            parameters[4].Value     = model.add_time;
            parameters[5].Direction = ParameterDirection.Output;

            List <CommandInfo> sqllist = new List <CommandInfo>();
            CommandInfo        cmd     = new CommandInfo(strSql.ToString(), parameters);

            sqllist.Add(cmd);

            StringBuilder strSql2 = new StringBuilder();

            strSql2.Append("update " + databaseprefix + "users set point=point+" + model.value);
            if (model.value > 0 && is_upgrade)
            {
                strSql2.Append(",exp=exp+" + model.value);
            }
            strSql2.Append(" where id=@id");
            SqlParameter[] parameters2 =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters2[0].Value = model.user_id;
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return((int)parameters[5].Value);
        }
Beispiel #3
0
        /// <summary>
        /// 增加积分及检查升级
        /// </summary>
        /// <param name="user_id">用户ID</param>
        /// <param name="user_name">用户名</param>
        /// <param name="value">积分值可为正负</param>
        /// <param name="remark">备注</param>
        /// <param name="is_upgrade">是否检查升级</param>
        public int Add(int user_id, string user_name, int value, string remark, bool is_upgrade)
        {
            Model.users.user_point_log model = new Model.users.user_point_log();
            model.user_id   = user_id;
            model.user_name = user_name;
            model.value     = value;
            model.remark    = remark;
            int result = dal.Add(model, is_upgrade);

            if (is_upgrade && value > 0 && result > 0)
            {
                new BLL.users.users().Upgrade(user_id);
            }
            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.users.user_point_log GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,user_id,user_name,value,remark,add_time from " + databaseprefix + "user_point_log ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.users.user_point_log model = new Model.users.user_point_log();
            DataSet ds = DbHelperSQL.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]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_name"] != null && ds.Tables[0].Rows[0]["user_name"].ToString() != "")
                {
                    model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["value"] != null && ds.Tables[0].Rows[0]["value"].ToString() != "")
                {
                    model.value = int.Parse(ds.Tables[0].Rows[0]["value"].ToString());
                }
                if (ds.Tables[0].Rows[0]["remark"] != null && ds.Tables[0].Rows[0]["remark"].ToString() != "")
                {
                    model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.users.user_point_log GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,user_id,user_name,value,remark,add_time from " + databaseprefix + "user_point_log ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.users.user_point_log model = new Model.users.user_point_log();
            DataSet ds = DbHelperSQL.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]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_name"] != null && ds.Tables[0].Rows[0]["user_name"].ToString() != "")
                {
                    model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["value"] != null && ds.Tables[0].Rows[0]["value"].ToString() != "")
                {
                    model.value = int.Parse(ds.Tables[0].Rows[0]["value"].ToString());
                }
                if (ds.Tables[0].Rows[0]["remark"] != null && ds.Tables[0].Rows[0]["remark"].ToString() != "")
                {
                    model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }