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

📄 teacaddgrade.cs

📁 简单的教师录入成绩系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.button2.TabIndex = 11;
			this.button2.Text = "修改";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.label2);
			this.groupBox2.Controls.Add(this.textBox2);
			this.groupBox2.Controls.Add(this.label3);
			this.groupBox2.Controls.Add(this.textBox3);
			this.groupBox2.Controls.Add(this.label4);
			this.groupBox2.Controls.Add(this.textBox4);
			this.groupBox2.Location = new System.Drawing.Point(424, 176);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(272, 192);
			this.groupBox2.TabIndex = 12;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "录入成绩";
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(432, 400);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(104, 32);
			this.button3.TabIndex = 13;
			this.button3.Text = "下一个";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// sqlDataAdapter1
			// 
			this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
			this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
			this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
			this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																									  new System.Data.Common.DataTableMapping("Table", "选课信息表", new System.Data.Common.DataColumnMapping[] {
																																																			   new System.Data.Common.DataColumnMapping("序号", "序号"),
																																																			   new System.Data.Common.DataColumnMapping("学号", "学号"),
																																																			   new System.Data.Common.DataColumnMapping("课程编号", "课程编号"),
																																																			   new System.Data.Common.DataColumnMapping("成绩", "成绩")})});
			this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = "DELETE FROM 选课信息表 WHERE (序号 = @Original_序号) AND (学号 = @Original_学号) AND (成绩 = @Or" +
				"iginal_成绩 OR @Original_成绩 IS NULL AND 成绩 IS NULL) AND (课程编号 = @Original_课程编号)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_序号", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "序号", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_学号", System.Data.SqlDbType.VarChar, 16, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "学号", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_成绩", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "成绩", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_课程编号", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "课程编号", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "workstation id=3366359E777E4EE;packet size=4096;integrated security=SSPI;data sou" +
				"rce=3366359E777E4EE;persist security info=False;initial catalog=jiaoshi";
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = "INSERT INTO 选课信息表(序号, 学号, 课程编号, 成绩) VALUES (@序号, @学号, @课程编号, @成绩); SELECT 序号, 学号," +
				" 课程编号, 成绩 FROM 选课信息表 WHERE (序号 = @序号)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@序号", System.Data.SqlDbType.VarChar, 10, "序号"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学号", System.Data.SqlDbType.VarChar, 16, "学号"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@课程编号", System.Data.SqlDbType.VarChar, 10, "课程编号"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@成绩", System.Data.SqlDbType.VarChar, 10, "成绩"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 序号, 学号, 课程编号, 成绩 FROM 选课信息表 WHERE (课程编号 LIKE @Param2)";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param2", System.Data.SqlDbType.VarChar, 10, "课程编号"));
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = "UPDATE 选课信息表 SET 序号 = @序号, 学号 = @学号, 课程编号 = @课程编号, 成绩 = @成绩 WHERE (序号 = @Original" +
				"_序号) AND (学号 = @Original_学号) AND (成绩 = @Original_成绩 OR @Original_成绩 IS NULL AND " +
				"成绩 IS NULL) AND (课程编号 = @Original_课程编号); SELECT 序号, 学号, 课程编号, 成绩 FROM 选课信息表 WHER" +
				"E (序号 = @序号)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@序号", System.Data.SqlDbType.VarChar, 10, "序号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学号", System.Data.SqlDbType.VarChar, 16, "学号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@课程编号", System.Data.SqlDbType.VarChar, 10, "课程编号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@成绩", System.Data.SqlDbType.VarChar, 10, "成绩"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_序号", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "序号", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_学号", System.Data.SqlDbType.VarChar, 16, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "学号", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_成绩", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "成绩", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_课程编号", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "课程编号", System.Data.DataRowVersion.Original, null));
			// 
			// button4
			// 
			this.button4.Location = new System.Drawing.Point(440, 472);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(96, 32);
			this.button4.TabIndex = 14;
			this.button4.Text = "保存";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(568, 472);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(112, 48);
			this.label5.TabIndex = 15;
			this.label5.Text = "修改完后,也就是录完,请保存";
			// 
			// TeacAddGrade
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(712, 533);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.button4);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.toolBar1);
			this.Controls.Add(this.dataGrid1);
			this.Name = "TeacAddGrade";
			this.Text = "TeacAddGrade";
			this.Load += new System.EventHandler(this.TeacAddGrade_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataSet81)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			this.sqlDataAdapter1.SelectCommand.Parameters[0].Value = "%%";
			if(this.textBox1.Text != "")
			{
				this.sqlDataAdapter1.SelectCommand.Parameters[0].Value = "%" + this.textBox1.Text + "%";
			}
			this.dataSet81.Clear ();
			this.sqlDataAdapter1.Fill (this.dataSet81);
		}

		private void TeacAddGrade_Load(object sender, System.EventArgs e)
		{
			this.sqlDataAdapter1.SelectCommand.Parameters[0].Value = "%%";
			
			this.textBox2.Enabled = false;
			this.textBox3.Enabled = false;
//			this.textBox5.Enabled = false;
			
			this.cmOrders = (CurrencyManager) BindingContext[dataSet81,"选课信息表"];
		}

		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			if(e.Button == this.toolBarButton1)
			{
				try
				{
					this.dataGrid1.UnSelect(cmOrders.Position); //取消原选中的行
					cmOrders.Position = 0;
					this.dataGrid1.Select(cmOrders.Position); //选中当前行
					this.dataGrid1.CurrentRowIndex = cmOrders.Position; //移动表头指示图标
					return;
				}
				catch(Exception ex)
				{
					MessageBox.Show(ex.Message);
				}
			}
			if(e.Button == this.toolBarButton2)
			{
				if (cmOrders.Position >= 0)
				{
					this.dataGrid1.UnSelect(cmOrders.Position); 
					cmOrders.Position++;
					this.dataGrid1.Select(cmOrders.Position);      
					this.dataGrid1.CurrentRowIndex = cmOrders.Position; 
				}
				return;
			}
			if(e.Button == this.toolBarButton3)
			{
				if (cmOrders.Position >= 0)
				{
					this.dataGrid1.UnSelect(cmOrders.Position); 
					cmOrders.Position--;
					this.dataGrid1.Select(cmOrders.Position);      
					this.dataGrid1.CurrentRowIndex = cmOrders.Position; 
				}
				return;
			}
			if(e.Button == this.toolBarButton4)
			{
				this.dataGrid1.UnSelect(cmOrders.Position); 
				cmOrders.Position = cmOrders.Count-1;
				this.dataGrid1.Select(cmOrders.Position);       
				this.dataGrid1.CurrentRowIndex = cmOrders.Position; 
				return;
			}
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			cmOrders.EndCurrentEdit();
			if(dataSet81.GetChanges()!=null)
			{
				float ss;
				ss = Convert.ToInt32(this.textBox4.Text);
				if(  ss > 0 && ss <= 100)
				{
					try
					{
						this.sqlDataAdapter1.Update(dataSet81);
						//					SetModifyMode(false);
					}
					catch(Exception express)
					{
						MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
						dataSet81.RejectChanges();
					}
				}
				else
				{
					MessageBox.Show("你输入的数字小于零或大于100","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
					this.textBox4.Clear();
				}
			}
			
			
			
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
			if (cmOrders.Position >= 0)
			{
				this.dataGrid1.UnSelect(cmOrders.Position); 
				cmOrders.Position++;
				this.dataGrid1.Select(cmOrders.Position);      
				this.dataGrid1.CurrentRowIndex = cmOrders.Position; 
			}
			return;
			
		}
		protected virtual void SetModifyMode(bool blnEdit)
		{
			this.button2.Enabled=!blnEdit;
		}
		protected virtual void SetDefaultValue()
		{
			return;
		}
		
		//------------供窗体重载,检查非空字段-----------------
		protected virtual bool CheckNotNull()
		{
			return(true);
		}

		private void button4_Click(object sender, System.EventArgs e)
		{
			this.textBox4.Enabled = false;
		}
	}
}

⌨️ 快捷键说明

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