<%@ page language="C#" autoeventwireup="true" inherits="SB_admin_N47_Customer, App_Web_wkioulim" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>操作</title>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/easy_ui/jquery.min.js?v=1")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/easy_ui/jquery.easyui.min.js?v=1")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/easy_ui/locale/easyui-lang-zh_CN.js?v=1")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/easy_ui/jquery.load.js?v=1")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/easy_ui/jquery.json.js?v=1")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/easy_ui/jquery.easyui.validtor.js?v=1")%>"></script>
    <script type="text/javascript" language="javascript" src="<%=ResolveUrl("~/SB/control/js/PageDialog.js?v=1")%>"></script>
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/SB/control/easy_ui/themes/bootstrap/easyui.css?v=1")%>" />
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/SB/control/easy_ui/themes/icon.css?v=1")%>" />
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/SB/control/easy_ui/load.css?v=1")%>" />
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/SB/control/css/main.css?v=1")%>" />
    <script language="javascript" type="text/javascript">
       function query(){
	        $("#dataview").datagrid("load",{
	        					c_name: $("#qc_name").val(),				
								c_linkman: $("#qc_linkman").val()			
					        });
   	   }
   </script>
   
   
</head>
<body class="easyui-layout" style="visibility:hidden" >
    <div region="center" border="false">
        <table id="dataview">
            <thead>
                <tr>  
					<th field="ck" checkbox="true"></th>
						<th field="id" width="<%=operWidth %>" formatter='OperFormat'>操作</th>
						<th field="c_name" width="150" >客户名称</th>
						<th field="c_linkman" width="150" >联系人</th>
						<th field="c_tel" width="150" >电话号码</th>
						<th field="c_qq" width="150" >QQ</th>
						
						<th field="c_address" width="150" >地址</th>
						<th field="c_contact" width="150" >其他联系方式</th>
						<th field="c_note" width="150" >备注</th>
						<th field="c_udate" width="150" >修改日期</th>


				</tr>
            </thead>
        </table>
    </div>
    <div id="toolbar"   style="height:54px"   >
        <a class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="Add()">添 加</a>
        <a class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="deleteList()">删除</a><br />
        		&nbsp;客户名称 ：<input id="qc_name" name="name" type="text" maxlength="255" onkeydown= "if(event.keyCode==13)query()"/>
				联系人 ：<input id="qc_linkman" name="name" type="text" maxlength="255" onkeydown= "if(event.keyCode==13)query()"/>
        <a class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="query()">查询 </a>
        <a class="easyui-linkbutton" iconcls="icon-book" plain="true" onclick="$('#dataview').datagrid('load',{})">全部显示</a>
    </div>
    
</body>

<script language="javascript" type="text/javascript">
$(function(){
 
    $("#dataview").datagrid({
        toolbar:"#toolbar",
        fit:true,
        idfield:"id",
        border:false,
        pageSize:30,
        resizable:true,
        pagination:true,
        rownumbers:true,
        url:"N47_Customer/N47_Customer_Dataview.aspx",
        onLoadSuccess:function(){ $('#dataview').datagrid("unselectAll"); }
      
    });
    $("body").css("visibility","visible"); 
});
function OperFormat(value,row,index){
    var str = "";
    if(<%=isEdit %>)
    str += "<a href='javascript:void(0)' onclick=\"editItem('"+value+"')\">编辑</a>&nbsp;|&nbsp;";
    if(<%=isDelete %>)
    str += "<a href='javascript:void(0)' onclick=\"deleteItem('"+value+"')\">删除</a>";
    return str;
}
function deleteItem(key){
     $.messager.confirm('确认','确定要删除选中吗?',function(r){
     if(!r){ return }load("删除中...");
             $.ajax({
                type: "POST",
                url:"N47_Customer/N47_Customer_Delete.aspx",
                dataType:"json",
                data: {"deleteKey": key},
                success: function(data){
                  unload();
                  if(data.state==1){
                      $.messager.show({title: '提示', msg: data.data});
                      $('#dataview').datagrid('reload').datagrid("unselectAll");
                  }
                  else{
                     $.messager.alert('错误',data.data,'message');
                  }
               }
            });
     });
}
function deleteList(){
     var row = $('#dataview').datagrid('getSelections');
     if(row.length==0){$.messager.alert('提示',"请选择删除项！",'message'); return;}
     $.messager.confirm('确认','确定要删除选中吗?',function(r){
     if(r){
                 load("删除中...");
                 var list = new Array();
                 for(var index =0; index<row.length;index++){ list.push(row[index].id);  }
                 $.ajax({
                    type: "POST",
                    url:"N47_Customer/N47_Customer_Delete.aspx",
                    dataType:"json",
                    data: {"deleteList": list.join(",")}, 
                    success: function(data){
                      unload();
                      if(data.state==1){
                          $.messager.show({ title: '提示', msg: "总共删除"+data.data+"条信息" });
                          $('#dataview').datagrid('reload').datagrid("unselectAll");
                      }else{
                         $.messager.alert('错误',data.data,'message');
                      }
                   }
                });
     }
     });
}

function editItem(key){
    ShowDialog("edit","N47_Customer/N47_Customer_Edit.aspx?id="+key,600,300,100,100);
}
function Add(){
 	ShowDialog("add","N47_Customer/N47_Customer_Insert.aspx",600,300,100,100);
}
function reload(param){
    if(param=='last'){
        var grid = $('#dataview'); 
        var gridOptions = grid.datagrid("options"); 
        var options = grid.datagrid('getPager').data("pagination").options;  
        var pagenumber = options.total==0?1:Math.ceil( options.total/options.pageSize);
        gridOptions.pageNumber = pagenumber 
        options.pageNumber = pagenumber;
        $('#dataview').datagrid('reload');
    }
    $('#dataview').datagrid('reload');
}
</script>

</html>
