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

📄 stud_info.cs

📁 学生管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// btn_top
			// 
			this.btn_top.Location = new System.Drawing.Point(12, 68);
			this.btn_top.Name = "btn_top";
			this.btn_top.Size = new System.Drawing.Size(60, 25);
			this.btn_top.TabIndex = 10;
			this.btn_top.Text = "<<";
			this.btn_top.Click += new System.EventHandler(this.btn_top_Click);
			// 
			// btn_syt
			// 
			this.btn_syt.Location = new System.Drawing.Point(12, 25);
			this.btn_syt.Name = "btn_syt";
			this.btn_syt.Size = new System.Drawing.Size(60, 25);
			this.btn_syt.TabIndex = 11;
			this.btn_syt.Text = "<";
			this.btn_syt.Click += new System.EventHandler(this.btn_syt_Click);
			// 
			// btn_xyt
			// 
			this.btn_xyt.Location = new System.Drawing.Point(84, 25);
			this.btn_xyt.Name = "btn_xyt";
			this.btn_xyt.Size = new System.Drawing.Size(60, 25);
			this.btn_xyt.TabIndex = 12;
			this.btn_xyt.Text = ">";
			this.btn_xyt.Click += new System.EventHandler(this.btn_xyt_Click);
			// 
			// btn_bottom
			// 
			this.btn_bottom.Location = new System.Drawing.Point(84, 68);
			this.btn_bottom.Name = "btn_bottom";
			this.btn_bottom.Size = new System.Drawing.Size(60, 25);
			this.btn_bottom.TabIndex = 13;
			this.btn_bottom.Text = ">>";
			this.btn_bottom.Click += new System.EventHandler(this.btn_bottom_Click);
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.btn_syt);
			this.groupBox2.Controls.Add(this.btn_bottom);
			this.groupBox2.Controls.Add(this.btn_xyt);
			this.groupBox2.Controls.Add(this.btn_top);
			this.groupBox2.Location = new System.Drawing.Point(0, 336);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(156, 100);
			this.groupBox2.TabIndex = 14;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "导航区";
			// 
			// groupBox3
			// 
			this.groupBox3.Controls.Add(this.btn_dele);
			this.groupBox3.Controls.Add(this.btn_change);
			this.groupBox3.Controls.Add(this.btn_save);
			this.groupBox3.Controls.Add(this.btn_add);
			this.groupBox3.Location = new System.Drawing.Point(162, 336);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(270, 100);
			this.groupBox3.TabIndex = 15;
			this.groupBox3.TabStop = false;
			this.groupBox3.Text = "作用区";
			this.groupBox3.Enter += new System.EventHandler(this.groupBox3_Enter);
			// 
			// btn_dele
			// 
			this.btn_dele.Location = new System.Drawing.Point(30, 68);
			this.btn_dele.Name = "btn_dele";
			this.btn_dele.Size = new System.Drawing.Size(90, 25);
			this.btn_dele.TabIndex = 3;
			this.btn_dele.Text = "删除";
			this.btn_dele.Click += new System.EventHandler(this.btn_dele_Click);
			// 
			// btn_change
			// 
			this.btn_change.Location = new System.Drawing.Point(156, 68);
			this.btn_change.Name = "btn_change";
			this.btn_change.Size = new System.Drawing.Size(90, 25);
			this.btn_change.TabIndex = 2;
			this.btn_change.Text = "修改";
			this.btn_change.Click += new System.EventHandler(this.btn_change_Click);
			// 
			// btn_save
			// 
			this.btn_save.Location = new System.Drawing.Point(156, 25);
			this.btn_save.Name = "btn_save";
			this.btn_save.Size = new System.Drawing.Size(90, 25);
			this.btn_save.TabIndex = 1;
			this.btn_save.Text = "保存";
			this.btn_save.Click += new System.EventHandler(this.btn_save_Click);
			// 
			// btn_add
			// 
			this.btn_add.Location = new System.Drawing.Point(30, 25);
			this.btn_add.Name = "btn_add";
			this.btn_add.Size = new System.Drawing.Size(90, 25);
			this.btn_add.TabIndex = 0;
			this.btn_add.Text = "增加";
			this.btn_add.Click += new System.EventHandler(this.btn_add_Click);
			// 
			// Stud_info
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(432, 441);
			this.Controls.Add(this.groupBox3);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.dataGrid1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.Name = "Stud_info";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "学生信息管理";
			this.Load += new System.EventHandler(this.Stud_info_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

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

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

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

		private void Stud_info_Load(object sender, System.EventArgs e)
		{
			dataGrid1.DataSource = myTable.DefaultView;	
			DataBindingsFunction();
			cmAmend=(CurrencyManager) BindingContext[myTable];
			this.txt_count.Text = ds.Tables[0].Rows.Count.ToString();
			
		}
		private void DataBindingsFunction()
		{
			this.txt_Xh.DataBindings.Add("Text",myTable,"学号");
			this.txt_Xm.DataBindings.Add("Text",myTable,"姓名");
			this.txt_sex.DataBindings.Add("Text",myTable,"性别");
			this.txt_csrq.DataBindings.Add("Text",myTable,"出生日期");

			this.txt_addr.DataBindings.Add("Text",myTable,"家庭地址");
			this.txt_tel.DataBindings.Add("Text",myTable,"电话号码");
			this.txt_qqhm.DataBindings.Add("Text",myTable,"QQ号码");
			
		}

		private void btn_change_Click(object sender, System.EventArgs e)
		{
			this.txt_Xm.ReadOnly = this.txt_Xh.ReadOnly = this.txt_tel.ReadOnly = this.txt_sex.ReadOnly = this.txt_addr.ReadOnly = this.txt_csrq.ReadOnly = this.txt_qqhm.ReadOnly =  false;
		}

		private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
		{
			if(this.myTable.Rows .Count>0)
			{
				int currentRowNumber=this.dataGrid1.CurrentCell.RowNumber;
				if(currentRowNumber>=0&&currentRowNumber<cmAmend.Count)
				{
					cmAmend.Position=currentRowNumber;
				}
			}
		}

		private void btn_dele_Click(object sender, System.EventArgs e)
		{
			if(MessageBox.Show("确实要删除这条记录吗?","询问",MessageBoxButtons.YesNo)==DialogResult.Yes)
			{
				try
				{
					if(cmAmend.Count>0)
						cmAmend.RemoveAt(cmAmend.Position);
					else
						MessageBox.Show("没有可以删除的数据","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
				}

				catch(Exception express)
				{
					MessageBox.Show(express.ToString (),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
				}
				cmAmend.EndCurrentEdit();
				if(myTable.GetChanges()!=null)
				{
					try
					{
						this.link.UpdateDataBase(this.ds,sendtable);
						this.txt_Xm.ReadOnly = this.txt_Xh.ReadOnly = this.txt_tel.ReadOnly = this.txt_sex.ReadOnly = this.txt_addr.ReadOnly = this.txt_csrq.ReadOnly = this.txt_qqhm.ReadOnly = true;
						this.txt_count.Text = ds.Tables[0].Rows.Count.ToString();
					}
					catch(Exception express)
					{
						MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
						this.myTable .RejectChanges();
					}
				}
				return;
			}
		}

		private void btn_add_Click(object sender, System.EventArgs e)
		{
			this.txt_Xm.ReadOnly = this.txt_Xh.ReadOnly = this.txt_tel.ReadOnly = this.txt_sex.ReadOnly = this.txt_addr.ReadOnly = this.txt_csrq.ReadOnly = this.txt_qqhm.ReadOnly = false;
			cmAmend.AddNew();
			return;
		}

		private void btn_save_Click(object sender, System.EventArgs e)
		{
			cmAmend.EndCurrentEdit();
			if(myTable.GetChanges()!=null)
			{
				try
				{
					this.link.UpdateDataBase(this.ds,sendtable);
					this.txt_Xm.ReadOnly = this.txt_Xh.ReadOnly = this.txt_tel.ReadOnly = this.txt_sex.ReadOnly = this.txt_addr.ReadOnly = this.txt_csrq.ReadOnly = this.txt_qqhm.ReadOnly = true;
				}
				catch(Exception express)
				{
					MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
					this.myTable .RejectChanges();
				}
			}
			this.txt_Xm.ReadOnly = this.txt_Xh.ReadOnly = this.txt_tel.ReadOnly = this.txt_sex.ReadOnly = this.txt_addr.ReadOnly = this.txt_csrq.ReadOnly = this.txt_qqhm.ReadOnly = true;
			this.txt_count.Text = ds.Tables[0].Rows.Count.ToString();
		}

		private void btn_syt_Click(object sender, System.EventArgs e)
		{
			if(cmAmend.Position>0)
			{
				this.dataGrid1.UnSelect(cmAmend.Position);
				cmAmend.Position--;
				this.dataGrid1.Select(cmAmend.Position);
				this.dataGrid1.CurrentRowIndex=cmAmend.Position;
			}
			return;
		}

		private void btn_xyt_Click(object sender, System.EventArgs e)
		{
			if(cmAmend.Position<cmAmend.Count-1)
			{
				this.dataGrid1.UnSelect(cmAmend.Position);
				cmAmend.Position++;
				this.dataGrid1.Select(cmAmend.Position);
				this.dataGrid1.CurrentRowIndex=cmAmend.Position;
				return;
			}
		}

		private void btn_top_Click(object sender, System.EventArgs e)
		{
			try
			{
				this.dataGrid1.UnSelect(cmAmend.Position);//取消原选中的行
				cmAmend.Position=0;
				this.dataGrid1.Select(cmAmend.Position);//选中当前行
				this.dataGrid1.CurrentRowIndex=cmAmend.Position;//移动表头指示图标
				return;
			}
			catch
			{
				MessageBox.Show("没有数据!");
			}
		}

		private void btn_bottom_Click(object sender, System.EventArgs e)
		{
			try
			{
				this.dataGrid1.UnSelect(cmAmend.Position);
				cmAmend.Position=cmAmend.Count-1;
				this.dataGrid1.Select(cmAmend.Position);
				this.dataGrid1.CurrentRowIndex=cmAmend.Position;
				return;	
			}
			catch
			{
				MessageBox.Show("没有数据!");
			}
		}

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

⌨️ 快捷键说明

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