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

            strSql.Append("update " + databaseprefix + "withdraw set ");
            strSql.Append("user_id=@user_id,");
            strSql.Append("card_no=@card_no,");
            strSql.Append("amount=@amount,");
            strSql.Append("banktype=@banktype,");
            strSql.Append("remark=@remark,");
            strSql.Append("status=@status,");
            strSql.Append("addtime=@addtime,");
            strSql.Append("reason=@reason,");
            strSql.Append("img_url=@img_url");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id",  SqlDbType.Int,          4),
                new SqlParameter("@card_no",  SqlDbType.VarChar,    100),
                new SqlParameter("@amount",   SqlDbType.Decimal,      5),
                new SqlParameter("@banktype", SqlDbType.Int,          4),
                new SqlParameter("@remark",   SqlDbType.NVarChar,  4000),
                new SqlParameter("@status",   SqlDbType.TinyInt,      1),
                new SqlParameter("@addtime",  SqlDbType.DateTime),
                new SqlParameter("@reason",   SqlDbType.NVarChar,   500),
                new SqlParameter("@img_url",  SqlDbType.NVarChar,   255),
                new SqlParameter("@id",       SqlDbType.Int, 4)
            };

            parameters[0].Value = model.user_id;
            parameters[1].Value = model.card_no;
            parameters[2].Value = model.amount;
            parameters[3].Value = model.banktype;
            parameters[4].Value = model.remark;
            parameters[5].Value = model.status;
            parameters[6].Value = model.addtime;
            parameters[7].Value = model.reason;
            parameters[8].Value = model.img_url;
            parameters[9].Value = model.id;

            try
            {
                int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
                if (rows > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.withdraw model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "withdraw(");
            strSql.Append("user_id,card_no,amount,banktype,remark,status,addtime,reason,img_url,openId,mobile)");
            strSql.Append(" values (");
            strSql.Append("@user_id,@card_no,@amount,@banktype,@remark,@status,@addtime,@reason,@img_url,@openId,@mobile)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id",     SqlDbType.Int,         4),
                new SqlParameter("@card_no",     SqlDbType.VarChar,   100),
                new SqlParameter("@amount",      SqlDbType.Decimal,     5),
                new SqlParameter("@banktype",    SqlDbType.Int,         4),
                new SqlParameter("@remark",      SqlDbType.NVarChar,  500),
                new SqlParameter("@status",      SqlDbType.TinyInt,     1),
                new SqlParameter("@addtime",     SqlDbType.DateTime),
                new SqlParameter("@reason",      SqlDbType.NVarChar,  500),
                new SqlParameter("@img_url",     SqlDbType.NVarChar,  255),
                new SqlParameter("@openId",      SqlDbType.VarChar,   100),
                new SqlParameter("@mobile",      SqlDbType.VarChar,   100),
                new SqlParameter("@ReturnValue", SqlDbType.Int)
            };
            parameters[0].Value      = model.user_id;
            parameters[1].Value      = model.card_no;
            parameters[2].Value      = model.amount;
            parameters[3].Value      = model.banktype;
            parameters[4].Value      = model.remark;
            parameters[5].Value      = model.status;
            parameters[6].Value      = model.addtime;
            parameters[7].Value      = model.reason;
            parameters[8].Value      = model.img_url;
            parameters[9].Value      = model.OpenId;
            parameters[10].Value     = model.Mobile;
            parameters[11].Direction = ParameterDirection.Output;

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

            sqllist.Add(cmd);

            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return((int)parameters[11].Value);
        }
コード例 #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.withdraw GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,user_id,card_no,amount,banktype,remark,status,addtime,reason,img_url,openid,mobile from " + databaseprefix + "withdraw ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.withdraw model = new Model.withdraw();
            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]["card_no"] != null && ds.Tables[0].Rows[0]["card_no"].ToString() != "")
                {
                    model.card_no = ds.Tables[0].Rows[0]["card_no"].ToString();
                }
                if (ds.Tables[0].Rows[0]["amount"] != null && ds.Tables[0].Rows[0]["amount"].ToString() != "")
                {
                    model.amount = decimal.Parse(ds.Tables[0].Rows[0]["amount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["banktype"] != null && ds.Tables[0].Rows[0]["banktype"].ToString() != "")
                {
                    model.banktype = int.Parse(ds.Tables[0].Rows[0]["banktype"].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]["status"] != null && ds.Tables[0].Rows[0]["status"].ToString() != "")
                {
                    model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["addtime"] != null && ds.Tables[0].Rows[0]["addtime"].ToString() != "")
                {
                    model.addtime = DateTime.Parse(ds.Tables[0].Rows[0]["addtime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["reason"] != null && ds.Tables[0].Rows[0]["reason"].ToString() != "")
                {
                    model.reason = ds.Tables[0].Rows[0]["reason"].ToString();
                }
                if (ds.Tables[0].Rows[0]["img_url"] != null && ds.Tables[0].Rows[0]["img_url"].ToString() != "")
                {
                    model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString();
                }
                if (ds.Tables[0].Rows[0]["openid"] != null && ds.Tables[0].Rows[0]["openid"].ToString() != "")
                {
                    model.OpenId = ds.Tables[0].Rows[0]["openid"].ToString();
                }
                if (ds.Tables[0].Rows[0]["mobile"] != null && ds.Tables[0].Rows[0]["mobile"].ToString() != "")
                {
                    model.Mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.withdraw model)
 {
     return(dal.Update(model));
 }
コード例 #5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.withdraw model)
 {
     return(dal.Add(model));
 }