Beispiel #1
0
        /// <summary>
        /// Event handler when the EntityGridView cell is clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EntityGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var dataGridView = (sender as DataGridView);

            if (dataGridView != null)
            {
                var clickedCell = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];

                if (clickedCell != null)
                {
                    var entityLogicalName = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value.ToString();

                    this.ShowProgress(string.Format("Loading views for entity : {0}", clickedCell.Value.ToString()));
                    this.ViewsGridView.DataSource = null;

                    LoadViewDelegate del    = CrmHelper.GetViewsForEntity;
                    IAsyncResult     result = del.BeginInvoke(_crmConnector.Service, entityLogicalName, null, null);
                    var views = del.EndInvoke(result);

                    // set the default view
                    this.SetDefaultView(false, views);

                    this.HideProgress();
                }
            }
        }
Beispiel #2
0
        private static void Run(Object obj)
        {
            Hashtable ht = obj as Hashtable;

            Yqun.Common.ContextCache.ApplicationContext.Current = ht[1] as Yqun.Common.ContextCache.ApplicationContext;

            TreeView         View    = ht[2] as TreeView;
            LoadViewDelegate operate = new LoadViewDelegate(TreeViewOperate);

            View.Invoke(operate, View, null, OperateEnum.Clear, null);

            //View.Nodes.Clear();

            TreeNode TopNode = new TreeNode();

            TopNode.Text = "工程列表";
            TopNode.SelectedImageIndex = 0;
            TopNode.ImageIndex         = 0;

            Selection Selection = new Selection();

            Selection.ID  = TreeID;//唯一标记
            Selection.Tag = "@top";
            TopNode.Tag   = Selection;

            View.Invoke(operate, View, null, OperateEnum.Add, TopNode);
            //View.Nodes.Add(TopNode);

            DataTable Data = Agent.CallService("Yqun.BO.BusinessManager.dll", "InitProjectCatlog", new object[] { }) as DataTable;

            if (Data != null && Data.Rows.Count > 0)
            {
                DataRow[] drParent = Data.Select(" len(NodeCode)=4");
                foreach (DataRow row in drParent)
                {
                    string Code       = row["NodeCode"].ToString();
                    string Name       = row["RalationText"].ToString();
                    string Tag        = row["NodeType"].ToString();
                    string RalationID = row["RalationID"].ToString();

                    int ImageIndex         = 0;
                    int SelectedImageIndex = 0;

                    TreeNode Node = new TreeNode();
                    Node.Name = Code;
                    Node.Text = Name;

                    Selection      = new Selection();
                    Selection.ID   = RalationID;
                    Selection.Code = Code;
                    Selection.Tag  = Tag;
                    Node.Tag       = Selection;

                    switch (Tag.ToLower())
                    {
                    case "@eng":
                        ImageIndex         = 1;
                        SelectedImageIndex = 2;
                        break;

                    case "@tenders":
                        ImageIndex         = 3;
                        SelectedImageIndex = ImageIndex;
                        break;

                    case "@unit_施工单位":
                    case "@unit_监理单位":
                        ImageIndex         = 4;
                        SelectedImageIndex = ImageIndex;
                        break;

                    case "@folder":
                        ImageIndex         = 5;
                        SelectedImageIndex = ImageIndex;
                        break;

                    case "@module":
                        ImageIndex         = 6;
                        SelectedImageIndex = ImageIndex;
                        break;
                    }

                    Node.SelectedImageIndex = SelectedImageIndex;
                    Node.ImageIndex         = ImageIndex;
                    View.Invoke(operate, View, TopNode, OperateEnum.NodeAdd, Node);
                    //TopNode.Nodes.Add(Node);
                    DataRow[] drSub = Data.Select("NodeCode like '" + Code + "%'");
                    if (drSub.Length > 0)
                    {
                        BindSubNode(Data, Code, Node, operate, View);
                    }
                }
            }
            View.Invoke(operate, View, null, OperateEnum.Set, View.TopNode);
            //View.SelectedNode = View.TopNode;
            if (View.TopNode != null)
            {
                View.Invoke(operate, View, null, OperateEnum.Expand, null);
                //View.TopNode.Expand();
            }
        }
Beispiel #3
0
        private static void BindSubNode(DataTable dt, string ParentCode, TreeNode ParentNode, LoadViewDelegate operate, TreeView view)
        {
            DataRow[] drParent  = dt.Select(string.Format("NodeCode like '{0}%' and len(NodeCode)>{1} and len(NodeCode)={1}+4 ", ParentCode, ParentCode.Length), "OrderID");
            Selection Selection = new Selection();

            if (drParent.Length > 0)
            {
                foreach (DataRow row in drParent)
                {
                    string Code       = row["NodeCode"].ToString();
                    string Name       = row["RalationText"].ToString();
                    string Tag        = row["NodeType"].ToString();
                    string RalationID = row["RalationID"].ToString();

                    int ImageIndex         = 0;
                    int SelectedImageIndex = 0;

                    TreeNode Node = new TreeNode();
                    Node.Name = Code;
                    Node.Text = Name;

                    Selection      = new Selection();
                    Selection.ID   = RalationID;
                    Selection.Code = Code;
                    Selection.Tag  = Tag;
                    Node.Tag       = Selection;

                    switch (Tag.ToLower())
                    {
                    case "@eng":
                        ImageIndex         = 1;
                        SelectedImageIndex = 2;
                        break;

                    case "@tenders":
                        ImageIndex         = 3;
                        SelectedImageIndex = ImageIndex;
                        break;

                    case "@unit_施工单位":
                    case "@unit_监理单位":
                        ImageIndex         = 4;
                        SelectedImageIndex = ImageIndex;
                        break;

                    case "@folder":
                        ImageIndex         = 5;
                        SelectedImageIndex = ImageIndex;
                        break;

                    case "@module":
                        ImageIndex         = 6;
                        SelectedImageIndex = ImageIndex;
                        break;
                    }

                    Node.SelectedImageIndex = SelectedImageIndex;
                    Node.ImageIndex         = ImageIndex;
                    view.Invoke(operate, view, ParentNode, OperateEnum.NodeAdd, Node);
                    //ParentNode.Nodes.Add(Node);
                    //DataRow[] drSub = dt.Select("NodeCode like '" + Code + "%'");
                    //if (drSub.Length > 1)
                    //{
                    BindSubNode(dt, Code, Node, operate, view);
                    //}
                }
            }
        }