using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DocumentManagement
{
    public partial class frmViewSelect : Form
    {
        /// 
        /// 知识库EntryId
        /// 
        public string EntryId;
        public string ViewInfo;
        /// 
        /// 返回结果
        /// 
        public string VcName = string.Empty;
        public frmViewSelect()
        {
            InitializeComponent();
        }
        public frmViewSelect(string _ViewInfo)
        {
            InitializeComponent();
            ViewInfo = _ViewInfo;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            VcName = tvReflection.SelectedNode == null ? string.Empty : tvReflection.SelectedNode.Text;
            Close();
        }
        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }
        private void frmViewSelect_Load(object sender, EventArgs e)
        {
            TreeNode root = new TreeNode()
            {
                Text = "视图映射列表",
                ForeColor = SystemColors.GrayText
            };
            //DocumentDAL dal = new DocumentDAL();
            DataTable dt = DocumentDAL.GetReflectionList(ViewInfo);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                TreeNode node = new TreeNode();
                node.Text = dt.Rows[i][0].ToString();
                if (!dt.Rows[i][1].ToString().Equals(string.Empty) && !dt.Rows[i][1].ToString().Equals(EntryId))
                {
                    node.ForeColor = SystemColors.GrayText;
                }
                root.Nodes.Add(node);
            }
            tvReflection.Nodes.Add(root);
            tvReflection.ExpandAll();
        }
        private void tvReflection_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeNode node = tvReflection.SelectedNode;
            if (node.Parent != null)
            {
                btnSave_Click(null, null);
            }
        }
    }
}