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

📄 form_kc.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>
	/// Form_kc 的摘要说明。
	/// </summary>
	public class Form_kc : System.Windows.Forms.Form
	{
		private System.Windows.Forms.DataGrid dgd_kc;
		private System.Windows.Forms.Label lbl_kcdm;
		private System.Windows.Forms.Label lbl_kcmc;
		private System.Windows.Forms.Label lbl_kcsl;
		private System.Windows.Forms.Label lbl_kcjd;
		private System.Windows.Forms.Label lbl_ckjc;
		private System.Windows.Forms.TextBox txt_kcdm;
		private System.Windows.Forms.TextBox txt_kcmc;
		private System.Windows.Forms.ComboBox cbb_kcsl;
		private System.Windows.Forms.TextBox txt_ckjc;
		private System.Windows.Forms.Label lbl_jxdgsm;
		private System.Windows.Forms.TextBox txt_jxdgsm;
		private System.Windows.Forms.Button btn_sjl;
		private System.Windows.Forms.Button btn_qyjl;
		private System.Windows.Forms.Button btn_hyjl;
		private System.Windows.Forms.Button btn_mjl;
		private System.Windows.Forms.Button btn_bj;
		private System.Windows.Forms.Button btn_sc;
		private System.Windows.Forms.Button btn_qx;
		private System.Windows.Forms.Button btn_qrtj;
		private System.Windows.Forms.Button btn_tj;
		private System.Windows.Forms.Panel pnl_kc1;
		private System.Windows.Forms.Panel pnl_kc2;
		private System.Windows.Forms.ComboBox cbb_kcjd;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form_kc()
		{
			//
			// 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.dgd_kc = new System.Windows.Forms.DataGrid();
			this.pnl_kc1 = new System.Windows.Forms.Panel();
			this.cbb_kcjd = new System.Windows.Forms.ComboBox();
			this.txt_jxdgsm = new System.Windows.Forms.TextBox();
			this.lbl_jxdgsm = new System.Windows.Forms.Label();
			this.txt_ckjc = new System.Windows.Forms.TextBox();
			this.cbb_kcsl = new System.Windows.Forms.ComboBox();
			this.txt_kcmc = new System.Windows.Forms.TextBox();
			this.txt_kcdm = new System.Windows.Forms.TextBox();
			this.lbl_ckjc = new System.Windows.Forms.Label();
			this.lbl_kcjd = new System.Windows.Forms.Label();
			this.lbl_kcsl = new System.Windows.Forms.Label();
			this.lbl_kcmc = new System.Windows.Forms.Label();
			this.lbl_kcdm = new System.Windows.Forms.Label();
			this.pnl_kc2 = new System.Windows.Forms.Panel();
			this.btn_qx = new System.Windows.Forms.Button();
			this.btn_qrtj = new System.Windows.Forms.Button();
			this.btn_sc = new System.Windows.Forms.Button();
			this.btn_tj = new System.Windows.Forms.Button();
			this.btn_bj = new System.Windows.Forms.Button();
			this.btn_mjl = new System.Windows.Forms.Button();
			this.btn_hyjl = new System.Windows.Forms.Button();
			this.btn_qyjl = new System.Windows.Forms.Button();
			this.btn_sjl = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.dgd_kc)).BeginInit();
			this.pnl_kc1.SuspendLayout();
			this.pnl_kc2.SuspendLayout();
			this.SuspendLayout();
			// 
			// dgd_kc
			// 
			this.dgd_kc.DataMember = "";
			this.dgd_kc.Dock = System.Windows.Forms.DockStyle.Top;
			this.dgd_kc.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dgd_kc.Name = "dgd_kc";
			this.dgd_kc.ReadOnly = true;
			this.dgd_kc.Size = new System.Drawing.Size(792, 248);
			this.dgd_kc.TabIndex = 0;
			this.dgd_kc.MouseDown += new System.Windows.Forms.MouseEventHandler(this.dgd_kc_MouseDown);
			this.dgd_kc.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgd_kc_MouseUp);
			this.dgd_kc.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dgd_kc_Navigate);
			// 
			// pnl_kc1
			// 
			this.pnl_kc1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.pnl_kc1.Controls.AddRange(new System.Windows.Forms.Control[] {
																				  this.cbb_kcjd,
																				  this.txt_jxdgsm,
																				  this.lbl_jxdgsm,
																				  this.txt_ckjc,
																				  this.cbb_kcsl,
																				  this.txt_kcmc,
																				  this.txt_kcdm,
																				  this.lbl_ckjc,
																				  this.lbl_kcjd,
																				  this.lbl_kcsl,
																				  this.lbl_kcmc,
																				  this.lbl_kcdm});
			this.pnl_kc1.Location = new System.Drawing.Point(0, 248);
			this.pnl_kc1.Name = "pnl_kc1";
			this.pnl_kc1.Size = new System.Drawing.Size(792, 248);
			this.pnl_kc1.TabIndex = 1;
			// 
			// cbb_kcjd
			// 
			this.cbb_kcjd.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cbb_kcjd.Location = new System.Drawing.Point(112, 160);
			this.cbb_kcjd.Name = "cbb_kcjd";
			this.cbb_kcjd.Size = new System.Drawing.Size(256, 20);
			this.cbb_kcjd.TabIndex = 12;
			// 
			// txt_jxdgsm
			// 
			this.txt_jxdgsm.Location = new System.Drawing.Point(408, 48);
			this.txt_jxdgsm.Multiline = true;
			this.txt_jxdgsm.Name = "txt_jxdgsm";
			this.txt_jxdgsm.Size = new System.Drawing.Size(368, 184);
			this.txt_jxdgsm.TabIndex = 11;
			this.txt_jxdgsm.Text = "";
			// 
			// lbl_jxdgsm
			// 
			this.lbl_jxdgsm.Location = new System.Drawing.Point(408, 8);
			this.lbl_jxdgsm.Name = "lbl_jxdgsm";
			this.lbl_jxdgsm.TabIndex = 10;
			this.lbl_jxdgsm.Text = "教学大纲说明";
			// 
			// txt_ckjc
			// 
			this.txt_ckjc.Location = new System.Drawing.Point(112, 216);
			this.txt_ckjc.Name = "txt_ckjc";
			this.txt_ckjc.Size = new System.Drawing.Size(256, 21);
			this.txt_ckjc.TabIndex = 9;
			this.txt_ckjc.Text = "";
			// 
			// cbb_kcsl
			// 
			this.cbb_kcsl.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cbb_kcsl.Location = new System.Drawing.Point(112, 112);
			this.cbb_kcsl.Name = "cbb_kcsl";
			this.cbb_kcsl.Size = new System.Drawing.Size(256, 20);
			this.cbb_kcsl.TabIndex = 7;
			// 
			// txt_kcmc
			// 
			this.txt_kcmc.Location = new System.Drawing.Point(112, 60);
			this.txt_kcmc.Name = "txt_kcmc";
			this.txt_kcmc.Size = new System.Drawing.Size(256, 21);
			this.txt_kcmc.TabIndex = 6;
			this.txt_kcmc.Text = "";
			// 
			// txt_kcdm
			// 
			this.txt_kcdm.Location = new System.Drawing.Point(112, 8);
			this.txt_kcdm.Name = "txt_kcdm";
			this.txt_kcdm.Size = new System.Drawing.Size(256, 21);
			this.txt_kcdm.TabIndex = 5;
			this.txt_kcdm.Text = "";
			// 
			// lbl_ckjc
			// 
			this.lbl_ckjc.Location = new System.Drawing.Point(8, 216);
			this.lbl_ckjc.Name = "lbl_ckjc";
			this.lbl_ckjc.TabIndex = 4;
			this.lbl_ckjc.Text = "参考教材";
			// 
			// lbl_kcjd
			// 
			this.lbl_kcjd.Location = new System.Drawing.Point(8, 164);
			this.lbl_kcjd.Name = "lbl_kcjd";
			this.lbl_kcjd.TabIndex = 3;
			this.lbl_kcjd.Text = "课程阶段";
			// 
			// lbl_kcsl
			// 
			this.lbl_kcsl.Location = new System.Drawing.Point(8, 112);
			this.lbl_kcsl.Name = "lbl_kcsl";
			this.lbl_kcsl.TabIndex = 2;
			this.lbl_kcsl.Text = "课程属类";
			// 
			// lbl_kcmc
			// 
			this.lbl_kcmc.Location = new System.Drawing.Point(8, 60);
			this.lbl_kcmc.Name = "lbl_kcmc";
			this.lbl_kcmc.TabIndex = 1;
			this.lbl_kcmc.Text = "课程名称";
			// 
			// lbl_kcdm
			// 
			this.lbl_kcdm.Location = new System.Drawing.Point(8, 8);
			this.lbl_kcdm.Name = "lbl_kcdm";
			this.lbl_kcdm.TabIndex = 0;
			this.lbl_kcdm.Text = "课程代码";
			// 
			// pnl_kc2
			// 
			this.pnl_kc2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.pnl_kc2.Controls.AddRange(new System.Windows.Forms.Control[] {
																				  this.btn_qx,
																				  this.btn_qrtj,
																				  this.btn_sc,
																				  this.btn_tj,
																				  this.btn_bj,
																				  this.btn_mjl,
																				  this.btn_hyjl,
																				  this.btn_qyjl,
																				  this.btn_sjl});
			this.pnl_kc2.Location = new System.Drawing.Point(0, 496);
			this.pnl_kc2.Name = "pnl_kc2";
			this.pnl_kc2.Size = new System.Drawing.Size(792, 72);
			this.pnl_kc2.TabIndex = 2;
			// 
			// btn_qx
			// 
			this.btn_qx.Location = new System.Drawing.Point(704, 16);
			this.btn_qx.Name = "btn_qx";
			this.btn_qx.TabIndex = 8;
			this.btn_qx.Text = "取消";
			this.btn_qx.Click += new System.EventHandler(this.btn_qx_Click);
			// 
			// btn_qrtj
			// 
			this.btn_qrtj.Location = new System.Drawing.Point(617, 16);
			this.btn_qrtj.Name = "btn_qrtj";
			this.btn_qrtj.TabIndex = 7;
			this.btn_qrtj.Text = "确认提交";
			this.btn_qrtj.Click += new System.EventHandler(this.btn_qrtj_Click);
			// 
			// btn_sc
			// 
			this.btn_sc.Location = new System.Drawing.Point(530, 16);
			this.btn_sc.Name = "btn_sc";
			this.btn_sc.TabIndex = 6;
			this.btn_sc.Text = "删除";
			this.btn_sc.Click += new System.EventHandler(this.btn_sc_Click);
			// 
			// btn_tj
			// 
			this.btn_tj.Location = new System.Drawing.Point(443, 16);
			this.btn_tj.Name = "btn_tj";
			this.btn_tj.TabIndex = 5;
			this.btn_tj.Text = "添加";
			this.btn_tj.Click += new System.EventHandler(this.btn_tj_Click);
			// 
			// btn_bj
			// 
			this.btn_bj.Location = new System.Drawing.Point(356, 16);
			this.btn_bj.Name = "btn_bj";
			this.btn_bj.TabIndex = 4;
			this.btn_bj.Text = "编辑";
			this.btn_bj.Click += new System.EventHandler(this.btn_bj_Click);
			// 
			// btn_mjl
			// 
			this.btn_mjl.Location = new System.Drawing.Point(269, 16);
			this.btn_mjl.Name = "btn_mjl";
			this.btn_mjl.TabIndex = 3;
			this.btn_mjl.Text = "末记录";
			this.btn_mjl.Click += new System.EventHandler(this.btn_mjl_Click);
			// 
			// btn_hyjl
			// 
			this.btn_hyjl.Location = new System.Drawing.Point(182, 16);
			this.btn_hyjl.Name = "btn_hyjl";
			this.btn_hyjl.TabIndex = 2;
			this.btn_hyjl.Text = "后一记录";
			this.btn_hyjl.Click += new System.EventHandler(this.btn_hyjl_Click);
			// 
			// btn_qyjl
			// 
			this.btn_qyjl.Location = new System.Drawing.Point(95, 16);
			this.btn_qyjl.Name = "btn_qyjl";
			this.btn_qyjl.TabIndex = 1;
			this.btn_qyjl.Text = "前一记录";
			this.btn_qyjl.Click += new System.EventHandler(this.btn_qyjl_Click);
			// 
			// btn_sjl
			// 
			this.btn_sjl.Location = new System.Drawing.Point(8, 16);
			this.btn_sjl.Name = "btn_sjl";
			this.btn_sjl.TabIndex = 0;
			this.btn_sjl.Text = "首记录";
			this.btn_sjl.Click += new System.EventHandler(this.btn_sjl_Click);
			// 
			// Form_kc
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(792, 573);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.pnl_kc2,
																		  this.pnl_kc1,
																		  this.dgd_kc});
			this.Name = "Form_kc";
			this.Text = "课程内容管理";
			this.Load += new System.EventHandler(this.Form_kc_Load);
			((System.ComponentModel.ISupportInitialize)(this.dgd_kc)).EndInit();
			this.pnl_kc1.ResumeLayout(false);
			this.pnl_kc2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		public SqlConnection sqlcnt = new SqlConnection();

		SqlDataAdapter sqldpt_kc = new SqlDataAdapter();
		DataSet dst_kc = new DataSet();
		SqlCommand sqlcmd = new SqlCommand ();

		int i=0 ;//1表示编辑,2表示添加,3表示删除
        int cou_no = 0;
		
		private void Form_kc_Load(object sender, System.EventArgs e)
		{
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.ControlBox = false;
			this.load_kc ();

//			i = 0;
//			dst_kc.Clear();
//			txt_kcdm.DataBindings.Clear();
//			txt_kcmc.DataBindings.Clear();
//			txt_ckjc.DataBindings.Clear();
//			txt_jxdgsm.DataBindings.Clear();
//
//			sqlcnt.ConnectionString = dbAccess.conn ;
//			try
//			{
//				sqlcnt.Open();
//							
//			}
//			catch
//			{
//				MessageBox.Show("Server Error");
//				return;
//			}
//
//			cbb_kcsl.Items.Add("基础课");
//			cbb_kcsl.Items.Add("公共课");
//			cbb_kcsl.Items.Add("专业课");
//			cbb_kcsl.Items.Add("其他");
//			cbb_kcjd.Items.Add ("第一阶段");
//			cbb_kcjd.Items.Add ("第二阶段");
//			cbb_kcjd.Items.Add ("第三阶段");
//	
//			sqlcmd.CommandText  = "select cou_no,cou_name,cou_kind = (case cou_kind when 1 then '基础课' when 2 then '公共课' when 3 then '专业课' when 4 then '其他' end),cou_level = (case cou_level when 1 then '第一阶段' when 2 then '第二阶段' when 3 then '第三阶段' end),cou_outline,cou_material,cou_memo from course where cou_no in (select cou_no from teachingAbility where emp_id = '" + common.emplidstr + "')";
//			sqlcmd.Connection = sqlcnt ;
//			sqldpt_kc.SelectCommand  = sqlcmd;
//			sqldpt_kc.Fill(dst_kc,"table");
//			
//			txt_kcdm.DataBindings.Add(new Binding("text",dst_kc,"table.cou_no"));
//			txt_kcmc.DataBindings.Add(new Binding("text",dst_kc,"table.cou_name"));
//			
//			txt_ckjc.DataBindings.Add(new Binding("text",dst_kc,"table.cou_outline"));
//			txt_jxdgsm.DataBindings.Add(new Binding("text",dst_kc,"table.cou_material"));
//
//
//			DataGridTableStyle style=new DataGridTableStyle();
//			style.MappingName = "table";
//
//			DataGridTextBoxColumn cou_no = new DataGridTextBoxColumn();
//			cou_no.HeaderText = "课程代码";
//			cou_no.MappingName = "cou_no";
//			cou_no.Width = 70;
//			
//			DataGridTextBoxColumn cou_name = new DataGridTextBoxColumn();
//			cou_name.HeaderText = "课程名称";
//			cou_name.MappingName = "cou_name";
//			cou_name.Width = 130;
//			
//			DataGridTextBoxColumn cou_kind = new DataGridTextBoxColumn();
//			cou_kind.HeaderText = "课程属类";
//			cou_kind.MappingName = "cou_kind";
//			cou_kind.Width = 70;
//
//			DataGridTextBoxColumn cou_level = new DataGridTextBoxColumn();
//			cou_level.HeaderText = "课程阶段";
//			cou_level.MappingName = "cou_level";
//			cou_level.Width =90;
//
//			DataGridTextBoxColumn cou_outline = new DataGridTextBoxColumn();
//			cou_outline.HeaderText = "课程教学大纲说明";
//			cou_outline.MappingName = "cou_outline";
//			cou_outline.Width = 200;
//
//			DataGridTextBoxColumn cou_material = new DataGridTextBoxColumn ();
//			cou_material.HeaderText ="参考教材";
//			cou_material.MappingName = "cou_material";
//			cou_material.Width = 200;
//
//			style.GridColumnStyles.AddRange(new DataGridColumnStyle[]{cou_no,cou_name,cou_kind,cou_level,cou_outline,cou_material,});
//			dgd_kc.TableStyles.Clear();
//			dgd_kc.TableStyles.Add (style);
//			dgd_kc.SetDataBinding(dst_kc,"table");
//
//			if (this.dst_kc.Tables[0].Rows.Count != 0)
//			{
//				dgd_kc.CurrentRowIndex = 0;
//				dgd_kc.Select(dgd_kc.CurrentRowIndex);
//				this.cbb_kcjd.SelectedItem = this.dst_kc.Tables [0].Rows[dgd_kc.CurrentRowIndex ][3].ToString ();
//				this.cbb_kcsl.SelectedItem = this.dst_kc.Tables [0].Rows[dgd_kc.CurrentRowIndex ][2].ToString ();
//			
//			}
//				
//			sqlcnt.Close ();
//			this.setfalse();
//			btn_qrtj.Enabled = false;
//			btn_qx.Enabled = false;

		}
		private void setenable()
		{
			cbb_kcsl.Enabled = true;
			cbb_kcjd.Enabled =true;
			txt_kcmc.Enabled = true;

⌨️ 快捷键说明

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