/// <summary> /// 更新一条数据 /// </summary> public bool Update(LEANJU.Model.Admin model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Admin set "); strSql.Append("admin=@admin,"); strSql.Append("password=@password"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@admin", SqlDbType.NVarChar, 10), new SqlParameter("@password", SqlDbType.NVarChar, 10) }; parameters[0].Value = model.admin; parameters[1].Value = model.password; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(LEANJU.Model.Admin model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Admin("); strSql.Append("admin,password)"); strSql.Append(" values ("); strSql.Append("@admin,@password)"); SqlParameter[] parameters = { new SqlParameter("@admin", SqlDbType.NVarChar, 10), new SqlParameter("@password", SqlDbType.NVarChar, 10) }; parameters[0].Value = model.admin; parameters[1].Value = model.password; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public LEANJU.Model.Admin DataRowToModel(DataRow row) { LEANJU.Model.Admin model = new LEANJU.Model.Admin(); if (row != null) { if (row["admin"] != null) { model.admin = row["admin"].ToString(); } if (row["password"] != null) { model.password = row["password"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public LEANJU.Model.Admin GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 admin,password from Admin "); strSql.Append(" where "); SqlParameter[] parameters = { }; LEANJU.Model.Admin model = new LEANJU.Model.Admin(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }