/// <summary> /// 增加一条数据 /// </summary> public bool Add(dbamet.Model.Admin model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Admin("); strSql.Append("uid,upwd)"); strSql.Append(" values ("); strSql.Append("@uid,@upwd)"); SqlParameter[] parameters = { new SqlParameter("@uid", SqlDbType.VarChar, 50), new SqlParameter("@upwd", SqlDbType.VarChar, 50) }; parameters[0].Value = model.uid; parameters[1].Value = model.upwd; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(dbamet.Model.Admin model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Admin set "); strSql.Append("upwd=@upwd"); strSql.Append(" where uid=@uid "); SqlParameter[] parameters = { new SqlParameter("@upwd", SqlDbType.VarChar, 50), new SqlParameter("@uid", SqlDbType.VarChar, 50) }; parameters[0].Value = model.upwd; parameters[1].Value = model.uid; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public dbamet.Model.Admin GetModel(string uid) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 uid,upwd from Admin "); strSql.Append(" where uid=@uid "); SqlParameter[] parameters = { new SqlParameter("@uid", SqlDbType.VarChar, 50) }; parameters[0].Value = uid; dbamet.Model.Admin model = new dbamet.Model.Admin(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["uid"] != null && ds.Tables[0].Rows[0]["uid"].ToString() != "") { model.uid = ds.Tables[0].Rows[0]["uid"].ToString(); } if (ds.Tables[0].Rows[0]["upwd"] != null && ds.Tables[0].Rows[0]["upwd"].ToString() != "") { model.upwd = ds.Tables[0].Rows[0]["upwd"].ToString(); } return(model); } else { return(null); } }