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

📄 frmreport.cs

📁 基于c#
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace 教务管理系统
{
	/// <summary>
	/// frmReport 的摘要说明。
	/// </summary>
	public class frmReport : System.Windows.Forms.Form
	{
		internal System.Windows.Forms.GroupBox grbSearch;
		internal System.Windows.Forms.Button btnPrint;
		internal System.Windows.Forms.Label Label3;
		internal System.Windows.Forms.TextBox txbClass;
		internal System.Windows.Forms.TextBox txbName;
		internal System.Windows.Forms.Label Label2;
		internal System.Windows.Forms.Label Label1;
		internal System.Windows.Forms.TextBox txbId;
		internal System.Windows.Forms.DataGrid dgdList;

		private DataTable dtData;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmReport()
		{
			//
			// 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.grbSearch = new System.Windows.Forms.GroupBox();
			this.btnPrint = new System.Windows.Forms.Button();
			this.Label3 = new System.Windows.Forms.Label();
			this.txbClass = new System.Windows.Forms.TextBox();
			this.txbName = new System.Windows.Forms.TextBox();
			this.Label2 = new System.Windows.Forms.Label();
			this.Label1 = new System.Windows.Forms.Label();
			this.txbId = new System.Windows.Forms.TextBox();
			this.dgdList = new System.Windows.Forms.DataGrid();
			this.grbSearch.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dgdList)).BeginInit();
			this.SuspendLayout();
			// 
			// grbSearch
			// 
			this.grbSearch.Controls.Add(this.txbClass);
			this.grbSearch.Controls.Add(this.btnPrint);
			this.grbSearch.Controls.Add(this.Label3);
			this.grbSearch.Controls.Add(this.txbName);
			this.grbSearch.Controls.Add(this.Label2);
			this.grbSearch.Controls.Add(this.Label1);
			this.grbSearch.Controls.Add(this.txbId);
			this.grbSearch.Dock = System.Windows.Forms.DockStyle.Top;
			this.grbSearch.Location = new System.Drawing.Point(0, 0);
			this.grbSearch.Name = "grbSearch";
			this.grbSearch.Size = new System.Drawing.Size(424, 36);
			this.grbSearch.TabIndex = 4;
			this.grbSearch.TabStop = false;
			this.grbSearch.Text = "学生信息";
			// 
			// btnPrint
			// 
			this.btnPrint.Location = new System.Drawing.Point(336, 9);
			this.btnPrint.Name = "btnPrint";
			this.btnPrint.Size = new System.Drawing.Size(62, 22);
			this.btnPrint.TabIndex = 7;
			this.btnPrint.Text = "打印";
			this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
			// 
			// Label3
			// 
			this.Label3.Location = new System.Drawing.Point(256, 15);
			this.Label3.Name = "Label3";
			this.Label3.Size = new System.Drawing.Size(26, 14);
			this.Label3.TabIndex = 6;
			this.Label3.Text = "班级";
			// 
			// txbClass
			// 
			this.txbClass.Location = new System.Drawing.Point(280, 8);
			this.txbClass.Name = "txbClass";
			this.txbClass.ReadOnly = true;
			this.txbClass.Size = new System.Drawing.Size(47, 20);
			this.txbClass.TabIndex = 5;
			this.txbClass.Text = "";
			// 
			// txbName
			// 
			this.txbName.Location = new System.Drawing.Point(200, 10);
			this.txbName.Name = "txbName";
			this.txbName.ReadOnly = true;
			this.txbName.Size = new System.Drawing.Size(47, 20);
			this.txbName.TabIndex = 4;
			this.txbName.Text = "";
			// 
			// Label2
			// 
			this.Label2.Location = new System.Drawing.Point(176, 15);
			this.Label2.Name = "Label2";
			this.Label2.Size = new System.Drawing.Size(26, 14);
			this.Label2.TabIndex = 3;
			this.Label2.Text = "姓名";
			// 
			// Label1
			// 
			this.Label1.Location = new System.Drawing.Point(48, 15);
			this.Label1.Name = "Label1";
			this.Label1.Size = new System.Drawing.Size(32, 14);
			this.Label1.TabIndex = 2;
			this.Label1.Text = "学号";
			// 
			// txbId
			// 
			this.txbId.Location = new System.Drawing.Point(88, 10);
			this.txbId.Name = "txbId";
			this.txbId.Size = new System.Drawing.Size(73, 20);
			this.txbId.TabIndex = 1;
			this.txbId.Text = "";
			this.txbId.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txbId_KeyDown);
			// 
			// dgdList
			// 
			this.dgdList.CaptionVisible = false;
			this.dgdList.DataMember = "";
			this.dgdList.Dock = System.Windows.Forms.DockStyle.Fill;
			this.dgdList.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dgdList.Location = new System.Drawing.Point(0, 36);
			this.dgdList.Name = "dgdList";
			this.dgdList.Size = new System.Drawing.Size(424, 226);
			this.dgdList.TabIndex = 5;
			// 
			// frmReport
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(424, 262);
			this.Controls.Add(this.dgdList);
			this.Controls.Add(this.grbSearch);
			this.Name = "frmReport";
			this.Text = "打印成绩单";
			this.grbSearch.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dgdList)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void btnPrint_Click(object sender, System.EventArgs e)
		{
			frmPrint childFrm = new frmPrint( dtData );
			childFrm.ShowDialog();
		}

			private void txbId_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
			{
				if ( e.KeyCode == Keys.Enter && txbId.Text.Trim().Length != 0 )
				{
					DataBase db = new DataBase();
					DataView dv;
					string strSQL = "select 姓名, 班级名称, 学籍编号 from";
					strSQL += " 学生信息 as a, 班级信息 as b where a.班级编号=";
					strSQL += "b.班级编号 and 学号='" + this.txbId.Text.Trim() + "'";
					dv = db.RunSelectSQL( strSQL );
					if ( dv.Count == 0 )
					{
						MessageBox.Show( "学号错误!" );
						return;
					}
					this.txbName.Text = dv[ 0 ][ "姓名" ].ToString();
					this.txbClass.Text = dv[ 0 ][ "班级名称" ].ToString();
					strSQL = "select b.课程名称,b.开课系别,b.教师,a.成绩 from ";
					strSQL += "成绩表 as a,  课程信息 as b where a.课程编号=";
					strSQL += "b.课程编号  and 学号='" + this.txbId.Text.Trim();
					strSQL += " ' order by a.课程编号";
					dv = db.RunSelectSQL( strSQL );
					this.dgdList.DataSource = dv;
					dv.AllowDelete = false;
					dv.AllowNew = false;
					dv.AllowEdit = false;
					dtData = dv.Table;
					this.dgdList.AllowSorting = false;
					db.Dispose();
				}
			
			}
	}
}

⌨️ 快捷键说明

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