paraform.cs

来自「初学Csharp」· CS 代码 · 共 897 行 · 第 1/3 页

CS
897
字号
			this.groupBox5.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dg_lan)).EndInit();
			this.groupBox6.ResumeLayout(false);
			this.tabPage3.ResumeLayout(false);
			this.groupBox4.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dg_class)).EndInit();
			this.groupBox3.ResumeLayout(false);
			this.tabPage2.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dg_plat)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.tabPage4.ResumeLayout(false);
			this.groupBox7.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dg_form)).EndInit();
			this.groupBox8.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void checkBox_Add_Plat_CheckedChanged(object sender, System.EventArgs e)
		{
			this.textBox1.Enabled=checkBox_Add_Plat.Checked;
			this.textBox2.Enabled=checkBox_Add_Plat.Checked;  
		}

		private void ParamForm_Load(object sender, System.EventArgs e)
		{
		   string sqlstr;
		   OleDbCommand command=new OleDbCommand();
		   connection.Open(); 
		   command.Connection=connection; 
           ////////////////////////////
		   sqlstr="select * from LanguageInfo";
		   OleDbDataAdapter oleAdapter=new OleDbDataAdapter(sqlstr,connection);     
		   //查询现有属性信息
           //oleAdapter.SelectCommand=sqlstr;
		   oleAdapter.Fill(dataset,"t_lan");
		   dg_lan.DataSource=dataset.Tables["t_lan"];
           /////////////;
           sqlstr="select * from PlatformInfo";
           command.CommandText=sqlstr; 
		   oleAdapter.SelectCommand=command;
		   oleAdapter.Fill(dataset,"t_plat");
		   dg_plat.DataSource=dataset.Tables["t_plat"];
           ////////////////
			sqlstr="select * from FormInfo";
			command.CommandText=sqlstr; 
			oleAdapter.SelectCommand=command;
			oleAdapter.Fill(dataset,"t_Form");
			dg_form.DataSource=dataset.Tables["t_Form"];
		   ////////////////
			sqlstr="select * from CLASSINFO";
			command.CommandText=sqlstr; 
			oleAdapter.SelectCommand=command;
			oleAdapter.Fill(dataset,"t_class");
			dg_class.DataSource=dataset.Tables["t_class"];
           ///////
           oleAdapter.Dispose(); 
		   connection.Close(); 
		}
        
		private void button5_Click(object sender, System.EventArgs e)
		{
			OleDbCommand command;
			OleDbDataAdapter oleAdapter=new OleDbDataAdapter();
			string sqlstr;
			bool flag=false;
			//////创建指定目录///////
			string appPath=Application.StartupPath;
			if(!Directory.Exists(appPath+"\\source\\"+textBox6.Text))
			{
				try
				{
					Directory.CreateDirectory(appPath+"\\source\\"+textBox6.Text);
		
				}
				catch (Exception ee) 
				{
					MessageBox.Show("错误:"+ee.ToString(),"错误");
					flag=true;
				}
			}	
			if(flag)
			{
				MessageBox.Show ("目录创建错误!","错误");
				return;
			}
			flag=false;
			////////////////////////
			//插入代码语言记录
		
			//检查数据有效
			if(this.textBox5.Text==""||this.textBox6.Text=="")
			{
				MessageBox.Show("数据必须填写完整","错误");
				return;
			}
			command=connection.CreateCommand();
			sqlstr="Insert into LanguageInfo values( '"+textBox5.Text+"','"+textBox6.Text+"')";
			try
			{
				connection.Open(); 
				command.CommandText=sqlstr;
				command.ExecuteReader();
				/////////////
//				sqlstr="select * from LanguageInfo";
//				command.CommandText=sqlstr; 
//				oleAdapter.SelectCommand=command;
//				oleAdapter.Fill(dataset,"t_lan");
//				dg_plat.DataSource=dataset.Tables["t_lan"];
			}
			catch(OleDbException ee)
			{
				MessageBox.Show (ee.Message,"错误!");
				flag=true;
			} 
			finally
			{
				connection.Close(); 
			}
			if(!flag)
			{
				DataRow row;
				row=dataset.Tables["t_lan"].NewRow();
				row["LANID"]=textBox5.Text;
				row["LANNAME"]=textBox6.Text;
				dataset.Tables["t_lan"].Rows.Add(row);   
				this.dg_lan.Refresh();  
			}
			else
			{
				//插入记录失败
                //删除创建目录
                Directory.Delete(appPath+"\\source\\"+textBox6.Text);
                 
			}
			this.textBox5.Text=this.textBox6.Text="";
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
			OleDbCommand command;
			string sqlstr;
			bool flag=false;
			//插入代码平台记录
			//检查数据有效
			if(this.textBox1.Text ==""||this.textBox2.Text =="")
			{
				MessageBox.Show("数据必须填写完整","错误");
				return;
			}
			command=connection.CreateCommand();
			sqlstr="Insert into PlatformInfo values( '"+textBox1.Text+"','"+textBox2.Text+"')";
			try
			{   connection.Open(); 
				command.CommandText=sqlstr;
				command.ExecuteReader(); 
			}
			catch(OleDbException ee)
			{
				MessageBox.Show (ee.Message,"错误!");
				flag=true;
			}  
			finally
			{
				connection.Close(); 
			}
			if(!flag)
			{
				DataRow row;
				row=dataset.Tables["t_plat"].NewRow();
				row["PLATFORMID"]=textBox1.Text;
				row["PLATFORMNAME"]=textBox2.Text;
				dataset.Tables["t_plat"].Rows.Add(row);   
				this.dg_plat.Refresh();  
			}
			this.textBox1.Text =this.textBox2.Text ="";
		}

		public void SetConnection(OleDbConnection conn)
		{
		   connection=conn;
		}

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

		private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
		{
			
			this.textBox5.Enabled=checkBox1.Checked;
			this.textBox6.Enabled=checkBox1.Checked;  
		}

		private void checkBox_Add_Class_CheckedChanged(object sender, System.EventArgs e)
		{
			this.textBox3.Enabled=checkBox_Add_Class.Checked;
			this.textBox4.Enabled=checkBox_Add_Class.Checked;  
		}

		private void checkBox_Add_form_CheckedChanged(object sender, System.EventArgs e)
		{
			this.textBox7.Enabled=checkBox_Add_form.Checked;
			this.textBox8.Enabled=checkBox_Add_form.Checked; 
		}

		private void button4_Click(object sender, System.EventArgs e)
		{
			OleDbCommand command;
			string sqlstr;
			bool flag=false;
			//插入代码语言记录
			//检查数据有效
			if(this.textBox3.Text ==""||this.textBox4.Text =="")
			{
				MessageBox.Show("数据必须填写完整","错误");
				return;
			}
			command=connection.CreateCommand();
			sqlstr="Insert into CLASSINFO values( '"+textBox3.Text+"','"+textBox4.Text+"')";
			try
			{  
				connection.Open(); 
				command.CommandText=sqlstr;
				command.ExecuteReader(); 
			}
			catch(OleDbException ee)
			{
				MessageBox.Show (ee.Message,"错误!");
				flag=true;
			} 
			finally
			{            
				connection.Close(); 
			}
			if(!flag)
			{
				DataRow row;
				row=dataset.Tables["t_class"].NewRow();
				row["CLASSID"]=textBox3.Text;
				row["CLASSNAME"]=textBox4.Text;
				dataset.Tables["t_class"].Rows.Add(row);   
				this.dg_class.Refresh();  
			}
			this.textBox3.Text =this.textBox4.Text="";
		}

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

		private void button6_Click(object sender, System.EventArgs e)
		{
			OleDbCommand command;
			string sqlstr;
			bool flag=false;
			//插入代码语言记录
			//检查数据有效
			if(this.textBox7.Text==""||this.textBox8.Text =="")
			{
				MessageBox.Show("数据必须填写完整","错误");
				return;
			}
			command=connection.CreateCommand();
			sqlstr="Insert into FormInfo values( '"+textBox7.Text+"','"+textBox8.Text+"')";
			try
			{   
				connection.Open(); 
				command.CommandText=sqlstr;
				command.ExecuteReader(); 
			}
			catch(OleDbException ee)
			{
				MessageBox.Show (ee.Message,"错误!");
				flag=true;
			} 
			finally
			{
				connection.Close(); 
			}
			if(!flag)
			{
				DataRow row;
				row=dataset.Tables["t_form"].NewRow();
			
				row["FORMID"]=textBox7.Text;
				row["FORMNAME"]=textBox8.Text;
				dataset.Tables["t_form"].Rows.Add(row);   
				this.dg_form.Refresh();  
			}
			this.textBox7.Text =this.textBox8.Text ="";
		}
	}
}

⌨️ 快捷键说明

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