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

📄 form_sjjgdy.cs

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

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

namespace bizdb
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form_sjjgdy : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Panel pnl_sjjgdy1;
		private System.Windows.Forms.Label lbl_kcmc;
		private System.Windows.Forms.ComboBox cbb_kcmc;
		private System.Windows.Forms.Button btn_qd;
		private System.Windows.Forms.Panel pnl_sjjgdy2;
		private System.Windows.Forms.Label lbl_kssx;
		private System.Windows.Forms.TextBox txt_kssx;
		private System.Windows.Forms.Label lbl_kkrq;
		private System.Windows.Forms.Label lbl_yxq1;
		private System.Windows.Forms.Panel pnl_sjjgdy3;
		private System.Windows.Forms.Button btn_sjsc;
		private System.Windows.Forms.Button btn_tj;
		private System.Windows.Forms.Button btn_dy;
		private System.Windows.Forms.Button btn_qx;
		private System.Windows.Forms.DataGrid dgd_sjjdy;
		private System.Windows.Forms.Label lbl_fz;
		private System.Windows.Forms.DateTimePicker ddtp_kkrq;
		private System.Windows.Forms.DateTimePicker ddtp_yxq1;
		private string c;
		dbAccess db = new dbAccess();


		private DataSet ds=new DataSet();
		private System.Windows.Forms.TextBox txt_sjh;
		private System.Windows.Forms.Label lbl_sjh;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form_sjjgdy()
		{
			//
			// 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.pnl_sjjgdy1 = new System.Windows.Forms.Panel();
			this.btn_qd = new System.Windows.Forms.Button();
			this.cbb_kcmc = new System.Windows.Forms.ComboBox();
			this.lbl_kcmc = new System.Windows.Forms.Label();
			this.dgd_sjjdy = new System.Windows.Forms.DataGrid();
			this.pnl_sjjgdy2 = new System.Windows.Forms.Panel();
			this.txt_sjh = new System.Windows.Forms.TextBox();
			this.ddtp_yxq1 = new System.Windows.Forms.DateTimePicker();
			this.ddtp_kkrq = new System.Windows.Forms.DateTimePicker();
			this.lbl_fz = new System.Windows.Forms.Label();
			this.lbl_yxq1 = new System.Windows.Forms.Label();
			this.lbl_kkrq = new System.Windows.Forms.Label();
			this.txt_kssx = new System.Windows.Forms.TextBox();
			this.lbl_kssx = new System.Windows.Forms.Label();
			this.lbl_sjh = new System.Windows.Forms.Label();
			this.pnl_sjjgdy3 = new System.Windows.Forms.Panel();
			this.btn_qx = new System.Windows.Forms.Button();
			this.btn_dy = new System.Windows.Forms.Button();
			this.btn_tj = new System.Windows.Forms.Button();
			this.btn_sjsc = new System.Windows.Forms.Button();
			this.pnl_sjjgdy1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dgd_sjjdy)).BeginInit();
			this.pnl_sjjgdy2.SuspendLayout();
			this.pnl_sjjgdy3.SuspendLayout();
			this.SuspendLayout();
			// 
			// pnl_sjjgdy1
			// 
			this.pnl_sjjgdy1.Controls.Add(this.btn_qd);
			this.pnl_sjjgdy1.Controls.Add(this.cbb_kcmc);
			this.pnl_sjjgdy1.Controls.Add(this.lbl_kcmc);
			this.pnl_sjjgdy1.Location = new System.Drawing.Point(8, 8);
			this.pnl_sjjgdy1.Name = "pnl_sjjgdy1";
			this.pnl_sjjgdy1.Size = new System.Drawing.Size(776, 40);
			this.pnl_sjjgdy1.TabIndex = 0;
			this.pnl_sjjgdy1.Paint += new System.Windows.Forms.PaintEventHandler(this.pnl_sjjgdy1_Paint);
			// 
			// btn_qd
			// 
			this.btn_qd.Location = new System.Drawing.Point(312, 8);
			this.btn_qd.Name = "btn_qd";
			this.btn_qd.TabIndex = 2;
			this.btn_qd.Text = "确   定";
			this.btn_qd.Click += new System.EventHandler(this.btn_qd_Click);
			// 
			// cbb_kcmc
			// 
			this.cbb_kcmc.Location = new System.Drawing.Point(72, 8);
			this.cbb_kcmc.Name = "cbb_kcmc";
			this.cbb_kcmc.Size = new System.Drawing.Size(200, 20);
			this.cbb_kcmc.TabIndex = 1;
			// 
			// 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 = "课程名称";
			// 
			// dgd_sjjdy
			// 
			this.dgd_sjjdy.DataMember = "";
			this.dgd_sjjdy.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dgd_sjjdy.Location = new System.Drawing.Point(8, 56);
			this.dgd_sjjdy.Name = "dgd_sjjdy";
			this.dgd_sjjdy.Size = new System.Drawing.Size(776, 344);
			this.dgd_sjjdy.TabIndex = 1;
			this.dgd_sjjdy.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dgd_sjjdy_Navigate);
			// 
			// pnl_sjjgdy2
			// 
			this.pnl_sjjgdy2.Controls.Add(this.txt_sjh);
			this.pnl_sjjgdy2.Controls.Add(this.ddtp_yxq1);
			this.pnl_sjjgdy2.Controls.Add(this.ddtp_kkrq);
			this.pnl_sjjgdy2.Controls.Add(this.lbl_fz);
			this.pnl_sjjgdy2.Controls.Add(this.lbl_yxq1);
			this.pnl_sjjgdy2.Controls.Add(this.lbl_kkrq);
			this.pnl_sjjgdy2.Controls.Add(this.txt_kssx);
			this.pnl_sjjgdy2.Controls.Add(this.lbl_kssx);
			this.pnl_sjjgdy2.Controls.Add(this.lbl_sjh);
			this.pnl_sjjgdy2.Location = new System.Drawing.Point(8, 416);
			this.pnl_sjjgdy2.Name = "pnl_sjjgdy2";
			this.pnl_sjjgdy2.Size = new System.Drawing.Size(776, 40);
			this.pnl_sjjgdy2.TabIndex = 2;
			// 
			// txt_sjh
			// 
			this.txt_sjh.Location = new System.Drawing.Point(664, 8);
			this.txt_sjh.Name = "txt_sjh";
			this.txt_sjh.Size = new System.Drawing.Size(104, 21);
			this.txt_sjh.TabIndex = 11;
			this.txt_sjh.Text = "";
			this.txt_sjh.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txt_sjh_keypress);
			// 
			// ddtp_yxq1
			// 
			this.ddtp_yxq1.Location = new System.Drawing.Point(472, 8);
			this.ddtp_yxq1.Name = "ddtp_yxq1";
			this.ddtp_yxq1.Size = new System.Drawing.Size(112, 21);
			this.ddtp_yxq1.TabIndex = 10;
			// 
			// ddtp_kkrq
			// 
			this.ddtp_kkrq.Location = new System.Drawing.Point(272, 8);
			this.ddtp_kkrq.Name = "ddtp_kkrq";
			this.ddtp_kkrq.Size = new System.Drawing.Size(112, 21);
			this.ddtp_kkrq.TabIndex = 9;
			// 
			// lbl_fz
			// 
			this.lbl_fz.Location = new System.Drawing.Point(160, 8);
			this.lbl_fz.Name = "lbl_fz";
			this.lbl_fz.Size = new System.Drawing.Size(40, 23);
			this.lbl_fz.TabIndex = 8;
			this.lbl_fz.Text = "分钟";
			// 
			// lbl_yxq1
			// 
			this.lbl_yxq1.Location = new System.Drawing.Point(408, 8);
			this.lbl_yxq1.Name = "lbl_yxq1";
			this.lbl_yxq1.Size = new System.Drawing.Size(64, 23);
			this.lbl_yxq1.TabIndex = 4;
			this.lbl_yxq1.Text = "有效期";
			// 
			// lbl_kkrq
			// 
			this.lbl_kkrq.Location = new System.Drawing.Point(208, 8);
			this.lbl_kkrq.Name = "lbl_kkrq";
			this.lbl_kkrq.Size = new System.Drawing.Size(64, 23);
			this.lbl_kkrq.TabIndex = 2;
			this.lbl_kkrq.Text = "开考日期";
			// 
			// txt_kssx
			// 
			this.txt_kssx.Location = new System.Drawing.Point(64, 8);
			this.txt_kssx.Multiline = true;
			this.txt_kssx.Name = "txt_kssx";
			this.txt_kssx.Size = new System.Drawing.Size(88, 23);
			this.txt_kssx.TabIndex = 1;
			this.txt_kssx.Text = "";
			this.txt_kssx.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txt_kssx_keypress);
			// 
			// lbl_kssx
			// 
			this.lbl_kssx.Location = new System.Drawing.Point(8, 8);
			this.lbl_kssx.Name = "lbl_kssx";
			this.lbl_kssx.Size = new System.Drawing.Size(56, 23);
			this.lbl_kssx.TabIndex = 0;
			this.lbl_kssx.Text = "考试时限";
			// 
			// lbl_sjh
			// 
			this.lbl_sjh.Location = new System.Drawing.Point(592, 8);
			this.lbl_sjh.Name = "lbl_sjh";
			this.lbl_sjh.Size = new System.Drawing.Size(64, 23);
			this.lbl_sjh.TabIndex = 5;
			this.lbl_sjh.Text = "试卷号";
			// 
			// pnl_sjjgdy3
			// 
			this.pnl_sjjgdy3.Controls.Add(this.btn_qx);
			this.pnl_sjjgdy3.Controls.Add(this.btn_dy);
			this.pnl_sjjgdy3.Controls.Add(this.btn_tj);
			this.pnl_sjjgdy3.Controls.Add(this.btn_sjsc);
			this.pnl_sjjgdy3.Location = new System.Drawing.Point(40, 480);
			this.pnl_sjjgdy3.Name = "pnl_sjjgdy3";
			this.pnl_sjjgdy3.Size = new System.Drawing.Size(712, 72);
			this.pnl_sjjgdy3.TabIndex = 3;
			// 
			// btn_qx
			// 
			this.btn_qx.Location = new System.Drawing.Point(584, 24);
			this.btn_qx.Name = "btn_qx";
			this.btn_qx.Size = new System.Drawing.Size(100, 25);
			this.btn_qx.TabIndex = 3;
			this.btn_qx.Text = "取    消";
			this.btn_qx.Click += new System.EventHandler(this.btn_qx_Click);
			// 
			// btn_dy
			// 
			this.btn_dy.Location = new System.Drawing.Point(208, 24);
			this.btn_dy.Name = "btn_dy";
			this.btn_dy.Size = new System.Drawing.Size(100, 25);
			this.btn_dy.TabIndex = 2;
			this.btn_dy.Text = "打    印";
			// 
			// btn_tj
			// 
			this.btn_tj.Location = new System.Drawing.Point(400, 24);
			this.btn_tj.Name = "btn_tj";
			this.btn_tj.Size = new System.Drawing.Size(100, 25);
			this.btn_tj.TabIndex = 1;
			this.btn_tj.Text = "提    交";
			this.btn_tj.Click += new System.EventHandler(this.btn_tj_Click);
			// 
			// btn_sjsc
			// 
			this.btn_sjsc.Location = new System.Drawing.Point(32, 24);
			this.btn_sjsc.Name = "btn_sjsc";
			this.btn_sjsc.Size = new System.Drawing.Size(100, 25);
			this.btn_sjsc.TabIndex = 0;
			this.btn_sjsc.Text = "试 卷 生 成";
			this.btn_sjsc.Click += new System.EventHandler(this.btn_sjsc_Click);
			// 
			// Form_sjjgdy
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(792, 573);
			this.Controls.Add(this.pnl_sjjgdy3);
			this.Controls.Add(this.pnl_sjjgdy2);
			this.Controls.Add(this.dgd_sjjdy);
			this.Controls.Add(this.pnl_sjjgdy1);
			this.Name = "Form_sjjgdy";
			this.Text = "试卷结构定义";
			this.Load += new System.EventHandler(this.Form_sjjgdy_Load);
			this.Closed += new System.EventHandler(this.Form_sjjgdy_Closed);
			this.pnl_sjjgdy1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dgd_sjjdy)).EndInit();
			this.pnl_sjjgdy2.ResumeLayout(false);
			this.pnl_sjjgdy3.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

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

		}

		private void btn_qd_Click(object sender, System.EventArgs e)
		{	
			ds.Clear();
			if (this.cbb_kcmc.Text!="【请选取课程】")
			{
				try
				{	//采集teachingunit教学单元表,条件课程名等于下拉列表框所选中的课程名			
					string sql="select t.* from course c join teachingunit t on c.cou_no=t.cou_no  where cou_name='"+cbb_kcmc.SelectedItem.ToString()+"'";
					SqlConnection cn=new SqlConnection(db.connStr);
					SqlDataAdapter da=new SqlDataAdapter(sql,cn);
					da.Fill(ds,"all");
					//把下拉列表框所选中的课程名变成课程号付给c这个变量
					c=ds.Tables["all"].Rows[0]["cou_no"].ToString();
 
					dgd_sjjdy.DataSource=ds.Tables["all"];
					dgd_sjjdy.ReadOnly=false;//只读
					//把数据窗口字段是英文的,改成中文的
					System.Windows.Forms.DataGridTableStyle dgts=new DataGridTableStyle();

⌨️ 快捷键说明

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