码迷,mamicode.com
首页 > Web开发 > 详细

aspx页面调用后台代码

时间:2018-05-28 16:03:57      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:src   error   pow   manage   get   birt   display   err   als   

一个参数:

JS代码:

            function Power(id) {
                $.ajax({
                    type: "Post",
                    url: "OPKeHuDetails.aspx/setupPower",
                    data: "{‘newsid‘:" + id + "}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async:false,
                    success: function (data) {
                        $("#btn").val(data.d);
                    },
                    error: function (err) {
                        alert(err);
                    }
                });
            };

 

后台代码:

    [WebMethod]
    public static string setupPower(int newsid)
    {
        DataTable dt = AXAManager.OPKeHuManager.SelectDealerToDHByUserId(UserId);
        if (dt.Rows.Count > 0)
        {
            AXAManager.OPKeHuManager.UpdateDealerToDH(UpdateUserId, UserId, newsid);
        }
        else
        {
            AXAManager.OPKeHuManager.InsertDealerToDH(UserId, UpdateUserId, newsid);
        }
        if (newsid.ToString() == "0")
        {
            return "开通权限";
        }
        if (newsid.ToString() == "1")
        {
            return "关闭权限";
        }
        return "";
    }

 

多个参数:

js代码:

        function UserDetail(PK_Store, PK_StoreUser) {
            $.ajax({
                type: "post",
                url: "StoreUser.aspx/ShowData",
                contentType: "application/json;",
                data: "{ ‘PK_Store‘:‘"+ PK_Store+"‘, ‘PK_StoreUser‘:‘"+PK_StoreUser+"‘ }",
                //data: JSON.stringify({ "PK_Store": PK_Store, "PK_StoreUser": PK_StoreUser }),
                dataType: "json",
                success: function (data) {
                    $("#Detail").css("display", "block");
                    $(‘#Detail‘).window({
                        title: "用户详细信息",
                        width: 400,
                        height: 300,
                        modal: true,
                        minimizable: false
                    });
                    $("#UserName").text(data.d.StoreUserName);
                    $("#UserSex").text(data.d.Sex);
                    $("#Birthday").text(data.d.Birthday);
                    $("#UserPhone").text(data.d.UserPhone);
                    $("#UserJiFen").text(data.d.JiFen);
                    $("#UserEmail").text(data.d.Email);
                    $("#Image").attr("src", data.d.Photo);
                    $("#UserType").text(data.d.UserType);
                    $("#UserShopState").text(data.d.UseShopState);
                    $("#UserJobState").text(data.d.UseJobState);
                    $("#Time").text(data.d.UpdateTime);
                },
                error: function (err) {
                    alert(err);
                }
            });
        }

后台代码:

     public class UserDetail
     {
         public string StoreUserName { get; set; }
         public string UserPhone { get; set; }
         public string Sex { get; set; }
         public string Email { get; set; }
         public string Birthday { get; set; }
         public string Photo { get; set; }
         public string JiFen { get; set; }
         public string UserType { get; set; }
         public string UseShopState { get; set; }
         public string UpdateTime { get; set; }
     }


     [WebMethod]
     public static UserDetail ShowData(string PK_Store, string PK_StoreUser)
    {
         UserDetail user=new UserDetail();
        DataTable dt = StoreSNDAL.GetStoreUserByPK_Store("", "", "", "", PK_Store, PK_StoreUser);
        if (dt != null && dt.Rows.Count > 0)
        {
            user.StoreUserName = dt.Rows[0]["StoreUserName"].ToString();
            user.UserPhone = dt.Rows[0]["UserPhone"].ToString();
            user.Sex = dt.Rows[0]["Sex"].ToString();
            user.Email = dt.Rows[0]["Email"].ToString();
            user.Birthday = dt.Rows[0]["Birthday"].ToString().Replace("0:00:00", "").Trim();
            user.Photo = dt.Rows[0]["Photo"].ToString();
            user.JiFen = dt.Rows[0]["JiFen"].ToString();
            user.UserType = dt.Rows[0]["UserType"].ToString();
            user.UseShopState = dt.Rows[0]["UseShopState"].ToString()=="False"?"否":"是";
            user.UpdateTime = dt.Rows[0]["UpdateTime"].ToString();
        }
        return user;
    }

aspx页面调用后台代码

标签:src   error   pow   manage   get   birt   display   err   als   

原文地址:https://www.cnblogs.com/suflowers1700218/p/9100380.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!