📄 modifyscore.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsApplication1
{
/// <summary>
/// ModifyScore 的摘要说明。
/// </summary>
public class ModifyScore : System.Windows.Forms.Form
{
public System.Windows.Forms.Label label1;
public System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label2;
private System.Data.OleDb.OleDbConnection oleDbConnection1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public ModifyScore()
{
//
// 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.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(21, 21);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(214, 29);
this.label1.TabIndex = 0;
this.label1.Text = "课程";
this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(117, 62);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(118, 25);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(32, 113);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(85, 30);
this.button1.TabIndex = 2;
this.button1.Text = "修改";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(149, 113);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(86, 30);
this.button2.TabIndex = 3;
this.button2.Text = "退出";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 21);
this.label2.TabIndex = 4;
this.label2.Text = "分数:";
//
// oleDbConnection1
//
this.oleDbConnection1.ConnectionString = "Data Source=xsxxdb.mdb;Jet OLEDB:Engine Type=5;Provider=Microsoft.Jet." +
"OLEDB.4.0;";
//
// ModifyScore
//
this.AutoScaleBaseSize = new System.Drawing.Size(8, 18);
this.ClientSize = new System.Drawing.Size(258, 152);
this.Controls.Add(this.label2);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "ModifyScore";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "成绩修改";
this.ResumeLayout(false);
}
#endregion
public int strisnumber(string s)
{
int n=0;
for (int i=0;i<=s.Length-1;i++)
{
if (!System.Char.IsNumber(s[i]))
{
n=-1;
break;
}
else
n++;
}
if (n>=1)
return (int.Parse(s));
else
return (-1);
}
private void button1_Click(object sender, System.EventArgs e)
{
int cj=strisnumber(textBox1.Text.Trim());
if (cj>=0 && cj<=100)
{
oleDbConnection1.Open();
string sql="update ScoreInfo set Score="+textBox1.Text.Trim()+" where ScoreId="+this.Tag.ToString().Trim();
OleDbCommand cmd=new OleDbCommand(sql,oleDbConnection1);
cmd.ExecuteNonQuery();
MessageBox.Show("成绩修改完成");
oleDbConnection1.Close();
this.Close();
}
else
MessageBox.Show("分数非法");
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -