Coolite TreePanel 操作之二: 右键菜单

  

代码
<script type="text/javascript">
        
function nodeLoad(node) {
            Coolite.AjaxMethods.NodeLoad(node.id, {
                success: 
function(result) {
                    
var data = eval("(" + result + ")");
                    node.loadNodes(data);
                },

                failure: 
function(errorMsg) {
                    Ext.Msg.alert(
'Failure', errorMsg);
                }
            });
        }


        
function addNode(tree) {
            
var node = tree.getSelectionModel().getSelectedNode();
            
if (node) {
                AddNewOrganization({
                    success: 
function(result) {
                        
var data = eval("(" + result + ")");
                        node.appendChild(data);
                    },
                    failure: 
function(errorMsg) {
                        Ext.Msg.alert(
'Failure', errorMsg);
                    }
                });
            }
        }
        
function delNode(tree) {

            
var node = tree.getSelectionModel().getSelectedNode();

            
if (node) {
                node.remove();
            }
        }
        
function refreshTree(tree) {
            tree.el.mask(
'Loading...''x-loading-mask');
            Coolite.AjaxMethods.RefreshMenu({
                success: 
function(result) {
                    
var nodes = eval(result);
                    tree.root.ui.remove();
                    tree.initChildren(nodes);
                    tree.root.render();
                    tree.el.unmask();
                },
                failure: 
function(msg) {

                    tree.el.unmask();

                    Ext.Msg.alert(
'Failure''未能加载数据');

                }

            });
        }

        
function getNode(tree) {

            
var node = tree.getSelectionModel().getSelectedNode();
            
if (node != null) {
                
if (node.parentNode.id != null) {
                    
//alert(node.parentNode.id);
                    Coolite.AjaxMethods.GetNode(node.parentNode.id);
                }
            }
        }

        Ext.override(Ext.grid.CheckboxSelectionModel, {
            onMouseDown: 
function(e, t) {
                
if (e.button === 0 && (!this.checkOnly || (this.checkOnly && t.className == "x-grid3-row-checker")) && t.className != "x-grid3-row-expander" && !Ext.fly(t).hasClass("x-grid3-td-expander")) {
                    e.stopEvent();

                    
var row = e.getTarget(".x-grid3-row");

                    
if (row) {
                        
var index = row.rowIndex;

                        
if (this.isSelected(index)) {
                            
if (!this.grid.enableDragDrop) {
                                
if (!this.allowDeselect) {
                                    
return;
                                }

                                
this.deselectRow(index);
                            } 
else {
                                
this.deselectingFlag = true;
                            }
                        } 
else {
                            
if (this.grid.enableDragDrop) {
                                
this.deselectingFlag = false;
                            }

                            
this.selectRow(index, true);
                        }
                    }
                }
            }
        });


    
</script>

    
<div style="padding-left: 250px">
        
<ext:Store ID="StoreUser" runat="server" OnRefreshData="my_RefreshData">
            
<Reader>
                
<ext:JsonReader>
                    
<Fields>
                        
<ext:RecordField Name="user_id">
                        
</ext:RecordField>
                        
<ext:RecordField Name="employee_name">
                        
</ext:RecordField>
                        
<ext:RecordField Name="e_mail">
                        
</ext:RecordField>
                        
<ext:RecordField Name="mobile_number">
                        
</ext:RecordField>
                        
<ext:RecordField Name="employee_no">
                        
</ext:RecordField>
                    
</Fields>
                
</ext:JsonReader>
            
</Reader>
        
</ext:Store>
        
<ext:Menu ID="cmenu" runat="server">
            
<Items>
                
<ext:MenuItem ID="copyItems" runat="server" Text="New" Icon="Add">
                    
<Listeners>
                    
<Click Handler="Coolite.AjaxMethods.CMenuMaintain(this.parentMenu.node.id,'New');" />
                       
</Listeners>
                
</ext:MenuItem>
                
<ext:MenuItem ID="editItems" runat="server" Text="Edit" Icon="NoteEdit">
                    
<Listeners>
                      
<Click Handler="Coolite.AjaxMethods.CMenuMaintain(this.parentMenu.node.id,'Edit');" />
                      
</Listeners>
                
</ext:MenuItem>
                
<ext:MenuItem ID="moveItems" runat="server" Text="Delete" Icon="Decline">
                    
<Listeners>
                       
<Click Handler="Coolite.AjaxMethods.CMenuMaintain(this.parentMenu.node.id,'Delete');" />
                        
</Listeners>
                
</ext:MenuItem>
            
</Items>
        
</ext:Menu>
        
<ext:ViewPort ID="ViewPort1" runat="server">
            
<Body>
                
<ext:BorderLayout ID="BorderLayout1" runat="server">
                    
<West Collapsible="true" Split="true" MinWidth="300" MaxWidth="350" MarginsSummary="5 0 5 5"
                        CMarginsSummary
="5 5 5 5">
                        
<ext:Panel runat="server" Title="Organization Property" Width="300" ID="pnlWest"
                            AutoScroll
="true">
                            
<Body>
                                
<ext:Toolbar runat="server">
                                    
<Items>
                                        
<ext:ToolbarButton ID="ButtonNewOG" runat="server" Text="New" Icon="Add">
                                            
<ToolTips>
                                                
<ext:ToolTip ID="ToolTip4" Title="New Organization" runat="server">
                                                
</ext:ToolTip>
                                            
</ToolTips>
                                            
<%-- <Listeners>
                                            
<Click Handler="addNode(#{TreePanelOrganization})" />
                                            
</Listeners>--%><Listeners>
                                                
<Click Handler="Coolite.AjaxMethods.OrganizationNew()" />
                                            
</Listeners>
                                            
<%--<AjaxEvents>
                                            
<Click OnEvent="OrganizationNew">
                                             
<EventMask ShowMask="true" Msg="Processing....."  MinDelay="100"/>
                                            
</Click>
                                            
</AjaxEvents>--%></ext:ToolbarButton><%-- <ext:Button ID="ButtonNewOG" runat="server" Text="New" Icon="Add">
                                            
<ToolTips>
                                                
<ext:ToolTip ID="ToolTip1" Title="New Organization" runat="server">
                                                
</ext:ToolTip>
                                            
</ToolTips>
                                            
<Listeners>
                                                
<Click Handler="Coolite.AjaxMethods.OrganizationNew()" />
                                            
</Listeners>
                                        
</ext:Button>--%><ext:ToolbarSeparator ID="ToolbarSeparator1" runat="server">
                                        
</ext:ToolbarSeparator>
                                        
<ext:Button ID="ButtonEditOG" runat="server" Text="Edit " Icon="NoteEdit">
                                            
<ToolTips>
                                                
<ext:ToolTip ID="ToolTip2" Title="Edit Organization" runat="server">
                                                
</ext:ToolTip>
                                            
</ToolTips>
                                            
<Listeners>
                                                
<Click Handler="Coolite.AjaxMethods.ButtonEditOG_Click()" />
                                            
</Listeners>
                                        
</ext:Button>
                                        
<ext:ToolbarSeparator ID="ToolbarSeparator2" runat="server">
                                        
</ext:ToolbarSeparator>
                                        
<ext:Button ID="ButtonDeleteOG" runat="server" Text="Delete" Icon="Decline">
                                            
<ToolTips>
                                                
<ext:ToolTip ID="ToolTip3" Title="Delete Organization" runat="server">
                                                
</ext:ToolTip>
                                            
</ToolTips>
                                            
<Listeners>
                                                
<Click Handler="Coolite.AjaxMethods.DoConfirm()" />
                                            
</Listeners>
                                        
</ext:Button>
                                    
</Items>
                                
</ext:Toolbar>
                                
<ext:TreePanel ID="TreePanelOrganization" runat="server" ContextMenuID="cmenu" AutoHeight="true"
                                    AutoScroll
="true">
                                    
<Listeners>
                                       
<ContextMenu  Handler=" #{cmenu}.node=node;#{cmenu}.showAt(e.getPoint());" />
                                        
<Click Handler="#{TextFieldNode}.setValue(node.id);" />
                                        
<%-- <BeforeLoad Fn="nodeLoad" />--%></Listeners>
                                    
<AjaxEvents>
                                        
<Click OnEvent="getNode">
                                        
</Click>
                                    
</AjaxEvents>
                                
</ext:TreePanel>
                                
<ext:TextField ID="TextFieldNode" runat="server" Hidden="true">
                                
</ext:TextField>
                                
<ext:TextField ID="TextFieldParentNode" runat="server" Hidden="true">
                                
</ext:TextField>
                            
</Body>
                            
<BottomBar>
                                
<ext:Toolbar runat="server">
                                    
<Items>
                                        
<ext:Button ID="ButtonNewRole" Icon="Add" Text="New Role" runat="server">
                                            
<ToolTips>
                                                
<ext:ToolTip Title="New Role" runat="server" ID="ToolTipNew">
                                                
</ext:ToolTip>
                                            
</ToolTips>
                                            
<Listeners>
                                                
<Click Handler="Coolite.AjaxMethods.ButtonNewRole_Click()" />
                                            
</Listeners>
                                        
</ext:Button>
                                        
<ext:ToolbarSeparator ID="ToolbarSeparator3" runat="server">
                                        
</ext:ToolbarSeparator>
                                        
<ext:Button ID="ButtonDeleteRole" Icon="Decline" Text="Delete Role" runat="server">
                                            
<ToolTips>
                                                
<ext:ToolTip ID="ToolTipDelete" Title="Delete Role" runat="server">
                                                
</ext:ToolTip>
                                            
</ToolTips>
                                            
<Listeners>
                                                
<Click Handler="Coolite.AjaxMethods.DoDeleteRoleConfirm()" />
                                            
</Listeners>
                                        
</ext:Button>
                                    
</Items>
                                
</ext:Toolbar>
                            
</BottomBar>
                        
</ext:Panel>
                    
</West>
                    
<Center MarginsSummary="5 5 5 0">
                        
<ext:Panel ID="Panel5" runat="server" Title="User List">
                            
<Body>
                                
<ext:FitLayout ID="FitLayout1" runat="server" BodyStyle="padding:15px;">
                                    
<ext:Panel runat="server" AutoHeight="true" AutoWidth="true">
                                        
<Body>
                                            
<ext:Toolbar runat="server">
                                                
<Items>
                                                    
<ext:ToolbarTextItem Text="Employee No">
                                                    
</ext:ToolbarTextItem>
                                                    
<ext:ToolbarSpacer ID="ToolbarSpacer2" runat="server" Width="20">
                                                    
</ext:ToolbarSpacer>
                                                    
<ext:TextField ID="TextFieldSNO" runat="server" FieldLabel="Employee NO">
                                                    
</ext:TextField>
                                                    
<ext:ToolbarSpacer ID="ToolbarSpacer3" runat="server" Width="20">
                                                    
</ext:ToolbarSpacer>
                                                    
<ext:ToolbarTextItem Text="Employee Name">
                                                    
</ext:ToolbarTextItem>
                                                    
<ext:TextField ID="TextFieldSName" runat="server" FieldLabel="Employee Name">
                                                    
</ext:TextField>
                                                    
<ext:Button ID="ButtonSearch" runat="server" Text="Query" Icon="Zoom">
                                                        
<Listeners>
                                                            
<Click Handler="Coolite.AjaxMethods.ButtonSearch_Click()" />
                                                        
</Listeners>
                                                    
</ext:Button>
                                                    
<ext:ToolbarFill ID="ToolbarFill1" runat="server">
                                                    
</ext:ToolbarFill>
                                                    
<ext:Button ID="ButtonNew" runat="server" Text="New User" Icon="Add">
                                                        
<AjaxEvents>
                                                            
<Click OnEvent="ButtonNewUser_Click">
                                                                
<EventMask ShowMask="true" />
                                                            
</Click>
                                                        
</AjaxEvents>
                                                    
</ext:Button>
                                                
</Items>
                                            
</ext:Toolbar>
                                            
<ext:GridPanel ID="GridPanelUser" runat="server" StoreID="StoreUser" Height="660"
                                                AutoWidth
="true" AutoExpandColumn="e_mail">
                                                
<ColumnModel>
                                                    
<Columns>
                                                        
<ext:CommandColumn Header="Delete" Hidden="true">
                                                            
<Commands>
                                                                
<ext:GridCommand Icon="Decline" Text="Delete" ToolTip-Text="Delete" CommandName="Delete">
                                                                
</ext:GridCommand>
                                                            
</Commands>
                                                        
</ext:CommandColumn>
                                                        
<ext:Column ColumnID="employee_no" Header="Employee No" DataIndex="employee_no" Sortable="true">
                                                        
</ext:Column>
                                                        
<ext:Column ColumnID="employee_name" Header="Employee Name" DataIndex="employee_name"
                                                            Sortable
="true">
                                                        
</ext:Column>
                                                        
<ext:Column ColumnID="mobile_number" Header="Mobile" DataIndex="mobile_number" Sortable="true">
                                                        
</ext:Column>
                                                        
<ext:Column ColumnID="e_mail" Header="Email" DataIndex="e_mail" Sortable="true">
                                                        
</ext:Column>
                                                        
<ext:Column ColumnID="user_id" Header="UserID" DataIndex="user_id" Hidden="true">
                                                        
</ext:Column>
                                                    
</Columns>
                                                
</ColumnModel>
                                                
<SelectionModel>
                                                    
<%--   <ext:RowSelectionModel runat="server" SingleSelect="true" ID="RowSelectionModelUser">
                                                    
</ext:RowSelectionModel>--%><ext:CheckboxSelectionModel ID="CheckboxSelectionModel2"
                                                        runat
="server">
                                                        
<%--<CustomConfig>
                                                            
<ext:ConfigItem Name="checkOnly" Value="true" Mode="Raw" />
                                                        
</CustomConfig>--%></ext:CheckboxSelectionModel></SelectionModel>
                                                
<BottomBar>
                                                    
<ext:PagingToolbar ID="PagingToolBar2" runat="server" PageSize="10" StoreID="StoreUser"
                                                        DisplayInfo
="true" />
                                                
</BottomBar>
                                                
<SaveMask ShowMask="false" />
                                                
<LoadMask ShowMask="true" />
                                                
<Listeners>
                                                    
<Command Handler="Coolite.AjaxMethods.GridPanelUser_Command(command,record.data.user_id,record.data.employee_no)" />
                                                
</Listeners>
                                            
</ext:GridPanel>
                                        
</Body>
                                    
</ext:Panel>
                                
</ext:FitLayout>
                            
</Body>
                        
</ext:Panel>
                    
</Center>
                
</ext:BorderLayout>
            
</Body>
        
</ext:ViewPort>
        
<!-- Organization Maintain-->
        
<ext:Store ID="StoreBu" runat="server" AutoLoad="true">
            
<Reader>
                
<ext:JsonReader>
                    
<Fields>
                        
<ext:RecordField Name="BuID">
                        
</ext:RecordField>
                        
<ext:RecordField Name="BuName">
                        
</ext:RecordField>
                    
</Fields>
                
</ext:JsonReader>
            
</Reader>
        
</ext:Store>
        
<ext:Store ID="StoreSite" runat="server" AutoLoad="true">
            
<Reader>
                
<ext:JsonReader>
                    
<Fields>
                        
<ext:RecordField Name="SiteID">
                        
</ext:RecordField>
                        
<ext:RecordField Name="SiteName">
                        
</ext:RecordField>
                    
</Fields>
                
</ext:JsonReader>
            
</Reader>
        
</ext:Store>
        
<ext:Window ID="WindowNewOrganization" runat="server" Icon="GroupAdd" Title="New Organization"
            ShowOnLoad
="false" Width="400" Height="400" BodyStyle="padding:5px;" Closable="true"
            Modal
="true">
            
<Body>
                
<%--  <ext:FormPanel ID="FormPanelMaintainOrg" runat="server">
           
<Body>
            
<ext:Panel ID="PanelMaintainOrg" runat="server">
                
<Body>
                    
<ext:ColumnLayout runat="server">
                        
<ext:LayoutColumn ColumnWidth="0.5"> 
                        
                        
</ext:LayoutColumn>
                    
</ext:ColumnLayout>
                
</Body>
            
</ext:Panel>
           
</Body>
           
</ext:FormPanel>
           
--%><ext:Hidden ID="HiddenOrganizationID" runat="server">
           
</ext:Hidden>
                
<ext:FormLayout runat="server" ID="FormLayoutNewOrganization" LabelWidth="150">
                    
<ext:Anchor>
                        
<ext:TextField ID="TextFielOrganizationName" runat="server" FieldLabel="OrganizationName"
                            Width
="200" BlankText="Organization Name " AllowBlank="false"  EmptyText="Organization Name">
                        
</ext:TextField>
                    
</ext:Anchor>
                    
<ext:Anchor>
                        
<ext:TextField ID="TextFieldParentOrgCode" runat="server" FieldLabel="ParentOrganization Code"
                            Width
="200" Enabled="false" ReadOnly="true">
                        
</ext:TextField>
                    
</ext:Anchor>
                    
<ext:Anchor>
                        
<ext:TextField ID="TextFielOrganizationCode" runat="server" FieldLabel="OrganizationCode"
                            Width
="200" BlankText="Organization Code " AllowBlank="false" EmptyText="Organization Code">
                        
</ext:TextField>
                    
</ext:Anchor>
                    
<%--   <ext:Anchor Horizontal="100%">
                        
<ext:TextArea ID="TextFieldGroupDescription" runat="server" Height="100" EmptyText="Description"
                            FieldLabel
="Description" BlankText="Description" AllowBlank="true">
                        
</ext:TextArea>
                        
<%--   <ext:TextField ID="TextFieldGroupDescription" runat="server" FieldLabel="Description" >
                        
</ext:TextField>
                    
</ext:Anchor>--%>
                    
<ext:Anchor>
                        
<ext:TextField ID="TextFieldOrganizationFullName" runat="server" FieldLabel="OrganizationFullName"
                            Width
="200" AllowBlank="false" BlankText="OrganizationFullName" EmptyText="OrganizationFullName">
                        
</ext:TextField>
                    
</ext:Anchor>
                    
<ext:Anchor>
                        
<ext:TextField ID="TextFieldEnglishName" runat="server" FieldLabel="EnglishName"
                            Width
="200">
                        
</ext:TextField>
                    
</ext:Anchor>
                    
<ext:Anchor>
                        
<ext:TextField ID="TextFieldChineseName" runat="server" FieldLabel="ChineseName"
                            Width
="200">
                        
</ext:TextField>
                    
</ext:Anchor>
                    
<ext:Anchor>
                        
<ext:TextField ID="TextFieldJapaneseName" runat="server" FieldLabel="JapaneseName"
                            Width
="200">
                        
</ext:TextField>
                    
</ext:Anchor>
                    
<ext:Anchor>
                        
<ext:TextField ID="TextFieldLegalEntityCode" runat="server" FieldLabel="LegalEntityCode"
                            Width
="200">
                        
</ext:TextField>
                    
</ext:Anchor>
                    
<ext:Anchor>
                        
<ext:ComboBox ID="ComboBoxBu" runat="server" StoreID="StoreBu" Editable="false" DisplayField="BuName"
                            ValueField
="BuID" TypeAhead="true" Mode="Local" ForceSelection="true" EmptyText="Select a bu..."
                            Resizable
="true" SelectOnFocus="true" FieldLabel="Bu" Width="200">
                        
</ext:ComboBox>
                    
</ext:Anchor>
                    
<ext:Anchor>
                        
<ext:ComboBox ID="ComboBoxSite" runat="server" DisplayField="SiteName" ValueField="SiteID"
                            FieldLabel
="Site" EmptyText="Select a site..." StoreID="StoreSite" Width="200">
                        
</ext:ComboBox>
                    
</ext:Anchor>
                
</ext:FormLayout>
            
</Body>
            
<Buttons>
                
<ext:Button ID="ButtonSave" runat="server" Text="Save" Icon="Disk">
                    
<AjaxEvents>
                        
<Click OnEvent="Save">
                        
</Click>
                    
</AjaxEvents>
                
</ext:Button>
                
<ext:Button ID="ButtonCancel" runat="server" Text="Cancel" Icon="Cancel">
                    
<AjaxEvents>
                        
<Click OnEvent="ButtonCancel_Click">
                        
</Click>
                    
</AjaxEvents>
                
</ext:Button>
            
</Buttons>
        
</ext:Window>
        
<!--Role Maintain -->
        
<ext:Store ID="StoreRoleList" runat="server" OnRefreshData="Rolelist_RefreshData">
            
<Reader>
                
<ext:JsonReader>
                    
<Fields>
                        
<ext:RecordField Name="orgrole_id">
                        
</ext:RecordField>
                        
<ext:RecordField Name="orgrole_name">
                        
</ext:RecordField>
                    
</Fields>
                
</ext:JsonReader>
            
</Reader>
        
</ext:Store>
        
<ext:Window ID="WindowNewRole" runat="server" Title="New Role" Icon="GroupAdd" ShowOnLoad="false"
            Width
="400" Height="400" BodyStyle="padding:5px;" Closable="true" Modal="true">
            
<Body>
                
<ext:Panel ID="PanelRoleList" runat="server" Title="Role List">
                    
<Body>
                        
<ext:GridPanel ID="GropRoleList" runat="server" Height="300" AutoExpandColumn="orgrole_name"
                            StoreID
="StoreRoleList">
                            
<ColumnModel>
                                
<Columns>
                                    
<ext:Column ColumnID="orgrole_id" Hidden="true" Header="Role ID" DataIndex="orgrole_id"
                                        Sortable
="true">
                                    
</ext:Column>
                                    
<ext:Column ColumnID="orgrole_name" Header="Role Name" DataIndex="orgrole_name" Sortable="true">
                                    
</ext:Column>
                                
</Columns>
                            
</ColumnModel>
                            
<%--<SelectionModel>
                                
<ext:RowSelectionModel runat="server" SingleSelect="true" ID="RowSelectionModel1">
                                
</ext:RowSelectionModel>
                            
</SelectionModel>--%>
                            
<SelectionModel>
                                
<ext:CheckboxSelectionModel ID="CheckboxSelectionModelRole" runat="server">
                                    
<CustomConfig>
                                        
<ext:ConfigItem Name="checkOnly" Value="true" Mode="Raw" />
                                    
</CustomConfig>
                                
</ext:CheckboxSelectionModel>
                            
</SelectionModel>
                            
<BottomBar>
                                
<ext:PagingToolbar ID="PagingToolBarRole" runat="server" PageSize="10" StoreID="StoreRoleList"
                                    DisplayInfo
="true" />
                            
</BottomBar>
                            
<SaveMask ShowMask="false" />
                            
<LoadMask ShowMask="true" />
                        
</ext:GridPanel>
                    
</Body>
                    
<Buttons>
                        
<ext:Button ID="ButtonSelect" runat="server" Text="Select">
                            
<AjaxEvents>
                                
<Click OnEvent="ButtonRoleListSelect_Click">
                                    
<ExtraParams>
                                        
<ext:Parameter Name="Values" Value="Ext.encode(#{GropRoleList}.getRowsValues())"
                                            Mode
="Raw" />
                                    
</ExtraParams>
                                
</Click>
                            
</AjaxEvents>
                        
</ext:Button>
                    
</Buttons>
                
</ext:Panel>
            
</Body>
        
</ext:Window>
        
<!--Organization Hr_Employee maintain-->
        
<ext:Store ID="StoreHrEmployee" runat="server" OnRefreshData="Userlist_RefreshData">
            
<Reader>
                
<ext:JsonReader>
                    
<Fields>
                        
<ext:RecordField Name="user_id">
                        
</ext:RecordField>
                        
<ext:RecordField Name="employee_no">
                        
</ext:RecordField>
                        
<ext:RecordField Name="employee_name">
                        
</ext:RecordField>
                    
</Fields>
                
</ext:JsonReader>
            
</Reader>
        
</ext:Store>
        
<ext:Window ID="WindowNewHremployee" runat="server" Title="New User" Icon="GroupAdd"
            ShowOnLoad
="false" Width="400" Height="400" BodyStyle="padding:5px;" Closable="true"
            Modal
="true">
            
<Body>
                
<ext:Panel ID="PanelUserList" runat="server" Title="User List">
                    
<Body>
                        
<ext:GridPanel ID="GridPanelNewhremployee" runat="server" Height="300" AutoExpandColumn="employee_name"
                            StoreID
="StoreHrEmployee">
                            
<ColumnModel>
                                
<Columns>
                                    
<ext:Column ColumnID="user_id" Hidden="false" Header="User ID" DataIndex="user_id"
                                        Sortable
="true">
                                    
</ext:Column>
                                    
<ext:Column ColumnID="employee_no" Hidden="false" Header="Employee No" DataIndex="employee_no"
                                        Sortable
="true">
                                    
</ext:Column>
                                    
<ext:Column ColumnID="employee_name" Header="Employee Name" DataIndex="employee_name"
                                        Sortable
="true">
                                    
</ext:Column>
                                
</Columns>
                            
</ColumnModel>
                            
<SelectionModel>
                                
<ext:CheckboxSelectionModel ID="CheckboxSelectionModelHremployee" runat="server">
                                    
<CustomConfig>
                                        
<ext:ConfigItem Name="checkOnly" Value="true" Mode="Raw" />
                                    
</CustomConfig>
                                
</ext:CheckboxSelectionModel>
                            
</SelectionModel>
                            
<BottomBar>
                                
<ext:PagingToolbar ID="PagingToolBarNewHremployee" runat="server" PageSize="10" StoreID="StoreHrEmployee"
                                    DisplayInfo
="true" />
                            
</BottomBar>
                            
<SaveMask ShowMask="false" />
                            
<LoadMask ShowMask="true" />
                        
</ext:GridPanel>
                    
</Body>
                    
<Buttons>
                        
<ext:Button ID="ButtonhrEmployeeSelect" runat="server" Text="Select">
                            
<AjaxEvents>
                                
<Click OnEvent="ButtonhrEmployeeSelect_Click">
                                    
<ExtraParams>
                                        
<ext:Parameter Name="Values" Value="Ext.encode(#{GridPanelNewhremployee}.getRowsValues())"
                                            Mode
="Raw" />
                                    
</ExtraParams>
                                
</Click>
                            
</AjaxEvents>
                        
</ext:Button>
                    
</Buttons>
                
</ext:Panel>
            
</Body>
        
</ext:Window>
    
</div>

    
<script type="text/javascript">

        
function ShowResult(btn) {
            
if (btn == 'yes') { Coolite.AjaxMethods.do_Yes(); } else { Coolite.AjaxMethods.do_No(); }
        }


        
function DeleteOrgResult(btn) {
            
if (btn == 'yes') { Coolite.AjaxMethods.DeleteYes(); } else { Coolite.AjaxMethods.DeleteNo(); }
        }
        

    
</script>

 

 

 

 

 

 

代码
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
//New Reference 
using Coolite.Ext.Web;
using System.Collections.Generic;
using PMS.Web.Admin.OrganizationService;
using System.Text;


