📄 modifyspecialty.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsApplication1
{
/// <summary>
/// xgzy 的摘要说明。
/// </summary>
public class ModifySpecialty : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
public System.Windows.Forms.TextBox textBox2;
public System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private OleDbConnection cn;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public ModifySpecialty()
{
//
// 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.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label3.ForeColor = System.Drawing.SystemColors.ControlText;
this.label3.Location = new System.Drawing.Point(16, 80);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(67, 21);
this.label3.TabIndex = 13;
this.label3.Text = "专业描述";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.ForeColor = System.Drawing.SystemColors.ControlText;
this.label2.Location = new System.Drawing.Point(176, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(67, 21);
this.label2.TabIndex = 12;
this.label2.Text = "专业名称";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.ForeColor = System.Drawing.SystemColors.ControlText;
this.label1.Location = new System.Drawing.Point(160, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(98, 21);
this.label1.TabIndex = 11;
this.label1.Text = "修改专业信息";
//
// textBox2
//
this.textBox2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox2.ForeColor = System.Drawing.SystemColors.ControlText;
this.textBox2.Location = new System.Drawing.Point(96, 80);
this.textBox2.Multiline = true;
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(330, 62);
this.textBox2.TabIndex = 8;
this.textBox2.Text = "";
//
// textBox1
//
this.textBox1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox1.ForeColor = System.Drawing.SystemColors.ControlText;
this.textBox1.Location = new System.Drawing.Point(248, 40);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(176, 25);
this.textBox1.TabIndex = 7;
this.textBox1.Text = "";
//
// button2
//
this.button2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button2.ForeColor = System.Drawing.SystemColors.ControlText;
this.button2.Location = new System.Drawing.Point(304, 152);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(100, 29);
this.button2.TabIndex = 10;
this.button2.Text = "取消";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button1.ForeColor = System.Drawing.SystemColors.ControlText;
this.button1.Location = new System.Drawing.Point(48, 152);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(100, 29);
this.button1.TabIndex = 9;
this.button1.Text = "确定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label4.ForeColor = System.Drawing.SystemColors.ControlText;
this.label4.Location = new System.Drawing.Point(16, 40);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(67, 21);
this.label4.TabIndex = 14;
this.label4.Text = "专业编号";
//
// label5
//
this.label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label5.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.label5.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label5.ForeColor = System.Drawing.SystemColors.ControlText;
this.label5.Location = new System.Drawing.Point(96, 40);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(74, 25);
this.label5.TabIndex = 15;
this.label5.Text = "专业编号";
//
// ModifySpecialty
//
this.AutoScaleBaseSize = new System.Drawing.Size(8, 18);
this.ClientSize = new System.Drawing.Size(450, 190);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "ModifySpecialty";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "修改专业信息";
this.Load += new System.EventHandler(this.xgzy_Load);
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
if ((textBox1.Text.Trim()=="") || (textBox2.Text.Trim()==""))
MessageBox.Show("提示","请输入完整的专业信息");
else
{
cn.Open();
OleDbCommand cmd=new OleDbCommand("select * from SpecialtyInfo where SpecialtyName='"+textBox1.Text.Trim()+"' and SpecialtyId<>"+this.Tag.ToString().Trim(),cn);
if (null!=cmd.ExecuteScalar())
MessageBox.Show("专业名称发生重复","提示");
else
{
string sql="update SpecialtyInfo set SpecialtyName='"+textBox1.Text.Trim()+"',Remark='"+textBox2.Text.Trim()+"' where Specialtyid="+this.Tag.ToString().Trim();
cmd.CommandText=sql;
cmd.ExecuteNonQuery();
MessageBox.Show("专业信息修改成功","提示");
}
cn.Close();
}
}
private void xgzy_Load(object sender, System.EventArgs e)
{
cn=new OleDbConnection("Data Source=xsxxdb.mdb;Jet OLEDB:Engine Type=5;Provider=Microsoft.Jet.OLEDB.4.0;");
label5.Text=this.Tag.ToString().Trim();
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -