function delLog(id,num)
        {               
            if (num == 0)
            {
                if (!confirm('确认要删除?'))
                    return;
                   
                $.post(
                    'user.ashx',
                    {act:'log',num:'0',id:id},
                    function (data,textStatus)
                    {           
                        if (data.result == 'success')window.location.reload();           
                        else alert('操作失败');                          
                    },
                    'json'
                    ); 
            }
            else
            {
                var checks = document.getElementsByName("checkme");
                var isChecked = false;
                for (i =0;i<checks.length;i++)
                {
                    if (checks[i].checked)  
                    {               
                        id +=  checks[i].value +  ',' ;
                        isChecked = true;   
                    }             
                }
                if (!isChecked)
                {
                    alert('请选择要删除的日志');
                    return;
                }
                if (!confirm('确认要删除?'))
                    return;               
                $.post(
                    'user.ashx',
                    {act:'log',Num:'1',id:id},
                    function (data,textStatus)
                    {           
                        if (data.result == 'success')window.location.reload();           
                        else alert('操作失败');                          
                    },
                    'json'
                    ); 
            }   
        }

 

<%@ WebHandler Language="C#" Class="user" %>

using System;
using System.Web;
using System.Web.SessionState;

public class user : IHttpHandler , IRequiresSessionState{
   
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "application/json";
        string action = context.Request.Form["act"] != null ? context.Request.Form["act"].ToString() : string.Empty;
        string id = context.Request.Form["id"] != null ? context.Request.Form["id"].ToString() : string.Empty;
        string num = context.Request.Form["num"] != null ? context.Request.Form["num"].ToString() : string.Empty;
       
        switch (action)
        {
            case "log":
                {
                    if (num == "0")
                    {
                        Wangzhi.Bll.LogBll logBll = new Wangzhi.Bll.LogBll();
                        if (logBll.Delete(Convert.ToInt64(id)))
                            context.Response.Write("{result:'success'}");
                        else
                            context.Response.Write("{result:'lose'}");
                    }
                    else
                    {
                        string[] ss = id.Split(',');
                        Wangzhi.Bll.LogBll logBll = new Wangzhi.Bll.LogBll();
                        int i = 0;
                        foreach (string s in ss)
                        {
                            if (string.IsNullOrEmpty(s)) continue;
                            if (logBll.Delete(Convert.ToInt64(s)))
                                i++;
                        }
                        if (i>0)
                            context.Response.Write("{result:'success'}");
                        else
                            context.Response.Write("{result:'lose'}");
                     }
                }
                break;
            default:
                break;
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}

 

posted on 2009-12-08 22:59  sweting  阅读(404)  评论(0编辑  收藏  举报