C#——教务管理系统设计01(20181003)

学生信息管理系统设计与实现
本文档详述了基于学生信息管理的数据库项目训练,旨在教授学生数据库系统设计与C#客户端软件开发技能。课程覆盖数据库表设计、客户端软件实现、数据验证、统计结果图形展示及输出等内容。

目录

任务目标

初步设计思路

设计日志


  • 任务目标

  • 基于学生信息管理的数据库项目训练

    1)课时: 4

    2)教学目的

     通过本次课程训练,使学生初步掌握数据库系统设计的基本思路。能够使用C#完成客户端软件的程序编写工作。

    3)教学内容:

      学生管理系统的数据库表的设计,学生管理系统客户端软件的设计与实现工作。

    4)教学重点及难点

          本次课程教学的重点和难点:表设计结果的合理性,客户端开发过程中各种技术使用的正确性。

    5)教学方法

      本次课程教学以任务驱动为主。

    6)教学内容

      1、训练说明任务

    C#端要求:

     1)首先系统分为三类用户角色:管理员角色具有学生、教师信息的添加、删除、修改、浏览功能,;教师角色具有录入学生成绩,修改成绩,成绩统计、成绩排序,学生基本信息查询等功能;学生角色具有本人成绩浏览,本人信息浏览等功能。在使用本系统时要进行登录验证,不同用户提供以上不同的系统功能。

     2)学生信息录入时,对数据项进行验证,要求使用C#正侧表达式或其他验证方式,对数据进行格式或其他方面的验证,如邮编格式,身份证、手机号码的验证等。

     3)所有统计结果通过图形展示。可以集成第三方类库完成,也可以自己设计完成。自己设计以一个类完成图形处理

     4)对于结果输出,如学生花名册、成绩表等,提供打印输出及预览功能。打印输出同样设计一个类完成处理。

     5)将输出结果,如学生基本信息表格,成绩表格输出到EXECL和Word文件中保存,输出的内容要完成排版处理。word和EXECL文件处理接口同样要求设计一个类完成数据的排版和保存。

     6)其他要求与《程序设计专项训练》一致。

    数据库部分要求:

     1)数据库表的设计要有约束或规则,确保数据的有效性。

     2)多表查询要有视图的使用。

     3)多表数据插入要通过事务处理完成,确保数据的完整性

     4)复杂的统计工作使用存储过程,利用存储过程完成统计。

      2、演示要求

     1)写好数据库的创建脚本,保存为.sql文件;或通过数据库的分离和附加操作,快速完成系统环境的搭建。

     2)准备好PPT,包含数据库设计和客户端设计两部分内容。


     

  • 初步设计思路

运用三层架构实现教务管理系统

  • 界面分三部分:
  1. 登陆界面(包括登陆和修改密码,忘记密码界面)
  2. 操作选择界面
    1. 欢迎界面,自动识别身份
    2. 自动识别身份后通过代码修改button属性,及单击事件调用的函数
  3. 展示台界面
    1. 图形展示界面
    2. 数字展示界面
  • 程序三层架构对应:
  1. 登陆界面:

对应在两个表中查询pwd和ID

  1. 操作选择界面
    1. 自动识别身份,在对应的表中查询修改数据
    2. 每个数据库的表建立一个类,将对其的操作封装

