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

📄 examitemman.cs

📁 网络考试系统 系统基于 .NET 框架开发
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.fen10.Text = "10分题";
			// 
			// et
			// 
			this.et.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.et.Items.AddRange(new object[] {
													"必考题",
													"抢答题",
													"自选题"});
			this.et.Location = new System.Drawing.Point(48, 152);
			this.et.Name = "et";
			this.et.Size = new System.Drawing.Size(128, 20);
			this.et.TabIndex = 5;
			this.et.SelectedIndexChanged += new System.EventHandler(this.et_SelectedIndexChanged);
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(16, 160);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(32, 23);
			this.label4.TabIndex = 4;
			this.label4.Text = "类型";
			// 
			// a
			// 
			this.a.Location = new System.Drawing.Point(48, 88);
			this.a.Multiline = true;
			this.a.Name = "a";
			this.a.Size = new System.Drawing.Size(704, 56);
			this.a.TabIndex = 3;
			this.a.Text = "";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(12, 88);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(32, 23);
			this.label3.TabIndex = 2;
			this.label3.Text = "答案";
			// 
			// q
			// 
			this.q.Location = new System.Drawing.Point(48, 24);
			this.q.Multiline = true;
			this.q.Name = "q";
			this.q.Size = new System.Drawing.Size(704, 56);
			this.q.TabIndex = 1;
			this.q.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(32, 23);
			this.label1.TabIndex = 0;
			this.label1.Text = "问题";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(704, 512);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(64, 23);
			this.button1.TabIndex = 2;
			this.button1.Text = "关闭";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(640, 512);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(64, 23);
			this.button2.TabIndex = 3;
			this.button2.Text = "取消";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(576, 512);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(64, 23);
			this.button3.TabIndex = 4;
			this.button3.Text = "保存";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// button4
			// 
			this.button4.Location = new System.Drawing.Point(464, 512);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(112, 23);
			this.button4.TabIndex = 5;
			this.button4.Text = "重置全部试题";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// ExamItemMan
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(776, 549);
			this.Controls.Add(this.button4);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "ExamItemMan";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "试题管理";
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 重新绑定符合当前类别的试题
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void examType_SelectedIndexChanged(object sender, System.EventArgs e) {
			this.DataBinder();
		}

		private void button4_Click(object sender, System.EventArgs e) {
			string sql = "update ExamItem set state = '可用'";
			this.conn.Open();
			OleDbCommand odc = new OleDbCommand(sql,conn);
			odc.ExecuteNonQuery();
			this.conn.Close();
			this.DataBinder();
			this.ClearForm();
			MessageBox.Show("重置成功!");
			this.DataBinder();
		}

		/// <summary>
		/// 关闭窗口
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button1_Click(object sender, System.EventArgs e) {
			this.Close();
		}

		/// <summary>
		/// 将当前的编辑窗口中的数据全部清除
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button2_Click(object sender, System.EventArgs e) {
			this.ClearForm();
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void et_SelectedIndexChanged(object sender, System.EventArgs e) {
			if(this.et.SelectedIndex == 2){
				this.fen10.Enabled = true;
				this.fen20.Enabled = true;
				this.fen30.Enabled = true;
			}else{
				this.fen10.Enabled = false;
				this.fen20.Enabled = false;
				this.fen30.Enabled = false;
			}
		}

		/// <summary>
		/// 保存试题
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button3_Click(object sender, System.EventArgs e) {

			if(this.a.Text.Trim() == "" || this.q.Text.Trim() == ""){
				MessageBox.Show("问题和答案不能为空!");
				return;
			}

			string fType = "";
			if(this.fen10.Checked){
				fType = "10分题";
			}else if(this.fen20.Checked){
				fType = "20分题";
			}else if(this.fen30.Checked){
				fType = "30分题";
			}else{
				//
			}

			if(this.et.SelectedIndex != 2) fType = "";

			string sql = "";
			if(this.eID != ""){
				sql = "update ExamItem set qStr = '"+ this.q.Text +"',aStr='"+ this.a.Text +"',examType='"+ this.et.Text +"',fenType='"+ fType +"' where eID=" + this.eID;
			}else{
				sql = "insert into ExamItem (qStr,aStr,examType,fenType) values ('"+ this.q.Text +"','"+ this.a.Text +"','"+ this.et.Text +"','"+ fType +"')";
			}

			this.conn.Open();
			OleDbCommand odc = new OleDbCommand(sql,conn);
			odc.ExecuteNonQuery();
			this.conn.Close();

			this.eID  = "";
			this.ClearForm();
			groupBox2.Text = "新建试题";

			this.examType.Text = this.et.Text;
			this.DataBinder();
		}

		/// <summary>
		/// 
		/// </summary>
		private void ClearForm(){
			this.a.Text = "";
			this.q.Text = "";
			this.eID    = "";
			groupBox2.Text = "新建试题";
		}

		/// <summary>
		/// 新建
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void menuItem1_Click(object sender, System.EventArgs e) {
			this.eID  = "";
			this.ClearForm();
			groupBox2.Text = "新建试题";
		}

		/// <summary>
		/// 编辑试题菜单
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void listView_SelectedIndexChanged(object sender, System.EventArgs e) {
			if(this.listView.Items.Count > 0 ){
				if(this.listView.SelectedItems.Count > 0){
					this.eID = ((ListViewItem)this.listView.Items[this.listView.SelectedItems[0].Index]).Tag.ToString();
					//this.menuItem2.Enabled = true;
					this.menuItem3.Enabled = true;

					string sql = "select * from ExamItem where eID="+this.eID;
					this.conn.Open();
					OleDbDataAdapter odp = new OleDbDataAdapter(sql,conn);
					DataSet ds = new DataSet();
					odp.Fill(ds,"ExamItem");
					this.conn.Close();

					if(ds.Tables[0].Rows.Count > 0){

						//赋值
						this.groupBox2.Text = "修改试题";

						DataRow row  = ds.Tables[0].Rows[0];
						this.q.Text  = row["qStr"].ToString();
						this.a.Text  = row["aStr"].ToString();
						this.et.Text = row["examType"].ToString();
						string fType = row["fenType"].ToString();

						if(this.et.Text == "自选题"){
							this.fen10.Enabled = true;
							this.fen20.Enabled = true;
							this.fen30.Enabled = true;

							if(fType == "10分题"){
								this.fen10.Checked = true;
							}else if(fType == "20分题"){
								this.fen20.Checked = true;
							}else if(fType == "30分题"){
								this.fen30.Checked = true;
							}

						}else{
							this.fen10.Enabled = false;
							this.fen20.Enabled = false;
							this.fen30.Enabled = false;
						}
					}

				}else{
					this.eID = "";
					//this.menuItem2.Enabled = false;
					this.menuItem3.Enabled = false;
				}
			}
		}

		/// <summary>
		/// 刷新
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void menuItem5_Click(object sender, System.EventArgs e) {
			this.DataBinder();
		}

		private void menuItem3_Click(object sender, System.EventArgs e) {
			if(this.eID != ""){
				string sql = "delete from ExamItem where eID=" + this.eID;
				this.conn.Open();
				OleDbCommand odc = new OleDbCommand(sql,conn);
				odc.ExecuteNonQuery();
				this.conn.Close();
				this.DataBinder();
				this.ClearForm();
			}
		}
	}
}

⌨️ 快捷键说明

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