📄 updateclass.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace prjClass
{
/// <summary>
/// UpdateClass 的摘要说明。
/// </summary>
///
public delegate void LoadDataHandler();
public class UpdateClass : System.Windows.Forms.Form
{
private ClassInfo class1;
public event LoadDataHandler LoadDataEvent;
private Class1 c = new Class1();
private System.Windows.Forms.Button btnOK;
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.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.TextBox txtTeacher;
private System.Windows.Forms.TextBox txtRoom;
private System.Windows.Forms.TextBox txtMemo;
private System.Windows.Forms.TextBox txtDate;
private System.Windows.Forms.TextBox txtYear;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox txtSpec;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public UpdateClass(ClassInfo class1)
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
this.class1=class1;
//
// 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.btnOK = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.txtName = new System.Windows.Forms.TextBox();
this.txtTeacher = new System.Windows.Forms.TextBox();
this.txtRoom = new System.Windows.Forms.TextBox();
this.txtMemo = new System.Windows.Forms.TextBox();
this.txtDate = new System.Windows.Forms.TextBox();
this.txtYear = new System.Windows.Forms.TextBox();
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.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.txtSpec = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(152, 264);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 10;
this.btnOK.Text = "修改";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(240, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 23);
this.label1.TabIndex = 11;
this.label1.Text = "修改班级信息";
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(112, 56);
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(160, 21);
this.txtName.TabIndex = 1;
//
// txtTeacher
//
this.txtTeacher.Location = new System.Drawing.Point(368, 96);
this.txtTeacher.Name = "txtTeacher";
this.txtTeacher.Size = new System.Drawing.Size(160, 21);
this.txtTeacher.TabIndex = 2;
//
// txtRoom
//
this.txtRoom.Location = new System.Drawing.Point(112, 136);
this.txtRoom.Name = "txtRoom";
this.txtRoom.Size = new System.Drawing.Size(160, 21);
this.txtRoom.TabIndex = 3;
//
// txtMemo
//
this.txtMemo.Location = new System.Drawing.Point(112, 176);
this.txtMemo.Multiline = true;
this.txtMemo.Name = "txtMemo";
this.txtMemo.Size = new System.Drawing.Size(416, 64);
this.txtMemo.TabIndex = 4;
//
// txtDate
//
this.txtDate.Enabled = false;
this.txtDate.Location = new System.Drawing.Point(368, 136);
this.txtDate.Name = "txtDate";
this.txtDate.Size = new System.Drawing.Size(160, 21);
this.txtDate.TabIndex = 13;
//
// txtYear
//
this.txtYear.Enabled = false;
this.txtYear.Location = new System.Drawing.Point(368, 56);
this.txtYear.Name = "txtYear";
this.txtYear.Size = new System.Drawing.Size(160, 21);
this.txtYear.TabIndex = 14;
//
// label2
//
this.label2.Location = new System.Drawing.Point(296, 56);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 15;
this.label2.Text = "年制";
//
// label3
//
this.label3.Location = new System.Drawing.Point(296, 96);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 23);
this.label3.TabIndex = 16;
this.label3.Text = "班主任";
//
// label4
//
this.label4.Location = new System.Drawing.Point(296, 136);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(72, 23);
this.label4.TabIndex = 17;
this.label4.Text = "入学日期";
//
// label5
//
this.label5.Location = new System.Drawing.Point(40, 176);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(72, 23);
this.label5.TabIndex = 18;
this.label5.Text = "备注";
//
// label6
//
this.label6.Location = new System.Drawing.Point(40, 136);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(72, 23);
this.label6.TabIndex = 19;
this.label6.Text = "教室编号";
//
// label7
//
this.label7.Location = new System.Drawing.Point(40, 96);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(72, 23);
this.label7.TabIndex = 20;
this.label7.Text = "专业";
//
// label8
//
this.label8.Location = new System.Drawing.Point(40, 56);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(72, 23);
this.label8.TabIndex = 21;
this.label8.Text = "班级名称";
//
// button1
//
this.button1.Location = new System.Drawing.Point(408, 264);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 22;
this.button1.Text = "取消";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// txtSpec
//
this.txtSpec.Enabled = false;
this.txtSpec.Location = new System.Drawing.Point(112, 96);
this.txtSpec.Name = "txtSpec";
this.txtSpec.Size = new System.Drawing.Size(160, 21);
this.txtSpec.TabIndex = 23;
this.txtSpec.TextChanged += new System.EventHandler(this.txtSpec_TextChanged);
//
// UpdateClass
//
this.AcceptButton = this.btnOK;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(578, 311);
this.Controls.Add(this.txtSpec);
this.Controls.Add(this.button1);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtYear);
this.Controls.Add(this.txtDate);
this.Controls.Add(this.txtMemo);
this.Controls.Add(this.txtRoom);
this.Controls.Add(this.txtTeacher);
this.Controls.Add(this.txtName);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnOK);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "UpdateClass";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "修改班级信息";
this.Load += new System.EventHandler(this.UpdateClass_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private void UpdateClass_Load(object sender, System.EventArgs e)
{
this.txtDate.Text=DateTime.Parse(class1.Date).ToShortDateString().ToString();
this.txtMemo.Text=class1.Memo;
this.txtName.Text=class1.Name;
this.txtRoom.Text=class1.Room;
this.txtSpec.Text=class1.Spec;
this.txtTeacher.Text=class1.Teacher;
this.txtYear.Text=class1.Year;
}
private void button1_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void btnOK_Click(object sender, System.EventArgs e)
{
string Sql = "select * from Class..ClassInfo where ClassID <> "+class1.ID+" and ClassName = '"+this.txtName.Text+"'";
string update = "update Class..ClassInfo set ClassName = '"+this.txtName.Text+"',Teacher = '"+this.txtTeacher.Text+"',ClassNumber = '"+this.txtRoom.Text+"' where ClassID = "+class1.ID+"";
if(c.IsExits(Sql)==true)
{
MessageBox.Show("该班级名称已经存在!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
}
else
{
c.EditData(update);
if(this.LoadDataEvent!=null)
{
this.LoadDataEvent();
}
this.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -