📄 创建考试.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data;
namespace 自动化考试系统
{
/// <summary>
/// 创建考试 的摘要说明。
/// </summary>
public class chuangjiankaoshi : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public chuangjiankaoshi()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private System.Windows.Forms.Label fenshou;
private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.Label label10;
/// <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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(chuangjiankaoshi));
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label10 = new System.Windows.Forms.Label();
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.fenshou = new System.Windows.Forms.Label();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Font = new System.Drawing.Font("宋体", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.ForeColor = System.Drawing.Color.White;
this.label1.Location = new System.Drawing.Point(104, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(176, 40);
this.label1.TabIndex = 0;
this.label1.Text = "创 建 考 试";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.ForeColor = System.Drawing.Color.White;
this.label2.Location = new System.Drawing.Point(72, 96);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(40, 24);
this.label2.TabIndex = 1;
this.label2.Text = "科目";
//
// label3
//
this.label3.BackColor = System.Drawing.Color.Transparent;
this.label3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label3.ForeColor = System.Drawing.Color.White;
this.label3.Location = new System.Drawing.Point(72, 144);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(64, 24);
this.label3.TabIndex = 1;
this.label3.Text = "考试代码";
//
// label4
//
this.label4.BackColor = System.Drawing.Color.Transparent;
this.label4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label4.ForeColor = System.Drawing.Color.White;
this.label4.Location = new System.Drawing.Point(72, 184);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(104, 24);
this.label4.TabIndex = 1;
this.label4.Text = "每道题的分数";
//
// label5
//
this.label5.BackColor = System.Drawing.Color.Transparent;
this.label5.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label5.ForeColor = System.Drawing.Color.White;
this.label5.Location = new System.Drawing.Point(360, 144);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(64, 24);
this.label5.TabIndex = 1;
this.label5.Text = "试题数目";
//
// label6
//
this.label6.BackColor = System.Drawing.Color.Transparent;
this.label6.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label6.ForeColor = System.Drawing.Color.White;
this.label6.Location = new System.Drawing.Point(360, 96);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(64, 24);
this.label6.TabIndex = 1;
this.label6.Text = "考试标题";
//
// comboBox1
//
this.comboBox1.Items.AddRange(new object[] {
"C#",
"数学",
"语文"});
this.comboBox1.Location = new System.Drawing.Point(152, 96);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(96, 20);
this.comboBox1.TabIndex = 2;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(152, 139);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(112, 21);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(456, 96);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(112, 21);
this.textBox2.TabIndex = 3;
this.textBox2.Text = "";
//
// groupBox1
//
this.groupBox1.BackColor = System.Drawing.Color.Transparent;
this.groupBox1.Controls.Add(this.label10);
this.groupBox1.Controls.Add(this.dateTimePicker1);
this.groupBox1.Controls.Add(this.textBox4);
this.groupBox1.Controls.Add(this.textBox3);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.label8);
this.groupBox1.Controls.Add(this.label9);
this.groupBox1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.groupBox1.ForeColor = System.Drawing.Color.White;
this.groupBox1.Location = new System.Drawing.Point(72, 216);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(496, 120);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "考试安排详细信息";
//
// label10
//
this.label10.Location = new System.Drawing.Point(424, 27);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(48, 16);
this.label10.TabIndex = 6;
this.label10.Text = "分钟";
//
// dateTimePicker1
//
this.dateTimePicker1.Location = new System.Drawing.Point(96, 24);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(120, 23);
this.dateTimePicker1.TabIndex = 5;
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(96, 72);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(88, 23);
this.textBox4.TabIndex = 4;
this.textBox4.Text = "";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(360, 24);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(48, 23);
this.textBox3.TabIndex = 1;
this.textBox3.Text = "";
//
// label7
//
this.label7.Location = new System.Drawing.Point(16, 24);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(64, 16);
this.label7.TabIndex = 0;
this.label7.Text = "预定时间";
//
// label8
//
this.label8.Location = new System.Drawing.Point(16, 72);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(64, 16);
this.label8.TabIndex = 0;
this.label8.Text = "预定地点";
//
// label9
//
this.label9.Location = new System.Drawing.Point(280, 24);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(64, 16);
this.label9.TabIndex = 0;
this.label9.Text = "持续时间";
//
// button2
//
this.button2.BackColor = System.Drawing.Color.Transparent;
this.button2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button2.ForeColor = System.Drawing.Color.White;
this.button2.Location = new System.Drawing.Point(120, 392);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(96, 40);
this.button2.TabIndex = 6;
this.button2.Text = "创 建";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.BackColor = System.Drawing.Color.Transparent;
this.button3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button3.ForeColor = System.Drawing.Color.White;
this.button3.Location = new System.Drawing.Point(400, 384);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(96, 40);
this.button3.TabIndex = 6;
this.button3.Text = "关 闭";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// fenshou
//
this.fenshou.BackColor = System.Drawing.Color.Transparent;
this.fenshou.ForeColor = System.Drawing.Color.White;
this.fenshou.Location = new System.Drawing.Point(176, 184);
this.fenshou.Name = "fenshou";
this.fenshou.Size = new System.Drawing.Size(48, 24);
this.fenshou.TabIndex = 7;
//
// comboBox2
//
this.comboBox2.Items.AddRange(new object[] {
"5",
"10\t",
"20",
"25",
"50"});
this.comboBox2.Location = new System.Drawing.Point(448, 144);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(72, 20);
this.comboBox2.TabIndex = 8;
this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
//
// chuangjiankaoshi
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(664, 480);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.fenshou);
this.Controls.Add(this.button2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label4);
this.Controls.Add(this.label5);
this.Controls.Add(this.label6);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.button3);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "chuangjiankaoshi";
this.Text = "创建考试";
this.Load += new System.EventHandler(this.chuangjiankaoshi_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void button3_Click(object sender, System.EventArgs e)
{
// Application.Exit();
this.Hide();
}
private void chuangjiankaoshi_Load(object sender, System.EventArgs e)
{
this.comboBox1.SelectedIndex=0;
}
private void numericUpDown1_ValueChanged(object sender, System.EventArgs e)
{
}
private void button2_Click(object sender, System.EventArgs e)
{
string stl="Provider=Microsoft.Jet.OLEDB.4.0;"+@"Data source=hua.mdb";
OleDbConnection con=new OleDbConnection(stl);
con.Open();
string str="insert into chuangjiankaoshi values('"+this.comboBox1.Text+"','"+this.textBox1.Text+"','"+this.textBox2.Text+"','"+this.comboBox2.Text+"','"+this.fenshou.Text+"','"+this.dateTimePicker1.Text+"','"+this.textBox3.Text+"','"+this.textBox4.Text+"')";
OleDbCommand an=new OleDbCommand(str,con);
int num=an.ExecuteNonQuery();
if(num==1)
{
MessageBox.Show("创建成功","信息");
}
else
{
MessageBox.Show("创建失败","信息");
}
}
private void comboBox2_SelectedIndexChanged(object sender, System.EventArgs e)
{
int minute=Convert.ToInt32(this.comboBox2.SelectedItem.ToString());
this.fenshou.Text=Convert.ToString(100/minute);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -