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

📄 courseelect2.cs

📁 数据库的课程设计作业。管理有关学生、课程的基本信息
💻 CS
📖 第 1 页 / 共 2 页
字号:
			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, "上课结束日期"));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "workstation id=\"IBM-1A298E66873\";packet size=4096;integrated security=SSPI;initia" +
				"l catalog=\"study&teach\";persist security info=False";
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 学号, 课程号, 成绩, 上课起始日期, 上课结束日期 FROM 选课表";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(16, 432);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(88, 24);
			this.button1.TabIndex = 2;
			this.button1.Text = "成批选课";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(16, 16);
			this.button2.Name = "button2";
			this.button2.TabIndex = 3;
			this.button2.Text = "退出";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// dataGrid2
			// 
			this.dataGrid2.CaptionVisible = false;
			this.dataGrid2.DataMember = "";
			this.dataGrid2.DataSource = this.dataSet81.课程表;
			this.dataGrid2.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid2.Location = new System.Drawing.Point(272, 272);
			this.dataGrid2.Name = "dataGrid2";
			this.dataGrid2.ReadOnly = true;
			this.dataGrid2.Size = new System.Drawing.Size(280, 184);
			this.dataGrid2.TabIndex = 4;
			// 
			// dataSet81
			// 
			this.dataSet81.DataSetName = "DataSet8";
			this.dataSet81.Locale = new System.Globalization.CultureInfo("zh-CN");
			// 
			// da2
			// 
			this.da2.DeleteCommand = this.sqlDeleteCommand1;
			this.da2.InsertCommand = this.sqlInsertCommand2;
			this.da2.SelectCommand = this.sqlSelectCommand2;
			this.da2.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("学分", "学分"),
																																																 new System.Data.Common.DataColumnMapping("学时", "学时"),
																																																 new System.Data.Common.DataColumnMapping("上课地点", "上课地点"),
																																																 new System.Data.Common.DataColumnMapping("是否本学期课程", "是否本学期课程")})});
			this.da2.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_学时 OR @Original_学时 IS NULL AND 学时 IS NULL) AND (必修或选修 = @Original_必修或选修) AND (教师 = @Original_教师 OR @Original_教师 IS NULL AND 教师 IS NULL) AND (是否本学期课程 = @Original_是否本学期课程 OR @Original_是否本学期课程 IS NULL AND 是否本学期课程 IS NULL) 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.VarChar, 40, 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.Real, 4, 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));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_必修或选修", System.Data.SqlDbType.VarChar, 6, 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, 50, 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, 2, 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, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "课程名", System.Data.DataRowVersion.Original, null));
			// 
			// sqlInsertCommand2
			// 
			this.sqlInsertCommand2.CommandText = "INSERT INTO 课程表(课程号, 课程名, 必修或选修, 教师, 学分, 学时, 上课地点, 是否本学期课程) VALUES (@课程号, @课程名, @" +
				"必修或选修, @教师, @学分, @学时, @上课地点, @是否本学期课程); SELECT 课程号, 课程名, 必修或选修, 教师, 学分, 学时, 上课地点" +
				", 是否本学期课程 FROM 课程表 WHERE (课程号 = @课程号)";
			this.sqlInsertCommand2.Connection = this.sqlConnection1;
			this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@课程号", System.Data.SqlDbType.VarChar, 8, "课程号"));
			this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@课程名", System.Data.SqlDbType.VarChar, 40, "课程名"));
			this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@必修或选修", System.Data.SqlDbType.VarChar, 6, "必修或选修"));
			this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@教师", System.Data.SqlDbType.VarChar, 50, "教师"));
			this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学分", System.Data.SqlDbType.Real, 4, "学分"));
			this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学时", System.Data.SqlDbType.Int, 4, "学时"));
			this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@上课地点", System.Data.SqlDbType.VarChar, 40, "上课地点"));
			this.sqlInsertCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@是否本学期课程", System.Data.SqlDbType.VarChar, 2, "是否本学期课程"));
			// 
			// sqlSelectCommand2
			// 
			this.sqlSelectCommand2.CommandText = "SELECT 课程号, 课程名, 必修或选修, 教师, 学分, 学时, 上课地点, 是否本学期课程 FROM 课程表";
			this.sqlSelectCommand2.Connection = this.sqlConnection1;
			// 
			// 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_学时 OR @Original_学时 IS NULL AND 学时 IS NULL) AND (必修或选修 = @Original_必修或选修) AND (教师 = @Original_教师 OR @Original_教师 IS NULL AND 教师 IS NULL) AND (是否本学期课程 = @Original_是否本学期课程 OR @Original_是否本学期课程 IS NULL AND 是否本学期课程 IS NULL) 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, 40, "课程名"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@必修或选修", System.Data.SqlDbType.VarChar, 6, "必修或选修"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@教师", System.Data.SqlDbType.VarChar, 50, "教师"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学分", System.Data.SqlDbType.Real, 4, "学分"));
			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.VarChar, 40, "上课地点"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@是否本学期课程", System.Data.SqlDbType.VarChar, 2, "是否本学期课程"));
			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.VarChar, 40, 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.Real, 4, 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.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_必修或选修", System.Data.SqlDbType.VarChar, 6, 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, 50, 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, 2, 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, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "课程名", System.Data.DataRowVersion.Original, null));
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 48);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(64, 23);
			this.label1.TabIndex = 10;
			this.label1.Text = "课程号";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// txt2
			// 
			this.txt2.Location = new System.Drawing.Point(104, 56);
			this.txt2.Name = "txt2";
			this.txt2.Size = new System.Drawing.Size(104, 21);
			this.txt2.TabIndex = 11;
			this.txt2.Text = "";
			// 
			// CourseElect2
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(576, 478);
			this.Controls.Add(this.dataGrid2);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.groupBox1);
			this.Name = "CourseElect2";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "选课[必修课]";
			this.Load += new System.EventHandler(this.CourseElect2_Load);
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataSet81)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

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

		private void button1_Click(object sender, System.EventArgs e)
		{
			
			SqlConnection cn = new SqlConnection ("workstation id=locolhost;integrated Security=sspi;database=study&teach;");
			cn.Open();
            SqlCommand cmd=cn.CreateCommand();
			cmd.CommandType=CommandType.StoredProcedure;
            cmd.CommandText="sf_成批选课";
			SqlParameter classname=cmd.Parameters.Add("@班级名",System.Data.SqlDbType.VarChar);
			classname.Direction=ParameterDirection.Input;
			classname.Value=this.txt1.Text;
			SqlParameter coursenumber=cmd.Parameters.Add("@课程编号",System.Data.SqlDbType.VarChar);
			coursenumber.Direction=ParameterDirection.Input;
			coursenumber.Value=this.txt2.Text;
			
			SqlParameter starttime=cmd.Parameters.Add("@起始日期",System.Data.SqlDbType.DateTime);
			starttime.Direction=ParameterDirection.Input;
			starttime.Value=this.dateTimePicker1.Value;
			SqlParameter finishtime=cmd.Parameters.Add("@结束日期",System.Data.SqlDbType.DateTime);
			finishtime.Direction=ParameterDirection.Input;
			finishtime.Value=this.dateTimePicker2.Value;
			cmd.ExecuteNonQuery();
			da1.Update(dataSet11.选课表);
			dataSet11.Clear();
			da1.Fill(dataSet11);
		}

		private void CourseElect2_Load(object sender, System.EventArgs e)
		{
			da1.Fill(dataSet11);
			da2.Fill(dataSet81);
		}

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

		private void button2_Click(object sender, System.EventArgs e)
		{
			this.Close(); 
		}
	}
}

⌨️ 快捷键说明

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