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

📄 frmtopics.cs

📁 考试管理系统CS架构 不需更多说明
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.label3.Size = new System.Drawing.Size(56, 16);
			this.label3.TabIndex = 2;
			this.label3.Text = "答案数:";
			// 
			// clbAnwser
			// 
			this.clbAnwser.Location = new System.Drawing.Point(40, 12);
			this.clbAnwser.Name = "clbAnwser";
			this.clbAnwser.Size = new System.Drawing.Size(112, 84);
			this.clbAnwser.TabIndex = 1;
			this.clbAnwser.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.clbAnwser_ItemCheck);
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(6, 16);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(42, 20);
			this.label2.TabIndex = 11;
			this.label2.Text = "答案:";
			// 
			// rtbTitle
			// 
			this.rtbTitle.AutoSize = true;
			this.rtbTitle.Dock = System.Windows.Forms.DockStyle.Fill;
			this.rtbTitle.Location = new System.Drawing.Point(0, 16);
			this.rtbTitle.Name = "rtbTitle";
			this.rtbTitle.Size = new System.Drawing.Size(332, 343);
			this.rtbTitle.TabIndex = 1;
			this.rtbTitle.Text = "";
			// 
			// label1
			// 
			this.label1.Dock = System.Windows.Forms.DockStyle.Top;
			this.label1.Location = new System.Drawing.Point(0, 0);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(332, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "题干:";
			// 
			// panSearch
			// 
			this.panSearch.Controls.Add(this.panel5);
			this.panSearch.Controls.Add(this.gpSearch);
			this.panSearch.Dock = System.Windows.Forms.DockStyle.Right;
			this.panSearch.Location = new System.Drawing.Point(332, 0);
			this.panSearch.Name = "panSearch";
			this.panSearch.Size = new System.Drawing.Size(184, 359);
			this.panSearch.TabIndex = 1;
			// 
			// panel5
			// 
			this.panel5.Controls.Add(this.button1);
			this.panel5.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.panel5.Location = new System.Drawing.Point(0, 323);
			this.panel5.Name = "panel5";
			this.panel5.Size = new System.Drawing.Size(184, 36);
			this.panel5.TabIndex = 19;
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(104, 10);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(72, 22);
			this.button1.TabIndex = 0;
			this.button1.Text = "查找";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// gpSearch
			// 
			this.gpSearch.Controls.Add(this.panel6);
			this.gpSearch.Controls.Add(this.panel4);
			this.gpSearch.Controls.Add(this.label9);
			this.gpSearch.Dock = System.Windows.Forms.DockStyle.Fill;
			this.gpSearch.Location = new System.Drawing.Point(0, 0);
			this.gpSearch.Name = "gpSearch";
			this.gpSearch.Size = new System.Drawing.Size(184, 359);
			this.gpSearch.TabIndex = 18;
			this.gpSearch.TabStop = false;
			this.gpSearch.Text = "搜索";
			// 
			// panel6
			// 
			this.panel6.Controls.Add(this.rtbSearchTitle);
			this.panel6.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel6.Location = new System.Drawing.Point(3, 37);
			this.panel6.Name = "panel6";
			this.panel6.Size = new System.Drawing.Size(178, 193);
			this.panel6.TabIndex = 25;
			// 
			// rtbSearchTitle
			// 
			this.rtbSearchTitle.Dock = System.Windows.Forms.DockStyle.Fill;
			this.rtbSearchTitle.Location = new System.Drawing.Point(0, 0);
			this.rtbSearchTitle.Name = "rtbSearchTitle";
			this.rtbSearchTitle.Size = new System.Drawing.Size(178, 193);
			this.rtbSearchTitle.TabIndex = 22;
			this.rtbSearchTitle.Text = "";
			// 
			// panel4
			// 
			this.panel4.Controls.Add(this.chkSearchType);
			this.panel4.Controls.Add(this.cmbSearchCate);
			this.panel4.Controls.Add(this.label7);
			this.panel4.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.panel4.Location = new System.Drawing.Point(3, 230);
			this.panel4.Name = "panel4";
			this.panel4.Size = new System.Drawing.Size(178, 126);
			this.panel4.TabIndex = 24;
			// 
			// chkSearchType
			// 
			this.chkSearchType.Checked = true;
			this.chkSearchType.CheckState = System.Windows.Forms.CheckState.Checked;
			this.chkSearchType.Location = new System.Drawing.Point(50, 56);
			this.chkSearchType.Name = "chkSearchType";
			this.chkSearchType.Size = new System.Drawing.Size(114, 20);
			this.chkSearchType.TabIndex = 26;
			this.chkSearchType.Text = "模糊查询";
			// 
			// cmbSearchCate
			// 
			this.cmbSearchCate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cmbSearchCate.Location = new System.Drawing.Point(64, 22);
			this.cmbSearchCate.Name = "cmbSearchCate";
			this.cmbSearchCate.Size = new System.Drawing.Size(102, 20);
			this.cmbSearchCate.TabIndex = 25;
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(22, 26);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(50, 16);
			this.label7.TabIndex = 24;
			this.label7.Text = "科目:";
			// 
			// label9
			// 
			this.label9.Dock = System.Windows.Forms.DockStyle.Top;
			this.label9.Location = new System.Drawing.Point(3, 17);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(178, 20);
			this.label9.TabIndex = 23;
			this.label9.Text = "题干:";
			// 
			// panel7
			// 
			this.panel7.Controls.Add(this.panel9);
			this.panel7.Dock = System.Windows.Forms.DockStyle.Left;
			this.panel7.Location = new System.Drawing.Point(0, 0);
			this.panel7.Name = "panel7";
			this.panel7.Size = new System.Drawing.Size(172, 359);
			this.panel7.TabIndex = 3;
			// 
			// panel9
			// 
			this.panel9.Controls.Add(this.dlvTopics);
			this.panel9.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel9.Location = new System.Drawing.Point(0, 0);
			this.panel9.Name = "panel9";
			this.panel9.Size = new System.Drawing.Size(172, 359);
			this.panel9.TabIndex = 0;
			// 
			// dlvTopics
			// 
			this.dlvTopics.AutoColumnsWidth = true;
			this.dlvTopics.BindTable = null;
			this.dlvTopics.ColumnsWidth = 100;
			this.dlvTopics.Dock = System.Windows.Forms.DockStyle.Fill;
			this.dlvTopics.FullRowSelect = true;
			this.dlvTopics.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
			this.dlvTopics.LineNumWidth = 40;
			this.dlvTopics.Location = new System.Drawing.Point(0, 0);
			this.dlvTopics.MultiSelect = false;
			this.dlvTopics.Name = "dlvTopics";
			this.dlvTopics.SelectedColor = System.Drawing.Color.White;
			this.dlvTopics.Size = new System.Drawing.Size(172, 359);
			this.dlvTopics.TabIndex = 1;
			this.dlvTopics.View = System.Windows.Forms.View.Details;
			this.dlvTopics.SelectedIndexChanged += new System.EventHandler(this.dlvTopics_SelectedIndexChanged);
			// 
			// FrmTopics
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(702, 359);
			this.Controls.Add(this.panel2);
			this.Controls.Add(this.panBtn);
			this.Controls.Add(this.panel7);
			this.Name = "FrmTopics";
			this.Text = "考题管理";
			this.Load += new System.EventHandler(this.FrmTopics_Load);
			this.panBtn.ResumeLayout(false);
			this.panel2.ResumeLayout(false);
			this.panel3.ResumeLayout(false);
			this.panel1.ResumeLayout(false);
			this.panButtom.ResumeLayout(false);
			this.panel8.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.nudLevel)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.nudAnwsers)).EndInit();
			this.panSearch.ResumeLayout(false);
			this.panel5.ResumeLayout(false);
			this.gpSearch.ResumeLayout(false);
			this.panel6.ResumeLayout(false);
			this.panel4.ResumeLayout(false);
			this.panel7.ResumeLayout(false);
			this.panel9.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnShow_Click(object sender, System.EventArgs e)
		{
			Button btn=(Button)sender;
			if(btn.Text=="<")
			{
				panSearch.Visible=false;
				this.Width-=panSearch.Width;
				btn.Text=">";
			}
			else
			{
				panSearch.Visible=true;
				this.Width+=panSearch.Width;
				btn.Text="<";
			}
		}

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

		private void FrmTopics_Load(object sender, System.EventArgs e)
		{
			fillSelector();
			fillSearch();
			enText(false);
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			FrmAddTopics frmAddTopics=new FrmAddTopics();
			frmAddTopics.ShowDialog();
		}

		/// <summary>
		/// 判断是否有必填项未填
		/// </summary>
		/// <returns></returns>
		private bool hasEmpty()
		{
			if(rtbTitle.Text.Trim()=="")
			{
				MessageBox.Show("请输入题干","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
				return true;
			}
			
			if(this.clbAnwser.CheckedItems.Count<=0)
			{
				MessageBox.Show("请选择正确答案","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
				return true;
			}
			return false;
		}
		
		private void button3_Click(object sender, System.EventArgs e)
		{
			if(hasEmpty())
			{
				return;
			}
			if(dlvTopics.SelectedIndices.Count>0)
			{
				int index=dlvTopics.SelectedIndices[0];
				DataTable dt=dlvTopics.BindTable;
				int topicID=Convert.ToInt32(dt.Rows[index][0]);
				string topicDetil=this.rtbTitle.Text;
				string titAnswer=getAnswer();
				int answers=(int)nudAnwsers.Value;
				int cateID=(int)cmbCate.SelectedValue;
				int level=(int)nudLevel.Value;
				TopicsFac topicFac=new TopicsFac();
				try
				{
					topicFac.updateTopic(topicID,topicDetil,titAnswer,answers,cateID,level);
					MessageBox.Show("修改完毕","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
					dt.Rows[index][1]=topicDetil;
					dt.Rows[index][2]=titAnswer;
					dt.Rows[index][3]=answers;
					dt.Rows[index][4]=cateID;
					dt.Rows[index][5]=level;
					dlvTopics.Items[index].SubItems[1].Text=topicDetil.ToString();
					dlvTopics.Items[index].SubItems[2].Text=level.ToString();

				}
				catch
				{
					MessageBox.Show("数据错误","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
				}
			}
		}

		private void nudAnswers_ValueChanged(object sender, System.EventArgs e)
		{
			clbAnwser.Items.Clear();
			int count=(int)nudAnwsers.Value;
			for(int i=0;i<count;i++)
			{
				clbAnwser.Items.Add((char)('A'+i));
			}
		}

		private void setAnswer(string answers)
		{
			string[] titAnswers=answers.Split(new char[]{','});
			//clbAnwser.ClearSelected();
			if(clbAnwser.Items.Count<titAnswers.Length)
			{
				return;
			}
			for(int i=0;i<titAnswers.Length;i++)
			{
				char ans=titAnswers[i][0];
				int selIndex=(int)(ans-'A');
				clbAnwser.SetItemCheckState(selIndex,CheckState.Checked);
			}
		}

		private string getAnswer()
		{
			string ans="";
			for(int i=0;i<clbAnwser.CheckedItems.Count;i++)
			{
				
				ans+=clbAnwser.CheckedItems[i].ToString();
				if(i<clbAnwser.CheckedItems.Count-1)
				{
					ans+=",";
				}
			}
			return ans;
		}

		private void dlvTopics_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(dlvTopics.SelectedIndices.Count>0)
			{
				int index=dlvTopics.SelectedIndices[0];
				DataTable dt=dlvTopics.BindTable;
				this.rtbTitle.Text=dt.Rows[index][1].ToString();
				this.nudAnwsers.Value=Convert.ToDecimal(dt.Rows[index][3]);
				setAnswer(dt.Rows[index][2].ToString());
				//nudAnswers_ValueChanged(null,null);
				nudLevel.Value=Convert.ToDecimal(dt.Rows[index][5]);
				cmbCate.SelectedValue=dt.Rows[index][4];
				enText(true);
			}
		}

		private void button4_Click(object sender, System.EventArgs e)
		{
			if(hasEmpty())
			{
				return;
			}
			if(dlvTopics.SelectedIndices.Count>0)
			{
				if(MessageBox.Show("是否要删除该数据?","问题",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
				{
					int index=dlvTopics.SelectedIndices[0];
					DataTable dt=dlvTopics.BindTable;
					int topicID=Convert.ToInt32(dt.Rows[index][0]);
					TopicsFac topicFac=new TopicsFac();
					try
					{
						topicFac.deleteTopic(topicID,"","",-1,-1,-1);
						MessageBox.Show("删除完毕","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
						dt.Rows.RemoveAt(index);
						dlvTopics.Items.RemoveAt(index);
						dlvTopics.RefreshLineNum();
						clearText();
						enText(false);
					}
					catch
					{
						MessageBox.Show("数据错误\n删除失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
					}
				}
			}
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			fillSearch();
			clearText();
			enText(false);
		}

		private void clbAnwser_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
		{
		
		}

		

	}
}

⌨️ 快捷键说明

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