www.pudn.com > classifier.rar > learn.cs


using System; 
using System.Drawing; 
using System.Collections; 
using System.ComponentModel; 
using System.Windows.Forms; 
using System.Data.OleDb; 
using System.Configuration; 
using System.Data; 
using System.Data.SqlClient; 
using System.Threading; 
 
 
namespace classifier 
{ 
	///  
	/// learn 的摘要说明。 
	///  
	public class learn : System.Windows.Forms.Form 
	{ 
		private System.Windows.Forms.ComboBox typeList; 
		private System.Windows.Forms.Label label1; 
		private System.Windows.Forms.TextBox textBox1; 
		private System.Windows.Forms.Label label2; 
		private System.Windows.Forms.Button newBtn; 
		private System.Windows.Forms.ProgressBar progressBar1; 
		private System.Windows.Forms.ListBox processList; 
		private System.Windows.Forms.Label label3; 
		private string[] fname; 
		private System.Windows.Forms.Button studyBtn; 
		OleDbConnection sqlCon; 
		///  
		/// 必需的设计器变量。 
		///  
		private System.ComponentModel.Container components = null; 
 
		public learn() 
		{ 
			// 
			// Windows 窗体设计器支持所必需的 
			// 
			InitializeComponent(); 
 
			// 
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码 
			// 
		} 
 
		public learn(string [] fileName) 
		{ 
			InitializeComponent(); 
			// 
			fname=fileName; 
			MessageBox.Show("Yes,here baby!"+fname[0]); 
		} 
 
		///  
		/// 清理所有正在使用的资源。 
		///  
		protected override void Dispose( bool disposing ) 
		{ 
			if( disposing ) 
			{ 
				if(components != null) 
				{ 
					components.Dispose(); 
				} 
			} 
			base.Dispose( disposing ); 
		} 
 
		#region Windows 窗体设计器生成的代码 
		///  
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改 
		/// 此方法的内容。 
		///  
		private void InitializeComponent() 
		{ 
			this.typeList = new System.Windows.Forms.ComboBox(); 
			this.label1 = new System.Windows.Forms.Label(); 
			this.textBox1 = new System.Windows.Forms.TextBox(); 
			this.label2 = new System.Windows.Forms.Label(); 
			this.newBtn = new System.Windows.Forms.Button(); 
			this.progressBar1 = new System.Windows.Forms.ProgressBar(); 
			this.processList = new System.Windows.Forms.ListBox(); 
			this.label3 = new System.Windows.Forms.Label(); 
			this.studyBtn = new System.Windows.Forms.Button(); 
			this.SuspendLayout(); 
			//  
			// typeList 
			//  
			this.typeList.Location = new System.Drawing.Point(136, 16); 
			this.typeList.Name = "typeList"; 
			this.typeList.Size = new System.Drawing.Size(121, 20); 
			this.typeList.TabIndex = 0; 
			//  
			// label1 
			//  
			this.label1.Location = new System.Drawing.Point(16, 16); 
			this.label1.Name = "label1"; 
			this.label1.TabIndex = 1; 
			this.label1.Text = "选择类别"; 
			//  
			// textBox1 
			//  
			this.textBox1.Location = new System.Drawing.Point(136, 56); 
			this.textBox1.Name = "textBox1"; 
			this.textBox1.Size = new System.Drawing.Size(120, 21); 
			this.textBox1.TabIndex = 2; 
			this.textBox1.Text = "textBox1"; 
			//  
			// label2 
			//  
			this.label2.Location = new System.Drawing.Point(16, 56); 
			this.label2.Name = "label2"; 
			this.label2.TabIndex = 3; 
			this.label2.Text = "新赠类别"; 
			//  
			// newBtn 
			//  
			this.newBtn.Location = new System.Drawing.Point(288, 56); 
			this.newBtn.Name = "newBtn"; 
			this.newBtn.TabIndex = 4; 
			this.newBtn.Text = "新增"; 
			//  
			// progressBar1 
			//  
			this.progressBar1.Location = new System.Drawing.Point(8, 264); 
			this.progressBar1.Name = "progressBar1"; 
			this.progressBar1.Size = new System.Drawing.Size(384, 23); 
			this.progressBar1.TabIndex = 5; 
			//  
			// processList 
			//  
			this.processList.HorizontalScrollbar = true; 
			this.processList.ItemHeight = 12; 
			this.processList.Location = new System.Drawing.Point(8, 120); 
			this.processList.Name = "processList"; 
			this.processList.ScrollAlwaysVisible = true; 
			this.processList.Size = new System.Drawing.Size(384, 124); 
			this.processList.TabIndex = 6; 
			//  
			// label3 
			//  
			this.label3.Location = new System.Drawing.Point(8, 88); 
			this.label3.Name = "label3"; 
			this.label3.TabIndex = 7; 
			this.label3.Text = "处理状态"; 
			//  
			// studyBtn 
			//  
			this.studyBtn.Location = new System.Drawing.Point(152, 304); 
			this.studyBtn.Name = "studyBtn"; 
			this.studyBtn.TabIndex = 8; 
			this.studyBtn.Text = "学习"; 
			this.studyBtn.Click += new System.EventHandler(this.studyBtn_Click); 
			//  
			// learn 
			//  
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); 
			this.ClientSize = new System.Drawing.Size(408, 341); 
			this.Controls.Add(this.studyBtn); 
			this.Controls.Add(this.label3); 
			this.Controls.Add(this.processList); 
			this.Controls.Add(this.progressBar1); 
			this.Controls.Add(this.newBtn); 
			this.Controls.Add(this.label2); 
			this.Controls.Add(this.textBox1); 
			this.Controls.Add(this.label1); 
			this.Controls.Add(this.typeList); 
			this.Name = "learn"; 
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 
			this.Text = "learn"; 
			this.Load += new System.EventHandler(this.learn_Load); 
			this.ResumeLayout(false); 
 
		} 
		#endregion 
 
		//load窗口时绑定已有类型表  
		private void learn_Load(object sender, System.EventArgs e) 
		{ 
			sqlCon=db.dbOpertation.getConnection(); 
			 
			try 
			{ 
				sqlCon.Open();			 
				string cmd="select * from typeTable"; 
				DataTable dt=new DataTable(); 
				OleDbDataAdapter sqlAd=new OleDbDataAdapter(cmd,sqlCon); 
				typeList.Items.Clear();	 
				sqlAd.Fill(dt); 
				foreach(DataRow dr in dt.Rows) 
				{ 
					typeList.Items.Add(dr["tableName"].ToString()); 
					//MessageBox.Show(dr["tableName"].ToString()); 
				}	 
				typeList.SelectedIndex=(dt.Rows.Count-1); 
 
				sqlCon.Close(); 
			} 
			catch(Exception ex) 
			{ 
				MessageBox.Show("打不开"); 
			} 
		} 
 
		///  
		/// 学习过程,将文件串和数据库连结传递过去 
		///  
		///  
		/// 		 
		private void studyBtn_Click(object sender, System.EventArgs e) 
		{ 
			//如果关闭,则打开 
			if(sqlCon.State==ConnectionState.Closed) 
			{ 
				sqlCon.Open(); 
			} 
			split.fileSpliter sp=new classifier.split.fileSpliter(fname,sqlCon,111,typeList.SelectedText,textBox1); 
			Thread sThread=new Thread(new ThreadStart(sp.readToEnd)); 
			sThread.Start(); 
			//sqlCon.Close(); 
			 
		} 
	} 
}