展示台界面:

  1. 同登陆界面,根据返回的结果调用第三方类库输出至显示台(图形化输出和数字格式输出)
  2. 使用代码建立控件存放数据(可将图形化数据保存为图片,然后用picturebox将其显示。

    设计日志

     

三层步骤:分析功能

  • 管理员:学生、教师信息的添加,删除,修改,浏览功能;
  • 教师:录入学生成绩,修改成绩,成绩统计,成绩排序,学生基本信息查询
  • 学生:本人成绩浏览,本人信息浏览
  • 学生信息录入时,对数据进行验证,要求正则表达式或其他,格式验证等。
  • 统计结果图形展示。借助第三方类库或自定义类
  • 结果输出(例如学生花名册,成绩表等)提供打印输出、打印预览功能,打印输出设计一个类完成
  • 将输出结果输出到EXECL和Word文件中保存,输出的内容要完成排版处理。文件处理接口设计一个类完成
  • 数据库要求:
  • 表的设计要有约束或规则,确保数据有效性
  • 多表查询要有视图的使用
  • 多表数据插入要通过事务处理完成,确保数据完整性
  • 展示要求:
  • 写好数据库的创建脚本,保存为.sql文件;或通过数据库的分离和附加操作,快速完成环境的搭建
  • 准备好PPT,分为数据库设计和客户端设计两部分
  • 根据功能确定SQL语句
  • 在数据访问层(DAL)编写执行该SQL语句的函数
  • //该函数应该在哪个类中,一般情况下,当前的SQL语句要操作哪张表,那么就在数据访问层中中建一个类,这个类的名字与该表名相同,所有操作这个表的函数都写出该类中。
  • 编写业务逻辑层的方法
  • 编写表现层代码
  • 5.1采集数据
  • 5.2展示数据
  • 5.3调用对应的业务逻辑层来实现具体功能
  • 添加timer 实时监控textbox等控件 可用于校验。
  • 复杂的统计工作使用存储过程,利用存储过程完成统计

日常笔记

  1. Textbox.passwordchar = ‘*’;
    //使textbox.text内容正常显示(默认以 * 显示)
            private void pictureBox4_Click(object sender, EventArgs e)
            {
                textBox2.PasswordChar = new char();
            }

//使输入的文本以 ‘*’显示

WinForm中TextBox控件的PasswordChar属性默认是没有设置的或者说没有开启密码模式,当设置了该属性之后就会开启密码模式,输入的内容以设置的该属性的值来显示。那么该如何取消PasswordChar的设置呢?归纳起来有三种方法,其本质都是把PasswordChar的值赋值为默认值,赋值为默认值后就会按照正常文本进行显示。三种方法代码如下。

this.textBox1.PasswordChar = new char();

this.textBox1.PasswordChar = '\0';

this.textBox1.PasswordChar = default(char);

//使输入的文本正常显示

  1. Shift+Alt+F10 生成对应函数
  2. 连接数据库,使用数据库通用格式 (登录按钮)
    //登录校验用户名是否存在以及密码是否正确
            private void button2_Click(object sender, EventArgs e)
            {
                //1.采集数据
                string loginID = textBox1.Text;
                string loginpwd = textBox2.Text;
                
    
                //2.先根据用户名去数据库中查找,是否有对应的用户
                string constr = "Data Source = localhost ; Initial Catalog = StudyOprationSytem ; Integrated Security = True;User ID=sa;Password=123456;Database=StudyOprationSystem;";
                using (SqlConnection con = new SqlConnection(constr))
                {
                    string sql = string.Format("select * from users where ID = '{0}'",loginID);
                    using (SqlCommand cmd = new SqlCommand(sql, con))
                    {
                        con.Open();
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                //存在该用户
                                if (reader.Read())
                                {
                                    //3.如果有对应的用户,再比较密码是否正确
                                    //获取查询出的密码,和用户输入的密码进行比较
                                    string dbpwd = reader.GetString(2);
                                    if (loginpwd == dbpwd)
                                    {
                                        //登陆成功
                                        MessageBox.Show("登录成功");
    
                                        //启用修改密码
                                        button3.Enabled = true;
                                        button3.Visible = true;
    
                                        //获取当前登陆用户的主键ID,设置到IDshare
                                        IDshare.ID = reader.GetString(1);
                                    }
                                    else
                                    {
                                        MessageBox.Show("密码错误");
                                    }
                                }
                            }
                            else
                            {
                                MessageBox.Show("用户不存在");
                                //4.如果没有对应的用户,直接提示“用户名不存在”
                            }
                        }
                    }
                }    
            }
  3. Form窗口切换

This.hide;

Form2 frm = new Form2();

Frm.show();

 

   

 


