예제 #1
0
파일: Balance.cs 프로젝트: z12578/Leanju
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LEANJU.Model.Balance model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Balance set ");
            strSql.Append("password=@password,");
            strSql.Append("balance=@balance");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@password", SqlDbType.NVarChar, 10),
                new SqlParameter("@balance",  SqlDbType.Decimal,   5),
                new SqlParameter("@id",       SqlDbType.NVarChar, 20)
            };
            parameters[0].Value = model.password;
            parameters[1].Value = model.balance;
            parameters[2].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
파일: Balance.cs 프로젝트: z12578/Leanju
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(LEANJU.Model.Balance model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Balance(");
            strSql.Append("id,password,balance)");
            strSql.Append(" values (");
            strSql.Append("@id,@password,@balance)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",       SqlDbType.NVarChar, 20),
                new SqlParameter("@password", SqlDbType.NVarChar, 10),
                new SqlParameter("@balance",  SqlDbType.Decimal, 5)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.password;
            parameters[2].Value = model.balance;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
파일: Balance.cs 프로젝트: z12578/Leanju
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public LEANJU.Model.Balance DataRowToModel(DataRow row)
 {
     LEANJU.Model.Balance model = new LEANJU.Model.Balance();
     if (row != null)
     {
         if (row["id"] != null)
         {
             model.id = row["id"].ToString();
         }
         if (row["password"] != null)
         {
             model.password = row["password"].ToString();
         }
         if (row["balance"] != null && row["balance"].ToString() != "")
         {
             model.balance = decimal.Parse(row["balance"].ToString());
         }
     }
     return(model);
 }
예제 #4
0
파일: Balance.cs 프로젝트: z12578/Leanju
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LEANJU.Model.Balance GetModel(string id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,password,balance from Balance ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.NVarChar, 20)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }