Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TSGLXT.Model.YHB model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update YHB set ");
            strSql.Append("password=@password");
            strSql.Append(" where username=@username ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@password", SqlDbType.VarChar, 10),
                new SqlParameter("@username", SqlDbType.VarChar, 10)
            };
            parameters[0].Value = model.password;
            parameters[1].Value = model.username;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(TSGLXT.Model.YHB model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into YHB(");
            strSql.Append("username,password)");
            strSql.Append(" values (");
            strSql.Append("@username,@password)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@username", SqlDbType.VarChar, 10),
                new SqlParameter("@password", SqlDbType.VarChar, 10)
            };
            parameters[0].Value = model.username;
            parameters[1].Value = model.password;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public TSGLXT.Model.YHB DataRowToModel(DataRow row)
 {
     TSGLXT.Model.YHB model = new TSGLXT.Model.YHB();
     if (row != null)
     {
         if (row["username"] != null)
         {
             model.username = row["username"].ToString();
         }
         if (row["password"] != null)
         {
             model.password = row["password"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TSGLXT.Model.YHB GetModel(string username)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 username,password from YHB ");
            strSql.Append(" where username=@username ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@username", SqlDbType.VarChar, 10)
            };
            parameters[0].Value = username;

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

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