📄 frmupdatescore.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace prjClass
{
/// <summary>
/// frmUpdateScore 的摘要说明。
/// </summary>
///
public delegate void UpdateHandler();
public class frmUpdateScore : System.Windows.Forms.Form
{
Class1 c = new Class1();
public event UpdateHandler UpdateEvent;
private string Course;
private string Score;
private string ScoreID;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button btnCancle;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public frmUpdateScore(string Course,string Score,string ScoreID)
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
this.Score=Score;
this.Course=Course;
this.ScoreID=ScoreID;
//
// 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.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.btnCancle = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(80, 184);
this.btnOK.Name = "btnOK";
this.btnOK.TabIndex = 0;
this.btnOK.Text = "确定";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(128, 40);
this.label1.Name = "label1";
this.label1.TabIndex = 1;
this.label1.Text = "label1";
//
// label2
//
this.label2.Location = new System.Drawing.Point(88, 96);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(40, 23);
this.label2.TabIndex = 2;
this.label2.Text = "分数";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(128, 96);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(152, 21);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
//
// btnCancle
//
this.btnCancle.Location = new System.Drawing.Point(208, 184);
this.btnCancle.Name = "btnCancle";
this.btnCancle.TabIndex = 4;
this.btnCancle.Text = "取消";
this.btnCancle.Click += new System.EventHandler(this.btnCancle_Click);
//
// frmUpdateScore
//
this.AcceptButton = this.btnOK;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(362, 239);
this.Controls.Add(this.btnCancle);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnOK);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "frmUpdateScore";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "成绩修改";
this.Load += new System.EventHandler(this.frmUpdateScore_Load);
this.ResumeLayout(false);
}
#endregion
private void frmUpdateScore_Load(object sender, System.EventArgs e)
{
this.label1.Text=this.Course;
this.textBox1.Text=this.Score;
}
private void btnOK_Click(object sender, System.EventArgs e)
{
if(c.IsYear(this.textBox1.Text)==true&&int.Parse(this.textBox1.Text)>=0&&int.Parse(this.textBox1.Text)<=100)
{
string Sql = "update Class..ScoreInfo set Score = "+this.textBox1.Text+" where ScoreID = "+this.ScoreID+"";
c.EditData(Sql);
if(this.UpdateEvent!=null)
{
this.UpdateEvent();
}
this.Close();
}
else
{
MessageBox.Show("成绩输入有误!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
}
}
private void btnCancle_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -