点击关注
这是前台写的js脚本
function guanzhu() {
var hotelid = "<%=HotelID %>";
var loginid = "<%=Loginid %>";
if (loginid == null || loginid == "") {
alert("请先登录")
}
else {
var aa = "<%= addatt2()%>";
}
if (aa == 1) {
document.getElementById("guanzhuid").innerHTML = "已关注"
} else if (aa == 2) {
alert("您已关注过此酒店");
}
}
这是调用后台的方法
public static string addatt2()
{
string rt="";
int userid = 0;
DataTable dt = userbll.GetList("LoginId='" + Loginid+"'").Tables[0];
for (int i = 0; i < dt.Rows.Count; i++)
{
userid = Convert.ToInt32( dt.Rows[i]["user_Id"]);
}
DataTable selectAtt = attbll.GetList("AttentionHotelId='" + hotelID + "' and AttentionUserId='" + userid + "'").Tables[0];
if (selectAtt.Rows.Count > 0)
{
rt = "2";
}
else
{
if (userid != 0)//我在这加了一个判断