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

📄 frmexams.cs

📁 考试管理系统CS架构 不需更多说明
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using TeachersClient.ExamFrms;
using ExamSystem.BusinessFacade.TeacherFac;
using ExamSystem.BusinessFacade.TopicsFacade;
using System.Data;
using ExamSystem.Common;
namespace TeachersClient
{
	/// <summary>
	/// FrmExams 的摘要说明。
	/// </summary>
	public class FrmExams : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Panel panel3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.GroupBox gpSearch;
		private System.Windows.Forms.Splitter splitter1;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.CheckBox chkEnd;
		private System.Windows.Forms.ComboBox cmbCate;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.ComboBox cmbClass;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox txtName;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button button5;
		private System.Windows.Forms.Panel panel4;
		private System.Windows.Forms.ComboBox cmbSearchCate;
		private System.Windows.Forms.ComboBox cmbSearchClass;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.NumericUpDown nupLevel5;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.NumericUpDown nupLevel4;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.NumericUpDown nupLevel3;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.NumericUpDown nupLevel2;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.NumericUpDown nupLevel1;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.Panel panel5;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.NumericUpDown nupTime;
		private System.Windows.Forms.Label label13;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.Label labHardLevel;
		private System.Windows.Forms.Button btnNew;
		private System.Windows.Forms.Button btnDelete;
		private System.Windows.Forms.Button btnChange;
		NumericUpDown[] nums=new NumericUpDown[5];
		DataView dvSearchCate;
		DataView dvCate;
		private ExamSystem.Common.DataListView dlvExams;
		DataView dvClass;
		private void fillArr()
		{
			nums[0]=this.nupLevel1;
			nums[1]=this.nupLevel2;
			nums[2]=this.nupLevel3;
			nums[3]=this.nupLevel4;
			nums[4]=this.nupLevel5;
		}


		private void displayExamInfo()
		{
			double titleCount=0;//题目总数
			double sum=0;//难度总数
			for(int i=0;i<this.nums.Length;i++)
			{
				sum+=Convert.ToDouble((i+1)*nums[i].Value);
				titleCount+=Convert.ToDouble(nums[i].Value);
				
			}
			double hardLevel=Math.Round(sum/titleCount,2);
			this.labHardLevel.Text="难度系数:"+hardLevel.ToString()+"\n题目总数:"+titleCount.ToString();
		}


		private void fillSelecter()
		{
			ClassFac clsFac=new ClassFac();
			DataSet dsClass=clsFac.getClass(-1,"",-1);
			CateFac cateFac=new CateFac();
			DataSet dsCate=cateFac.getCate(-1,"",-1);

			dvClass=dsClass.Copy().Tables[0].DefaultView;
			fillClass(this.cmbClass,dsClass);
			fillSerachClass(this.cmbSearchClass,dsClass);

			fillSearchCate(dsCate);
			fillCate(dsCate);

			this.cmbClass.SelectedIndexChanged += new System.EventHandler(this.cmbClass_SelectedIndexChanged);
			this.cmbSearchClass.SelectedIndexChanged += new System.EventHandler(this.cmbSearchClass_SelectedIndexChanged);
			
			if(cmbClass.Items.Count>0)
			{
				cmbClass.SelectedIndex=0;

			}
			if(cmbSearchClass.Items.Count>0)
			{
				cmbSearchClass.SelectedIndex=0;
			}

			
		}
		
		private void fillSearchCate(DataSet ds)
		{
			DataSet dsCate=ds.Copy();
			DataRow dr=dsCate.Tables[0].NewRow();
			dr[0]=-1;
			dr[1]="不限";
			dr[2]=-1;
			dsCate.Tables[0].Rows.InsertAt(dr,0);
			dvSearchCate=dsCate.Tables[0].DefaultView;

			cmbSearchCate.DataSource=dvSearchCate;
			cmbSearchCate.DisplayMember="CateName";
			cmbSearchCate.ValueMember="CateID";
		}

		private void fillCate(DataSet ds)
		{
			DataSet dsCate=ds.Copy();
			dvCate=dsCate.Tables[0].DefaultView;
			cmbCate.DataSource=dvCate;
			cmbCate.DisplayMember="CateName";
			cmbCate.ValueMember="CateID";
		}
		
		/// <summary>
		/// 清空所有文本框
		/// </summary>
		private void clearText()
		{
			this.txtName.Text="";
			this.cmbCate.Text="";
			this.cmbClass.Text="";
			this.chkEnd.Checked=false;
			this.nupTime.Value=nupTime.Minimum;
			for(int i=0;i<nums.Length;i++)
			{
				nums[i].Value=nums[i].Minimum;
			}
			enChange(false);
		}

		private void enChange(bool en)
		{
			this.txtName.Enabled=en;
			this.cmbCate.Enabled=en;
			this.cmbClass.Enabled=en;
			this.chkEnd.Enabled=en;
			this.nupTime.Enabled=en;
			for(int i=0;i<nums.Length;i++)
			{
				nums[i].Enabled=en;
			}
			this.btnChange.Enabled=en;
			this.btnDelete.Enabled=en;
		}

		/// <summary>
		/// 把选中项的信息显示出来
		/// </summary>
		/// <param name="item"></param>
		private void fillDisplay(int index)
		{
			if(index<0)
			{
				return;
			}
			DataTable dt=this.dlvExams.BindTable;
			this.txtName.Text=dt.Rows[index][1].ToString();
			this.cmbCate.SelectedValue=dt.Rows[index][7];
			this.cmbClass.SelectedValue=dt.Rows[index][8];
			this.chkEnd.Checked=Convert.ToBoolean(dt.Rows[index][6]);
			this.nupTime.Value=Convert.ToDecimal(dt.Rows[index][9]);
			string[] levels=dt.Rows[index][4].ToString().Split(new char[]{','});
			for(int i=0;i<nums.Length;i++)
			{
				nums[i].Value=Convert.ToDecimal(levels[i]);
			}
		}


		/// <summary>
		/// 填充搜索班级
		/// </summary>
		private void fillSerachClass(ComboBox cmb,DataSet ds)
		{
			cmb.Items.Clear();
			
			DataSet dsTmp=ds.Copy();
			DataRow dr=dsTmp.Tables[0].NewRow();
			dr[0]=-1;
			dr[1]="所有班级";
			dr[2]=0;
			dsTmp.Tables[0].Rows.InsertAt(dr,0);

			cmb.DataSource=dsTmp.Tables[0];
			cmb.DisplayMember="ClassName";
			cmb.ValueMember="ClassID";
		}

		/// <summary>
		/// 填充班级
		/// </summary>
		private void fillClass(ComboBox cmb,DataSet ds)
		{
			cmb.DataSource=ds.Tables[0];
			cmb.DisplayMember="ClassName";
			cmb.ValueMember="ClassID";
		}
		
		private void search()
		{
			ExamFac examFac=new ExamFac();
			int classID=(int)cmbSearchClass.SelectedValue;
			int cateID=(int)cmbSearchCate.SelectedValue;
			DataSet ds=examFac.getExam(-1,"",classID,cateID,"",SearchBooleans.NULL);
			dlvExams.BindTable=ds.Tables[0];
//			dlvExams.Columns[1].Width=0;
//			dlvExams.Columns[5].Width=0;
//			dlvExams.Columns[8].Width=0;
//			dlvExams.Columns[9].Width=0;
//			dlvExams.Columns[10].Width=0;
			dlvExams.Columns[2].Text="考试名";
			dlvExams.Columns[3].Text="考试班级";
			dlvExams.Columns[4].Text="创建日期";
			dlvExams.Columns[5].Text="考试科目";
			dlvExams.Columns[6].Text="已完结";
			dlvExams.AutoColumnsWidth=true;
			dlvExams.Columns.RemoveAt(10);
			dlvExams.Columns.RemoveAt(9);
			dlvExams.Columns.RemoveAt(8);
			dlvExams.Columns.RemoveAt(5);
			dlvExams.Columns.RemoveAt(1);
			dlvExams.AutoColumnsWidth=true;
		}


		

		public FrmExams()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.panel1 = new System.Windows.Forms.Panel();
			this.panel2 = new System.Windows.Forms.Panel();
			this.label13 = new System.Windows.Forms.Label();
			this.nupTime = new System.Windows.Forms.NumericUpDown();
			this.label12 = new System.Windows.Forms.Label();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.labHardLevel = new System.Windows.Forms.Label();
			this.nupLevel5 = new System.Windows.Forms.NumericUpDown();
			this.label8 = new System.Windows.Forms.Label();
			this.nupLevel4 = new System.Windows.Forms.NumericUpDown();
			this.label6 = new System.Windows.Forms.Label();
			this.nupLevel3 = new System.Windows.Forms.NumericUpDown();
			this.label7 = new System.Windows.Forms.Label();
			this.nupLevel2 = new System.Windows.Forms.NumericUpDown();
			this.label10 = new System.Windows.Forms.Label();
			this.nupLevel1 = new System.Windows.Forms.NumericUpDown();
			this.label11 = new System.Windows.Forms.Label();
			this.chkEnd = new System.Windows.Forms.CheckBox();
			this.cmbCate = new System.Windows.Forms.ComboBox();
			this.label3 = new System.Windows.Forms.Label();
			this.cmbClass = new System.Windows.Forms.ComboBox();
			this.label2 = new System.Windows.Forms.Label();
			this.txtName = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.panel5 = new System.Windows.Forms.Panel();
			this.btnNew = new System.Windows.Forms.Button();
			this.btnDelete = new System.Windows.Forms.Button();
			this.btnChange = new System.Windows.Forms.Button();
			this.panel4 = new System.Windows.Forms.Panel();
			this.button5 = new System.Windows.Forms.Button();
			this.splitter1 = new System.Windows.Forms.Splitter();
			this.gpSearch = new System.Windows.Forms.GroupBox();
			this.button1 = new System.Windows.Forms.Button();
			this.cmbSearchCate = new System.Windows.Forms.ComboBox();
			this.label4 = new System.Windows.Forms.Label();
			this.cmbSearchClass = new System.Windows.Forms.ComboBox();
			this.label5 = new System.Windows.Forms.Label();
			this.panel3 = new System.Windows.Forms.Panel();

⌨️ 快捷键说明

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