Winform之学生信息管理系统各种子窗体(一)

        先来补充一下学生信息管理系统登录窗体,在完成的过程中总是遇到各种各样的问题,对于登录窗体的设计还是存在着一些弊端,那就是需要登录学生信息管理系统时如果输入的数据出错不必一个个删除,就需要在窗体上再添加一个清空写入数据的button控件,将其属性Text改为重置。还有一个与登录窗口设计的属性AcceptButton将其改为确定按钮的唯一名字(也就是button1),因此在按下回车键后我们也能登录到学生信息管理系统主页面相对应的CancelButton将其改为取消按钮的唯一名字(也就是button2),因此在按下退出键后也能退出登录窗口。

       需要在重置的button按钮控件添加的Click事件的代码为:

        <span style="font-size:18px;">private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
        }</span>

        完成改动后的登录窗口为:

 

       下面就来设计一些需要都用到的子窗体。

        一学生信息添加窗体

        学生信息添加窗体窗体主要是用来添加学生信息或者修改学生信息,输入学号、姓名、性别、出生日期、家庭住址、家庭电话和所在班级,点击“保存”按钮即可录入或者修改学生信息记录,点击“取消”按钮,退出学生信息添加窗体。这个窗体需要用到的控件有Label控件,TextBox控件,Button控件,Panel控件和ComboBox控件。在学生信息管理系统主页面中的菜单选项中找到学生管理,再次单击学生信息就会出现学生信息添加的窗口。

 

          二用户信息添加窗体

         用户信息添加窗体主要是实现登录用户的添加操作。该窗体中包含了用户名、密码、确认密码和用户权限这些信息。当点击“保存”按钮时,即可以将用户的这些信息添加到数据库中。点击“取消”按钮,可以退出用户信息添加窗体。这个窗体需要用到的控件有Label控件,TextBox控件,Button控件,Panel控件和ComboBox控件。在学生信息管理系统主页面中的菜单选项中找到系统管理,再次单击用户信息就会出现用户信息添加的窗口。

 

        三用户修改密码窗体

        用户修改密码窗体主要是实现用户修改密码的功能。该窗体中,可以通过输入用户名和原密码,然后输入新密码和确认新密码,来修改用户的登录密码。这个窗体需要用到的控件有Label控件,TextBox控件,Button控件,Panel控件。在学生信息管理系统主页面中的菜单选项中找到系统管理,再次单击用户修改密码就会出现用户修改密码添加的窗口。

 

        上述三个子窗体中的取消按钮都是一样的代码写入:

        <span style="font-size:18px;">private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }</span>

       经过上述的改动和子窗体的添加后的完整的Form1(学生信息管理系统登录窗口)的代码为:

<span style="font-size:18px;">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsForms
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str = textBox1.Text;//获取你在textBox1中输入的信息
            Form2 ad = new Form2(str);//创建一个学生信息管理系统主界面的对象
            ad.Show();//点击确定后进入学生信息管理系统主界面
            this.Hide();//单击确定后隐藏登录窗口
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();//点击取消退出整个程序
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";//这是清空你写入的用户名称
            textBox2.Text = "";//这是清空你写入的用户密码
        }
    }
}</span></span>

         完整的Form2(学生信息管理系统主页面)的代码为:

<span style="font-size:18px;"><span style="font-size:18px;">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsForms
{
    public partial class Form2 : Form
    {
        public Form2(string s)
        {
            InitializeComponent();
            tssl_name.Text = s;//将登陆窗口textBox1输入的信息传递给状态栏Text属性
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();//单击主菜单中的退出我们退出整个程序
        }

        private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            Children qq = new Children();//创建一个子窗体的实例
            qq.MdiParent = this;//要求子窗体的父窗体是MDI窗体
            qq.Show();
        }

        private void 学生信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Children1 c1 = new Children1();
            c1.MdiParent = this;
            c1.Show();
        }

        private void 用户信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Children2 c2 = new Children2();
            c2.MdiParent = this;
            c2.Show();
        }

        private void 用户密码修改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Children3 c3 = new Children3();
            c3.MdiParent = this;
            c3.Show();
        }
    }
}</span>

       完整的子窗体Children1(学生信息添加窗体)的代码为:

<span style="font-size:18px;">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsForms
{
    public partial class Children1 : Form
    {
        public Children1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}</span>

          完整的子窗体Children2(用户信息添加窗体)的代码为:

<span style="font-size:18px;">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsForms
{
    public partial class Children2 : Form
    {
        public Children2()
        {
            InitializeComponent();
        }

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

        private void s(object sender, EventArgs e)
        {
        }
    }
}</span>

             完整的子窗体Children2(用户密码修改窗体)的代码为:

<span style="font-size:18px;">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsForms
{
    public partial class Children3 : Form
    {
        public Children3()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}</span>

            在登录学生信息管理系统主页面打开子窗体的界面为:

         在文件中找到你所编写的程序,打开exe运行学生信息管理系统,检验是否与自己设计想象的有什么不同,不同的话进行修改调试,直到与自己预想的结果相吻合就可以了。

 


 





 


 

 

 

 

 


 

 

  • 18
    点赞
  • 88
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值