StudentInfo.cs
资源名称:VCSDB.rar [点击查看]
上传用户:hjieqiu
上传日期:2013-05-11
资源大小:16494k
文件大小:34k
源码类别:
企业管理
开发平台:
C#
- using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace 教务管理系统 { public class StudentInfo : 医院管理系统.ParentForm {
- private System.Data.SqlClient.SqlConnection sqlConnection1;
- private System.Data.SqlClient.SqlDataAdapter da3;
- private System.Data.SqlClient.SqlDataAdapter da4;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand3;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand4;
- private System.Data.SqlClient.SqlDataAdapter da5;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand5;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand6;
- private System.Windows.Forms.TextBox txt4;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.TextBox txt5;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.TextBox txt7;
- private System.Windows.Forms.Label label9;
- private System.Windows.Forms.ComboBox cmb1;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.ComboBox cmb2;
- private System.Windows.Forms.Label label8;
- private System.Windows.Forms.Label label10;
- private System.Windows.Forms.ComboBox cmb3;
- private System.Windows.Forms.Label label11;
- private System.Windows.Forms.ComboBox cmb4;
- private System.Windows.Forms.Label label12;
- private System.Windows.Forms.ComboBox cmb5;
- private System.Windows.Forms.Label label13;
- private System.Windows.Forms.ComboBox cmb6;
- private 教务管理系统.DataSet1 dataSet11;
- private System.Data.SqlClient.SqlDataAdapter da2;
- private System.Windows.Forms.TextBox txt6;
- private System.Data.SqlClient.SqlDataAdapter da6;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand2;
- 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.ComponentModel.IContainer components = null; public StudentInfo() { // 该调用是 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.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
- this.da3 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlSelectCommand3 = new System.Data.SqlClient.SqlCommand();
- this.da4 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlSelectCommand4 = new System.Data.SqlClient.SqlCommand();
- this.da5 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlSelectCommand5 = new System.Data.SqlClient.SqlCommand();
- this.da2 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlSelectCommand6 = new System.Data.SqlClient.SqlCommand();
- this.txt4 = new System.Windows.Forms.TextBox();
- this.label4 = new System.Windows.Forms.Label();
- this.txt5 = new System.Windows.Forms.TextBox();
- this.label5 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.txt7 = new System.Windows.Forms.TextBox();
- this.txt6 = new System.Windows.Forms.TextBox();
- this.label9 = new System.Windows.Forms.Label();
- this.cmb1 = new System.Windows.Forms.ComboBox();
- this.label7 = new System.Windows.Forms.Label();
- this.cmb2 = new System.Windows.Forms.ComboBox();
- this.label8 = new System.Windows.Forms.Label();
- this.label10 = new System.Windows.Forms.Label();
- this.cmb3 = new System.Windows.Forms.ComboBox();
- this.dataSet11 = new 教务管理系统.DataSet1();
- this.label11 = new System.Windows.Forms.Label();
- this.cmb4 = new System.Windows.Forms.ComboBox();
- this.label12 = new System.Windows.Forms.Label();
- this.cmb5 = new System.Windows.Forms.ComboBox();
- this.label13 = new System.Windows.Forms.Label();
- this.cmb6 = new System.Windows.Forms.ComboBox();
- this.da6 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlSelectCommand2 = new System.Data.SqlClient.SqlCommand();
- this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
- ((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 = "姓名";
- this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- //
- // 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 = "学号";
- this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- //
- // txt3
- //
- this.txt3.Name = "txt3";
- //
- // label3
- //
- this.label3.Name = "label3";
- this.label3.Text = "年级";
- this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- //
- // 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.label4);
- this.groupBox2.Controls.Add(this.txt5);
- this.groupBox2.Controls.Add(this.label5);
- this.groupBox2.Controls.Add(this.label6);
- this.groupBox2.Controls.Add(this.txt7);
- this.groupBox2.Controls.Add(this.txt6);
- this.groupBox2.Controls.Add(this.label9);
- this.groupBox2.Controls.Add(this.label7);
- this.groupBox2.Controls.Add(this.cmb2);
- this.groupBox2.Controls.Add(this.label8);
- this.groupBox2.Controls.Add(this.label10);
- this.groupBox2.Controls.Add(this.cmb3);
- this.groupBox2.Controls.Add(this.label11);
- this.groupBox2.Controls.Add(this.cmb4);
- this.groupBox2.Controls.Add(this.label12);
- this.groupBox2.Controls.Add(this.cmb5);
- this.groupBox2.Controls.Add(this.label13);
- this.groupBox2.Controls.Add(this.cmb6);
- this.groupBox2.Location = new System.Drawing.Point(0, 378);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(728, 120);
- //
- // 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("籍贯编号", "籍贯编号"),
- new System.Data.Common.DataColumnMapping("身份证号", "身份证号"),
- new System.Data.Common.DataColumnMapping("学籍编号", "学籍编号")})});
- this.da1.UpdateCommand = this.sqlUpdateCommand1;
- //
- // sqlConnection1
- //
- this.sqlConnection1.ConnectionString = "workstation id=localhost;packet size=4096;integrated security=SSPI;data source="." +
- "";persist security info=False;initial catalog=eisbook";
- //
- // da3
- //
- this.da3.SelectCommand = this.sqlSelectCommand3;
- this.da3.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("籍贯", "籍贯")})});
- //
- // sqlSelectCommand3
- //
- this.sqlSelectCommand3.CommandText = "SELECT 籍贯编号, 籍贯 FROM 籍贯代码表";
- this.sqlSelectCommand3.Connection = this.sqlConnection1;
- //
- // da4
- //
- this.da4.SelectCommand = this.sqlSelectCommand4;
- this.da4.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("民族", "民族")})});
- //
- // sqlSelectCommand4
- //
- this.sqlSelectCommand4.CommandText = "SELECT 民族编号, 民族 FROM 民族代码表";
- this.sqlSelectCommand4.Connection = this.sqlConnection1;
- //
- // da5
- //
- this.da5.SelectCommand = this.sqlSelectCommand5;
- this.da5.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("学籍名称", "学籍名称")})});
- //
- // sqlSelectCommand5
- //
- this.sqlSelectCommand5.CommandText = "SELECT 学籍编号, 学籍名称 FROM 学籍代码表";
- this.sqlSelectCommand5.Connection = this.sqlConnection1;
- //
- // da2
- //
- this.da2.SelectCommand = this.sqlSelectCommand6;
- this.da2.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("政治面貌", "政治面貌")})});
- //
- // sqlSelectCommand6
- //
- this.sqlSelectCommand6.CommandText = "SELECT 政治面貌编号, 政治面貌 FROM 政治面貌代码表";
- this.sqlSelectCommand6.Connection = this.sqlConnection1;
- //
- // txt4
- //
- this.txt4.Location = new System.Drawing.Point(24, 32);
- this.txt4.Name = "txt4";
- this.txt4.ReadOnly = true;
- this.txt4.Size = new System.Drawing.Size(112, 21);
- this.txt4.TabIndex = 7;
- this.txt4.Text = "";
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(24, 16);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(100, 16);
- this.label4.TabIndex = 5;
- this.label4.Text = "学号";
- //
- // txt5
- //
- this.txt5.Location = new System.Drawing.Point(160, 32);
- this.txt5.Name = "txt5";
- this.txt5.ReadOnly = true;
- this.txt5.Size = new System.Drawing.Size(120, 21);
- this.txt5.TabIndex = 8;
- this.txt5.Text = "";
- //
- // label5
- //
- this.label5.Location = new System.Drawing.Point(160, 16);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(100, 16);
- this.label5.TabIndex = 2;
- this.label5.Text = "姓名";
- //
- // label6
- //
- this.label6.Location = new System.Drawing.Point(304, 16);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(56, 16);
- this.label6.TabIndex = 3;
- this.label6.Text = "性别";
- //
- // txt7
- //
- this.txt7.Location = new System.Drawing.Point(24, 80);
- this.txt7.Name = "txt7";
- this.txt7.ReadOnly = true;
- this.txt7.Size = new System.Drawing.Size(136, 21);
- this.txt7.TabIndex = 9;
- this.txt7.Text = "";
- //
- // txt6
- //
- this.txt6.Location = new System.Drawing.Point(424, 32);
- this.txt6.Name = "txt6";
- this.txt6.ReadOnly = true;
- this.txt6.Size = new System.Drawing.Size(136, 21);
- this.txt6.TabIndex = 6;
- this.txt6.Text = "";
- //
- // label9
- //
- this.label9.Location = new System.Drawing.Point(424, 16);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(48, 16);
- this.label9.TabIndex = 4;
- this.label9.Text = "年级";
- //
- // cmb1
- //
- this.cmb1.Enabled = false;
- this.cmb1.Items.AddRange(new object[] {
- "男",
- "女"});
- this.cmb1.Location = new System.Drawing.Point(304, 32);
- this.cmb1.Name = "cmb1";
- this.cmb1.Size = new System.Drawing.Size(88, 20);
- this.cmb1.TabIndex = 10;
- //
- // label7
- //
- this.label7.Location = new System.Drawing.Point(24, 64);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(100, 16);
- this.label7.TabIndex = 5;
- this.label7.Text = "身份证编号";
- //
- // cmb2
- //
- this.cmb2.Enabled = false;
- this.cmb2.Location = new System.Drawing.Point(576, 32);
- this.cmb2.Name = "cmb2";
- this.cmb2.Size = new System.Drawing.Size(128, 20);
- this.cmb2.TabIndex = 10;
- //
- // label8
- //
- this.label8.Location = new System.Drawing.Point(576, 16);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(100, 16);
- this.label8.TabIndex = 3;
- this.label8.Text = "班级";
- //
- // label10
- //
- this.label10.Location = new System.Drawing.Point(192, 64);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(100, 16);
- this.label10.TabIndex = 3;
- this.label10.Text = "政治面貌";
- //
- // cmb3
- //
- this.cmb3.Enabled = false;
- this.cmb3.Location = new System.Drawing.Point(192, 80);
- this.cmb3.Name = "cmb3";
- this.cmb3.Size = new System.Drawing.Size(128, 20);
- this.cmb3.TabIndex = 10;
- //
- // dataSet11
- //
- this.dataSet11.DataSetName = "DataSet1";
- this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
- //
- // label11
- //
- this.label11.Location = new System.Drawing.Point(352, 64);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(100, 16);
- this.label11.TabIndex = 3;
- this.label11.Text = "民族";
- //
- // cmb4
- //
- this.cmb4.Enabled = false;
- this.cmb4.Location = new System.Drawing.Point(352, 80);
- this.cmb4.Name = "cmb4";
- this.cmb4.Size = new System.Drawing.Size(88, 20);
- this.cmb4.TabIndex = 10;
- //
- // label12
- //
- this.label12.Location = new System.Drawing.Point(472, 64);
- this.label12.Name = "label12";
- this.label12.Size = new System.Drawing.Size(100, 16);
- this.label12.TabIndex = 3;
- this.label12.Text = "籍贯";
- //
- // cmb5
- //
- this.cmb5.Enabled = false;
- this.cmb5.Location = new System.Drawing.Point(472, 80);
- this.cmb5.Name = "cmb5";
- this.cmb5.Size = new System.Drawing.Size(104, 20);
- this.cmb5.TabIndex = 10;
- //
- // label13
- //
- this.label13.Location = new System.Drawing.Point(600, 64);
- this.label13.Name = "label13";
- this.label13.Size = new System.Drawing.Size(72, 16);
- this.label13.TabIndex = 3;
- this.label13.Text = "学籍";
- //
- // cmb6
- //
- this.cmb6.Enabled = false;
- this.cmb6.Location = new System.Drawing.Point(600, 80);
- this.cmb6.Name = "cmb6";
- this.cmb6.Size = new System.Drawing.Size(104, 20);
- this.cmb6.TabIndex = 10;
- //
- // da6
- //
- this.da6.SelectCommand = this.sqlSelectCommand2;
- this.da6.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("班主任", "班主任")})});
- //
- // sqlSelectCommand2
- //
- this.sqlSelectCommand2.CommandText = "SELECT 班级编号, 年级, 班级名称, 班级简称, 人数, 班主任 FROM 班级信息";
- this.sqlSelectCommand2.Connection = this.sqlConnection1;
- //
- // sqlSelectCommand1
- //
- this.sqlSelectCommand1.CommandText = "SELECT 学号, 姓名, 班级编号, 性别, 年级, 政治面貌编号, 民族编号, 籍贯编号, 身份证号, 学籍编号 FROM 学生信息 WHERE (学号 L" +
- "IKE @Param4) AND (姓名 LIKE @Param5) AND (年级 LIKE @Param6)";
- this.sqlSelectCommand1.Connection = this.sqlConnection1;
- this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param4", System.Data.SqlDbType.VarChar, 14, "学号"));
- this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param5", System.Data.SqlDbType.VarChar, 8, "姓名"));
- this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param6", System.Data.SqlDbType.VarChar, 8, "年级"));
- //
- // 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.VarChar, 14, "学号"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@姓名", System.Data.SqlDbType.VarChar, 8, "姓名"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@班级编号", System.Data.SqlDbType.VarChar, 14, "班级编号"));
- 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.Int, 4, "年级"));
- 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, 2, "民族编号"));
- 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, 15, "身份证号"));
- this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学籍编号", System.Data.SqlDbType.VarChar, 2, "学籍编号"));
- //
- // sqlUpdateCommand1
- //
- this.sqlUpdateCommand1.CommandText = @"UPDATE 学生信息 SET 学号 = @学号, 姓名 = @姓名, 班级编号 = @班级编号, 性别 = @性别, 年级 = @年级, 政治面貌编号 = @政治面貌编号, 民族编号 = @民族编号, 籍贯编号 = @籍贯编号, 身份证号 = @身份证号, 学籍编号 = @学籍编号 WHERE (学号 = @Original_学号) AND (姓名 = @Original_姓名 OR @Original_姓名 IS NULL AND 姓名 IS NULL) AND (学籍编号 = @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_民族编号) AND (班级编号 = @Original_班级编号 OR @Original_班级编号 IS NULL AND 班级编号 IS NULL) AND (籍贯编号 = @Original_籍贯编号) AND (身份证号 = @Original_身份证号 OR @Original_身份证号 IS NULL AND 身份证号 IS NULL); SELECT 学号, 姓名, 班级编号, 性别, 年级, 政治面貌编号, 民族编号, 籍贯编号, 身份证号, 学籍编号 FROM 学生信息 WHERE (学号 = @学号)";
- this.sqlUpdateCommand1.Connection = this.sqlConnection1;
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学号", System.Data.SqlDbType.VarChar, 14, "学号"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@姓名", System.Data.SqlDbType.VarChar, 8, "姓名"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@班级编号", System.Data.SqlDbType.VarChar, 14, "班级编号"));
- 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.Int, 4, "年级"));
- 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, 2, "民族编号"));
- 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, 15, "身份证号"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学籍编号", System.Data.SqlDbType.VarChar, 2, "学籍编号"));
- this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_学号", System.Data.SqlDbType.VarChar, 14, 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, 8, 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.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, 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, 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, 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, 14, 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, 15, 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_学籍编号) 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_班级编号 OR @Original_班级编号 IS NULL AND 班级编号 IS NULL) AND (籍贯编号 = @Original_籍贯编号) AND (身份证号 = @Original_身份证号 OR @Original_身份证号 IS NULL AND 身份证号 IS NULL)";
- this.sqlDeleteCommand1.Connection = this.sqlConnection1;
- this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_学号", System.Data.SqlDbType.VarChar, 14, 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, 8, 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.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, 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, 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, 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, 14, 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, 15, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "身份证号", System.Data.DataRowVersion.Original, null));
- //
- // StudentInfo
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(728, 502);
- this.Name = "StudentInfo";
- this.Text = "【学生信息维护】";
- this.Load += new System.EventHandler(this.StudentInfo_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
- this.groupBox2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
- } #endregion
- //-----------初始化窗体时,读入数据集--------------
- private void StudentInfo_Load(object sender, System.EventArgs e)
- {
- da1.SelectCommand.Parameters[0].Value="%";
- da1.SelectCommand.Parameters[1].Value="%";
- da1.SelectCommand.Parameters[2].Size=8;//4位年份输入
- da1.SelectCommand.Parameters[2].Value="%";
- da1.Fill(dataSet11);//填充学生信息
- //设置数据导航控件
- this.cmOrders=(CurrencyManager) BindingContext[dataSet11,"学生信息"];
- //将基类中的数据集与派生类中的数据集连接
- base.dataSet11=this.dataSet11;
- //填充其他编号和名称数据
- da2.Fill(dataSet11);
- da3.Fill(dataSet11);
- da4.Fill(dataSet11);
- da5.Fill(dataSet11);
- da6.Fill(dataSet11);
- //绑定数据集
- this.SetBindings();
- } //---------设置文本框和下拉列表框数据源的绑定---------- private void SetBindings() { //绑定文本框显示 txt4.DataBindings.Add("Text",dataSet11,"学生信息.学号"); txt5.DataBindings.Add("Text",dataSet11,"学生信息.姓名"); txt6.DataBindings.Add("Text",dataSet11,"学生信息.年级"); txt7.DataBindings.Add("Text",dataSet11,"学生信息.身份证号"); cmb1.DataBindings.Add("Text",dataSet11,"学生信息.性别"); //绑定班级编号字段,显示班级名称 cmb2.DataSource=dataSet11; cmb2.DisplayMember="班级信息.班级名称"; cmb2.ValueMember="班级信息.班级编号"; cmb2.DataBindings.Add("SelectedValue",dataSet11,"学生信息.班级编号"); //绑定政治面貌编号字段,显示政治面貌 cmb3.DataSource=dataSet11; cmb3.DisplayMember="政治面貌代码表.政治面貌"; cmb3.ValueMember="政治面貌代码表.政治面貌编号"; cmb3.DataBindings.Add("SelectedValue",dataSet11,"学生信息.政治面貌编号"); //绑定民族编号字段,显示民族名称 cmb4.DataSource=dataSet11; cmb4.DisplayMember="民族代码表.民族"; cmb4.ValueMember="民族代码表.民族编号"; cmb4.DataBindings.Add("SelectedValue",dataSet11,"学生信息.民族编号"); //绑定籍贯编号字段,显示籍贯 cmb5.DataSource=dataSet11; cmb5.DisplayMember="籍贯代码表.籍贯"; cmb5.ValueMember="籍贯代码表.籍贯编号"; cmb5.DataBindings.Add("SelectedValue",dataSet11,"学生信息.籍贯编号"); //绑定学籍编号字段,显示学籍 cmb6.DataSource=dataSet11; cmb6.DisplayMember="学籍代码表.学籍名称"; cmb6.ValueMember="学籍代码表.学籍编号"; cmb6.DataBindings.Add("SelectedValue",dataSet11,"学生信息.学籍编号"); } //-----------根据输入,检索信息----------
- 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);
- //填充其他编号和名称数据
- da2.Fill(dataSet11);
- da3.Fill(dataSet11);
- da4.Fill(dataSet11);
- da5.Fill(dataSet11);
- da6.Fill(dataSet11);
- } //----------重写设置控件只读属性函数----------
- protected override void SetModifyMode(bool blnEdit)
- {
- base.SetModifyMode (blnEdit);
- txt4.ReadOnly=!blnEdit;
- txt5.ReadOnly=!blnEdit;
- txt6.ReadOnly=!blnEdit;
- txt7.ReadOnly=!blnEdit;
- cmb1.Enabled=blnEdit;
- cmb2.Enabled=blnEdit;
- cmb3.Enabled=blnEdit;
- cmb4.Enabled=blnEdit;
- cmb5.Enabled=blnEdit;
- cmb6.Enabled=blnEdit;
- }
- //-------重写新增记录时设置默认值函数--------
- protected override void SetDefaultValue()
- {
- base.SetDefaultValue ();
- cmb1.Text="男";
- txt6.Text=System.DateTime.Now.Year.ToString();//默认年级为今年
- cmb3.SelectedText="";//让用户选择信息
- cmb4.SelectedText="";
- cmb5.SelectedText="";
- cmb6.SelectedText="";
- }
- //-------重写检查非空字段函数--------
- protected override bool CheckNotNull()
- {
- if(txt4.Text.Trim()=="")// 检查学号字段
- {
- MessageBox.Show("学号不能为空","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- return(false);
- }
- if(cmb4.Text.Trim()=="")//检查民族
- {
- MessageBox.Show("民族不能为空","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- return(false);
- }
- if(cmb5.Text.Trim()=="")//检查籍贯
- {
- MessageBox.Show("籍贯不能为空","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- return(false);
- }
- if(cmb6.Text.Trim()=="")//检查学籍
- {
- MessageBox.Show("学籍不能为空","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- return(false);
- }
- return base.CheckNotNull ();
- }
- } }