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

📄 coursememberlist.cs

📁 数据库的课程设计作业。管理有关学生、课程的基本信息
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace 教务管理系统1
{
	/// <summary>
	/// CoursememberList 的摘要说明。
	/// </summary>
	public class CoursememberList : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TextBox txt1;
		private System.Windows.Forms.Label label1;
		private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
		private System.Windows.Forms.Button button1;
		private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
		private System.Data.SqlClient.SqlConnection sqlConnection1;
		private System.Data.SqlClient.SqlDataAdapter da;
		private 教务管理系统1.DataSet4 ds;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public CoursememberList()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.txt1 = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
			this.button1 = new System.Windows.Forms.Button();
			this.da = new System.Data.SqlClient.SqlDataAdapter();
			this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
			this.ds = new 教务管理系统1.DataSet4();
			((System.ComponentModel.ISupportInitialize)(this.ds)).BeginInit();
			this.SuspendLayout();
			// 
			// txt1
			// 
			this.txt1.Location = new System.Drawing.Point(184, 16);
			this.txt1.Name = "txt1";
			this.txt1.TabIndex = 0;
			this.txt1.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(40, 16);
			this.label1.Name = "label1";
			this.label1.TabIndex = 1;
			this.label1.Text = "请输入课程名";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// crystalReportViewer1
			// 
			this.crystalReportViewer1.ActiveViewIndex = -1;
			this.crystalReportViewer1.DisplayGroupTree = false;
			this.crystalReportViewer1.Location = new System.Drawing.Point(0, 56);
			this.crystalReportViewer1.Name = "crystalReportViewer1";
			this.crystalReportViewer1.ReportSource = null;
			this.crystalReportViewer1.Size = new System.Drawing.Size(536, 384);
			this.crystalReportViewer1.TabIndex = 2;
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(360, 16);
			this.button1.Name = "button1";
			this.button1.TabIndex = 3;
			this.button1.Text = "打印名单";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// da
			// 
			this.da.SelectCommand = this.sqlSelectCommand1;
			this.da.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("Expr1", "Expr1"),
																																																new System.Data.Common.DataColumnMapping("课程号", "课程号"),
																																																new System.Data.Common.DataColumnMapping("Expr2", "Expr2")})});
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 课程表.课程名, 学生表.姓名, 选课表.学号, 学生表.学号 AS Expr1, 课程表.课程号, 选课表.课程号 AS Expr2 FROM 选" +
				"课表 INNER JOIN 课程表 ON 课程表.课程号 = 选课表.课程号 INNER JOIN 学生表 ON 选课表.学号 = 学生表.学号 WHERE (" +
				"课程表.课程名 LIKE @Param2)";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param2", System.Data.SqlDbType.VarChar, 40, "课程名"));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "workstation id=\"IBM-1A298E66873\";packet size=4096;integrated security=SSPI;initia" +
				"l catalog=\"study&teach\";persist security info=False";
			// 
			// ds
			// 
			this.ds.DataSetName = "DataSet4";
			this.ds.Locale = new System.Globalization.CultureInfo("zh-CN");
			// 
			// CoursememberList
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(536, 438);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.crystalReportViewer1);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.txt1);
			this.Name = "CoursememberList";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "课程选修名单";
			((System.ComponentModel.ISupportInitialize)(this.ds)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			CrystalReport2 rpt=new CrystalReport2();
			da.SelectCommand.Parameters[0].Value=txt1.Text.Trim();
			da.Fill(ds);
			//连接报表数据源
			rpt.SetDataSource(ds.Tables[0]);
			crystalReportViewer1.ReportSource=rpt;
		}
	}
}

⌨️ 快捷键说明

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