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

📄 登分.cs

📁 数据库的课程设计作业。管理有关学生、课程的基本信息
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.toolBarButton4.Text = "取消";
			this.toolBarButton4.ToolTipText = "取消";
			// 
			// toolBarButton5
			// 
			this.toolBarButton5.Text = "提交";
			this.toolBarButton5.ToolTipText = "提交";
			// 
			// toolBarButton6
			// 
			this.toolBarButton6.Text = "退出";
			this.toolBarButton6.ToolTipText = "退出";
			// 
			// txt3
			// 
			this.txt3.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "选课表.成绩"));
			this.txt3.Location = new System.Drawing.Point(144, 120);
			this.txt3.Name = "txt3";
			this.txt3.ReadOnly = true;
			this.txt3.Size = new System.Drawing.Size(112, 21);
			this.txt3.TabIndex = 5;
			this.txt3.Text = "";
			// 
			// dataGrid1
			// 
			this.dataGrid1.CaptionVisible = false;
			this.dataGrid1.DataMember = "";
			this.dataGrid1.DataSource = this.dataSet11.选课表;
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(32, 152);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.ReadOnly = true;
			this.dataGrid1.Size = new System.Drawing.Size(496, 232);
			this.dataGrid1.TabIndex = 6;
			// 
			// da1
			// 
			this.da1.DeleteCommand = this.sqlDeleteCommand1;
			this.da1.InsertCommand = this.sqlInsertCommand1;
			this.da1.SelectCommand = this.sqlSelectCommand1;
			this.da1.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("上课起始日期", "上课起始日期"),
																																																 new System.Data.Common.DataColumnMapping("上课结束日期", "上课结束日期")})});
			this.da1.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = @"DELETE FROM 选课表 WHERE (课程号 = @Original_课程号) AND (上课结束日期 = @Original_上课结束日期 OR @Original_上课结束日期 IS NULL AND 上课结束日期 IS NULL) AND (上课起始日期 = @Original_上课起始日期 OR @Original_上课起始日期 IS NULL AND 上课起始日期 IS NULL) AND (学号 = @Original_学号) AND (成绩 = @Original_成绩 OR @Original_成绩 IS NULL AND 成绩 IS NULL)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_课程号", System.Data.SqlDbType.VarChar, 8, 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.DateTime, 8, 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.DateTime, 8, 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, 8, 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.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "成绩", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "workstation id=localhost;packet size=4096;integrated security=SSPI;initial catalo" +
				"g=\"study&teach\";persist security info=False";
			// 
			// 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, 8, "学号"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@课程号", System.Data.SqlDbType.VarChar, 8, "课程号"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@成绩", System.Data.SqlDbType.Int, 4, "成绩"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@上课起始日期", System.Data.SqlDbType.DateTime, 8, "上课起始日期"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@上课结束日期", System.Data.SqlDbType.DateTime, 8, "上课结束日期"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 学号, 课程号, 成绩, 上课起始日期, 上课结束日期 FROM 选课表 WHERE (学号 LIKE @Param3) AND (课程号 LIKE" +
				" @Param4)";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param3", System.Data.SqlDbType.VarChar, 8, "学号"));
			this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param4", System.Data.SqlDbType.VarChar, 8, "课程号"));
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = @"UPDATE 选课表 SET 学号 = @学号, 课程号 = @课程号, 成绩 = @成绩, 上课起始日期 = @上课起始日期, 上课结束日期 = @上课结束日期 WHERE (课程号 = @Original_课程号) AND (上课结束日期 = @Original_上课结束日期 OR @Original_上课结束日期 IS NULL AND 上课结束日期 IS NULL) AND (上课起始日期 = @Original_上课起始日期 OR @Original_上课起始日期 IS NULL AND 上课起始日期 IS NULL) AND (学号 = @Original_学号) AND (成绩 = @Original_成绩 OR @Original_成绩 IS NULL AND 成绩 IS NULL); SELECT 学号, 课程号, 成绩, 上课起始日期, 上课结束日期 FROM 选课表 WHERE (课程号 = @课程号)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学号", System.Data.SqlDbType.VarChar, 8, "学号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@课程号", System.Data.SqlDbType.VarChar, 8, "课程号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@成绩", System.Data.SqlDbType.Int, 4, "成绩"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@上课起始日期", System.Data.SqlDbType.DateTime, 8, "上课起始日期"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@上课结束日期", System.Data.SqlDbType.DateTime, 8, "上课结束日期"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_课程号", System.Data.SqlDbType.VarChar, 8, 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.DateTime, 8, 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.DateTime, 8, 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, 8, 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.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "成绩", System.Data.DataRowVersion.Original, null));
			// 
			// 登分
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(576, 406);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.txt3);
			this.Controls.Add(this.toolBar1);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.groupBox1);
			this.Name = "登分";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "登分";
			this.Load += new System.EventHandler(this.登分_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void 登分_Load(object sender, System.EventArgs e)
		{
			da1.SelectCommand.Parameters[0].Value="%%";
			da1.SelectCommand.Parameters[1].Value="%%";
			cmOrders=(CurrencyManager) BindingContext[dataSet11,"选课表"];
		}

		private void btnSearch_Click(object sender, System.EventArgs e)
		{
			da1.SelectCommand.Parameters[0].Value="%%";
			da1.SelectCommand.Parameters[1].Value="%%";
			if(txt1.Text.Trim()!="")
			{
				da1.SelectCommand.Parameters[0].Value="%"+txt1.Text.Trim()+"%";
				txt1.Text=txt1.Text;
			}
			if(txt2.Text!="")
			{
				da1.SelectCommand.Parameters[1].Value="%"+txt2.Text+"%";
				txt2.Text=txt2.Text;
			}
			dataSet11.选课表.Clear();//刷新数据集
			da1.Fill(dataSet11);
		}

		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			if (e.Button.ToolTipText=="登记成绩")
			{
				SetModifyMode(true);
			}
			if (e.Button.ToolTipText=="修改成绩")
			{
				SetModifyMode(true);
			}
			if (e.Button.ToolTipText=="提交")
			{
				if(txt3.Text.Trim()=="")
				{
					MessageBox.Show("请输入成绩","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
					return;
				}
				cmOrders.EndCurrentEdit();
				if(dataSet11.GetChanges()!=null)
				{
					try
					{
						da1.Update(dataSet11.选课表);
						SetModifyMode(false);
					}
					catch(Exception express)
					{
						MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
						dataSet11.RejectChanges();
					}
				}
				return;
			}
			if (e.Button.ToolTipText=="取消")
			{
				try
				{
					cmOrders.CancelCurrentEdit();
					SetModifyMode(false);
				}
				catch(Exception express)
				{
					MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
				}
				return;
			}
			if (e.Button.ToolTipText=="退出")
				this.Close();
		}
		private void SetModifyMode(bool blnEdit)
		{
			txt3.ReadOnly=!blnEdit;
			btnSearch.Enabled=!blnEdit;
		}
	}
}

⌨️ 快捷键说明

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