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

📄 form_da.cs

📁 一个很简单的考试系统。实用性很强啊!数据库在里面
💻 CS
📖 第 1 页 / 共 4 页
字号:
			this.dgd_st.Name = "dgd_st";
			this.dgd_st.ReadOnly = true;
			this.dgd_st.Size = new System.Drawing.Size(376, 208);
			this.dgd_st.TabIndex = 3;
			this.dgd_st.Click += new System.EventHandler(this.dgd_st_Click);
			this.dgd_st.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgd_st_MouseUp);
			// 
			// dgd_da
			// 
			this.dgd_da.DataMember = "";
			this.dgd_da.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dgd_da.Location = new System.Drawing.Point(400, 136);
			this.dgd_da.Name = "dgd_da";
			this.dgd_da.ReadOnly = true;
			this.dgd_da.Size = new System.Drawing.Size(376, 208);
			this.dgd_da.TabIndex = 4;
			this.dgd_da.Click += new System.EventHandler(this.dgd_da_Click);
			this.dgd_da.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgd_da_MouseUp);
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.dgd_st);
			this.panel1.Location = new System.Drawing.Point(8, 128);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(392, 224);
			this.panel1.TabIndex = 5;
			// 
			// Form_da
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(792, 573);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.dgd_da);
			this.Controls.Add(this.pnl_da3);
			this.Controls.Add(this.pnl_da2);
			this.Controls.Add(this.pnl_da1);
			this.Name = "Form_da";
			this.Text = "答案内容管理";
			this.Load += new System.EventHandler(this.Form_da_Load);
			this.pnl_da1.ResumeLayout(false);
			this.pnl_da2.ResumeLayout(false);
			this.pnl_da3.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dgd_st)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dgd_da)).EndInit();
			this.panel1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void btn_cx_Click(object sender, System.EventArgs e)
		{
			try
			{
				string tname = cbb_jxdy.GetItemText(cbb_jxdy.SelectedItem);
				foreach(DataRow datar in dst_st.Tables["teachingUnit"].Rows)
				{
					if(datar["teau_name"].ToString() == tname)
					{
						tno = datar["teau_no"].ToString();
						break;
					}
				}
				if(dst_st.Tables.IndexOf("Question") !=-1)
				{
					dst_st.Tables["Question"].Clear();
				}
				sqlcmd_st.CommandText = "SELECT cou_no,teau_no,que_no,que_type=(case que_type when 1 then '单选' " +
					"when 2 then '多选' end),que_score,que_difficulty=(case que_difficulty when 1 then '易' when 2 then '中' "+
					"when 3 then '难' end),que_picture,que_content,que_createtime,que_modifytime,que_memo FROM Question WHERE teau_no =" + tno;
				sqldpt_st.SelectCommand = sqlcmd_st;
				sqlcnt_st.Open();
				sqldpt_st.Fill(dst_st,"Question");
				sqlcnt_st.Close();
				
				this.dgd_st.DataSource = dst_st;
				this.dgd_st.DataMember = "Question";
			}
			catch
			{
				sqlcnt_st.Close();
			}
		}

		private void Form_da_Load(object sender, System.EventArgs e)
		{
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.ControlBox = false;
			try
			{
				sqlcnt_st.ConnectionString =db.connStr;
				sqlcmd_st = sqlcnt_st.CreateCommand();
				sqlcmd_sts = sqlcnt_st.CreateCommand();
				sqlcmd_st.CommandText = "SELECT * FROM Course";
				sqldpt_st.SelectCommand = sqlcmd_st;
				sqlcnt_st.Open();
				sqldpt_st.Fill(dst_st,"Course");
				sqlcnt_st.Close();
				DataTable datat = dst_st.Tables["Course"];
				this.txt_danr.Enabled = false;
				this.ckb_zqda.Enabled = false;
				foreach(DataRow datar in datat.Rows)
				{

					cbb_kc.Items.Add(datar["cou_name"]);
				}
			}
			catch
			{
				MessageBox.Show("jjk");
			}
			System.Windows.Forms.DataGridTableStyle dgt_st = new DataGridTableStyle();
			dgt_st.MappingName = "Question";
			System.Windows.Forms.DataGridColumnStyle dgc_st1 = new DataGridTextBoxColumn();
			dgc_st1.MappingName = "que_content";
			dgc_st1.HeaderText = "试题内容";
			dgc_st1.NullText = "";
			dgc_st1.Width = (this.dgd_st.Width)*2/3;
			System.Windows.Forms.DataGridColumnStyle dgc_st2 = new DataGridTextBoxColumn();
			dgc_st2.MappingName = "que_type";
			dgc_st2.HeaderText = "试题样式";
			dgc_st2.NullText = "";
			System.Windows.Forms.DataGridColumnStyle dgc_st3 = new DataGridTextBoxColumn();
			dgc_st3.MappingName = "que_score";
			dgc_st3.HeaderText = "试题分值";
			dgc_st3.NullText = "";
			System.Windows.Forms.DataGridColumnStyle dgc_st4 = new DataGridTextBoxColumn();
			dgc_st4.MappingName = "que_difficulty";
			dgc_st4.HeaderText = "试题难度";
			dgc_st4.NullText = "";
			dgt_st.GridColumnStyles.Add(dgc_st1);
			dgt_st.GridColumnStyles.Add(dgc_st2);
			dgt_st.GridColumnStyles.Add(dgc_st3);
			dgt_st.GridColumnStyles.Add(dgc_st4);
			this.dgd_st.TableStyles.Add(dgt_st);
			System.Windows.Forms.DataGridTableStyle dgt_st5 = new DataGridTableStyle();
			dgt_st5.MappingName = "Answer";
			System.Windows.Forms.DataGridColumnStyle dgc_st6 = new DataGridTextBoxColumn();
			dgc_st6.MappingName = "ans_content";
			dgc_st6.HeaderText = "答案内容";
			dgc_st6.NullText = "";
			dgc_st6.Width = (this.dgd_da.Width)*2/3;
			System.Windows.Forms.DataGridColumnStyle dgc_st7 = new DataGridTextBoxColumn();
			dgc_st7.MappingName = "ans_item";
			dgc_st7.HeaderText = "答案选项";
			dgc_st7.NullText = "";
			System.Windows.Forms.DataGridColumnStyle dgc_st8 = new DataGridTextBoxColumn();
			dgc_st8.MappingName = "ans_isResult";
			dgc_st8.HeaderText = "正确答案";
			dgc_st8.NullText = "";
			dgt_st5.GridColumnStyles.Add(dgc_st6);
			dgt_st5.GridColumnStyles.Add(dgc_st7);
			dgt_st5.GridColumnStyles.Add(dgc_st8);
			this.dgd_da.TableStyles.Add(dgt_st5);
			this.txt_danr.Enabled = false;
			this.txt_daxx.Enabled = false;
			this.ckb_zqda.Enabled = false;
			this.btn_fjtp.Enabled = false;
			this.btn_tj.Enabled = false;
			this.btn_sc.Enabled = false;
			this.btn_xg.Enabled = false;
			this.btn_fjtp.Enabled = false;
			this.btn_qyjl.Enabled = false;
			this.btn_hyjl.Enabled = false;
			this.btn_sjl.Enabled = false;
			this.btn_mjl.Enabled = false;
			this.btn_qrtj.Enabled = false;
			this.btn_qx.Enabled = false;
			this.btn_cx.Enabled = false;
		}

		private void cbb_kc_SelectionChange(object sender, System.EventArgs e)
		{
			
			cno = "";
			string cname = cbb_kc.GetItemText(cbb_kc.SelectedItem);
			foreach(DataRow datar in dst_st.Tables["Course"].Rows)
			{
				if(datar["cou_name"].ToString() == cname)
				{
					cno = datar["cou_no"].ToString();
					break;
				}
			}
			cbb_jxdy.Items.Clear();
			cbb_jxdy.Text="";
			if(dst_st.Tables.IndexOf("teachingUnit") !=-1)
			{
				dst_st.Tables["teachingUnit"].Clear();
			}
			sqlcmd_st.CommandText = "SELECT * FROM teachingUnit WHERE cou_no =" + cno;
			sqldpt_st.SelectCommand = sqlcmd_st;
			
			sqlcnt_st.Open();
			sqldpt_st.Fill(dst_st,"teachingUnit");
			sqlcnt_st.Close();
			foreach(DataRow datar in dst_st.Tables["teachingUnit"].Rows)
			{
				cbb_jxdy.Items.Add(datar["teau_name"]);
			}
			if(dst_st.Tables.IndexOf("Question") !=-1)
			{
				dst_st.Tables["Question"].Clear();
				this.txt_danr.Enabled = false;
				this.txt_daxx.Enabled = false;
				this.ckb_zqda.Enabled = false;
				this.btn_fjtp.Enabled = false;
				this.btn_tj.Enabled = false;
				this.btn_sc.Enabled = false;
				this.btn_xg.Enabled = false;
				this.btn_fjtp.Enabled = false;
				this.btn_qyjl.Enabled = false;
				this.btn_hyjl.Enabled = false;
				this.btn_sjl.Enabled = false;
				this.btn_mjl.Enabled = false;
				this.btn_qrtj.Enabled = false;
				this.btn_qx.Enabled = false;
				bl_qx = 0;
			}
			if(dst_st.Tables.IndexOf("Answer") != -1)
			{
				dst_st.Tables["Answer"].Clear();
			}
		}

		private void cbb_jxdy_SelectionChange(object sender, System.EventArgs e)
		{
			if(dst_st.Tables.IndexOf("Question") !=-1)
			{
				dst_st.Tables["Question"].Clear();
				this.txt_danr.Enabled = false;
				this.txt_daxx.Enabled = false;
				this.ckb_zqda.Enabled = false;
				this.btn_fjtp.Enabled = false;
				this.btn_tj.Enabled = false;
				this.btn_sc.Enabled = false;
				this.btn_xg.Enabled = false;
				this.btn_fjtp.Enabled = false;
				this.btn_qyjl.Enabled = false;
				this.btn_hyjl.Enabled = false;
				this.btn_sjl.Enabled = false;
				this.btn_mjl.Enabled = false;
				this.btn_qrtj.Enabled = false;
				this.btn_qx.Enabled = false;
				this.btn_cx.Enabled = true;
				bl_qx = 0;
			}
			if(dst_st.Tables.IndexOf("Answer") != -1)
			{
				dst_st.Tables["Answer"].Clear();
			}
			string jname = cbb_jxdy.GetItemText(cbb_jxdy.SelectedItem);
			foreach(DataRow datar in dst_st.Tables["teachingUnit"].Rows)
			{
				if(datar["teau_name"].ToString() == jname)
				{
					jno = datar["teau_no"].ToString();
					break;
				}
			}
			this.btn_cx.Enabled = true;
			bl_qx = 0;
		}

		private void btn_sjl_Click(object sender, System.EventArgs e)
		{
			if(this.dgd_da.CurrentRowIndex !=  -1)
			{
				this.dgd_da.UnSelect(this.dgd_da.CurrentRowIndex);
				this.dgd_da.CurrentRowIndex = 0;
				this.dgd_da.Select(0);
				if(dst_st.Tables["Answer"].Rows[this.dgd_da.CurrentRowIndex]["ans_isResult"].ToString() == "0")
				{
					this.ckb_zqda.CheckState = System.Windows.Forms.CheckState.Checked;
				}
				else
				{
					this.ckb_zqda.CheckState = System.Windows.Forms.CheckState.Unchecked;
				}
				try
				{
					byte[] by = (byte[])this.dst_st.Tables["Answer"].Rows[this.dgd_da.CurrentRowIndex]["ans_picture"];
					System.IO.MemoryStream ms = new System.IO.MemoryStream(by);
					//ofd_fjtp.ShowDialog();
					Image img = Image.FromStream(ms); //Image.FromFile(ofd_fjtp.FileName);
					this.pcb_yltp.Image = img.GetThumbnailImage(this.pcb_yltp.Width,this.pcb_yltp.Height,null,IntPtr.Zero);
				}
				catch
				{
					this.pcb_yltp.Image = null;
				}
			}
			if(this.dst_st.Tables.IndexOf("Answer") != -1)
			{
				this.dst_st.Tables["Answer"].RejectChanges();
			}
				this.txt_daxx.Enabled = false;
				this.txt_danr.Enabled = false;
				this.ckb_zqda.Enabled = false;
				this.btn_tj.Enabled = true;
				this.btn_xg.Enabled = true;
				this.btn_sc.Enabled = true;
				this.btn_fjtp.Enabled = false;
				bl_qx = 0;
		}

		private void btn_qyjl_Click(object sender, System.EventArgs e)
		{
			if (this.dgd_da.CurrentRowIndex != 0 & this.dgd_da.CurrentRowIndex !=  -1)
			{
				this.dgd_da.UnSelect(this.dgd_da.CurrentRowIndex);
				this.dgd_da.CurrentRowIndex -= 1;
				this.dgd_da.Select(this.dgd_da.CurrentRowIndex);
				if(dst_st.Tables["Answer"].Rows[this.dgd_da.CurrentRowIndex]["ans_isResult"].ToString() == "0")
				{
					this.ckb_zqda.CheckState = System.Windows.Forms.CheckState.Checked;
				}
				else
				{
					this.ckb_zqda.CheckState = System.Windows.Forms.CheckState.Unchecked;
				}
				try
				{
					byte[] by = (byte[])this.dst_st.Tables["Answer"].Rows[this.dgd_st.CurrentRowIndex]["ans_picture"];
					System.IO.MemoryStream ms = new System.IO.MemoryStream(by);
					//ofd_fjtp.ShowDialog();
					Image img = Image.FromStream(ms); //Image.FromFile(ofd_fjtp.FileName);
					this.pcb_yltp.Image = img.GetThumbnailImage(this.pcb_yltp.Width,this.pcb_yltp.Height,null,IntPtr.Zero);
				}
				catch
				{
					this.pcb_yltp.Image = null;
				}
			}
			if(this.dst_st.Tables.IndexOf("Answer") != -1)
			{
				this.dst_st.Tables["Answer"].RejectChanges();
			}
			this.txt_daxx.Enabled = false;
			this.txt_danr.Enabled = false;
			this.ckb_zqda.Enabled = false;
			this.btn_tj.Enabled = true;
			this.btn_xg.Enabled = true;
			this.btn_sc.Enabled = true;
			this.btn_fjtp.Enabled = false;
			bl_qx = 0;
		}

		private void btn_hyjl_Click(object sender, System.EventArgs e)
		{
			if (this.dgd_da.CurrentRowIndex != this.BindingContext[this.dst_st,"Answer"].Count - 1& this.dgd_da.CurrentRowIndex !=  -1)
			{
				this.dgd_da.UnSelect(this.dgd_da.CurrentRowIndex);
				this.dgd_da.CurrentRowIndex += 1;
				this.dgd_da.Select(this.dgd_da.CurrentRowIndex);
				if(dst_st.Tables["Answer"].Rows[this.dgd_da.CurrentRowIndex]["ans_isResult"].ToString() == "0")
				{
					this.ckb_zqda.CheckState = System.Windows.Forms.CheckState.Checked;
				}
				else
				{
					this.ckb_zqda.CheckState = System.Windows.Forms.CheckState.Unchecked;
				}
				try
				{
					byte[] by = (byte[])this.dst_st.Tables["Answer"].Rows[this.dgd_st.CurrentRowIndex]["ans_picture"];
					System.IO.MemoryStream ms = new System.IO.MemoryStream(by);
					//ofd_fjtp.ShowDialog();
					Image img = Image.FromStream(ms); //Image.FromFile(ofd_fjtp.FileName);
					this.pcb_yltp.Image = img.GetThumbnailImage(this.pcb_yltp.Width,this.pcb_yltp.Height,null,IntPtr.Zero);
				}
				catch

⌨️ 快捷键说明

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