📄 frmaddexam.cs
字号:
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;
namespace TeachersClient.ExamFrms
{
/// <summary>
/// FrmAddExam 的摘要说明。
/// </summary>
public class FrmAddExam : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Panel panel1;
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;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.NumericUpDown nupLevel5;
private System.Windows.Forms.NumericUpDown nupLevel4;
private System.Windows.Forms.NumericUpDown nupLevel3;
private System.Windows.Forms.NumericUpDown nupLevel2;
private System.Windows.Forms.NumericUpDown nupLevel1;
private System.Windows.Forms.Label labHardLevel;
private bool hasAdd;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.NumericUpDown nupTime;
DataView dvCate;
DataView dvClass;
/// <summary>
/// 返回是否有添加过记录
/// </summary>
public bool HasAdd
{
get
{
return hasAdd;
}
}
NumericUpDown[] nums=new NumericUpDown[5];
/// <summary>
/// 填充班级
/// </summary>
private void fillClass(ComboBox cmb,DataSet ds)
{
cmb.DataSource=ds.Tables[0];
cmb.DisplayMember="ClassName";
cmb.ValueMember="ClassID";
}
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);
fillCate(dsCate);
this.cmbClass.SelectedIndexChanged+=new EventHandler(cmbClass_SelectedIndexChanged);
if(cmbClass.Items.Count>0)
{
cmbClass.SelectedIndex=0;
}
}
private void fillCate(DataSet ds)
{
DataSet dsCate=ds.Copy();
dvCate=dsCate.Tables[0].DefaultView;
cmbCate.DataSource=dvCate;
cmbCate.DisplayMember="CateName";
cmbCate.ValueMember="CateID";
}
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();
}
public FrmAddExam()
{
//
// 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.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
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.label5 = new System.Windows.Forms.Label();
this.nupLevel1 = new System.Windows.Forms.NumericUpDown();
this.label4 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.label10 = new System.Windows.Forms.Label();
this.nupTime = new System.Windows.Forms.NumericUpDown();
this.label9 = new System.Windows.Forms.Label();
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.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nupLevel5)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupLevel4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupLevel3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupLevel2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nupLevel1)).BeginInit();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nupTime)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(96, 322);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(62, 24);
this.button1.TabIndex = 12;
this.button1.Text = "添加";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(184, 322);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(60, 24);
this.button2.TabIndex = 13;
this.button2.Text = "关闭";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.labHardLevel);
this.groupBox1.Controls.Add(this.nupLevel5);
this.groupBox1.Controls.Add(this.label8);
this.groupBox1.Controls.Add(this.nupLevel4);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.nupLevel3);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.nupLevel2);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.nupLevel1);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.groupBox1.Location = new System.Drawing.Point(0, 146);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(348, 162);
this.groupBox1.TabIndex = 14;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "题目数";
//
// labHardLevel
//
this.labHardLevel.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.labHardLevel.Location = new System.Drawing.Point(112, 26);
this.labHardLevel.Name = "labHardLevel";
this.labHardLevel.Size = new System.Drawing.Size(220, 122);
this.labHardLevel.TabIndex = 10;
this.labHardLevel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// nupLevel5
//
this.nupLevel5.Location = new System.Drawing.Point(62, 124);
this.nupLevel5.Name = "nupLevel5";
this.nupLevel5.Size = new System.Drawing.Size(42, 21);
this.nupLevel5.TabIndex = 9;
this.nupLevel5.ValueChanged += new System.EventHandler(this.nupLevel1_ValueChanged);
this.nupLevel5.Leave += new System.EventHandler(this.nupLevel1_Leave);
//
// label8
//
this.label8.Location = new System.Drawing.Point(18, 128);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(44, 16);
this.label8.TabIndex = 8;
this.label8.Text = "难度5:";
//
// nupLevel4
//
this.nupLevel4.Location = new System.Drawing.Point(60, 98);
this.nupLevel4.Name = "nupLevel4";
this.nupLevel4.Size = new System.Drawing.Size(42, 21);
this.nupLevel4.TabIndex = 7;
this.nupLevel4.ValueChanged += new System.EventHandler(this.nupLevel1_ValueChanged);
this.nupLevel4.Leave += new System.EventHandler(this.nupLevel1_Leave);
//
// label6
//
this.label6.Location = new System.Drawing.Point(18, 102);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(44, 16);
this.label6.TabIndex = 6;
this.label6.Text = "难度4:";
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -