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

📄 form_lssjyl.cs

📁 一个很简单的考试系统。实用性很强啊!数据库在里面
💻 CS
字号:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;

namespace bizdb
{
	/// <summary>
	/// Form_lssjyl 的摘要说明。
	/// </summary>
	public class Form_lssjyl : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label lbl_kcmc;
		private System.Windows.Forms.ComboBox cbb_kcmc;
		private System.Windows.Forms.Label lbl_sjcx1;
		private System.Windows.Forms.Label lbl_sjcx2;
		private System.Windows.Forms.Button btn_qd;
		private System.Windows.Forms.Button btn_yl;
		private System.Windows.Forms.Button btn_qx;
		private System.Windows.Forms.Button btn_dy;
		private System.Windows.Forms.Panel pnl_lssjyl1;
		private System.Windows.Forms.DataGrid dgd_lssjyl;
		private System.Windows.Forms.Panel pnl_lssjyl2;
		private System.Windows.Forms.DateTimePicker ddtp_sjcx1;
		private System.Windows.Forms.DateTimePicker ddtp_sjcx2;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

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

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

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

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.lbl_kcmc = new System.Windows.Forms.Label();
			this.pnl_lssjyl1 = new System.Windows.Forms.Panel();
			this.ddtp_sjcx2 = new System.Windows.Forms.DateTimePicker();
			this.ddtp_sjcx1 = new System.Windows.Forms.DateTimePicker();
			this.btn_qd = new System.Windows.Forms.Button();
			this.lbl_sjcx2 = new System.Windows.Forms.Label();
			this.cbb_kcmc = new System.Windows.Forms.ComboBox();
			this.lbl_sjcx1 = new System.Windows.Forms.Label();
			this.dgd_lssjyl = new System.Windows.Forms.DataGrid();
			this.pnl_lssjyl2 = new System.Windows.Forms.Panel();
			this.btn_dy = new System.Windows.Forms.Button();
			this.btn_qx = new System.Windows.Forms.Button();
			this.btn_yl = new System.Windows.Forms.Button();
			this.pnl_lssjyl1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dgd_lssjyl)).BeginInit();
			this.pnl_lssjyl2.SuspendLayout();
			this.SuspendLayout();
			// 
			// lbl_kcmc
			// 
			this.lbl_kcmc.Location = new System.Drawing.Point(8, 8);
			this.lbl_kcmc.Name = "lbl_kcmc";
			this.lbl_kcmc.Size = new System.Drawing.Size(56, 23);
			this.lbl_kcmc.TabIndex = 0;
			this.lbl_kcmc.Text = "课程名称";
			// 
			// pnl_lssjyl1
			// 
			this.pnl_lssjyl1.Controls.Add(this.ddtp_sjcx2);
			this.pnl_lssjyl1.Controls.Add(this.ddtp_sjcx1);
			this.pnl_lssjyl1.Controls.Add(this.btn_qd);
			this.pnl_lssjyl1.Controls.Add(this.lbl_sjcx2);
			this.pnl_lssjyl1.Controls.Add(this.cbb_kcmc);
			this.pnl_lssjyl1.Controls.Add(this.lbl_kcmc);
			this.pnl_lssjyl1.Controls.Add(this.lbl_sjcx1);
			this.pnl_lssjyl1.Location = new System.Drawing.Point(8, 8);
			this.pnl_lssjyl1.Name = "pnl_lssjyl1";
			this.pnl_lssjyl1.Size = new System.Drawing.Size(776, 40);
			this.pnl_lssjyl1.TabIndex = 1;
			// 
			// ddtp_sjcx2
			// 
			this.ddtp_sjcx2.Location = new System.Drawing.Point(440, 8);
			this.ddtp_sjcx2.Name = "ddtp_sjcx2";
			this.ddtp_sjcx2.Size = new System.Drawing.Size(112, 21);
			this.ddtp_sjcx2.TabIndex = 8;
			// 
			// ddtp_sjcx1
			// 
			this.ddtp_sjcx1.Location = new System.Drawing.Point(288, 8);
			this.ddtp_sjcx1.Name = "ddtp_sjcx1";
			this.ddtp_sjcx1.Size = new System.Drawing.Size(112, 21);
			this.ddtp_sjcx1.TabIndex = 7;
			// 
			// btn_qd
			// 
			this.btn_qd.Location = new System.Drawing.Point(600, 8);
			this.btn_qd.Name = "btn_qd";
			this.btn_qd.TabIndex = 6;
			this.btn_qd.Text = "确   定";
			this.btn_qd.Click += new System.EventHandler(this.btn_qd_Click);
			// 
			// lbl_sjcx2
			// 
			this.lbl_sjcx2.Location = new System.Drawing.Point(408, 8);
			this.lbl_sjcx2.Name = "lbl_sjcx2";
			this.lbl_sjcx2.Size = new System.Drawing.Size(24, 23);
			this.lbl_sjcx2.TabIndex = 4;
			this.lbl_sjcx2.Text = "至";
			// 
			// cbb_kcmc
			// 
			this.cbb_kcmc.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cbb_kcmc.Location = new System.Drawing.Point(72, 8);
			this.cbb_kcmc.Name = "cbb_kcmc";
			this.cbb_kcmc.Size = new System.Drawing.Size(152, 20);
			this.cbb_kcmc.TabIndex = 1;
			// 
			// lbl_sjcx1
			// 
			this.lbl_sjcx1.Location = new System.Drawing.Point(232, 8);
			this.lbl_sjcx1.Name = "lbl_sjcx1";
			this.lbl_sjcx1.Size = new System.Drawing.Size(56, 23);
			this.lbl_sjcx1.TabIndex = 2;
			this.lbl_sjcx1.Text = "时间查询";
			// 
			// dgd_lssjyl
			// 
			this.dgd_lssjyl.DataMember = "";
			this.dgd_lssjyl.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dgd_lssjyl.Location = new System.Drawing.Point(8, 48);
			this.dgd_lssjyl.Name = "dgd_lssjyl";
			this.dgd_lssjyl.Size = new System.Drawing.Size(776, 432);
			this.dgd_lssjyl.TabIndex = 2;
			// 
			// pnl_lssjyl2
			// 
			this.pnl_lssjyl2.Controls.Add(this.btn_dy);
			this.pnl_lssjyl2.Controls.Add(this.btn_qx);
			this.pnl_lssjyl2.Controls.Add(this.btn_yl);
			this.pnl_lssjyl2.Location = new System.Drawing.Point(8, 496);
			this.pnl_lssjyl2.Name = "pnl_lssjyl2";
			this.pnl_lssjyl2.Size = new System.Drawing.Size(776, 48);
			this.pnl_lssjyl2.TabIndex = 3;
			// 
			// btn_dy
			// 
			this.btn_dy.Location = new System.Drawing.Point(568, 8);
			this.btn_dy.Name = "btn_dy";
			this.btn_dy.TabIndex = 2;
			this.btn_dy.Text = "打   印";
			// 
			// btn_qx
			// 
			this.btn_qx.Location = new System.Drawing.Point(344, 8);
			this.btn_qx.Name = "btn_qx";
			this.btn_qx.TabIndex = 1;
			this.btn_qx.Text = "取   消";
			// 
			// btn_yl
			// 
			this.btn_yl.Location = new System.Drawing.Point(128, 8);
			this.btn_yl.Name = "btn_yl";
			this.btn_yl.TabIndex = 0;
			this.btn_yl.Text = "阅   览";
			this.btn_yl.Click += new System.EventHandler(this.btn_yl_Click);
			// 
			// Form_lssjyl
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(792, 573);
			this.Controls.Add(this.pnl_lssjyl2);
			this.Controls.Add(this.dgd_lssjyl);
			this.Controls.Add(this.pnl_lssjyl1);
			this.Name = "Form_lssjyl";
			this.Text = "历史试卷阅览";
			this.Load += new System.EventHandler(this.Form_lssjyl_Load);
			this.pnl_lssjyl1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dgd_lssjyl)).EndInit();
			this.pnl_lssjyl2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void Form_lssjyl_Load(object sender, System.EventArgs e)
		{   
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.ControlBox = false;
			//在下拉列表框中填入课程名
			SqlDataAdapter dataA=new SqlDataAdapter("select * from course",dbAccess.conn);
			DataSet ds=new DataSet();
			dataA.Fill(ds);
			
			foreach(DataRow dater in ds.Tables[0].Rows)
			{
				cbb_kcmc.Items.Add(dater["cou_name"]);
			}
//			cbb_kcmc.SelectedText="【请选取课程】";


		}

		private void btn_qd_Click(object sender, System.EventArgs e)
		{//在paper表中选出等于课程号的记录
			if (this.cbb_kcmc.Text !="")

			try
			{

				SqlDataAdapter da_cou=new SqlDataAdapter("select cou_no from course where cou_name='"+cbb_kcmc.SelectedItem.ToString()+"'",dbAccess.conn);
				DataSet ds=new DataSet();
				da_cou.Fill(ds,"cou");
				string cou;
				cou=ds.Tables["cou"].Rows[0]["cou_no"].ToString();

				SqlDataAdapter da_pap=new SqlDataAdapter("select * from paper where cou_no='"+cou+"' and pap_createtime between '"+ddtp_sjcx1.Value.ToShortDateString()+"' and '"+ ddtp_sjcx2.Value.ToShortDateString()+"'",dbAccess.conn);
				da_pap.Fill(ds,"pap");
	            dgd_lssjyl.DataSource=ds.Tables["pap"];
			}
			catch(System.Exception m)
			{MessageBox.Show(m.Message);}

			
				dgd_lssjyl.ReadOnly=true;
			
            //把数据窗口字段是英文的,改成中文的
			System.Windows.Forms.DataGridTableStyle dgts=new DataGridTableStyle();
			dgts.MappingName="pap";

            dgd_lssjyl.TableStyles.Clear();

			System.Windows.Forms.DataGridTextBoxColumn  dgtb_1=new DataGridTextBoxColumn();
			dgtb_1.MappingName="cou_no";
			dgtb_1.HeaderText="课程代码";
			System.Windows.Forms.DataGridTextBoxColumn  dgtb_2=new DataGridTextBoxColumn();
			dgtb_2.MappingName="teau_no";
			dgtb_2.HeaderText="教学单元代码";
			System.Windows.Forms.DataGridTextBoxColumn  dgtb_3=new DataGridTextBoxColumn();
			dgtb_3.MappingName="que_no";
			dgtb_3.HeaderText="试题代码";
			System.Windows.Forms.DataGridTextBoxColumn  dgtb_4=new DataGridTextBoxColumn();
			dgtb_4.MappingName="ans_no";
			dgtb_4.HeaderText="答案代码";
			System.Windows.Forms.DataGridTextBoxColumn  dgtb_5=new DataGridTextBoxColumn();
			dgtb_5.MappingName="pap_no";
			dgtb_5.HeaderText="试卷代码";
			System.Windows.Forms.DataGridTextBoxColumn  dgtb_6=new DataGridTextBoxColumn();
			dgtb_6.MappingName="pap_createtime";
			dgtb_6.HeaderText="创建时间";
			System.Windows.Forms.DataGridTextBoxColumn  dgtb_7=new DataGridTextBoxColumn();
			dgtb_7.MappingName="pap_limitterm";
			dgtb_7.HeaderText="考试时限";
			System.Windows.Forms.DataGridTextBoxColumn  dgtb_8=new DataGridTextBoxColumn();
			dgtb_8.MappingName="pap_examtime";
			dgtb_8.HeaderText="开考时间";
			System.Windows.Forms.DataGridTextBoxColumn  dgtb_9=new DataGridTextBoxColumn();
			dgtb_9.MappingName="pap_avalibledate";
			dgtb_9.HeaderText="有效期";
			System.Windows.Forms.DataGridTextBoxColumn  dgtb_10=new DataGridTextBoxColumn();
			dgtb_10.MappingName="pap_canbesaved";
			dgtb_10.HeaderText="归档";
			System.Windows.Forms.DataGridTextBoxColumn  dgtb_11=new DataGridTextBoxColumn();
			dgtb_11.MappingName="pap_memo";
			dgtb_11.HeaderText="备注";

			
			dgts.GridColumnStyles.Add(dgtb_1);
			dgts.GridColumnStyles.Add(dgtb_2);
			dgts.GridColumnStyles.Add(dgtb_3);
			dgts.GridColumnStyles.Add(dgtb_4);
			dgts.GridColumnStyles.Add(dgtb_5);
			dgts.GridColumnStyles.Add(dgtb_6);
			dgts.GridColumnStyles.Add(dgtb_7);
			dgts.GridColumnStyles.Add(dgtb_8);
			dgts.GridColumnStyles.Add(dgtb_9);
			dgts.GridColumnStyles.Add(dgtb_10);
			dgts.GridColumnStyles.Add(dgtb_11);


			dgd_lssjyl.TableStyles.Add(dgts);

		}

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

⌨️ 快捷键说明

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