private void treeBusinessData_MouseClick(object sender, MouseEventArgs e)
        {
            // 复选框控制
            TreeListHitInfo hitInfo = treeBusinessData.CalcHitInfo(new Point(e.X, e.Y));
            TreeListNode    node    = hitInfo.Node;

            treeBusinessData.FocusedNode = node;
            treeBusinessData.UncheckAll();
            if (null != node)
            {
                node.CheckState = CheckState.Checked;
            }
            else
            {
                return;
            }

            treeBusinessData.ContextMenuStrip = cmsBusinessDatas;
            // 加载右边的详情树
            if (null != treeBusinessData.FocusedNode && treeBusinessData.FocusedNode.Level != 0) // 点击的是非根节点
            {
                CurrBusinessData = treeBusinessData.FocusedNode.Tag as SYS_BUSINESSDATA;
                treeBusinessData.ContextMenuStrip = cmsBusinessData;
            }
        }
        public SYS_BUSINESSDATA BusinessData(int BusinessDataID)
        {
            SYS_BUSINESSDATA result = null;

            using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
            {
                result = orm.Init <SYS_BUSINESSDATA>("where ID=" + BusinessDataID);
            }
            return(result);
        }
        private void tsmiDel_Click(object sender, EventArgs e)
        {
            //treeBusinessData
            TreeListNode currNode = treeBusinessData.FocusedNode;

            SYS_BUSINESSDATA bData = currNode.Tag as SYS_BUSINESSDATA;

            BusinessServcie.DelBusinessData(bData.ID);

            RefreshBusinessDataTree();
        }
        public SYS_BUSINESSDATA EditBusinessData(int Id, string Name, string Description)
        {
            SYS_BUSINESSDATA result = null;

            using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
            {
                result             = orm.Init <SYS_BUSINESSDATA>("where ID=" + Id);
                result.NAME        = Name;
                result.DESCRIPTION = Description;
                orm.Update(result);
            }
            return(result);
        }
        public SYS_BUSINESSDATA AddBusinessData(string Name, string Description)
        {
            SYS_BUSINESSDATA result = new SYS_BUSINESSDATA();

            result.ID          = ValueOperator.CreatePk("SYS_BUSINESSDATA");
            result.NAME        = Name;
            result.DESCRIPTION = Description;
            using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
            {
                orm.Save(result);
            }
            return(result);
        }
        /// <summary>
        /// 刷新右侧详情树
        /// </summary>
        /// <param name="currBusinessData">选中的业务数据</param>
        void RefreshBusinessDataDetailTree(SYS_BUSINESSDATA currBusinessData)
        {
            treeListDetail.Nodes.Clear();
            // 根节点
            SYS_BUSINESSDATADETAIL obj = new SYS_BUSINESSDATADETAIL();

            obj.ID = 0;
            TreeListNode root = treeListDetail.AppendNode(new object[] { currBusinessData.NAME }, -1);

            root.Tag = obj;

            CascadeAddNode(currBusinessData.ID, 0, root);
            treeListDetail.ExpandAll();
        }
        private void tsmiEdit_Click(object sender, EventArgs e)
        {
            TreeListNode     currNode = treeBusinessData.FocusedNode;
            SYS_BUSINESSDATA bData    = currNode.Tag as SYS_BUSINESSDATA;

            DlgEditBusinessData dlg = new DlgEditBusinessData();

            dlg.BusinessId          = bData.ID;
            dlg.BusinessName        = bData.NAME;
            dlg.BusinessDescription = bData.DESCRIPTION;

            if (DialogResult.OK == dlg.ShowDialog())
            {
                BusinessServcie.EditBusinessData(bData.ID, dlg.BusinessName, dlg.BusinessDescription);
                RefreshBusinessDataTree();
            }
        }
        /// <summary>
        /// 刷新业务数据树
        /// </summary>
        void RefreshBusinessDataTree()
        {
            treeBusinessData.Nodes.Clear();
            SYS_BUSINESSDATA obj = new SYS_BUSINESSDATA();

            obj.ID   = -1;
            obj.NAME = "业务数据";
            TreeListNode root = treeBusinessData.AppendNode(new object[] { obj.NAME, "" }, obj.ID);

            root.Tag = obj;

            List <SYS_BUSINESSDATA> datas = BusinessServcie.BusinessDatas();

            foreach (SYS_BUSINESSDATA data in datas)
            {
                TreeListNode node = treeBusinessData.AppendNode(new object[] { data.NAME, data.DESCRIPTION }, root);
                node.Tag = data;
            }

            treeBusinessData.ExpandAll();
        }