using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace 教务管理系统 { public class ClassInfo : 医院管理系统.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.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.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.ComponentModel.IContainer components = null; public ClassInfo() { // 该调用是 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.label4 = new System.Windows.Forms.Label(); this.txt4 = new System.Windows.Forms.TextBox(); this.txt5 = new System.Windows.Forms.TextBox(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.txt6 = new System.Windows.Forms.TextBox(); this.txt9 = new System.Windows.Forms.TextBox(); this.label7 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); this.txt8 = new System.Windows.Forms.TextBox(); this.txt7 = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); ((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 = "班级编号"; // // 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.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.txt6); this.groupBox2.Controls.Add(this.txt9); this.groupBox2.Controls.Add(this.label7); this.groupBox2.Controls.Add(this.label8); this.groupBox2.Controls.Add(this.txt8); this.groupBox2.Controls.Add(this.txt7); this.groupBox2.Controls.Add(this.label9); 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("班主任", "班主任")})}); this.da1.UpdateCommand = this.sqlUpdateCommand1; // // sqlSelectCommand1 // this.sqlSelectCommand1.CommandText = "SELECT 班级编号, 年级, 班级名称, 班级简称, 人数, 班主任 FROM 班级信息 WHERE (班级编号 LIKE @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, 4, "年级")); this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param6", System.Data.SqlDbType.VarChar, 30, "班级名称")); // // 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.VarChar, 14, "班级编号")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@年级", System.Data.SqlDbType.VarChar, 4, "年级")); 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.VarChar, 16, "班级简称")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@人数", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(3)), ((System.Byte)(0)), "人数", System.Data.DataRowVersion.Current, null)); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@班主任", System.Data.SqlDbType.VarChar, 8, "班主任")); // // 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_班级简称 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, 4, "年级")); 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.VarChar, 16, "班级简称")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@人数", System.Data.SqlDbType.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(3)), ((System.Byte)(0)), "人数", System.Data.DataRowVersion.Current, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@班主任", System.Data.SqlDbType.VarChar, 8, "班主任")); 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.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(3)), ((System.Byte)(0)), "人数", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_年级", System.Data.SqlDbType.VarChar, 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, 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, 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, 16, 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_班级简称 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.Decimal, 5, System.Data.ParameterDirection.Input, false, ((System.Byte)(3)), ((System.Byte)(0)), "人数", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_年级", System.Data.SqlDbType.VarChar, 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, 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, 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, 16, 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"); // // label4 // this.label4.Location = new System.Drawing.Point(64, 32); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(100, 16); this.label4.TabIndex = 0; this.label4.Text = "班级编号"; // // txt4 // this.txt4.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "班级信息.班级编号")); this.txt4.Location = new System.Drawing.Point(64, 48); this.txt4.Name = "txt4"; this.txt4.ReadOnly = true; this.txt4.Size = new System.Drawing.Size(136, 21); this.txt4.TabIndex = 1; this.txt4.Text = ""; // // txt5 // this.txt5.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "班级信息.年级")); this.txt5.Location = new System.Drawing.Point(232, 48); this.txt5.Name = "txt5"; this.txt5.ReadOnly = true; this.txt5.Size = new System.Drawing.Size(136, 21); this.txt5.TabIndex = 1; this.txt5.Text = ""; // // label5 // this.label5.Location = new System.Drawing.Point(232, 32); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(100, 16); this.label5.TabIndex = 0; this.label5.Text = "年级"; // // label6 // this.label6.Location = new System.Drawing.Point(408, 32); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(100, 16); this.label6.TabIndex = 0; this.label6.Text = "班级名称"; // // txt6 // this.txt6.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "班级信息.班级名称")); this.txt6.Location = new System.Drawing.Point(408, 48); this.txt6.Name = "txt6"; this.txt6.ReadOnly = true; this.txt6.Size = new System.Drawing.Size(136, 21); this.txt6.TabIndex = 1; this.txt6.Text = ""; // // txt9 // this.txt9.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "班级信息.班主任")); this.txt9.Location = new System.Drawing.Point(408, 96); this.txt9.Name = "txt9"; this.txt9.ReadOnly = true; this.txt9.Size = new System.Drawing.Size(136, 21); this.txt9.TabIndex = 1; this.txt9.Text = ""; // // label7 // this.label7.Location = new System.Drawing.Point(408, 80); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(100, 16); this.label7.TabIndex = 0; this.label7.Text = "班主任"; // // label8 // this.label8.Location = new System.Drawing.Point(232, 80); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(100, 16); this.label8.TabIndex = 0; this.label8.Text = "人数"; // // txt8 // this.txt8.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "班级信息.班级简称")); this.txt8.Location = new System.Drawing.Point(232, 96); this.txt8.Name = "txt8"; this.txt8.ReadOnly = true; this.txt8.Size = new System.Drawing.Size(136, 21); this.txt8.TabIndex = 1; this.txt8.Text = ""; // // txt7 // this.txt7.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "班级信息.班级简称")); this.txt7.Location = new System.Drawing.Point(64, 96); this.txt7.Name = "txt7"; this.txt7.ReadOnly = true; this.txt7.Size = new System.Drawing.Size(136, 21); this.txt7.TabIndex = 1; this.txt7.Text = ""; // // label9 // this.label9.Location = new System.Drawing.Point(64, 80); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(100, 16); this.label9.TabIndex = 0; this.label9.Text = "班级简称"; // // ClassInfo // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(728, 502); this.Name = "ClassInfo"; this.Text = "【班级信息维护】"; this.Load += new System.EventHandler(this.ClassInfo_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit(); this.groupBox2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit(); } #endregion //--------创建窗体时,读入数据------- private void ClassInfo_Load(object sender, System.EventArgs e) { da1.SelectCommand.Parameters[0].Value="%"; da1.SelectCommand.Parameters[1].Size=8;//4位年份输入 da1.SelectCommand.Parameters[1].Value="%"; da1.SelectCommand.Parameters[2].Value="%"; da1.Fill(dataSet11); //设置数据导航控件 this.cmOrders=(CurrencyManager) BindingContext[dataSet11,"班级信息"]; //将基类中的数据集与派生类中的数据集连接 base.dataSet11=this.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); } //----------重写设置控件只读属性函数---------- 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; } //-------重写新增记录时设置默认值函数-------- protected override void SetDefaultValue() { base.SetDefaultValue (); } //-------重写检查非空字段函数-------- protected override bool CheckNotNull() { if(txt4.Text.Trim()=="")// 班级编号不能为空 { MessageBox.Show("班级编号不能为空","提示",MessageBoxButtons.OK,MessageBoxIcon.Stop); return(false); } return base.CheckNotNull (); } } }
评论 5
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值