⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modifycourse.cs

📁 C#编写的学籍管理系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data;

namespace WindowsApplication1
{
	/// <summary>
	/// ModifyCourse 的摘要说明。
	/// </summary>
	public class ModifyCourse : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label6;
		public System.Windows.Forms.Label label5;
		public System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button1;
		private System.Data.OleDb.OleDbConnection oleDbConnection1;
		public System.Windows.Forms.TextBox textBox1;
		public System.Windows.Forms.Label label7;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public ModifyCourse()
		{
			//
			// 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.label6 = new System.Windows.Forms.Label();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.label5 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.button2 = new System.Windows.Forms.Button();
			this.button1 = new System.Windows.Forms.Button();
			this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
			this.label7 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// label6
			// 
			this.label6.AutoSize = true;
			this.label6.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label6.ForeColor = System.Drawing.SystemColors.ControlText;
			this.label6.Location = new System.Drawing.Point(107, 10);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(98, 21);
			this.label6.TabIndex = 27;
			this.label6.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(96, 134);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(181, 25);
			this.textBox1.TabIndex = 23;
			this.textBox1.Text = "";
			// 
			// label5
			// 
			this.label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			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, 82);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(181, 34);
			this.label5.TabIndex = 22;
			// 
			// label4
			// 
			this.label4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			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(96, 41);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(181, 31);
			this.label4.TabIndex = 20;
			// 
			// 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(11, 134);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(67, 21);
			this.label3.TabIndex = 18;
			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(43, 93);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(36, 21);
			this.label2.TabIndex = 16;
			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(43, 51);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(36, 21);
			this.label1.TabIndex = 15;
			this.label1.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(213, 175);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(64, 31);
			this.button2.TabIndex = 25;
			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(32, 175);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(64, 31);
			this.button1.TabIndex = 24;
			this.button1.Text = "修改";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// oleDbConnection1
			// 
			this.oleDbConnection1.ConnectionString = "Data Source=xsxxdb.mdb;Jet OLEDB:Engine Type=5;Provider=Microsoft.Jet." +
				"OLEDB.4.0;";
			// 
			// label7
			// 
			this.label7.AutoSize = true;
			this.label7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label7.ForeColor = System.Drawing.SystemColors.ControlText;
			this.label7.Location = new System.Drawing.Point(11, 10);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(67, 21);
			this.label7.TabIndex = 28;
			this.label7.Text = "班级编号";
			this.label7.Visible = false;
			// 
			// ModifyCourse
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(8, 18);
			this.ClientSize = new System.Drawing.Size(322, 224);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Name = "ModifyCourse";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "修改课程";
			this.Load += new System.EventHandler(this.ModifyCourse_Load);
			this.Closed += new System.EventHandler(this.ModifyCourse_Closed);
			this.ResumeLayout(false);

		}
		#endregion


		public bool strisyear(string s)
		{
			if (s.Trim().Length!=4)
				return (false);
			else
			{
				int n=1;
				for (int i=0;i<=s.Length-1;i++)
				{
					if (!System.Char.IsNumber(s[i]))
					{
						n=-1;
						break;
					}
				}
				if (n==1)
					return (true);
				else
					return (false);
			}
		}

		private void ModifyCourse_Load(object sender, System.EventArgs e)
		{
			oleDbConnection1.Open();
			string sql="select ClassInfo.ClassName,CourseInfo.Course,CourseInfo.Semester,CourseInfo.ClassId from CourseInfo inner join ClassInfo on CourseInfo.ClassId=ClassInfo.ClassId where CourseInfo.CourseId="+this.Tag.ToString().Trim();
            OleDbCommand cmd=new OleDbCommand(sql,oleDbConnection1);
            OleDbDataReader dr;
			dr=cmd.ExecuteReader();
			if (dr.Read())
			{
				label4.Text=dr.GetValue(0).ToString().Trim();
				textBox1.Text=dr.GetString(1).Trim();
				label5.Text=dr.GetString(2).Trim();
				label7.Text=dr.GetValue(3).ToString().Trim();
				dr.Close();
			}
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			string sql="select * from CourseInfo where ClassId="+label7.Text.Trim()+" and Semester='"+label5.Text.Trim()+"' and Course='"+textBox1.Text.Trim()+"' and CourseId<>"+this.Tag.ToString().Trim();
			OleDbCommand cmd=new OleDbCommand(sql,oleDbConnection1);
			cmd.CommandText=sql;
			if (null==cmd.ExecuteScalar())
			{
				sql="update CourseInfo set Course='"+textBox1.Text.Trim()+"' where CourseId="+this.Tag.ToString().Trim();
				cmd.CommandText=sql;
				cmd.ExecuteNonQuery();
				MessageBox.Show("课程修改成功","提示");
			}
			else
                MessageBox.Show("课程重复开设","错误");
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void ModifyCourse_Closed(object sender, System.EventArgs e)
		{
			oleDbConnection1.Close();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -