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

📄 frmaddexam.cs

📁 考试管理系统CS架构 不需更多说明
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// nupLevel3
			// 
			this.nupLevel3.Location = new System.Drawing.Point(60, 74);
			this.nupLevel3.Name = "nupLevel3";
			this.nupLevel3.Size = new System.Drawing.Size(42, 21);
			this.nupLevel3.TabIndex = 5;
			this.nupLevel3.ValueChanged += new System.EventHandler(this.nupLevel1_ValueChanged);
			this.nupLevel3.Leave += new System.EventHandler(this.nupLevel1_Leave);
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(18, 78);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(44, 16);
			this.label7.TabIndex = 4;
			this.label7.Text = "难度3:";
			// 
			// nupLevel2
			// 
			this.nupLevel2.Location = new System.Drawing.Point(60, 48);
			this.nupLevel2.Name = "nupLevel2";
			this.nupLevel2.Size = new System.Drawing.Size(42, 21);
			this.nupLevel2.TabIndex = 3;
			this.nupLevel2.ValueChanged += new System.EventHandler(this.nupLevel1_ValueChanged);
			this.nupLevel2.Leave += new System.EventHandler(this.nupLevel1_Leave);
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(18, 52);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(44, 16);
			this.label5.TabIndex = 2;
			this.label5.Text = "难度2:";
			// 
			// nupLevel1
			// 
			this.nupLevel1.Location = new System.Drawing.Point(60, 24);
			this.nupLevel1.Name = "nupLevel1";
			this.nupLevel1.Size = new System.Drawing.Size(42, 21);
			this.nupLevel1.TabIndex = 1;
			this.nupLevel1.ValueChanged += new System.EventHandler(this.nupLevel1_ValueChanged);
			this.nupLevel1.Leave += new System.EventHandler(this.nupLevel1_Leave);
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(18, 28);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(44, 16);
			this.label4.TabIndex = 0;
			this.label4.Text = "难度1:";
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.label10);
			this.panel1.Controls.Add(this.nupTime);
			this.panel1.Controls.Add(this.label9);
			this.panel1.Controls.Add(this.cmbCate);
			this.panel1.Controls.Add(this.label3);
			this.panel1.Controls.Add(this.cmbClass);
			this.panel1.Controls.Add(this.label2);
			this.panel1.Controls.Add(this.txtName);
			this.panel1.Controls.Add(this.label1);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
			this.panel1.Location = new System.Drawing.Point(0, 0);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(348, 146);
			this.panel1.TabIndex = 15;
			// 
			// label10
			// 
			this.label10.Location = new System.Drawing.Point(194, 112);
			this.label10.Name = "label10";
			this.label10.Size = new System.Drawing.Size(42, 18);
			this.label10.TabIndex = 20;
			this.label10.Text = "分钟";
			// 
			// nupTime
			// 
			this.nupTime.Location = new System.Drawing.Point(122, 108);
			this.nupTime.Maximum = new System.Decimal(new int[] {
																	300,
																	0,
																	0,
																	0});
			this.nupTime.Minimum = new System.Decimal(new int[] {
																	30,
																	0,
																	0,
																	0});
			this.nupTime.Name = "nupTime";
			this.nupTime.Size = new System.Drawing.Size(66, 21);
			this.nupTime.TabIndex = 19;
			this.nupTime.Value = new System.Decimal(new int[] {
																  30,
																  0,
																  0,
																  0});
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(60, 110);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(62, 16);
			this.label9.TabIndex = 18;
			this.label9.Text = "考试时间:";
			// 
			// cmbCate
			// 
			this.cmbCate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cmbCate.Location = new System.Drawing.Point(124, 72);
			this.cmbCate.Name = "cmbCate";
			this.cmbCate.Size = new System.Drawing.Size(114, 20);
			this.cmbCate.TabIndex = 17;
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(62, 74);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(60, 16);
			this.label3.TabIndex = 16;
			this.label3.Text = "考试科目:";
			// 
			// cmbClass
			// 
			this.cmbClass.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cmbClass.Location = new System.Drawing.Point(124, 40);
			this.cmbClass.Name = "cmbClass";
			this.cmbClass.Size = new System.Drawing.Size(114, 20);
			this.cmbClass.TabIndex = 15;
			
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(62, 42);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(60, 18);
			this.label2.TabIndex = 14;
			this.label2.Text = "考试班级:";
			// 
			// txtName
			// 
			this.txtName.Location = new System.Drawing.Point(122, 10);
			this.txtName.Name = "txtName";
			this.txtName.Size = new System.Drawing.Size(114, 21);
			this.txtName.TabIndex = 13;
			this.txtName.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(62, 14);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(56, 16);
			this.label1.TabIndex = 12;
			this.label1.Text = "考试名:";
			// 
			// FrmAddExam
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(348, 357);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.panel1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "FrmAddExam";
			this.Text = "添加考试";
			this.Load += new System.EventHandler(this.FrmAddExam_Load);
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.nupLevel5)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.nupLevel4)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.nupLevel3)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.nupLevel2)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.nupLevel1)).EndInit();
			this.panel1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.nupTime)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 判断是否有文本没有填入
		/// </summary>
		/// <returns></returns>
		private bool hasEmpty()
		{
			if(this.txtName.Text.Trim()=="")
			{
				MessageBox.Show("请填入考试名称","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
				txtName.Focus();
				return true;
			}
			return false;
		}

		private string getTitles()
		{
			string resStr="";
			for(int i=0;i<this.nums.Length;i++)
			{
				resStr+=nums[i].Value.ToString();
				if(i<nums.Length-1)
				{
					resStr+=",";
				}
			}
			return resStr;
		}
		private void button1_Click(object sender, System.EventArgs e)
		{
			if(hasEmpty())
			{
				return;
			}
			ExamFac examFac=new ExamFac();
			
			try
			{
				if(examFac.insertExam(this.txtName.Text,(int)cmbClass.SelectedValue,(int)cmbCate.SelectedValue,getTitles(),(int)this.nupTime.Value))
				{
					MessageBox.Show("添加成功","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
					this.hasAdd=true;
				}
				else
				{
					MessageBox.Show("有重复的考试名","添加失败",MessageBoxButtons.OK,MessageBoxIcon.Error);
				}
			}
			catch
			{
				MessageBox.Show("添加出错","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}

		private void FrmAddExam_Load(object sender, System.EventArgs e)
		{
			fillSelecter();
			
			fillArr();
			//cmbCate.SelectedIndex=0;
			hasAdd=false;
		}

		private void nupLevel1_ValueChanged(object sender, System.EventArgs e)
		{
			displayExamInfo();
		}

		private void nupLevel1_Leave(object sender, System.EventArgs e)
		{
			displayExamInfo();
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void cmbClass_SelectedIndexChanged(object sender, EventArgs e)
		{
			if(cmbClass.SelectedIndex<0)
			{
				return;
			}
			dvClass.RowFilter="ClassID="+cmbClass.SelectedValue.ToString();
			if(dvClass.Count>0)
			{
				dvCate.RowFilter="GradeID="+dvClass[0]["Grade"].ToString()+" or GradeID=0";
			}
		}
	}
}

⌨️ 快捷键说明

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