153 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			153 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| 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
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 知识库集合
 | |
|         /// </summary>
 | |
|         private List<KnowledgeBase> list;
 | |
|         public frmKnowledgeBase()
 | |
|         {
 | |
|             InitializeComponent();
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 关闭
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         private void button1_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             this.Close();
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 生成书名列表
 | |
|         /// </summary>
 | |
|         /// 
 | |
|         //DataTable dt = null;
 | |
|         /// <summary>
 | |
|         /// 获取所有知识库节点
 | |
|         /// </summary>
 | |
|         /// <param name="pid"></param>
 | |
|         /// <param name="tnode"></param>
 | |
|         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];
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 生成知识库树
 | |
|         /// </summary>
 | |
|         /// <param name="list"></param>
 | |
|         /// <param name="node"></param>
 | |
|         private void FullTreeView(List<KnowledgeBase> 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;
 | |
|             }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 查询
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         private void Search_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             FullTreeView(0, null);
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 按回车键触发button事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         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)
 | |
|         {
 | |
| 
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 点击查询文本框
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         private void textBox1_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if(textBox1.Text.Equals("书名关键字"))
 | |
|             {
 | |
|                 textBox1.Text = "";
 | |
|                 textBox1.ForeColor = Color.Black;
 | |
|             }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 按下书名文本框
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         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);
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |