⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 knowledgeform.cs

📁 汽车销售公司ERP进销存系统 汽车销售公司ERP进销存系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
				KnowledgeInfo knowledgeInfo=new KnowledgeInfo();
				knowledgeInfo.ktitle = "";
				knowledgeInfo.kkeywords = "";
				knowledgeInfo.ktype = kType;
				ilist =m_KnowledgeBLL.queryKnowledge(knowledgeInfo);
				
				
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
			}
			return ilist;
		}
		DevExpress.XtraTreeList.Nodes.TreeListNode Node=null;
		public void AddTree(int ParentID,DevExpress.XtraTreeList.Nodes.TreeListNode pNode) 
		{
//			DataSet ds=(DataSet) this.ViewState["ds"];
			IList plist=null;
			DataView dvTree = new DataView(ds.Tables[0]);
			//过滤ParentID,得到当前的所有子节点
			dvTree.RowFilter =  "[PARENTID] = " + ParentID;

			foreach(DataRowView Row in dvTree) 
			{
				
				if(pNode == null) 
				{    //添加根节点
					
//					Node.Text = Row["TNAME"].ToString();
					Node = this.treeList2.AppendNode(new Object[]{Row["TNAME"],Row["OAMARK"],Row["ID"],Row["PARENTID"]},null);

//					MessageBox.Show(Node.GetDisplayText(0));
//					this.treeView1.Nodes.Add(Node);
//					Node.Expand();
					AddTree(Int32.Parse(Row["ID"].ToString()), Node);    //再次递归
				} 
				else 
				{   //?添加当前节点的子节点
//					Node.Text = Row["TNAME"].ToString();
					if(Node==null)
					{
//						MessageBox.Show(pNode.GetDisplayText(0));
						plist=GetKList(pNode.GetDisplayText(2));
						for(int i=0;i<plist.Count;i++)
						{
							listAll.Add((KnowledgeInfo)plist[i]);
						}
					}
					else
					{
//						MessageBox.Show(Node.GetDisplayText(0));
						plist=GetKList(Node.GetDisplayText(2));
						for(int i=0;i<plist.Count;i++)
						{
							listAll.Add((KnowledgeInfo)plist[i]);
						}
					}
					Node = this.treeList2.AppendNode(new Object[]{Row["TNAME"],Row["OAMARK"],Row["ID"],Row["PARENTID"]},null);

					
					
//					pNode.Nodes.Add(Node);
					
//					Node.Expand();
					AddTree(Int32.Parse(Row["ID"].ToString()),Node);     //再次递归
				}
			}   
			
		}            

		private void KnowledgeForm_Load(object sender, System.EventArgs e) 
		{
			ds = bll.getKnowledgeType("KNOWLEDGETYPE");
//			AddTree(0, (TreeNode)null);

			initTreeList();
			initTreeList2();
			paintTreeList();
		}

		private void initTreeList() {
			this.colTNAME = new DevExpress.XtraTreeList.Columns.TreeListColumn();
			this.colOAMARK = new DevExpress.XtraTreeList.Columns.TreeListColumn();
			this.colID = new DevExpress.XtraTreeList.Columns.TreeListColumn();
			this.colPARENTID = new DevExpress.XtraTreeList.Columns.TreeListColumn();
			// 
			// treeList1
			// 
			this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] {
																									 this.colTNAME,
																									 this.colOAMARK,
																									 this.colID,
																									 this.colPARENTID});
			this.treeList1.Location = new System.Drawing.Point(16, 48);
			this.treeList1.Name = "treeList1";
			this.treeList1.Size = new System.Drawing.Size(280, 464);
			this.treeList1.TabIndex = 0;
			this.treeList1.FocusedNodeChanged += new DevExpress.XtraTreeList.FocusedNodeChangedEventHandler(this.treeList1_FocusedNodeChanged);
			// 
			// colTNAME
			// 
			this.colTNAME.Caption = "分类名称";
			this.colTNAME.FieldName = "TNAME";
			this.colTNAME.Name = "colTNAME";
			this.colTNAME.OptionsColumn.AllowEdit = false;
			this.colTNAME.OptionsColumn.FixedWidth = true;
			this.colTNAME.VisibleIndex = 0;
			this.colTNAME.Width = 160;
			// 
			// colOAMARK
			// 
			this.colOAMARK.FieldName = "OAMARK";
			this.colOAMARK.Name = "colOAMARK";
			this.colOAMARK.OptionsColumn.AllowEdit = false;
			this.colOAMARK.Width = 20;
			// 
			// colID
			// 
			this.colID.Caption = "ID";
			this.colID.FieldName = "ID";
			this.colID.Name = "colID";
			this.colID.OptionsColumn.AllowEdit = false;
			// 
			// colPARENTID
			// 
			this.colPARENTID.Caption = "PARENTID";
			this.colPARENTID.FieldName = "PARENTID";
			this.colPARENTID.Name = "colPARENTID";
			this.colPARENTID.OptionsColumn.AllowEdit = false;
		}
		private void initTreeList2() 
		{
			this.colTNAME1 = new DevExpress.XtraTreeList.Columns.TreeListColumn();
			this.colOAMARK1 = new DevExpress.XtraTreeList.Columns.TreeListColumn();
			this.colID1 = new DevExpress.XtraTreeList.Columns.TreeListColumn();
			this.colPARENTID1 = new DevExpress.XtraTreeList.Columns.TreeListColumn();
			// 
			// treeList1
			// 
			this.treeList2.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] {
																									 this.colTNAME1,
																									 this.colOAMARK1,
																									 this.colID1,
																									 this.colPARENTID1});
			this.treeList2.Location = new System.Drawing.Point(16, 48);
			this.treeList2.Name = "treeList1";
			this.treeList2.Size = new System.Drawing.Size(280, 464);
			this.treeList2.TabIndex = 0;
			// 
			// colTNAME
			// 
			this.colTNAME1.Caption = "分类名称";
			this.colTNAME1.FieldName = "TNAME";
			this.colTNAME1.Name = "colTNAME";
			this.colTNAME1.OptionsColumn.AllowEdit = false;
			this.colTNAME1.OptionsColumn.FixedWidth = true;
			this.colTNAME1.VisibleIndex = 0;
			this.colTNAME1.Width = 160;
			// 
			// colOAMARK
			// 
			this.colOAMARK1.FieldName = "OAMARK";
			this.colOAMARK1.Name = "colOAMARK";
			this.colOAMARK1.OptionsColumn.AllowEdit = false;
			this.colOAMARK1.Width = 20;
			// 
			// colID
			// 
			this.colID1.Caption = "ID";
			this.colID1.FieldName = "ID";
			this.colID1.Name = "colID";
			this.colID1.OptionsColumn.AllowEdit = false;
			// 
			// colPARENTID
			// 
			this.colPARENTID1.Caption = "PARENTID";
			this.colPARENTID1.FieldName = "PARENTID";
			this.colPARENTID1.Name = "colPARENTID";
			this.colPARENTID1.OptionsColumn.AllowEdit = false;
		}
		private void RomoveRecorde()
		{
			string str="";
			for(int j=0;j<knowledageLV.Items.Count;j++)
			{
				str=knowledageLV.Items[j].Text;
				for(int i=0;i<knowledageLV.Items.Count;i++)
				{
					if(knowledageLV.Items[i].Text==str && i!=j)
					{
//						MessageBox.Show("j="+j+",i="+i);
						knowledageLV.Items[i].Remove();
					}
				}
			}
		}
		private void treeList1_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e) {
//			MessageBox.Show(e.Node.Nodes.Count.ToString());
			listAll.Clear();
			knowledageLV.Items.Clear();
			Node=null;
			AddTree(Convert.ToInt32(e.Node.GetDisplayText(2)), e.Node);
//			MessageBox.Show(listAll.Count.ToString());
			m_KList=listAll;
//			m_kType = e.Node.GetDisplayText(2);
			this.tbType.Text = e.Node.GetDisplayText(0);
			knowledageLV.Refresh_UserDefine(listAll,m_KnowledgeInfo,DisPlayCol);
			RomoveRecorde();
//			RetrieveLV();
			//
			
		}

		private void paintTreeList() {
			TreeListNode node;
			string strexp="id="+1;
			DataRow[] funrow= ds.Tables[0].Select(strexp,"");
			DataRow dr = funrow[0];	
			node = this.treeList1.AppendNode(new Object[]{dr["TNAME"],dr["OAMARK"],dr["ID"],dr["PARENTID"]},null);

			string strsel = "parentid="+dr["ID"];
			DataRow[] chdr = ds.Tables[0].Select(strsel);
			if(chdr.Length>0) {
				digui(node,chdr);
			}
			this.treeList1.ExpandAll();
		}

		private void digui(TreeListNode pnode,DataRow[] chdr) {						
			TreeListNode node;
			for(int i=0;i<chdr.Length;i++) {
				node = this.treeList1.AppendNode(new Object[]{chdr[i]["TNAME"],chdr[i]["OAMARK"],chdr[i]["ID"],chdr[i]["PARENTID"]},pnode);
				string strsel = "parentid="+chdr[i]["ID"];
				DataRow[] dgdr = ds.Tables[0].Select(strsel);
				if(dgdr.Length>0) {
					digui(node,dgdr);
				}

			}			
		}
		#endregion

		#region method

		private void InitKListView(){
			knowledageLV.InitLV_UserDefined(m_KLVColName,DisPlayCol);
			knowledageLV.BackColor=Color.FromArgb(ShareClass.Rcolor,ShareClass.Gcolor,ShareClass.Bcolor);
			
			knowledageLV.Dock=DockStyle.Fill;
			knowledageLV.BorderStyle = BorderStyle.Fixed3D;
			knowledageLV.Columns[0].Width = 370;
			knowledageLV.Columns[1].Width = 196;
			knowledageLV.Columns[1].TextAlign = HorizontalAlignment.Left;
			KLVPanel.Controls.Add(knowledageLV);
			knowledageLV.DoubleClick+=new EventHandler(knowledageLV_DoubleClick);

			this.ctMenu_Edit.MenuItems.Add("修改",new EventHandler(ctMenu_ModifyClick));
			knowledageLV.ContextMenu = this.ctMenu_Edit;
		}
		private void RetrieveLV(){
			SetKList();
			if(m_KList!=null){
				knowledageLV.Refresh_UserDefine(m_KList,m_KnowledgeInfo,DisPlayCol);
			}
		}
		private void UpLoadKnowledgeInfo(){
			m_KnowledgeInfo.ktitle = this.tbTitle.Text;
			m_KnowledgeInfo.kkeywords = this.tbKeyWords.Text;
			m_KnowledgeInfo.ktype = this.m_kType;
		}
		
		private void SetKList(){
			try{
				if(m_KList!=null){
					m_KList.Clear();
				}
				UpLoadKnowledgeInfo();
				m_KList =m_KnowledgeBLL.queryKnowledge(m_KnowledgeInfo);
			}catch(Exception ex){
				MessageBox.Show(ex.Message,"警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
			}
		}

		private void Reset(){
			this.tbTitle.Text=string.Empty;
			this.tbKeyWords.Text=string.Empty;
			this.tbType.Text = string.Empty;
			this.m_kType = string.Empty;
		}

		private KnowledgeInfo GetCurrentKInfo(){
			if(this.knowledageLV.SelectedIndices.Count>0 && this.m_KList.Count>0){
				int index = knowledageLV.SelectedIndices[0];
				KnowledgeInfo kInfo =(KnowledgeInfo)m_KList[index];
				return kInfo;
			}
			return null;
		}
		#endregion

		private void btnRetrieve_Click(object sender, System.EventArgs e) {
			RetrieveLV();
		}

		private void btnReset_Click(object sender, System.EventArgs e) {
			Reset();
		}

		private void knowledageLV_DoubleClick(object sender, EventArgs e) {
			this.Cursor = Cursors.WaitCursor;
			KnowledgeInfo temp_KInfo = GetCurrentKInfo();
			if(temp_KInfo!=null){
				KnowledgeInfo info=m_KnowledgeBLL.getKnowledgeById(temp_KInfo.id);
				KnowledgeDetailForm km = new KnowledgeDetailForm(info);
				km.ShowDialog();
			}
			this.Cursor = Cursors.Arrow;
		}

		private void tbTitle_TextChanged(object sender, EventArgs e) {
			RetrieveLV();
		}

		private void tbKeyWords_TextChanged(object sender, EventArgs e) {
			RetrieveLV();
		}
		private void ctMenu_ModifyClick(object sender, EventArgs e){
			KnowledgeInfo temp_KInfo = GetCurrentKInfo();
			if(temp_KInfo!=null){
				KnowledgeInfo info=m_KnowledgeBLL.getKnowledgeById(temp_KInfo.id);
				KnowledgeManage_Dialog kmDlg = new KnowledgeManage_Dialog(info);
				DialogResult dlg = kmDlg.ShowDialog();
				RetrieveLV();
			}
		}

		private void tbTitle_EditValueChanged(object sender, System.EventArgs e)
		{
			RetrieveLV();
		}

		private void tbKeyWords_EditValueChanged(object sender, System.EventArgs e)
		{
			RetrieveLV();
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -