📄 scorelist.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace 教务管理系统1
{
/// <summary>
/// ScoreList 的摘要说明。
/// </summary>
public class ScoreList : System.Windows.Forms.Form
{
public static string studentID;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private System.Data.SqlClient.SqlDataAdapter da;
private 教务管理系统1.DataSet3 ds;
private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public ScoreList()
{
//
// 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.da = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.ds = new 教务管理系统1.DataSet3();
this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
((System.ComponentModel.ISupportInitialize)(this.ds)).BeginInit();
this.SuspendLayout();
//
// 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("学分", "学分"),
new System.Data.Common.DataColumnMapping("教师", "教师"),
new System.Data.Common.DataColumnMapping("成绩", "成绩"),
new System.Data.Common.DataColumnMapping("课程号", "课程号"),
new System.Data.Common.DataColumnMapping("Expr1", "Expr1")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 学生表.学号, 学生表.姓名, 课程表.课程名, 课程表.学分, 课程表.教师, 选课表.成绩, 课程表.课程号, 选课表.课程号 AS Expr1" +
" 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, 8, "学号"));
//
// 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 = "DataSet3";
this.ds.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// crystalReportViewer1
//
this.crystalReportViewer1.ActiveViewIndex = -1;
this.crystalReportViewer1.DisplayGroupTree = false;
this.crystalReportViewer1.Location = new System.Drawing.Point(0, 0);
this.crystalReportViewer1.Name = "crystalReportViewer1";
this.crystalReportViewer1.ReportSource = null;
this.crystalReportViewer1.Size = new System.Drawing.Size(600, 368);
this.crystalReportViewer1.TabIndex = 0;
//
// ScoreList
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(600, 374);
this.Controls.Add(this.crystalReportViewer1);
this.Name = "ScoreList";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "成绩单打印";
this.Load += new System.EventHandler(this.ScoreList_Load);
((System.ComponentModel.ISupportInitialize)(this.ds)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void ScoreList_Load(object sender, System.EventArgs e)
{
CrystalReport1 rpt=new CrystalReport1();
da.SelectCommand.Parameters[0].Value=studentID;
da.Fill(ds);
//连接报表数据源
rpt.SetDataSource(ds.Tables[0]);
crystalReportViewer1.ReportSource=rpt;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -