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

📄 knowledgemanage.cs

📁 c#编写的汽车销售公司erp进销存系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// label8
			// 
			this.label8.Location = new System.Drawing.Point(192, 208);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(80, 23);
			this.label8.TabIndex = 37;
			this.label8.Text = "审核人编号";
			this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(0, 232);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(64, 23);
			this.label6.TabIndex = 35;
			this.label6.Text = "录入时间";
			this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(0, 208);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(72, 23);
			this.label5.TabIndex = 34;
			this.label5.Text = "录入人姓名";
			this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// txtkaname
			// 
			this.txtkaname.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtkaname.Location = new System.Drawing.Point(283, 140);
			this.txtkaname.Name = "txtkaname";
			this.txtkaname.ReadOnly = true;
			this.txtkaname.Size = new System.Drawing.Size(128, 21);
			this.txtkaname.TabIndex = 49;
			this.txtkaname.Text = "";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(184, 144);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(72, 23);
			this.label4.TabIndex = 33;
			this.label4.Text = "录入人编号";
			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// panel3
			// 
			this.panel3.AutoScroll = true;
			this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel3.Location = new System.Drawing.Point(0, 0);
			this.panel3.Name = "panel3";
			this.panel3.Size = new System.Drawing.Size(668, 128);
			this.panel3.TabIndex = 59;
			// 
			// hRichTextBox1
			// 
			this.hRichTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.hRichTextBox1.Location = new System.Drawing.Point(184, 128);
			this.hRichTextBox1.Name = "hRichTextBox1";
			this.hRichTextBox1.RtfText = "{\\rtf1\\ansi\\ansicpg936\\deff0\\deflang1033\\deflangfe2052{\\fonttbl{\\f0\\fnil\\fcharset" +
				"134 \\\'cb\\\'ce\\\'cc\\\'e5;}}\r\n{\\*\\generator Riched20 5.40.11.2210;}\\viewkind4\\uc1\\par" +
				"d\\lang2052\\f0\\fs18\\par\r\n}\r\n\0";
			this.hRichTextBox1.Size = new System.Drawing.Size(668, 421);
			this.hRichTextBox1.TabIndex = 7;
			// 
			// KnowledgeManage
			// 
			this.Controls.Add(this.hRichTextBox1);
			this.Controls.Add(this.panel2);
			this.Controls.Add(this.panel1);
			this.Name = "KnowledgeManage";
			this.Size = new System.Drawing.Size(852, 549);
			this.Load += new System.EventHandler(this.KnowledgeManage_Load);
			this.panel1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.treeList1)).EndInit();
			this.panel2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void KnowledgeManage_Load(object sender, System.EventArgs e)
		{
			initTreeList();
			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 treeList1_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e)
		{
			if(i==0)
			{
				i++;
				return;
			}
			else
			{
			
	//			MessageBox.Show(this,e.Node.GetDisplayText(0)+" ; "+e.Node.GetDisplayText(2));
				string strtype="";
				string strpoint="";
				string strnopoint="";

				strtype=this.txtktype.Text.Trim();
				strpoint=e.Node.GetDisplayText(0)+",";
				strnopoint=e.Node.GetDisplayText(2)+",";
				if (strtype.IndexOf(strpoint)==-1)
				{
					
					this.txtktype.Text+=strpoint;
					strnumber+=strnopoint;
				}
				else
				{
					strtype=strtype.Replace(strpoint,"");
					this.txtktype.Text=strtype;
					strnumber=strnumber.Replace(strnopoint,"");
				}
					
			}
		}

		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);
				}

			}			
		}
		private int isLength()
		{
			if(ShareClass.checkoutLength(50,this.txtktitle,"知识标题")==1)
			{
				return 1;
			}
			else if(ShareClass.checkoutLength(100,this.txtkkeywords,"关键字")==1)
			{
				return 1;
			}
			return 0;
		}

		private void btAdd_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(isLength()==1)
				{
					return;
				}
				else
				{
					insertData();
				}
				
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
		private void insertData()
		{
			if(!this.checkValidate())
			{
				return;
			}
			KnowledgeInfo kinfo=new KnowledgeInfo();
			kinfo=setData("添加");
			KnowledgeBLL kbll=new KnowledgeBLL();
//			MessageBox.Show(kinfo.kcontent);
			if(kbll.addKnowledge(kinfo)>0)
			{
				MessageBox.Show(this,"添加成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
//				getDataBind();
				ClearData();
			}
			else
			{
				MessageBox.Show(this,"添加失败!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
			}
			
		}
		private KnowledgeInfo setData(string tag)
		{
			KnowledgeInfo kinfo=new KnowledgeInfo();
			try
			{
				
				if(tag=="修改")
				{
					kinfo.id=knowledgeinfo.id;
				}
				kinfo.ktitle=this.txtktitle.Text;
				kinfo.ktype=","+strnumber;//this.txtktype.Text;
				kinfo.kkeywords=this.txtkkeywords.Text;
				kinfo.kwid=ShareClass.Operator;
				kinfo.kwname=ShareClass.OperatorChinese;
				kinfo.kwdate=DateTime.Today.ToString();
				if(this.cboamark.Text=="不可访问")
				{
					kinfo.oamark=0;
				}
				else
				{
					kinfo.oamark=1;
				}
				kinfo.kaid=ShareClass.Operator;
				kinfo.kaname=ShareClass.OperatorChinese;
				if(tag=="添加")
				{
					kinfo.oamount=0;//Convert.ToInt32(this.txtoamount.Text);
					kinfo.iamount=0;//Convert.ToInt32(this.txtiamount.Text);
					kinfo.camount=0;//Convert.ToInt32(this.txtcamount.Text);
				}
				else if(tag=="修改")
				{
					kinfo.oamount=Convert.ToInt32(this.txtoamount.Text);
					kinfo.iamount=Convert.ToInt32(this.txtiamount.Text);
					kinfo.camount=Convert.ToInt32(this.txtcamount.Text);
				}
				kinfo.kcontent=this.hRichTextBox1.RtfText;//this.txtkcontent.Rtf;
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
			
				return kinfo;
			}

		private void ClearData()
		{
			this.txtktitle.Text="";
			this.txtktype.Text="";
			this.txtkkeywords.Text="";
			this.txtkwid.Text=ShareClass.Operator;
			this.txtkwname.Text=ShareClass.OperatorChinese;
			this.txtkwdate.Text=DateTime.Today.Year.ToString()+"-"+DateTime.Today.Month.ToString()+"-"+DateTime.Today.Day.ToString();
			this.cboamark.Text="不可访问";
			
			this.txtkaid.Text=ShareClass.Operator;
			this.txtkaname.Text=ShareClass.OperatorChinese;
			this.txtoamount.Text="0";
			this.txtiamount.Text="0";
			this.txtcamount.Text="0";
//			this.txtkcontent.Text="";
			this.hRichTextBox1.Text="";
			getEnabled(false);
		}
		private void getEnabled(bool enabled)
		{
			if(enabled==true)
			{
//				this.btSave.Enabled=true;
//				this.btDelete.Enabled=true;
				this.btReset.Enabled=true;
			}
			else
			{
//				this.btSave.Enabled=false;
//				this.btDelete.Enabled=false;
				this.btReset.Enabled=false;
			}
		}

		private void groupBox1_Enter(object sender, System.EventArgs e)
		{
		
		}

		private void btClose_Click(object sender, System.EventArgs e)
		{
//			this.Close();
		}

		private void btDelete_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(MessageBox.Show("确定要删除此条记录吗?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Warning)==DialogResult.Yes)
				{
					KnowledgeBLL kbll=new KnowledgeBLL();

					kbll.delKnowledgeByIds(knowledgeinfo.id.ToString());
					ClearData();
					MessageBox.Show("删除成功!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
				}
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void btSave_Click(object sender, System.EventArgs e)
		{
			try
			{
				modifyData();
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
		private void modifyData()
		{
			if(!this.checkValidate())
			{
				return;
			}
			
			KnowledgeInfo kinfo=new KnowledgeInfo();
			kinfo=setData("修改");
			KnowledgeBLL kbll=new KnowledgeBLL();
			if(kbll.updateKnowledge(kinfo)<=0)
			{
				MessageBox.Show("修改失败!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
			}
			else
			{
				MessageBox.Show("修改成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
				ClearData();
			}
		}

		private bool checkValidate()
		{
			if(""==this.txtktitle.Text.Trim())
			{
				MessageBox.Show(this,"知识标题不能为空,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
				this.txtktitle.Focus();
				return false;
			}
			if(this.txtktitle.Text.Length>50)
			{
				MessageBox.Show(this,"知识标题不能多于50个字符,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
				this.txtktitle.Focus();
				return false;
			}
			
			if("".Equals(this.txtktype.Text.Trim()))
			{
				MessageBox.Show(this,"知识类别不能为空,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
				this.txtktype.Focus();
				return false;
			}
			
			if("".Equals(this.txtkkeywords.Text.Trim()))
			{
				MessageBox.Show(this,"关键字不能为空,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
				this.txtkkeywords.Focus();
				return false;
			}
			if(this.txtkkeywords.Text.Length>50)
			{
				MessageBox.Show(this,"关键字不能多于50个字符,请重新输入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
				this.txtkkeywords.Focus();
				return false;
			}
			return true;
			
		}
		private void btReset_Click(object sender, System.EventArgs e)
		{
			ClearData();
		}

	
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		

	}
}

⌨️ 快捷键说明

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