📄 添加科目.cs
字号:
namespace 毕业设计
{
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using 毕业设计.数据处理;
namespace 软件系统
{
/// <summary>
/// RuleAdd 的摘要说明。
/// </summary>
public class 添加科目 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtCourse;
private System.Windows.Forms.Button btnRuleAdd;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox cmbCourseType;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private int type=3;
public 添加科目()
{
//
// 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.label1 = new System.Windows.Forms.Label();
this.btnRuleAdd = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.txtCourse = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.cmbCourseType = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 40);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "科目名称";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// btnRuleAdd
//
this.btnRuleAdd.Location = new System.Drawing.Point(56, 120);
this.btnRuleAdd.Name = "btnRuleAdd";
this.btnRuleAdd.TabIndex = 2;
this.btnRuleAdd.Text = "添加";
this.btnRuleAdd.Click += new System.EventHandler(this.btnRuleAdd_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(168, 120);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "取消";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// txtCourse
//
this.txtCourse.Location = new System.Drawing.Point(136, 40);
this.txtCourse.Name = "txtCourse";
this.txtCourse.TabIndex = 4;
this.txtCourse.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 80);
this.label2.Name = "label2";
this.label2.TabIndex = 5;
this.label2.Text = "科目类型";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// cmbCourseType
//
this.cmbCourseType.Items.AddRange(new object[] {
"健康项目",
"公共考核",
"专项课程"});
this.cmbCourseType.Location = new System.Drawing.Point(136, 80);
this.cmbCourseType.Name = "cmbCourseType";
this.cmbCourseType.Size = new System.Drawing.Size(104, 20);
this.cmbCourseType.TabIndex = 6;
this.cmbCourseType.Text = "专项课程";
//
// RuleAdd
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 174);
this.Controls.Add(this.cmbCourseType);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtCourse);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnRuleAdd);
this.Controls.Add(this.label1);
this.Name = "RuleAdd";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "添加科目";
this.Load += new System.EventHandler(this.RuleAdd_Load);
this.ResumeLayout(false);
}
#endregion
private void RuleAdd_Load(object sender, System.EventArgs e)
{
}
private void btnRuleAdd_Click(object sender, System.EventArgs e)
{
if(txtCourse.Text.Trim()!="")
{
毕业设计.数据处理.数据处理 o=new 毕业设计.数据处理.数据处理();
if(this.cmbCourseType.Text=="健康项目")
{
type=1;
}
if(this.cmbCourseType.Text=="公共考核")
{
type=2;
}
if(this.cmbCourseType.Text=="专项课程")
{
type=3;
}
if(o.NewCourse(txtCourse.Text.Trim(),type))
{
MessageBox.Show("添加成功");
this.Dispose(true);
}
else
MessageBox.Show("添加失败");
}
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
this.Dispose(true);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -