<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ordertypemanage.aspx.cs" Inherits="HySoft.BaseCallCenter.Web.workordermanage.workorderset.ordertypemanage" %>

<!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 runat="server">
    <title>类型信息</title>
     <link href="../../scripts/ui/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="../../scripts/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../../scripts/ui/json2.js" type="text/javascript"></script>
    <script src="../../scripts/ui/js/core/base.js" type="text/javascript"></script>
    <script src="../../scripts/ui/js/ligerui.min.js" type="text/javascript"></script>
    <link href="../../scripts/ui/skins/Tab/css/tab.css" rel="stylesheet" type="text/css" />
    <link href="../../scripts/ui/skins/Tab/css/grid.css" rel="stylesheet" type="text/css" />
    <script src="../../scripts/ui/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="../../scripts/ui/js/plugins/ligerLayout.js" type="text/javascript"></script>
    <script src="../../scripts/ui/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="../../scripts/ui/js/plugins/ligerMenu.js" type="text/javascript"></script>
    <script src="../../scripts/CustomersData.js" type="text/javascript"></script>
    <link href="../../scripts/ui/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="../../images/style.css" rel="stylesheet" type="text/css" />

      <script type="text/javascript">
          var gridlist;
          var singleClick;
          var actionNodeID;
          var parentId;
          $(function () {
              $("#layout1").ligerLayout({
                  leftWidth: 200,
                  allowCenterBottomResize: false
              });
              tree();
              InitList();
          });
          function tree() {
              $("#tree1").ligerTree({
                  nodeWidth: 135,
                  checkbox: false,
                  url: '../ajax/WorkTypeManageAjax.ashx?action=gettreelist',
                  onClick: function (node, e) {
                      actionNodeID = node.data.id;
                      parentId = node.data.IconCls;
                      InitList();
                  }
              });
          }


          function InitList() {

              var sql = GetSql();
              try {
                  gridlist = $("#divDataList").ligerGrid({
                  checkbox:'true',
                      height: '99%',
                      columns: [
                { display: 'ID', name: '_f_workordertypeid', width: '1%', hide: 'ID' },
                 { display: '编号', name: '_f_workordertypeid', width: '20%' },
                { display: '名称', name: '_f_name', id: 'tree1', width: '20%' },
                  { display: '简称', name: '_f_ename', width: '20%' },
             
                { display: '描述', name: '_f_des', width: '30%' }
                ],
                      url: '../ajax/WorkTypeManageAjax.ashx?action=getlist&whereSql='+sql, pageSize: 10, rownumbers: true
//                      onSelectRow: function (data, rowindex, rowobj) {
//                          singleClick = data._f_workordertypeid;
//                      }
                  });
              }
              catch (e) {
                  alert(e.Message);
              }
              gridlist.changePage('first');
              $("#pageloading").hide();
          }
          function GetSql() {
              var sql = "";
              
              if (actionNodeID != undefined) {
                  sql += actionNodeID;
              } else {
              sql = 0;
              }
              return sql;
          }


          //添加事件
          function Add() {
              $.ligerDialog.open({ url: 'ordertypemanageedit.aspx?action=Add&parentId=' + parentId + '&actionNodeID=' + actionNodeID, title: '添加类型信息', height: 420, width: 680, isResize: true, overflow: 'hidden'
     });
          }

          //修改事件
          function ModifyEdit() {
              var selectedRow = gridlist.getSelectedRows();
              if (selectedRow != null && selectedRow.length != 0) {
                  if (selectedRow.length > 0 && selectedRow.length < 2) {
                      $.ligerDialog.open({ url: 'ordertypemanageedit.aspx?action=Addedit&actionNodeID=' + selectedRow[0]._f_workordertypeid, title: '修改类型信息', height: 420, width: 680, isResize: true, overflow: 'hidden' });

                  } else {
                      $.ligerDialog.alert("最多修改一条记录!");
                  } 
              } else {
                  $.ligerDialog.alert("请选择修改项!");
              }
          }

          function Delete() {
              try {
                  //获取选择的行
                  var rows = gridlist.getSelectedRows();
                  if (rows.length > 0) {
                   try {
                                  var arr = new Array();
                                  var i = 0;
                                  for (var i = 0; i < rows.length; i++) {
                                      arr[i] = rows[i]._f_workordertypeid;
                                  }
                                  $.post("../ajax/WorkTypeManageAjax.ashx?action=deletePanDuan&arrid=" + arr.toString(), function (data) {
                                      if (data > 0) {
                                          $.ligerDialog.alert('删除的存在子类型！');
                                      }
                                      else {
                                          $.ligerDialog.confirm('确定要批量删除选择的记录吗？', function (yes) {
                                              if (yes) {
                                                  $.post("../ajax/WorkTypeManageAjax.ashx?action=delete&arrid=" + arr.toString(), function (data) {
                                                      if (data == "success") {
                                                          $.ligerDialog.success('删除成功');
                                                          tree();
                                                          InitList();
                                                      }
                                                      else {
                                                          $.ligerDialog.error('删除失败');
                                                      }
                                                  });
                                              }
                                          });

                                      }
                                  });
                              }
                              catch (e) {
                                  alert(e.Message);
                              }
                  }
                  else {
                      $.ligerDialog.error('没有选择要删除的参数');
                  }
              }
              catch (e) {
                  $.ligerDialog.error(e.Message);
              }
          }

      
      </script>
</head>
<body>
    <form id="form1" runat="server">
      <div class="tools_box">
        <div class="tools_bar">
            <a class="tools_btn" href="#" onclick="Add();">
                <span><b class="add">新增</b></span>
            </a>
           
            <a class="tools_btn" href="#" onclick="ModifyEdit();">
                <span><b class="modify">修改</b></span>
            </a>
            <a class="tools_btn" href="#" onclick="Delete();"><span>
                    <b class="delete">批量删除</b></span> </a>
           <%-- <div class="search_box">
                状态编号：<asp:TextBox ID="txtF_ParamCode" runat="server" CssClass="txtInput"></asp:TextBox>&nbsp;&nbsp;
                <input id="btnSearch" type="button" value="搜 索" class="btnSearch" onclick="InitList();" />
            </div>--%>
        </div>
    </div>
    <div id="layout1">
      <div position="left" title="类型信息">
            <ul id="tree1">
                <li isexpand="false" id="-1">
                    <span>类型信息</span>
                    <ul>
                    </ul>
                </li> 
            </ul>
        </div>
      <div position="center" title="类型列表">
            <div id="divDataList">
            </div>
        </div>
    </div>
    </form>
</body>
</html>