namespace PMS.Web.Admin.Department
{
    
public partial class DepartmentListMaintain : PMS.Web.Base.PageBase
    {

        
//  PMS_ConnectionString context = new PMS_ConnectionString();

        
//web service 实例化
        OrganizationService.OrganizationServiceClient client = new PMS.Web.Admin.OrganizationService.OrganizationServiceClient();
        Hashtable table 
= new Hashtable();

       
//操作状态的标示
        static string flag = "New";

        
/// <summary>
        
/// Load Data 
        
/// Init Page
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {

            
if (!IsPostBack && !Ext.IsAjaxRequest)
            {
                
//组织机构与组织人员、组织角色与组织人员的加载
                GridPanelBind("""");

                
//LoadTree();
                
//组织机构树的加载,返回Json
                string temp = RefreshMenu();

                
//site列表加载
                BindComboBoxSite();

                
//bu列表加载
                BindComboxBu();

                
this.NavigationChildFunction = "Organization Maintain";

            }

            
if (string.Compare(TextFieldNode.Text.Trim(), ""!= 0)
            {
                DC_Resorganization orgEntity 
= client.GetOrganizationEntity(TextFieldNode.Text.Trim());
                
if (orgEntity != null)
                {
                    Node_id 
= TextFieldNode.Text;
                    Role_id 
= "";
                    org_RoleID 
= TextFieldParentNode.Text;
                }
                
else
                {
                    Role_id 
= TextFieldNode.Text;
                    Node_id 
= "";
                    org_RoleID 
= TextFieldParentNode.Text;
                }
            }

           

        }


        
//获取树节点ID
        public string Node_id
        {
            
get
            {
                
object TreeNodeId = this.ViewState["TreeNodeId"];

                
return TreeNodeId == null ? string.Empty : (string)TreeNodeId;
            }
            
set
            {
                
this.ViewState["TreeNodeId"= value;
            }

        }



        
public string Role_id
        {
            
get
            {
                
object RoleID = this.ViewState["RoleID"];

                
return RoleID == null ? string.Empty : (string)RoleID;
            }
            
set
            {
                
this.ViewState["RoleID"= value;
            }

        }



        
public string org_RoleID
        {
            
get
            {
                
object org_RoleID = this.ViewState["org_RoleID"];

                
return org_RoleID == null ? string.Empty : (string)org_RoleID;
            }
            
set
            {
                
this.ViewState["org_RoleID"= value;
            }
        }


        
#region ----------递归加载树-----------

        
/// <summary>
        
/// 组织角色的加载
        
/// </summary>
        
/// <param name="OrganizationID">组织部门的code</param>
        
/// <param name="node">组织部门node</param>
        private void LoadOrgRoleByOrganizationID(string OrganizationID, Coolite.Ext.Web.TreeNode node)
        {
            MSG_GetOrgRoleOrgListRequest request 
= new MSG_GetOrgRoleOrgListRequest();
            request.organizationid 
= OrganizationID;
            request.orgrole_id 
= "";
            DCC_OrgRoleList orgRoleList 
= client.GetOrgRoleOrgList(request);
            
foreach (var orgrole in orgRoleList.ToList())
            {
                Coolite.Ext.Web.TreeNode rolenode 
= new Coolite.Ext.Web.TreeNode();

                rolenode.NodeID 
= orgrole.orgrole_id;
                rolenode.Text 
= orgrole.orgrole_name;
                rolenode.Qtip 
= orgrole.orgrole_desc;
                rolenode.Expanded 
= true;
                
                node.Nodes.Add(rolenode);
            }
        }

        
private void LoadTree()
        {

            TreePanelOrganization.Root.Clear();
            Coolite.Ext.Web.TreeNode node 
= new Coolite.Ext.Web.TreeNode("Hisoft""Hisoft", Icon.Group);
            node.Qtip 
= "Hisoft";
            TreePanelOrganization.Root.Add(node);
            node.Expanded 
= true;




            
//client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            DCC_ResorganizationList organizationlist = client.GetOrganizationList("");


            
foreach (var superCode in organizationlist.ToList())
            {
                Coolite.Ext.Web.TreeNode supernode 
= new Coolite.Ext.Web.TreeNode();
                
string parentcode = superCode.OrganizationCode;
                supernode.NodeID 
= superCode.OrganizationCode;
                supernode.Text 
= superCode.OrganizationName;
                supernode.Qtip 
= superCode.OrganizationFullName;
                supernode.Cls 
= superCode.OrganizationID;
                supernode.Icon 
= Icon.GroupKey;
                node.Expanded 
= true;
                node.Nodes.Add(supernode);
                LoadOrgRoleByOrganizationID(superCode.OrganizationID, supernode);
                CreateCycleTree(parentcode, supernode);
            }

            
//IList<RES_Organization> OrgSuperDepartment = OrgData.GetCycleOrganization("", context);
            
//foreach (var superCode in OrgSuperDepartment)
            
//{
            
//    Coolite.Ext.Web.TreeNode supernode = new Coolite.Ext.Web.TreeNode();
            
//    supernode.NodeID = superCode.organization_code;
            
//    supernode.Text = superCode.organization_name;
            
//    supernode.Qtip = superCode.organization_full_name;
            
//    supernode.Icon = Icon.GroupKey;
            
//    node.Nodes.Add(supernode);
            
//    CreateCycleTree(supernode.NodeID, supernode);

            
//}

        }


        
/// <summary>
        
/// 组织机构、组织角色树的加载 //WCF entity framework 方法
        
/// </summary>
        
/// <param name="nodes"></param>
        
/// <returns>TreeNodeCollection</returns>
        private Coolite.Ext.Web.TreeNodeCollection LoadTree(Coolite.Ext.Web.TreeNodeCollection nodes)
        {

           
            
if (nodes == null)
            {
                nodes 
= new Coolite.Ext.Web.TreeNodeCollection();
            }
//根节点为null时

            TreePanelOrganization.Root.Clear();

            Coolite.Ext.Web.TreeNode node 
= new Coolite.Ext.Web.TreeNode("Hisoft""Hisoft", Icon.Group);
            node.Qtip 
= "Hisoft";
            nodes.Add(node);
            node.Expanded 
= true;

            
// OrganizationService.OrganizationServiceClient client = new PMS.Web.Admin.OrganizationService.OrganizationServiceClient();
            
//  client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

            
//所有父节点的加载
            DCC_ResorganizationList organizationlist = client.GetOrganizationList("");

            
foreach (var superCode in organizationlist.ToList())
            {
                Coolite.Ext.Web.TreeNode supernode 
= new Coolite.Ext.Web.TreeNode();
                
string parentcode = superCode.OrganizationCode;
                supernode.NodeID 
= superCode.OrganizationCode;
                supernode.Text 
= superCode.OrganizationName;
                supernode.Qtip 
= superCode.OrganizationFullName;
                supernode.Cls 
= superCode.OrganizationID;
                
//supernode.Expanded = true;
                supernode.Icon = Icon.GroupKey;
                
//supernode.CustomAttributes.Add(new ConfigItem(
                node.Nodes.Add(supernode);
                LoadOrgRoleByOrganizationID(superCode.OrganizationID, supernode);
                CreateCycleTree(parentcode, supernode);
            }

            
return nodes;

            
//linq to sql class 方法
            
//IList<RES_Organization> OrgSuperDepartment = OrgData.GetCycleOrganization("", context);
            
//foreach (var superCode in OrgSuperDepartment)
            
//{
            
//    Coolite.Ext.Web.TreeNode supernode = new Coolite.Ext.Web.TreeNode();
            
//    supernode.NodeID = superCode.organization_code;
            
//    supernode.Text = superCode.organization_name;
            
//    supernode.Qtip = superCode.organization_full_name;
            
//    supernode.Icon = Icon.GroupKey;
            
//    node.Nodes.Add(supernode);
            
//    CreateCycleTree(supernode.NodeID, supernode);

            
//}
           
        }


        
/// <summary>
        
/// 递归加载树
        
/// </summary>
        
/// <param name="code">父节点的code</param>
        
/// <param name="parentcode">父节点</param>
        private void CreateCycleTree(string code, Coolite.Ext.Web.TreeNode parentcode)
        {
            
// OrganizationService.OrganizationServiceClient client = new PMS.Web.Admin.OrganizationService.OrganizationServiceClient();

            
//根据父节点的ID得到该节点下的所有子节点
            DCC_ResorganizationList orgDepartment = client.GetOrganizationList(code);

            
// IList<RES_Organization> orgDepartment = OrgData.GetCycleOrganization(code, context);

            
foreach (var org in orgDepartment.ToList())
            {
                Coolite.Ext.Web.TreeNode node 
= new Coolite.Ext.Web.TreeNode();
                
string orgparentcode = org.OrganizationCode;
                node.NodeID 
= org.OrganizationCode;
                node.Text 
= org.OrganizationName;
                node.Qtip 
= org.OrganizationFullName;
                node.Cls 
= org.OrganizationID;
                node.Icon 
= Icon.GroupGo;
                parentcode.Nodes.Add(node);
                LoadOrgRoleByOrganizationID(org.OrganizationID, node);
                CreateCycleTree(orgparentcode, node);
            }

        }

        
#endregion






        
/// <summary>
        
/// Bind GridPanel
        
/// </summary>
        private void GridPanelBind(string employeeno, string employeename)
        {
            MSG_GetOrganizationEntityRequest request 
= new MSG_GetOrganizationEntityRequest();
            DC_Resorganization organizationEntity 
= new DC_Resorganization();
            MSG_GetHREmployeeListRequest hremployeelistrequest 
= new MSG_GetHREmployeeListRequest();


            
if (string.Compare(TextFieldNode.Text, ""!= 0)
            {
                
if (string.Compare(TextFieldNode.Text, "Hisoft"== 0)
                {
                    Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please input query condition.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSearch.ClientID
                });
                    
return;
                }
                organizationEntity 
= client.GetOrganizationEntity(TextFieldNode.Text);
                
//organizationEntity 为null ,则是组织角色与组织人员
                if (organizationEntity == null)
                {

                    
string JsFunction = "getNode(#{TreePanelOrganization})";

                    Coolite.Ext.Web.ScriptManager sm 
= Coolite.Ext.Web.ScriptManager.GetInstance(HttpContext.Current);
                    sm.AddScript(
string.Format("{0};", JsFunction));


                    hremployeelistrequest.DepartmentID 
= TextFieldParentNode.Text;
                    hremployeelistrequest.EmployeeName 
= "";
                    hremployeelistrequest.OrgRoleID 
= TextFieldNode.Text;
                    hremployeelistrequest.EmployeeNo 
= "";
                    DCC_HREmployeeList hremployeelist 
= client.GetHREmployeeList(hremployeelistrequest);
                    
if (hremployeelist != null)
                    {
                        StoreUser.DataSource 
= hremployeelist.ToList();
                        StoreUser.DataBind();

                    }
                }
                
else
                {
                    hremployeelistrequest.DepartmentID 
= TextFieldNode.Text;
                    hremployeelistrequest.EmployeeName 
= "";
                    hremployeelistrequest.OrgRoleID 
= "";
                    hremployeelistrequest.EmployeeNo 
= "";
                    DCC_HREmployeeList hremployeelist 
= client.GetHREmployeeList(hremployeelistrequest);
                    
if (hremployeelist != null)
                    {
                        StoreUser.DataSource 
= hremployeelist.ToList();
                        StoreUser.DataBind();

                    }
                }
//组织部门与组织人员

                
            }

        }


        
#region -----右键菜单-----
        [AjaxMethod]
        
public void CMenuMaintain(string id,string flag)
        {
             DC_Resorganization orgEntity 
= client.GetOrganizationEntity(id);
            
if(string.Compare(flag,"New")==0)
            {
                
if (id == "Hisoft")
                {
                    Ext.Msg.Show(
new MessageBox.Config
                    {
                        Title 
= "Tips",
                        Message 
= "Please choose a organization or a role.",
                        Buttons 
= MessageBox.Button.OK,
                        Icon 
= MessageBox.Icon.INFO,
                        
                    });
                    
return;
                }
                
else
                {
                   
                    
if (orgEntity == null)
                    {
                        ButtonNewRole_Click();
                    }
                    
else
                    {
                        Node_id 
= id;
                        TextFieldNode.Text 
= id;
                        OrganizationNew();
                    }
                }
            }
            
else if(string.Compare(flag,"Edit")==0)
            {
                
if (orgEntity == null)
                {
                    Ext.Msg.Show(
new MessageBox.Config
                    {
                        Title 
= "Tips",
                        Message 
= "Please choose a organization.",
                        Buttons 
= MessageBox.Button.OK,
                        Icon 
= MessageBox.Icon.INFO,

                    });
                    
return;
                }
                
else
                {
                    Node_id 
= id;
                    ButtonEditOG_Click();
                }
            }
            
else if (string.Compare(flag, "Delete"== 0)
            {
                
if (orgEntity == null)
                {
                    DoDeleteRoleConfirm();
                }
                
else
                {
                    DoConfirm();
                }
            }
        }
        
#endregion





        
#region ---------查询操作-------


        
/// <summary>
        
/// Query
        
/// Condition:EmployeeNo EmployeeName
        
/// </summary>
        [AjaxMethod]
        
public void ButtonSearch_Click()
        {
            
if (TextFieldSNO.Text.Trim() == "" && TextFieldSName.Text.Trim() == "")
            {
                GridPanelBind(
"""");
            }
            
else
            {
                MSG_GetHREmployeeListRequest hremployeelistrequest 
= new MSG_GetHREmployeeListRequest();
                hremployeelistrequest.DepartmentID 
= Node_id;
                hremployeelistrequest.EmployeeName 
= TextFieldSName.Text.Trim();
                hremployeelistrequest.OrgRoleID 
= "";
                hremployeelistrequest.EmployeeNo 
= TextFieldSNO.Text.Trim();

                DCC_HREmployeeList hremployeelist 
= client.GetHREmployeeList(hremployeelistrequest);
                
if (hremployeelist != null)
                {

                    StoreUser.DataSource 
= hremployeelist.ToList();
                    StoreUser.DataBind();

                }
            }
        }


        
#endregion


        
private void HrEmployeeBind()
        {
            MSG_GetHREmployeeListRequest hremployeelistrequest 
= new MSG_GetHREmployeeListRequest();
            hremployeelistrequest.DepartmentID 
= "hremployee";
            hremployeelistrequest.EmployeeName 
= "";
            hremployeelistrequest.OrgRoleID 
= "";
            hremployeelistrequest.EmployeeNo 
= "";

            DCC_HREmployeeList hremployeelist 
= client.GetHREmployeeList(hremployeelistrequest);
            
if (hremployeelist != null)
            {

                StoreHrEmployee.DataSource 
= hremployeelist.ToList();
                StoreHrEmployee.DataBind();

            }
        }

        
#region ----------添加用户操作-------

        
protected void ButtonNewUser_Click(object sender, AjaxEventArgs e)
        {
            WindowNewHremployee.Show();
            HrEmployeeBind();
        }


        
public void ButtonhrEmployeeSelect_Click(object sender, AjaxEventArgs e)
        {
            RowSelectionModel sm 
= this.GridPanelNewhremployee.SelectionModel.Primary as RowSelectionModel;
            
string json = e.ExtraParams["Values"];
            
bool addHeader = true;
            DataTable dt 
= new DataTable();
              StringBuilder strstring 
= new StringBuilder();
            Dictionary
<stringstring>[] companies = JSON.Deserialize<Dictionary<stringstring>[]>(json);
            
foreach (Dictionary<stringstring> row in companies)
            {
                
if (addHeader)
                {
                    
foreach (KeyValuePair<stringstring> keyValuePair in row)
                    {
                        dt.Columns.Add(keyValuePair.Key);
                    }
                }
                addHeader 
= false;
                ArrayList list 
= new ArrayList();
                DataRow dr 
= dt.NewRow();
              
                
foreach (KeyValuePair<stringstring> keyValuePair in row)
                {
                    dr[keyValuePair.Key] 
= keyValuePair.Value;
                    
if (keyValuePair.Key == "user_id")
                    {
                        strstring.Append(keyValuePair.Value 
+ ";");
                    }

                }
                dt.Rows.Add(dr);

            }

            
if (dt.Rows.Count > 0)
            {

                
foreach (DataRow dr in dt.Rows)
                {
                    DC_Resorganization resorgEntity 
= client.GetOrganizationEntity(TextFieldNode.Text);
                    
if (resorgEntity != null)
                    {
                        DC_HREmployee hrEmployee 
= new DC_HREmployee();
                        DC_OperationType operationtype 
= new DC_OperationType();
                        MSG_HREmployeeMaintainRequest request 
= new MSG_HREmployeeMaintainRequest();
                        operationtype.DCE_OperationType 
= DCE_OperationType.Add;
                        request.OperationType 
= operationtype;
                        hrEmployee.user_id 
= dr["user_id"].ToString();
                        hrEmployee.employee_no 
= dr["employee_no"].ToString();
                        hrEmployee.department_id 
= Node_id;

                        request.HREmployeeEntity 
= hrEmployee;
                        client.HREmployeeMaintain(request);
                    }
                    
else
                    {
                      
                       MSG_UserOrgRoleMaintainRequest request
=new MSG_UserOrgRoleMaintainRequest();
                       DC_OperationType operationtype 
= new DC_OperationType();
                       operationtype.DCE_OperationType 
= DCE_OperationType.Add;
                       request.OperationType 
= operationtype;
                       request.orgrole_id 
= TextFieldNode.Text;
                       request.user_id 
= strstring.ToString();
                       client.UserOrgRoleMaintain(request);
                       
break;
                    }
                }
                
this.WindowNewHremployee.Hide();
                GridPanelBind(
"""");
            }
        }



        
#endregion


        
#region 

        
/// <summary>
        
/// Refresh Data
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>
        protected void my_RefreshData(object sender, StoreRefreshDataEventArgs e)
        {
            GridPanelBind(
"""");
        }

        
/// <summary>
        
/// Role List Refresh Data
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>
        protected void Rolelist_RefreshData(object sender, StoreRefreshDataEventArgs e)
        {
            RoleGridPanelBind();
        }

        
/// <summary>
        
/// User List Refresh Data
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>
        protected void Userlist_RefreshData(object sender, StoreRefreshDataEventArgs e)
        {
            
if (TextFieldSNO.Text.Trim() == "" && TextFieldSName.Text.Trim() == "")
            {
                GridPanelBind(
"""");
            }
            
else
            {

                MSG_GetHREmployeeListRequest hremployeelistrequest 
= new MSG_GetHREmployeeListRequest();
                hremployeelistrequest.DepartmentID 
= Node_id;
                hremployeelistrequest.EmployeeName 
= TextFieldSName.Text.Trim();
                hremployeelistrequest.OrgRoleID 
= "";
                hremployeelistrequest.EmployeeNo 
= TextFieldSNO.Text.Trim();

                DCC_HREmployeeList hremployeelist 
= client.GetHREmployeeList(hremployeelistrequest);
                
if (hremployeelist != null)
                {

                    StoreUser.DataSource 
= hremployeelist.ToList();
                    StoreUser.DataBind();

                }


            }
        }


        
#endregion



        
/// <summary>
        
/// GridPanel Command
        
/// </summary>
        
/// <param name="command"></param>
        
/// <param name="id"></param>
        [AjaxMethod]
        
public void GridPanelUser_Command(string command, string userid, string employeeno)
        {
            
if (command == "Delete")
            {
                DC_HREmployee hrEmployee 
= new DC_HREmployee();
                DC_OperationType operationtype 
= new DC_OperationType();

                MSG_HREmployeeMaintainRequest request 
= new MSG_HREmployeeMaintainRequest();
                operationtype.DCE_OperationType 
= DCE_OperationType.Delete;
                request.OperationType 
= operationtype;
                hrEmployee.user_id 
= userid;
                hrEmployee.employee_no 
= employeeno;
                request.HREmployeeEntity 
= hrEmployee;
                client.HREmployeeMaintain(request);
                GridPanelBind(
"""");

            }


        }


        
#region 组织机构树维护



        
/// <summary>
        
/// 得到点击的树节点的ID
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>
        public void getNode(object sender, AjaxEventArgs e)
        {

            
if (string.Compare(TextFieldNode.Text.Trim(), "Hisoft"!= 0)
            {

                
string JsFunction = "getNode(#{TreePanelOrganization})";

                Coolite.Ext.Web.ScriptManager sm 
= Coolite.Ext.Web.ScriptManager.GetInstance(HttpContext.Current);
                sm.AddScript(
string.Format("{0};", JsFunction));

               
// GridPanelBind("", "");


                
if (string.Compare(TextFieldNode.Text.Trim(), ""!= 0)
                {
                    DC_Resorganization orgEntity 
= client.GetOrganizationEntity(TextFieldNode.Text.Trim());
                    
if (orgEntity != null)
                    {
                        Node_id 
= TextFieldNode.Text;
                       GridPanelBind(
"""");
                        Role_id 
= "";
                    }
                    
else
                    {
                        Role_id 
= TextFieldNode.Text;
                       GridPanelBind(
"""");
                        Node_id 
= "";
                    }
                }
            }

        }



        [AjaxMethod]
        
public void GetNode(string id)
        {

            TextFieldParentNode.Text 
= id;

            
//string JsFunction = "alert('"+id+"');";

            
//Coolite.Ext.Web.ScriptManager sm = Coolite.Ext.Web.ScriptManager.GetInstance(HttpContext.Current);
            
//sm.AddScript(string.Format("{0};", JsFunction));
        }




        
#region ----------Cancel Organization Maintain-------
        
/// <summary>
        
///Cancel Organization Maintain 
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>
        public void ButtonCancel_Click(object sender, AjaxEventArgs e)
        {

            Ext.Msg.Confirm(
"Tips""Are you sure want to cancel ?"new JFunction { Fn = "ShowResult" }).Show();


        }

        
/// <summary>
        
///Cancel Organization Maintain  Hidden WindowNewOrganization
        
/// </summary>
        [AjaxMethod]
        
public void do_Yes()
        {
            ClearOrganizationMaintainTextBox(
"");
            WindowNewOrganization.Hidden 
= true;
        }

        [AjaxMethod]
        
public void do_No()
        {
            ClearOrganizationMaintainTextBox(
"");
            WindowNewOrganization.Hidden 
= false;
            
return;
        }
        
private void ClearOrganizationMaintainTextBox(string result)
        {
            
this.TextFielOrganizationCode.Text = result;
            
this.TextFielOrganizationName.Text = result;
            
this.TextFieldOrganizationFullName.Text = result;
            
this.TextFieldEnglishName.Text = result;
            
this.TextFieldChineseName.Text = result;
            
this.TextFieldJapaneseName.Text = result;
            
this.TextFieldLegalEntityCode.Text = result;
            BindComboxBu();
            BindComboBoxSite();
        }
        
#endregion


        
#region --------------组织机构树删除--------------
        [AjaxMethod]
        
public void DoConfirm()
        {
            
// Manually configure Handler...
            
//Ext.Msg.Confirm("Message", "Confirm?", "if(buttonId == 'yes') { CompanyX.DoYes(); } else { CompanyX.DoNo(); }").Show();

            
// Configure individualock Buttons using a ButtonsConfig...
            DC_Resorganization resOrgEntity = new DC_Resorganization();
            resOrgEntity 
= client.GetOrganizationEntity(TextFieldNode.Text.Trim());
            
if (resOrgEntity == null)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a organization.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
else
            {
                Ext.Msg.Confirm(
"Tips""Are you sure want to delete?"new MessageBox.ButtonsConfig
                {
                    Yes 
= new MessageBox.ButtonConfig
                    {
                        Handler 
= "Coolite.AjaxMethods.DeleteYes();delNode(#{TreePanelOrganization});",
                        Text 
= "Yes"
                    },
                    No 
= new MessageBox.ButtonConfig
                    {
                        Handler 
= "Coolite.AjaxMethods.DeleteNo()",
                        Text 
= "No"
                    }
                }).Show();
            }
        }

        [AjaxMethod]
        
public void DeleteYes()
        {
            
if (string.Compare(Node_id, ""== 0)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a organization.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
if (string.Compare(Node_id, "Hisoft"== 0)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a valid organization.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
            
else
            {
                
//组织结构树删除
                DC_Resorganization resOrgEntity = new DC_Resorganization();
                DC_OperationType operationtype 
= new DC_OperationType();
                MSG_OrganizationMaintainRequest requst 
= new MSG_OrganizationMaintainRequest();
                operationtype.DCE_OperationType 
= DCE_OperationType.Delete;
                requst.OperationType 
= operationtype;
                
//resOrgEntity.OrganizationCode = Node_id.Trim();

                resOrgEntity 
= client.GetOrganizationEntity(TextFieldNode.Text.Trim());
               
                requst.OrganizationEntity 
= resOrgEntity;

                client.OrganizationMaintain(requst);

                
//RES_Organization Resorganization = context.RES_Organization.FirstOrDefault(cc => cc.organization_code == Node_id);
                
//context.DeleteObject(Resorganization);
                
//context.SaveChanges();
            }
        }

        [AjaxMethod]
        
public void DeleteNo()
        {

            
return;
        }
        [AjaxMethod]
        
public void DoDeleteRoleConfirm()
        {
            DC_Resorganization resOrgEntity 
= new DC_Resorganization();
            resOrgEntity 
= client.GetOrganizationEntity(TextFieldNode.Text.Trim());
            
if (resOrgEntity != null)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a role.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
else
            {

                Ext.Msg.Confirm(
"Tips""Are you sure want to delete?"new MessageBox.ButtonsConfig
                {
                    Yes 
= new MessageBox.ButtonConfig
                    {
                        Handler 
= "Coolite.AjaxMethods.DeleteRoleYes();delNode(#{TreePanelOrganization});",
                        Text 
= "Yes"
                    },
                    No 
= new MessageBox.ButtonConfig
                    {
                        Handler 
= "Coolite.AjaxMethods.DeleteNo()",
                        Text 
= "No"
                    }
                }).Show();
            }
        }

        [AjaxMethod]
        
public void DeleteRoleYes()
        {
            
if (string.Compare(Role_id, ""== 0)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a role.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
else if (string.Compare(Role_id, "Hisoft"== 0)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a valid role.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
else if (string.Compare(org_RoleID, "Hisoft"== 0)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a valid role.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
else
            {
                
//组织结构树删除

                
// DC_OrgRoleOrg orgroleEntity = new DC_OrgRoleOrg();
                DC_OperationType operationtype = new DC_OperationType();
                MSG_OrgRoleOrgMainTainRequest request 
= new MSG_OrgRoleOrgMainTainRequest();
                operationtype.DCE_OperationType 
= DCE_OperationType.Delete;
                request.OperationType 
= operationtype;
                request.orgrole_id 
= Role_id;
                request.organization_id 
= org_RoleID;
                client.OrgRoleOrgMaintain(request);

            }
        }


        
#endregion--=




        
#region  ---------组织机构树添加跟修改操作---------


        [AjaxMethod]
        
public void OrganizationNew()
        {
            
if (string.Compare(Node_id, ""== 0)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a organization.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
if (string.Compare(Node_id, "Hisoft"== 0)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a valid organization.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
else
            {


                
this.WindowNewOrganization.Title = "New Organization";
                
this.WindowNewOrganization.Icon = Icon.GroupAdd;
                
this.ButtonSave.Text = "New";
                flag 
= "New";
                ClearOrganizationMaintainTextBox(
"");
                TextFieldParentOrgCode.FieldLabel 
= "ParentOrganization Code";
                TextFielOrganizationCode.AllowBlank 
= false;
                TextFielOrganizationCode.Hidden 
= false;
                TextFieldParentOrgCode.Text 
= Node_id.Trim();
                BindComboxBu();
                BindComboBoxSite();
                
this.WindowNewOrganization.Show();
            }
        }

        [AjaxMethod]
        
public void ButtonEditOG_Click()
        {
            
if (string.Compare(Node_id, ""== 0)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a organization.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
if (string.Compare(Node_id, "Hisoft"== 0)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a valid organization.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
else
            {


                
this.WindowNewOrganization.Title = "Edit Organization";
                
this.WindowNewOrganization.Icon = Icon.GroupEdit;
                
this.ButtonSave.Text = "Save";
                flag 
= "Save";
                
this.WindowNewOrganization.Show();

                BindComboBoxSite();
                BindComboxBu();

                DC_Resorganization organizationEntity 
= new DC_Resorganization();

                MSG_GetOrganizationEntityRequest request 
= new MSG_GetOrganizationEntityRequest();
                TextFieldParentOrgCode.Text 
= Node_id.Trim();
                organizationEntity 
= client.GetOrganizationEntity(Node_id.Trim());
                TextFielOrganizationName.Text 
= organizationEntity.OrganizationName;
                TextFieldOrganizationFullName.Text 
= organizationEntity.OrganizationFullName;
                TextFieldEnglishName.Text 
= organizationEntity.EnglishName;
                TextFieldChineseName.Text 
= organizationEntity.ChineseName;
                TextFieldJapaneseName.Text 
= organizationEntity.JapaneseName;
                TextFieldLegalEntityCode.Text 
= organizationEntity.LegalentityCode;
                ComboBoxBu.SelectedItem.Value 
= organizationEntity.BuID;
                ComboBoxSite.SelectedItem.Value 
= organizationEntity.SiteID;
                HiddenOrganizationID.Value 
= organizationEntity.OrganizationID;

                TextFieldParentOrgCode.FieldLabel 
= "Organization Code";
                TextFielOrganizationCode.AllowBlank 
= true;
                TextFielOrganizationCode.Hidden 
= true;
                
//TextFielOrganizationCode.Text = organizationEntity.OrganizationCode.Substring(2, organizationEntity.OrganizationCode.Length);

            }

        }



        
public void Save(object sender, AjaxEventArgs e)
        {

            
try
            {
                MaintainOrganization();

            }
            
catch (Exception ex)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= ex.Message,
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonNewOG.ClientID
                });
                
return;
            }

        }

        
/// <summary>
        
/// 组织角色添加与修改
        
/// </summary>
        public void MaintainOrganization()
        {

            
try
            {

                DC_Resorganization resorganization 
= new DC_Resorganization();
                DC_OperationType operationType 
= new DC_OperationType();
                MSG_OrganizationMaintainRequest request 
= new MSG_OrganizationMaintainRequest();
                
if (string.Compare(flag, "New"== 0)
                {
                    
if (TextFielOrganizationCode.Text.Trim().Length % 2 != 0)
                    {
                        Ext.Msg.Show(
new MessageBox.Config
                        {
                            Title 
= "Tips",
                            Message 
= "Please input a valid OrganizationCode.",
                            Buttons 
= MessageBox.Button.OK,
                            Icon 
= MessageBox.Icon.INFO,
                            AnimEl 
= this.ButtonNewOG.ClientID
                        });
                        
return;
                    }

                    
else if (string.Compare(TextFieldParentOrgCode.Text.Trim(), ""> 0 && string.Compare(TextFielOrganizationCode.Text.Trim(), ""> 0)
                    {
                        DC_Resorganization orgEntity 
= client.GetOrganizationEntity(TextFieldParentOrgCode.Text.Trim() + TextFielOrganizationCode.Text.Trim());
                        
if (orgEntity != null)
                        {
                            Ext.Msg.Alert(
"Tips""Message: The " + TextFieldParentOrgCode.Text.Trim() + TextFielOrganizationCode.Text.Trim() + "has exists,Please retype a valid code.").Show();
                            
return;
                        }


                    }
                    
else if (string.Compare(TextFieldOrganizationFullName.Text.Trim(), ""> 0)
                    {
                        DC_Resorganization orgEntity 
= client.GetOrganizationEntity(TextFieldParentOrgCode.Text.Trim() + TextFielOrganizationCode.Text.Trim());
                        
if (orgEntity != null)
                        {

                            
if (string.Compare(orgEntity.OrganizationFullName, TextFieldOrganizationFullName.Text.Trim()) == 0)
                            {
                                Ext.Msg.Alert(
"Tips""Message: The " + orgEntity.OrganizationFullName + "has exists,Please retype a valid full name.").Show();
                                
return;
                            }
                        }
                    }
                    
else if (TextFielOrganizationCode.Text.Length > 2)
                    {
                        Ext.Msg.Alert(
"Tips""Message:The OrganizationCode's length could not greater than two.").Show();
                        
return;
                    }
                    operationType.DCE_OperationType 
= DCE_OperationType.Add;
                    request.OperationType 
= operationType;
                    resorganization.OrganizationCode 
= TextFieldParentOrgCode.Text.Trim() + TextFielOrganizationCode.Text.Trim();
                    resorganization.ChineseName 
= TextFieldChineseName.Text.Trim();
                    resorganization.EnglishName 
= TextFieldEnglishName.Text.Trim();
                    resorganization.JapaneseName 
= TextFieldJapaneseName.Text.Trim();
                    resorganization.LegalentityCode 
= TextFieldLegalEntityCode.Text.Trim();
                    resorganization.OrganizationFullName 
= TextFieldOrganizationFullName.Text.Trim();
                    resorganization.OrganizationTypeCatid 
= "HR";
                    resorganization.OrganizationName 
= TextFielOrganizationName.Text.Trim();
                    resorganization.IsDeleted 
= 0;
                    resorganization.LastModifiedTime 
= DateTime.Now;
                    resorganization.OrganizationID 
= Convert.ToString(Guid.NewGuid());
                    resorganization.BuID 
= ComboBoxBu.SelectedItem.Value;
                    resorganization.SiteID 
= ComboBoxSite.SelectedItem.Value;
                    request.OrganizationEntity 
= resorganization;
                    client.OrganizationMaintain(request);


                }

                
else if (string.Compare(flag, "Save"== 0)
                {

                    operationType.DCE_OperationType 
= DCE_OperationType.Update;
                    request.OperationType 
= operationType;
                    resorganization.OrganizationCode 
= TextFieldParentOrgCode.Text.Trim();
                    resorganization.ChineseName 
= TextFieldChineseName.Text.Trim();
                    resorganization.EnglishName 
= TextFieldEnglishName.Text.Trim();
                    resorganization.JapaneseName 
= TextFieldJapaneseName.Text.Trim();
                    resorganization.LegalentityCode 
= TextFieldLegalEntityCode.Text.Trim();
                    resorganization.OrganizationFullName 
= TextFieldOrganizationFullName.Text.Trim();
                    resorganization.OrganizationTypeCatid 
= "HR";
                    resorganization.OrganizationName 
= TextFielOrganizationName.Text.Trim();
                    resorganization.IsDeleted 
= 0;
                    resorganization.LastModifiedTime 
= DateTime.Now;
                    resorganization.BuID 
= ComboBoxBu.SelectedItem.Value;
                    resorganization.SiteID 
= ComboBoxSite.SelectedItem.Value;
                    resorganization.OrganizationID 
= HiddenOrganizationID.Value.ToString();
                    request.OrganizationEntity 
= resorganization;
                    client.OrganizationMaintain(request);

                }

                
string JsFunction = "refreshTree(#{TreePanelOrganization})";
                
//string JsFunction = "alert('dd');";
                
//string JsFunction = "refreshTree()";
                Coolite.Ext.Web.ScriptManager sm = Coolite.Ext.Web.ScriptManager.GetInstance(HttpContext.Current);
                sm.AddScript(
string.Format("{0};", JsFunction));

                WindowNewOrganization.Hide();
            }
            
catch (Exception ex)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= ex.Message,
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonNewOG.ClientID
                });
                
return;

            }
        }



        
#endregion


        
/// <summary>
        
/// 刷新树 Json 获取
        
/// </summary>
        
/// <returns></returns>
        [AjaxMethod]
        
public string RefreshMenu()
        {
            Coolite.Ext.Web.TreeNodeCollection nodes 
= LoadTree(this.TreePanelOrganization.Root);
            
return nodes.ToJson();
        }




        
#region ----------Bu/Site 绑定----------------

        
public void BindComboxBu()
        {
            DCC_ResBuList bulist 
= client.GetBuList("");
            StoreBu.DataSource 
= bulist.ToArray();
            StoreBu.DataBind();

            
//StoreBu.DataSource = OrgData.GetBu("", context);
            
//StoreBu.DataBind();
        }

        
public void BindComboBoxSite()
        {
            
// StoreSite.DataSource = OrgData.GetSite("", context);
            StoreSite.DataSource = client.GetSiteList("");
            StoreSite.DataBind();
        }

        
#endregion








        
#region OrgRole Bind   &&  New Role

        
/// <summary>
        
/// Bind Role GridPanel
        
/// </summary>
        private void RoleGridPanelBind()
        {
            
if (client.GetOrgRoleList("").ToList() != null)
            {
                StoreRoleList.DataSource 
= client.GetOrgRoleList("");
                StoreRoleList.DataBind();
            }
        }



        [AjaxMethod]
        
public void ButtonNewRole_Click()
        {

            DC_Resorganization orgEntity 
= client.GetOrganizationEntity(org_RoleID);


            
if (string.Compare(Role_id, ""== 0)
            {
                
//Ext.Msg.Show(new MessageBox.Config
                
//{
                
//    Title = "Tips",
                
//    Message = "Please choose a role.",
                
//    Buttons = MessageBox.Button.OK,
                
//    Icon = MessageBox.Icon.INFO,
                
//    AnimEl = this.ButtonSave.ClientID
                
//});
                
//return;

                
this.WindowNewRole.Show();
                RoleGridPanelBind();

            }
            
else if (string.Compare(Role_id, "Hisoft"== 0)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a  valid organization.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
else if (orgEntity != null)
            {
                Ext.Msg.Show(
new MessageBox.Config
                {
                    Title 
= "Tips",
                    Message 
= "Please choose a  organization.",
                    Buttons 
= MessageBox.Button.OK,
                    Icon 
= MessageBox.Icon.INFO,
                    AnimEl 
= this.ButtonSave.ClientID
                });
                
return;
            }
            
else if (orgEntity == null)
            {

                
this.WindowNewRole.Show();
                RoleGridPanelBind();
            }

        }



        
public void ButtonRoleListSelect_Click(object sender, AjaxEventArgs e)
        {
            
string json = e.ExtraParams["Values"];
            
bool addHeader = true;
            DataTable dt 
= new DataTable();
            StringBuilder sbstr 
= new StringBuilder();
            Dictionary
<stringstring>[] companies = JSON.Deserialize<Dictionary<stringstring>[]>(json);
            
foreach (Dictionary<stringstring> row in companies)
            {


                
if (addHeader)
                {
                    
foreach (KeyValuePair<stringstring> keyValuePair in row)
                    {
                        dt.Columns.Add(keyValuePair.Key);
                    }
                }
                addHeader 
= false;
                ArrayList list 
= new ArrayList();
                DataRow dr 
= dt.NewRow();
                
foreach (KeyValuePair<stringstring> keyValuePair in row)
                {

                    dr[keyValuePair.Key] 
= keyValuePair.Value;
                    
if (dr["orgrole_id"== dr[keyValuePair.Key])
                    {
                        sbstr.Append(keyValuePair.Value 
+ ";");
                    }
                }
                dt.Rows.Add(dr);

            }
            
if (dt.Rows.Count > 0)
            {
                
try
                {
                    DC_OperationType operationtype 
= new DC_OperationType();
                    MSG_OrgRoleOrgMainTainRequest request 
= new MSG_OrgRoleOrgMainTainRequest();
                    request.orgrole_id 
= sbstr.ToString();
                    operationtype.DCE_OperationType 
= DCE_OperationType.Add;
                    request.OperationType 
= operationtype;
                    request.organization_id 
= Node_id;
                    client.OrgRoleOrgMaintain(request);

                    
string JsFunction = "refreshTree(#{TreePanelOrganization})";
                    
//string JsFunction = "alert('dd');";
                    
//string JsFunction = "refreshTree()";
                    Coolite.Ext.Web.ScriptManager sm = Coolite.Ext.Web.ScriptManager.GetInstance(HttpContext.Current);
                    sm.AddScript(
string.Format("{0};", JsFunction));
                    
this.WindowNewRole.Hide();


                }
                
catch (Exception ex)
                {
                    Ext.Msg.Alert(
"错误""Message: " + ex.Message + ";").Show();
                }
            }


        }

        
#endregion



        
#endregion



    }
}

 

 

posted @ 2010-06-08 13:11  StarWang  阅读(1112)  评论(0编辑  收藏  举报