using AIMSBLL;
using AIMSModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
namespace AIMS.OperationAanesthesia
{
public partial class frmKnowledgeBase : Form
{
///
/// 知识库集合
///
private List list;
public frmKnowledgeBase()
{
InitializeComponent();
}
///
/// 关闭
///
///
///
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 生成书名列表
///
///
//DataTable dt = null;
///
/// 获取所有知识库节点
///
///
///
private void FullTreeView(int pid, TreeNode tnode)
{
TVknow.Nodes.Clear();
if (textBox1.Text != "书名关键字")
{
list = BKnowledgeBase.SelectAll(0, textBox1.Text);
}
else
{
list = BKnowledgeBase.SelectAll(0, null);
}
FullTreeView(list, TVknow.Nodes);
foreach (TreeNode TR in TVknow.Nodes)
{
if (TR.Level == 0)
{
TR.Expand();
}
}
TVknow.SelectedNode = TVknow.Nodes[0];
}
///
/// 生成知识库树
///
///
///
private void FullTreeView(List list, TreeNodeCollection node)
{
foreach (KnowledgeBase OR in list)
{
TreeNode TR = new TreeNode(OR.Nanme);
TR.Tag = OR;
node.Add(TR);
FullTreeView(OR.SubItem, TR.Nodes);
}
}
private void KnowledgeBase_Load(object sender, EventArgs e)
{
textBox1.Text = "书名关键字";
textBox1.ForeColor = Color.FromArgb(164, 164, 164);
// dt = AIMSBKnowledgeBase.datatable();
FullTreeView(0, null);
}
private void TVknow_AfterSelect(object sender, TreeViewEventArgs e)
{
if (TVknow.SelectedNode.Level == 2)
{
KnowledgeBase know = (KnowledgeBase)TVknow.SelectedNode.Tag;
richTextBox1.Text = know.Content == null ? "" : know.Content;
}
}
///
/// 查询
///
///
///
private void Search_Click(object sender, EventArgs e)
{
FullTreeView(0, null);
}
///
/// 按回车键触发button事件
///
///
///
private void Search_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)//如果输入的是回车键
{
this.Search_Click(sender,e);//触发button事件
}
}
private void Search_KeyPress(object sender, KeyPressEventArgs e)
{
}
///
/// 点击查询文本框
///
///
///
private void textBox1_Click(object sender, EventArgs e)
{
if(textBox1.Text.Equals("书名关键字"))
{
textBox1.Text = "";
textBox1.ForeColor = Color.Black;
}
}
///
/// 按下书名文本框
///
///
///
private void textBox1_MouseDown(object sender, MouseEventArgs e)
{
textBox1.Text = "书名关键字";
textBox1.ForeColor = Color.FromArgb(164,164,164);
}
private void textBox1_Leave(object sender, EventArgs e)
{
if(textBox1.Text=="")
{
textBox1.Text = "书名关键字";
textBox1.ForeColor = Color.FromArgb(164,164,164);
}
}
}
}