CourseInfo.cs
资源名称:VCSDB.rar [点击查看]
上传用户:hjieqiu
上传日期:2013-05-11
资源大小:16494k
文件大小:24k
源码类别:
企业管理
开发平台:
C#
- using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; using System.Data; using System.Data.SqlClient; namespace 教务管理系统 { public class CourseInfo : 医院管理系统.ParentForm {
- private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
- private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
- private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
- private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
- private System.Data.SqlClient.SqlConnection sqlConnection1;
- private 教务管理系统.DataSet1 dataSet11;
- private System.Windows.Forms.TextBox txt4;
- private System.Windows.Forms.TextBox txt5;
- private System.Windows.Forms.TextBox txt6;
- private System.Windows.Forms.TextBox txt9;
- private System.Windows.Forms.TextBox txt8;
- private System.Windows.Forms.TextBox txt7;
- 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.Label label9;
- private System.Windows.Forms.Label label10;
- private System.Windows.Forms.Label label11;
- private System.Windows.Forms.TextBox txt10;
- private System.Windows.Forms.ComboBox cmb1; private System.ComponentModel.IContainer components = null; public CourseInfo() { // 该调用是 Windows 窗体设计器所必需的。 InitializeComponent(); // TODO: 在 InitializeComponent 调用后添加任何初始化 } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region 设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
- this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
- this.dataSet11 = new 教务管理系统.DataSet1();
- this.txt4 = new System.Windows.Forms.TextBox();
- this.txt5 = new System.Windows.Forms.TextBox();
- this.txt6 = new System.Windows.Forms.TextBox();
- this.txt9 = new System.Windows.Forms.TextBox();
- this.txt8 = new System.Windows.Forms.TextBox();
- this.txt7 = new System.Windows.Forms.TextBox();
- 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.label9 = new System.Windows.Forms.Label();
- this.txt10 = new System.Windows.Forms.TextBox();
- this.label10 = new System.Windows.Forms.Label();
- this.label11 = new System.Windows.Forms.Label();
- this.cmb1 = new System.Windows.Forms.ComboBox();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
- this.groupBox2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
- //
- // groupBox1
- //
- this.groupBox1.Name = "groupBox1";
- //
- // txt2
- //
- this.txt2.Name = "txt2";
- //
- // label1
- //
- this.label1.Name = "label1";
- this.label1.Text = "课程名称";
- //
- // btnSearch
- //
- this.btnSearch.Name = "btnSearch";
- this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
- //
- // txt1
- //
- this.txt1.Name = "txt1";
- //
- // label2
- //
- this.label2.Name = "label2";
- this.label2.Text = "课程编号";
- //
- // txt3
- //
- this.txt3.Name = "txt3";
- //
- // label3
- //
- this.label3.Name = "label3";
- this.label3.Text = "拼音码";
- //
- // toolBar1
- //
- this.toolBar1.Name = "toolBar1";
- this.toolBar1.Size = new System.Drawing.Size(728, 41);
- //
- // dataGrid1
- //
- this.dataGrid1.DataMember = "课程信息";
- this.dataGrid1.DataSource = this.dataSet11;
- this.dataGrid1.Name = "dataGrid1";
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.cmb1);
- this.groupBox2.Controls.Add(this.txt4);
- this.groupBox2.Controls.Add(this.txt5);
- this.groupBox2.Controls.Add(this.txt6);
- this.groupBox2.Controls.Add(this.txt9);
- this.groupBox2.Controls.Add(this.txt8);
- this.groupBox2.Controls.Add(this.txt7);
- this.groupBox2.Controls.Add(this.label4);
- this.groupBox2.Controls.Add(this.label5);
- this.groupBox2.Controls.Add(this.label6);
- this.groupBox2.Controls.Add(this.label7);
- this.groupBox2.Controls.Add(this.label8);
- this.groupBox2.Controls.Add(this.label9);
- this.groupBox2.Controls.Add(this.txt10);
- this.groupBox2.Controls.Add(this.label10);
- this.groupBox2.Controls.Add(this.label11);
- this.groupBox2.Name = "groupBox2";
- //
- // da1
- //
- this.da1.DeleteCommand = this.sqlDeleteCommand1;
- this.da1.InsertCommand = this.sqlInsertCommand1;
- this.da1.SelectCommand = this.sqlSelectCommand1;
- this.da1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
- new System.Data.Common.DataTableMapping("Table", "课程信息", new System.Data.Common.DataColumnMapping[] {
- new System.Data.Common.DataColumnMapping("课程编号", "课程编号"),
- new System.Data.Common.DataColumnMapping("课程名称", "课程名称"),
- new System.Data.Common.DataColumnMapping("课程简称", "课程简称"),
- new System.Data.Common.DataColumnMapping("拼音码", "拼音码"),
- new System.Data.Common.DataColumnMapping("本学期课程", "本学期课程"),
- new System.Data.Common.DataColumnMapping("教师", "教师"),
- new System.Data.Common.DataColumnMapping("开课系别", "开课系别"),
- new System.Data.Common.DataColumnMapping("学分", "学分")})});
- this.da1.UpdateCommand = this.sqlUpdateCommand1;
- //
- // sqlSelectCommand1
- //
- this.sqlSelectCommand1.CommandText = "SELECT 课程编号, 课程名称, 课程简称, 拼音码, 本学期课程, 教师, 开课系别, 学分 FROM 课程信息 WHERE (课程编号 LIKE @Par" +
- "am4) AND (课程名称 LIKE @Param5) AND (拼音码 LIKE @Param6)";
- this.sqlSelectCommand1.Connection = this.sqlConnection1;
- this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param4", System.Data.SqlDbType.Int, 4, "课程编号"));
- this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param5", System.Data.SqlDbType.VarChar, 40, "课程名称"));
- this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param6", System.Data.SqlDbType.VarChar, 6, "拼音码"));
- //
- // sqlConnection1
- //
- this.sqlConnection1.ConnectionString = "workstation id=localhost;packet size=4096;integrated security=SSPI;data source="." +
- "";persist security info=False;initial catalog=eisbook";
- //
- // sqlInsertCommand1
- //
- this.sqlInsertCommand1.CommandText = "INSERT INTO 课程信息(课程编号, 课程名称, 课程简称, 拼音码, 本学期课程, 教师, 开课系别, 学分) VALUES (@课程编号, @课程名称" +
- ", @课程简称, @拼音码, @本学期课程, @教师, @开课系别, @学分); SELECT 课程编号, 课程名称, 课程简称, 拼音码, 本学期课程, 教师" +
- ", 开课系别, 学分 FROM 课程信息 WHERE (课程编号 = @课程编号)";
- this.sqlInsertCommand1.Connection = this.sqlConnection1;
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@课程编号", System.Data.SqlDbType.Int, 4, "课程编号"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@课程名称", System.Data.SqlDbType.VarChar, 40, "课程名称"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@课程简称", System.Data.SqlDbType.VarChar, 40, "课程简称"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@拼音码", System.Data.SqlDbType.VarChar, 6, "拼音码"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@本学期课程", System.Data.SqlDbType.VarChar, 2, "本学期课程"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@教师", System.Data.SqlDbType.VarChar, 10, "教师"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开课系别", System.Data.SqlDbType.VarChar, 30, "开课系别"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学分", System.Data.SqlDbType.Int, 4, "学分"));
- //
- // sqlUpdateCommand1
- //
- this.sqlUpdateCommand1.CommandText = @"UPDATE 课程信息 SET 课程编号 = @课程编号, 课程名称 = @课程名称, 课程简称 = @课程简称, 拼音码 = @拼音码, 本学期课程 = @本学期课程, 教师 = @教师, 开课系别 = @开课系别, 学分 = @学分 WHERE (课程编号 = @Original_课程编号) AND (学分 = @Original_学分 OR @Original_学分 IS NULL AND 学分 IS NULL) AND (开课系别 = @Original_开课系别 OR @Original_开课系别 IS NULL AND 开课系别 IS NULL) AND (拼音码 = @Original_拼音码 OR @Original_拼音码 IS NULL AND 拼音码 IS NULL) AND (教师 = @Original_教师 OR @Original_教师 IS NULL AND 教师 IS NULL) AND (本学期课程 = @Original_本学期课程) AND (课程名称 = @Original_课程名称) AND (课程简称 = @Original_课程简称); SELECT 课程编号, 课程名称, 课程简称, 拼音码, 本学期课程, 教师, 开课系别, 学分 FROM 课程信息 WHERE (课程编号 = @课程编号)";
- this.sqlUpdateCommand1.Connection = this.sqlConnection1;
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@课程编号", System.Data.SqlDbType.Int, 4, "课程编号"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@课程名称", System.Data.SqlDbType.VarChar, 40, "课程名称"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@课程简称", System.Data.SqlDbType.VarChar, 40, "课程简称"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@拼音码", System.Data.SqlDbType.VarChar, 6, "拼音码"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@本学期课程", System.Data.SqlDbType.VarChar, 2, "本学期课程"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@教师", System.Data.SqlDbType.VarChar, 10, "教师"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@开课系别", System.Data.SqlDbType.VarChar, 30, "开课系别"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学分", System.Data.SqlDbType.Int, 4, "学分"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_课程编号", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "课程编号", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_学分", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "学分", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_开课系别", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "开课系别", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_拼音码", System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "拼音码", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_教师", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "教师", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_本学期课程", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "本学期课程", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_课程名称", System.Data.SqlDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "课程名称", System.Data.DataRowVersion.Original, null));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_课程简称", System.Data.SqlDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "课程简称", System.Data.DataRowVersion.Original, null));
- //
- // sqlDeleteCommand1
- //
- this.sqlDeleteCommand1.CommandText = @"DELETE FROM 课程信息 WHERE (课程编号 = @Original_课程编号) AND (学分 = @Original_学分 OR @Original_学分 IS NULL AND 学分 IS NULL) AND (开课系别 = @Original_开课系别 OR @Original_开课系别 IS NULL AND 开课系别 IS NULL) AND (拼音码 = @Original_拼音码 OR @Original_拼音码 IS NULL AND 拼音码 IS NULL) AND (教师 = @Original_教师 OR @Original_教师 IS NULL AND 教师 IS NULL) AND (本学期课程 = @Original_本学期课程) AND (课程名称 = @Original_课程名称) AND (课程简称 = @Original_课程简称)";
- this.sqlDeleteCommand1.Connection = this.sqlConnection1;
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_课程编号", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "课程编号", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_学分", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "学分", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_开课系别", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "开课系别", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_拼音码", System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "拼音码", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_教师", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "教师", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_本学期课程", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "本学期课程", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_课程名称", System.Data.SqlDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "课程名称", System.Data.DataRowVersion.Original, null));
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_课程简称", System.Data.SqlDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "课程简称", System.Data.DataRowVersion.Original, null));
- //
- // dataSet11
- //
- this.dataSet11.DataSetName = "DataSet1";
- this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
- //
- // txt4
- //
- this.txt4.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.课程编号"));
- this.txt4.Location = new System.Drawing.Point(88, 38);
- this.txt4.Name = "txt4";
- this.txt4.ReadOnly = true;
- this.txt4.Size = new System.Drawing.Size(136, 21);
- this.txt4.TabIndex = 10;
- this.txt4.Text = "";
- //
- // txt5
- //
- this.txt5.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.课程名称"));
- this.txt5.Location = new System.Drawing.Point(256, 38);
- this.txt5.Name = "txt5";
- this.txt5.ReadOnly = true;
- this.txt5.Size = new System.Drawing.Size(216, 21);
- this.txt5.TabIndex = 9;
- this.txt5.Text = "";
- //
- // txt6
- //
- this.txt6.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.课程简称"));
- this.txt6.Location = new System.Drawing.Point(496, 38);
- this.txt6.Name = "txt6";
- this.txt6.ReadOnly = true;
- this.txt6.Size = new System.Drawing.Size(168, 21);
- this.txt6.TabIndex = 8;
- this.txt6.Text = "";
- //
- // txt9
- //
- this.txt9.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.开课系别"));
- this.txt9.Location = new System.Drawing.Point(304, 86);
- this.txt9.Name = "txt9";
- this.txt9.ReadOnly = true;
- this.txt9.Size = new System.Drawing.Size(136, 21);
- this.txt9.TabIndex = 13;
- this.txt9.Text = "";
- //
- // txt8
- //
- this.txt8.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.教师"));
- this.txt8.Location = new System.Drawing.Point(176, 86);
- this.txt8.Name = "txt8";
- this.txt8.ReadOnly = true;
- this.txt8.Size = new System.Drawing.Size(104, 21);
- this.txt8.TabIndex = 12;
- this.txt8.Text = "";
- //
- // txt7
- //
- this.txt7.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.拼音码"));
- this.txt7.Location = new System.Drawing.Point(88, 86);
- this.txt7.Name = "txt7";
- this.txt7.ReadOnly = true;
- this.txt7.Size = new System.Drawing.Size(64, 21);
- this.txt7.TabIndex = 11;
- this.txt7.Text = "";
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(88, 22);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(100, 16);
- this.label4.TabIndex = 4;
- this.label4.Text = "课程编号";
- //
- // label5
- //
- this.label5.Location = new System.Drawing.Point(256, 22);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(100, 16);
- this.label5.TabIndex = 3;
- this.label5.Text = "课程名称";
- //
- // label6
- //
- this.label6.Location = new System.Drawing.Point(496, 22);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(100, 16);
- this.label6.TabIndex = 2;
- this.label6.Text = "课程简称";
- //
- // label7
- //
- this.label7.Location = new System.Drawing.Point(304, 72);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(100, 16);
- this.label7.TabIndex = 7;
- this.label7.Text = "开课系别";
- //
- // label8
- //
- this.label8.Location = new System.Drawing.Point(176, 72);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(100, 16);
- this.label8.TabIndex = 6;
- this.label8.Text = "教师";
- //
- // label9
- //
- this.label9.Location = new System.Drawing.Point(88, 70);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(100, 16);
- this.label9.TabIndex = 5;
- this.label9.Text = "拼音码";
- //
- // txt10
- //
- this.txt10.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.学分"));
- this.txt10.Location = new System.Drawing.Point(464, 88);
- this.txt10.Name = "txt10";
- this.txt10.ReadOnly = true;
- this.txt10.Size = new System.Drawing.Size(56, 21);
- this.txt10.TabIndex = 13;
- this.txt10.Text = "";
- //
- // label10
- //
- this.label10.Location = new System.Drawing.Point(464, 72);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(32, 16);
- this.label10.TabIndex = 7;
- this.label10.Text = "学分";
- //
- // label11
- //
- this.label11.Location = new System.Drawing.Point(544, 72);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(96, 16);
- this.label11.TabIndex = 7;
- this.label11.Text = "是否本学期课程";
- //
- // cmb1
- //
- this.cmb1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "课程信息.本学期课程"));
- this.cmb1.Enabled = false;
- this.cmb1.Items.AddRange(new object[] {
- "Y",
- "N"});
- this.cmb1.Location = new System.Drawing.Point(544, 88);
- this.cmb1.Name = "cmb1";
- this.cmb1.Size = new System.Drawing.Size(121, 20);
- this.cmb1.TabIndex = 14;
- //
- // CourseInfo
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(728, 502);
- this.Name = "CourseInfo";
- this.Text = "【课程信息维护】";
- this.Load += new System.EventHandler(this.CourseInfo_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
- this.groupBox2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
- } #endregion
- //-----------根据输入,检索信息----------
- private void btnSearch_Click(object sender, System.EventArgs e)
- {
- da1.SelectCommand.Parameters[0].Value="%";
- da1.SelectCommand.Parameters[1].Value="%";
- da1.SelectCommand.Parameters[2].Value="%";
- if(txt1.Text.Trim()!="")
- {
- da1.SelectCommand.Parameters[0].Value="%"+txt1.Text.Trim()+"%";
- }
- if(txt2.Text.Trim()!="")
- {
- da1.SelectCommand.Parameters[1].Value="%"+txt2.Text.Trim()+"%";
- }
- if(txt3.Text.Trim()!="")
- {
- da1.SelectCommand.Parameters[2].Value="%"+txt3.Text.Trim()+"%";
- }
- dataSet11.Clear();//刷新数据集
- da1.Fill(dataSet11);
- }
- //-----------新建窗体,读入数据----------
- private void CourseInfo_Load(object sender, System.EventArgs e)
- {
- da1.SelectCommand.Parameters[0].SqlDbType=System.Data.SqlDbType.VarChar;//更改类型
- da1.SelectCommand.Parameters[0].Value="%";
- da1.SelectCommand.Parameters[1].Value="%";
- da1.SelectCommand.Parameters[2].Value="%";
- da1.Fill(dataSet11);
- //设置数据导航控件
- this.cmOrders=(CurrencyManager) BindingContext[dataSet11,"课程信息"];
- //将基类中的数据集与派生类中的数据集连接
- base.dataSet11=this.dataSet11;
- } //----------重写设置控件只读属性函数----------
- protected override void SetModifyMode(bool blnEdit)
- {
- base.SetModifyMode (blnEdit);
- txt4.ReadOnly=!blnEdit;
- txt5.ReadOnly=!blnEdit;
- txt6.ReadOnly=!blnEdit;
- txt7.ReadOnly=!blnEdit;
- txt8.ReadOnly=!blnEdit;
- txt9.ReadOnly=!blnEdit;
- txt10.ReadOnly=!blnEdit;
- cmb1.Enabled=blnEdit;
- }
- //-------重写新增记录时设置默认值函数--------
- protected override void SetDefaultValue()
- {
- base.SetDefaultValue ();
- txt4.Text=this.NewCouseID();//生成新编号
- }
- //-------重写检查非空字段函数--------
- protected override bool CheckNotNull()
- {
- if(txt4.Text.Trim()=="")// 课程编号不能为空
- {
- MessageBox.Show("课程编号不能为空","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- return(false);
- }
- if(txt5.Text.Trim()==""||txt6.Text.Trim()=="")// 课程名称不能为空
- {
- MessageBox.Show("课程名称和简称不能为空","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- return(false);
- }
- if(txt7.Text.Trim()=="")
- {
- MessageBox.Show("请输入拼音码","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- return(false);
- }
- if(cmb1.Text.Trim()=="")
- {
- MessageBox.Show("请先确定该课程是否是本学期课程","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- return(false);
- }
- return base.CheckNotNull ();
- } //--------计算新的课程编号-------- private string NewCouseID() { string strConn="workstation id=localhost;Integrated Security=SSPI;database=eisbook;"; SqlConnection cn=new SqlConnection(strConn); cn.Open(); SqlCommand cmd=cn.CreateCommand(); cmd.CommandText="select max(课程编号) 最大编号 from 课程信息"; int newID=Convert.ToInt32(cmd.ExecuteScalar()); newID++; return(newID.ToString()); } } }