﻿

function operate(opt)
{
    if(opt==2 || opt==3 || opt==4 || opt==6 || opt==8 || opt==10)
    {
        var ids ="";
    
        var chks = window.document.getElementById("gvList").getElementsByTagName("input");
    
        for(var i=0;i<chks.length;i++)
        {
            if(chks[i].getAttribute("type")=="checkbox")
            {
                if(chks[i].checked)
                {
                   
                        if("" != ids)
                        {
                            ids += ','+ chks[i].value;
                        }
                        else
                        {
                            ids = chks[i].value;
                        }
                }
            }
        }
        
        //alert(ids);
        
        if(''==ids)
        {
            alert('请先选择你要操作的数据！');
            return false;
        }
        else
        {
           if(opt==2)  //删除
           {
                document.getElementById('txtId').value=ids;
                
                if(confirm("您确定要删除吗？"))
                {
                   document.getElementById('btnDel').click();
                }
            }
            
            
            
            if(opt==3)//编辑链接
            {
            
               var strs= new Array(); //定义一数组
               strs=ids.split(",")
               if(strs.length>1)
               {
                    alert('编辑数据只能是选中一笔!');
                    return false;
               }
               else
               {
                    window.location.href='LinkOperate.aspx?id='+ids+'&type=edit';//编辑
               }
               
            }
            
            if(opt==4)//审核留言
            {
                document.getElementById('txtId').value=ids;
                
                if(confirm("您确定要审核吗？"))
                {
                   document.getElementById('btnCheck').click();
                }
            }
            
            if(opt==6)//编辑新闻
            {
               var strs= new Array(); //定义一数组
               strs=ids.split(",")
               if(strs.length>1)
               {
                    alert('编辑数据只能是选中一笔!');
                    return false;
               }
               else
               {
                    window.location.href='NewsOperate.aspx?id='+ids+'&type=edit';//编辑
               }
            }
            if(opt==8)
            {
               var strs= new Array(); //定义一数组
               strs=ids.split(",")
               if(strs.length>1)
               {
                    alert('编辑数据只能是选中一笔!');
                    return false;
               }
               else
               {
                    window.location.href='UserOperate.aspx?id='+ids+'&type=edit';//编辑
               }
            }
            if(opt==10)
            {
               var strs= new Array(); //定义一数组
               strs=ids.split(",")
               if(strs.length>1)
               {
                    alert('编辑数据只能是选中一笔!');
                    return false;
               }
               else
               {
                    window.location.href='CaseOperate.aspx?id='+ids+'&type=edit';//编辑
               }
            }
    }
    }
    else
    {
        if(opt==1)
        {
            window.location.href='LinkOperate.aspx?id=0&type=add';//添加链接
        }
        if(opt==5)
        {
            window.location.href='NewsOperate.aspx?id=0&type=add';//添加新闻
        }
        if(opt==7)
        {
            window.location.href='UserOperate.aspx?id=0&type=add';//添加新闻
        }
        if(opt==9)
        {
            window.location.href='CaseOperate.aspx?id=0&type=add';//添加案例
        }
    }
    return false;
}
