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

📄 studentmanage.cs

📁 c#写图书管理系统 界面美观 功能齐全 配有完整的数据库
💻 CS
📖 第 1 页 / 共 4 页
字号:
				this.numericUpDown1.Enabled=false;
				this.textNativePlace.Enabled=false;
				this.textName.Enabled=false;				
				this.textID.Enabled=false;
				
			}

		}

		private void btnModify_Click(object sender, System.EventArgs e)
		{			
			this.Buttons_Control(true);
			this.comboClass.Enabled=false;
			this.comboDepartment.Enabled=false;
		}

		/*private void btnExcel_Click(object sender, System.EventArgs e)
		{
			Excel.Application myExcel = new Excel.Application ( ) ;
			int i=0;
			myExcel.Application.Workbooks.Add ( true ) ;			
			myExcel.Visible=true;//让Excel文件可见			
			myExcel.Cells[1,3]="'"+"职工信息";//第一行为报表名称			
			myExcel.Cells[2,4]="'"+"打印时间:"+System.DateTime.Now.ToShortDateString().ToString();
			for(int j=0;j<15;j++)
			{
				myExcel.Cells[4+j,2]="'"+this.ListHeader[j];//逐行写入表格标题,

			}						
			i=this.BindingContext[this.DataSetStudent,"Student"].Position;
			for(int j=0;j<15;j++)
			{					
				myExcel.Cells[4+j,4]="'"+this.DataSetStudent.Tables["Student"].Rows[i][j].ToString();
				//以单引号开头,表示该单元格为纯文本
			}	
			myExcel.Cells[20,2]="'"+"职工部门、职务变动历史信息:";
			
			this.commandStr="select * from Move where StudentID="+"'"+this.textStudentID.Text+"'";	
			this.Command1.CommandText=this.commandStr;
			try
			{
				this.Connection1.Open();
				this.DataReader1=this.Command1.ExecuteReader();
				i=1;
				while(this.DataReader1.Read())
				{
					myExcel.Cells[20+i,1]="'"+DataReader1["Date"].ToString();
					myExcel.Cells[20+i,2]="'"+"从";
					myExcel.Cells[20+i,3]="'"+DataReader1["OriginalDep"].ToString();
					myExcel.Cells[20+i,4]="'"+"到";
					myExcel.Cells[20+i,5]="'"+DataReader1["PresentDep"].ToString();				
					i++;
				}
				this.DataReader1.Close();
				this.commandStr="select * from UpDown where StudentID="+"'"+this.textStudentID.Text+"'";	
				this.Command1.CommandText=this.commandStr;
				this.DataReader1=this.Command1.ExecuteReader();		
				i++;
				while(this.DataReader1.Read())
				{
					myExcel.Cells[20+i,1]="'"+DataReader1["Date"].ToString();
					myExcel.Cells[20+i,2]="'"+"从";
					myExcel.Cells[20+i,3]="'"+DataReader1["OriginalDuty"].ToString();
					myExcel.Cells[20+i,4]="'"+"到";
					myExcel.Cells[20+i,5]="'"+DataReader1["PresentDuty"].ToString();
					i++;
				}

			}
			catch(Exception E)
			{
				this.ErrorHandle(E);
			}
			finally
			{
				this.DataReader1.Close();
				this.Connection1.Close();
			}			
			
		}*/

		private void btnPicture_Click(object sender, System.EventArgs e)
		{
			int position=this.BindingContext[this.DataSetStudent,"Student"].Position;
			this.openFileDialog1.InitialDirectory="c:\\Picture";
			this.openFileDialog1.Filter="jpg files(*.jpg)|*.jpg|gif files(*.gif)|*.gif|bmp files(*.bmp)|*.bmp|All files (*.*)|*.*";
			if(this.openFileDialog1.ShowDialog()==DialogResult.OK)
			{
				this.pictureBox1.Image=Image.FromFile(this.openFileDialog1.FileName);
				//this.DataSetStudent.Tables["Student"].Rows[position]["Picture"]=this.openFileDialog1.FileName;
				this.lblPicture.Text=this.openFileDialog1.FileName;
			}

		}
		private void Picture_Change(int position)
		{					
			if(this.DataSetStudent.Tables["Student"].Rows[position]["Picture"].ToString()!="")
			{
				this.pictureBox1.Image=Image.FromFile(this.DataSetStudent.Tables["Student"].Rows[position]["Picture"].ToString());			
			}
			else
				return;				
		}

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

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

		}

		private void dataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
		{
		
		}

		/*private void btnMove_Click(object sender, System.EventArgs e)
		{
			
			this.btnApply.Enabled=true;
			this.btnCancel.Enabled=true;
			this.originValue=this.comboDepartment.Text;
			this.move=true;
		}

		private void btnUpDown_Click(object sender, System.EventArgs e)
		{
			
			this.btnApply.Enabled=true;
			this.btnCancel.Enabled=true;			
			this.updown=true;
		}*/

		
		private string SearchStr_Made()
		{
			string searchStr=null;
			bool first=true;

			if(this.textID2.Text!="")
			{				
				searchStr="StudentID="+"'"+this.textID2.Text+"'";
				first=false;
				this.selectStr="职工号:"+this.textID2.Text;

			}
			if(this.comboDepartment2.Text!="")
			{
				if(first)
				{
					searchStr="Department="+"'"+this.comboDepartment2.Text+"'";
					first=false;
					this.selectStr="院系:"+this.comboDepartment2.Text;
				}
				else
				{
					searchStr=searchStr+" and Department="+"'"+this.comboDepartment2.Text+"'";
					this.selectStr+=" 院系:"+this.comboDepartment2.Text;
				}

			}
			if(this.comboClass2.Text!="")
			{
				if(first)
				{
					searchStr="Class="+"'"+this.comboClass2.Text+"'";
					first=false;
					this.selectStr="班级:"+this.comboClass2.Text;
				}
				else
				{
					searchStr=searchStr+" and Class="+"'"+this.comboClass2.Text+"'";
					this.selectStr+=" 班级:"+this.comboClass2.Text;
				}
			}
		
			return searchStr;

		}

		private void btnStudentSearch_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(this.Connection1.State==ConnectionState.Closed)
				this.Connection1.Open();								
				this.DataViewStudent.Table=this.DataSetStudent.Tables["Student"];
				this.DataViewStudent.RowFilter=this.SearchStr_Made();				
				this.dataGrid2.DataSource=this.DataViewStudent;	
				
			}
			catch(System.Exception E)
			{
				this.ErrorHandle(E);
			}
			finally
			{
				this.Connection1.Close();
			}
			if(this.DataViewStudent.Count==0)
				MessageBox.Show("没有符合查询条件的记录","没有记录",MessageBoxButtons.OK,MessageBoxIcon.Information);			
			this.textID2.Clear();
			this.comboDepartment2.Text="";
			this.comboClass2.Text="";						
		}

		private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(this.tabControl1.SelectedIndex==1)
			{
				this.DataSetStudent.Clear();
				this.dataAdapter1.Fill(this.DataSetStudent,"Student");

			}			
		}

		

		/*private void btnStudentExport_Click(object sender, System.EventArgs e)
		{
			Excel.Application myExcel = new Excel.Application ( ) ;
			myExcel.Application.Workbooks.Add ( true ) ;
			//让Excel文件可见
			myExcel.Visible=true;
			//第一行为报表名称
			myExcel.Cells[1,8]="'"+"员工查询报表";
			myExcel.Cells[2,8]=this.selectStr;
			//逐行写入数据,
			myExcel.Cells[3,10]="'"+"打印时间:"+System.DateTime.Now.ToShortDateString().ToString();
			for(int j=0;j<15;j++)
			{
				myExcel.Cells[4,1+j]="'"+this.ListHeader[j];

			}			
			this.Connection1.Open();									
			for(int i=0;i<this.DataViewStudent.Count;i++)
			{
				for(int j=0;j<15;j++)
				{
					//以单引号开头,表示该单元格为纯文本
					myExcel.Cells[6+i,1+j]="'"+this.DataViewStudent[i][j].ToString();
				}
			}			
		
		}*/

		private void button5_Click(object sender, System.EventArgs e)
		{
			this.dataGrid2.DataSource=this.DataSetStudent;
			this.dataGrid2.DataMember="Student";
		}

		private void btnStudentSearchAll_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(this.Connection1.State==ConnectionState.Closed)
				this.Connection1.Open();								
				this.DataViewStudent.Table=this.DataSetStudent.Tables["Student"];
				this.DataViewStudent.RowFilter="";
				this.dataGrid2.DataSource=this.DataViewStudent;
				this.selectStr="员工全部记录";
				
			}
			catch(System.Exception E)
			{
				this.ErrorHandle(E);
			}
			finally
			{
				this.Connection1.Close();
			}					
			this.textID2.Clear();
			this.comboDepartment2.Text="";
			this.comboClass2.Text="";				
		
		}

		private void comboDepartment_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			this.comboClass.Items.Clear();
			this.comboClass.Text="";
			try
			{
				if(this.Connection1.State==ConnectionState.Closed)
				this.Connection1.Open();						
				this.commandStr="select ClassName from Class where DepartmentName="+"'"+this.comboDepartment.Text+"'";		
				this.Command1.CommandText=this.commandStr;
				this.DataReader1.Close();
				this.DataReader1=this.Command1.ExecuteReader();
				while(this.DataReader1.Read())
				{
					this.comboClass.Items.Add(this.DataReader1["ClassName"].ToString());					
				}
				this.DataReader1.Close();				
				
			}
			catch(Exception E)
			{
				MessageBox.Show(E.ToString());
			}
			finally
			{
				this.DataReader1.Close();
				this.Connection1.Close();	
			}		
		
		}

		private void btnSearchCancel_Click(object sender, System.EventArgs e)
		{
			this.textID2.Clear();
			this.comboDepartment2.Text="";
			this.comboClass2.Text="";
		}

		private void comboDepartment2_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			this.comboClass2.Items.Clear();
			try
			{
				this.Connection1.Open();						
				this.commandStr="select ClassName from Class where DepartmentName="+"'"+this.comboDepartment2.Text+"'";									
				this.Command1.CommandText=this.commandStr;
				this.DataReader1=this.Command1.ExecuteReader();
				while(this.DataReader1.Read())
				{
					this.comboClass2.Items.Add(this.DataReader1["ClassName"].ToString());					
				}
				this.DataReader1.Close();				
				
			}
			catch(Exception E)
			{
				MessageBox.Show(E.ToString());
			}
			finally
			{
				this.DataReader1.Close();
				this.Connection1.Close();	
			}		
		
		}

		private void btnOk_Click(object sender, System.EventArgs e)
		{
			this.StuClass=this.comboClass.Text;
			this.StuDepartment=this.comboDepartment.Text;
			this.selectStr="select * from Student where Department='"+this.comboDepartment.Text+"' and Class='"+this.comboClass.Text+"'";
			this.dataAdapter1=new SqlDataAdapter(this.selectStr,this.Connection1);			
			try
			{				
				if(this.Connection1.State==ConnectionState.Closed)
				this.Connection1.Open();
				this.DataSetStudent.Clear();
				this.dataAdapter1.Fill(this.DataSetStudent,"Student");	
			}
			catch(Exception E)
			{
				MessageBox.Show(E.ToString());
			}
			finally
			{
				this.Connection1.Close();			
			}			
			if(first)
			{
				this.DataSet_Bingding();			
				first=false;
			}
			this.Buttons_Control(false);
			this.BindingContext[this.DataSetStudent,"Student"].Position=0;
			this.lblRecord_Change();
		}

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

		/*private void btnStudentLeaveExport_Click(object sender, System.EventArgs e)
		{
			Excel.Application myExcel = new Excel.Application ( ) ;
			myExcel.Application.Workbooks.Add ( true ) ;
			//让Excel文件可见
			myExcel.Visible=true;
			//第一行为报表名称
			myExcel.Cells[1,4]="普通报表";
			//逐行写入数据,
			for(int j=0;j<15;j++)
			{
				myExcel.Cells[2,1+j]=this.ListHeader[j];

			}			
			this.Connection1.Open();									
			for(int i=0;i<this.DataViewStudent.Count;i++)
			{
				for(int j=0;j<15;j++)
				{
					//以单引号开头,表示该单元格为纯文本
					myExcel.Cells[5+i,1+j]="'"+this.DataViewStudent[i][j].ToString();
				}
			}			
		
		}*/
	}
}

⌨️ 快捷键说明

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