- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
ViewScore.cs
资源名称:VCSDB.rar [点击查看]
上传用户:hjieqiu
上传日期:2013-05-11
资源大小:16494k
文件大小:12k
源码类别:
企业管理
开发平台:
C#
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using System.Data.SqlClient;
- namespace 教务管理系统
- {
- /// <summary>
- /// ViewScore 的摘要说明。
- /// </summary>
- public class ViewScore : System.Windows.Forms.Form
- {
- private string stuID;//保存学生学号
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.TextBox txt1;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.TextBox txt2;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.TextBox txt3;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.DataGrid dataGrid1;
- private System.Data.SqlClient.SqlDataAdapter da1;
- private System.Data.SqlClient.SqlConnection sqlConnection1;
- protected System.Windows.Forms.Button btnPrint;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
- private 教务管理系统.DataSet2 dataSet21;
- private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
- private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
- private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn2;
- private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn3;
- private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn4;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public ViewScore()
- {
- //
- // 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()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ViewScore));
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.btnPrint = new System.Windows.Forms.Button();
- this.txt1 = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.txt2 = new System.Windows.Forms.TextBox();
- this.label2 = new System.Windows.Forms.Label();
- this.txt3 = new System.Windows.Forms.TextBox();
- this.label4 = new System.Windows.Forms.Label();
- this.dataGrid1 = new System.Windows.Forms.DataGrid();
- this.dataSet21 = new 教务管理系统.DataSet2();
- this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
- this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn();
- this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn();
- this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn();
- this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn();
- this.da1 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
- this.groupBox1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataSet21)).BeginInit();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.btnPrint);
- this.groupBox1.Controls.Add(this.txt1);
- this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Controls.Add(this.txt2);
- this.groupBox1.Controls.Add(this.label2);
- this.groupBox1.Controls.Add(this.txt3);
- this.groupBox1.Controls.Add(this.label4);
- this.groupBox1.Location = new System.Drawing.Point(0, 8);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(616, 53);
- this.groupBox1.TabIndex = 2;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "输入学生信息";
- //
- // btnPrint
- //
- this.btnPrint.Image = ((System.Drawing.Image)(resources.GetObject("btnPrint.Image")));
- this.btnPrint.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.btnPrint.Location = new System.Drawing.Point(512, 22);
- this.btnPrint.Name = "btnPrint";
- this.btnPrint.Size = new System.Drawing.Size(72, 23);
- this.btnPrint.TabIndex = 2;
- this.btnPrint.Text = "打印";
- this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
- //
- // txt1
- //
- this.txt1.Location = new System.Drawing.Point(64, 24);
- this.txt1.Name = "txt1";
- this.txt1.TabIndex = 1;
- this.txt1.Text = "";
- this.txt1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txt1_KeyPress);
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(16, 28);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(48, 16);
- this.label1.TabIndex = 0;
- this.label1.Text = "学号";
- this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- //
- // txt2
- //
- this.txt2.Location = new System.Drawing.Point(224, 24);
- this.txt2.Name = "txt2";
- this.txt2.ReadOnly = true;
- this.txt2.TabIndex = 1;
- this.txt2.Text = "";
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(176, 28);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(48, 16);
- this.label2.TabIndex = 0;
- this.label2.Text = "姓名";
- this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- //
- // txt3
- //
- this.txt3.Location = new System.Drawing.Point(384, 24);
- this.txt3.Name = "txt3";
- this.txt3.ReadOnly = true;
- this.txt3.TabIndex = 1;
- this.txt3.Text = "";
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(336, 28);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(48, 16);
- this.label4.TabIndex = 0;
- this.label4.Text = "班级";
- this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- //
- // dataGrid1
- //
- this.dataGrid1.CaptionVisible = false;
- this.dataGrid1.DataMember = "成绩表";
- this.dataGrid1.DataSource = this.dataSet21;
- this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGrid1.Location = new System.Drawing.Point(0, 64);
- this.dataGrid1.Name = "dataGrid1";
- this.dataGrid1.ReadOnly = true;
- this.dataGrid1.Size = new System.Drawing.Size(616, 352);
- this.dataGrid1.TabIndex = 3;
- this.dataGrid1.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
- this.dataGridTableStyle1});
- //
- // dataSet21
- //
- this.dataSet21.DataSetName = "DataSet2";
- this.dataSet21.Locale = new System.Globalization.CultureInfo("zh-CN");
- //
- // dataGridTableStyle1
- //
- this.dataGridTableStyle1.DataGrid = this.dataGrid1;
- this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
- this.dataGridTextBoxColumn1,
- this.dataGridTextBoxColumn2,
- this.dataGridTextBoxColumn3,
- this.dataGridTextBoxColumn4});
- this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGridTableStyle1.MappingName = "成绩表";
- //
- // dataGridTextBoxColumn1
- //
- this.dataGridTextBoxColumn1.Format = "";
- this.dataGridTextBoxColumn1.FormatInfo = null;
- this.dataGridTextBoxColumn1.HeaderText = "课程名称";
- this.dataGridTextBoxColumn1.MappingName = "课程名称";
- this.dataGridTextBoxColumn1.Width = 200;
- //
- // dataGridTextBoxColumn2
- //
- this.dataGridTextBoxColumn2.Format = "";
- this.dataGridTextBoxColumn2.FormatInfo = null;
- this.dataGridTextBoxColumn2.HeaderText = "开课系别";
- this.dataGridTextBoxColumn2.MappingName = "开课系别";
- this.dataGridTextBoxColumn2.Width = 75;
- //
- // dataGridTextBoxColumn3
- //
- this.dataGridTextBoxColumn3.Format = "";
- this.dataGridTextBoxColumn3.FormatInfo = null;
- this.dataGridTextBoxColumn3.HeaderText = "成绩";
- this.dataGridTextBoxColumn3.MappingName = "成绩";
- this.dataGridTextBoxColumn3.Width = 75;
- //
- // dataGridTextBoxColumn4
- //
- this.dataGridTextBoxColumn4.Format = "";
- this.dataGridTextBoxColumn4.FormatInfo = null;
- this.dataGridTextBoxColumn4.HeaderText = "教师";
- this.dataGridTextBoxColumn4.MappingName = "教师";
- this.dataGridTextBoxColumn4.Width = 75;
- //
- // da1
- //
- 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("教师", "教师"),
- new System.Data.Common.DataColumnMapping("成绩", "成绩")})});
- //
- // sqlSelectCommand1
- //
- this.sqlSelectCommand1.CommandText = "SELECT a.学号, c.姓名, b.课程名称, b.开课系别, b.教师, a.成绩 FROM 成绩表 a INNER JOIN 课程信息 b ON a.课" +
- "程编号 = b.课程编号 INNER JOIN 学生信息 c ON a.学号 = c.学号 WHERE (a.学号 = @Param2)";
- this.sqlSelectCommand1.Connection = this.sqlConnection1;
- this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param2", System.Data.SqlDbType.VarChar, 14, "学号"));
- //
- // sqlConnection1
- //
- this.sqlConnection1.ConnectionString = "workstation id=localhost;packet size=4096;integrated security=SSPI;initial catalo" +
- "g=eisbook;persist security info=False";
- //
- // ViewScore
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(616, 421);
- this.Controls.Add(this.dataGrid1);
- this.Controls.Add(this.groupBox1);
- this.Name = "ViewScore";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "【成绩单打印】";
- this.groupBox1.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- //--------输入学号后回车,显示学生信息和其选课成绩信息---------------
- private void txt1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
- {
- if(e.KeyChar==13)
- {
- txt2.Clear();//先清空信息 txt3.Clear(); dataSet21.Clear(); string strConn="workstation id=localhost;Integrated Security=SSPI;database=eisbook;"; SqlConnection cn=new SqlConnection(strConn); cn.Open();
- SqlCommand cmd=cn.CreateCommand();
- cmd.CommandText="select a.姓名,b.班级名称,a.学籍编号 from 学生信息 a,班级信息 b "
- +"where(a.班级编号=b.班级编号)and(学号='"+txt1.Text.Trim()+"')";
- SqlDataReader dr=cmd.ExecuteReader();
- dr.Read();//读入学生的数据
- if(!dr.HasRows)//判断学号是否输入正确
- {
- MessageBox.Show("无此学生,请重新输入学号","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- dr.Close();
- return;
- }
- txt2.Text=dr.GetValue(0).ToString().Trim();//显示姓名
- txt3.Text=dr.GetValue(1).ToString().Trim();//显示班级名称
- dr.Close();
- da1.SelectCommand.Parameters[0].Value=txt1.Text.Trim();
- da1.Fill(dataSet21);
- }
- }
- //---------显示报表预览窗口------------
- private void btnPrint_Click(object sender, System.EventArgs e)
- {
- if(txt2.Text.Trim()=="")
- {
- MessageBox.Show("请先输入正确的学号","提示");
- return;
- }
- CrystalReport newfrm=new CrystalReport();
- CrystalReport.studentID=txt1.Text.Trim();//向报表预览窗体中传递学号
- newfrm.Text=txt2.Text+" 同学成绩表";
- newfrm.ShowDialog();
- }
- }
- }