Winform项目之学生成绩管理系统设计与实现(一)

1.项目简介:

  实现学生信息的增、删、改、查;班级信息的。。。。。、课程信息的、、、、、、;成绩信息的、、、、、、、。用户登录校验与密码修改等。

2.框架搭建

开发中,还不完善。

3.登录与退出

  //登录
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //数据验证
            if (this.txtUserName.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入登录账号!", "登录提示");
                this.txtUserName.Focus();
                return;
            }
            if (this.txtPassword.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入登录密码!", "登录提示");
                this.txtPassword.Focus();
                return;
            }

            //登录用户对象
            Admin admin = new Admin();
            admin.UserName = this.txtUserName.Text.Trim();
            admin.Password = this.txtPassword.Text.Trim();

            //提交信息

            try
            {
                admin = adminService.AdminLogin(admin);
                if (admin == null)
                {
                    MessageBox.Show("登录账号或密码错误!", "登录提示");
                }
                else
                {
                    Program.onlineAdmin = admin;//保存在线用户
                    this.DialogResult = DialogResult.OK;//设置登录成功信息提示
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,"登录失败!");
            }
        }


        //关闭
        private void btnExit_Click(object sender, EventArgs e)
        {
                 this.Close();
        }

        private void LoginForm_Load(object sender, EventArgs e)
        {
            int x = (System.Windows.Forms.SystemInformation.WorkingArea.Width - this.Size.Width) / 2;
            int y = (System.Windows.Forms.SystemInformation.WorkingArea.Height - this.Size.Height) / 2;
            this.StartPosition = FormStartPosition.Manual; //窗体的位置由Location属性决定  
            this.Location = (Point)new Size(x, y);
        }

4.密码修改

    private void ModifyPwdForm_Load(object sender, EventArgs e)
        {
            int x = (System.Windows.Forms.SystemInformation.WorkingArea.Width - this.Size.Width) / 2;
            int y = (System.Windows.Forms.SystemInformation.WorkingArea.Height - this.Size.Height) / 2;
            this.StartPosition = FormStartPosition.Manual; //窗体的位置由Location属性决定  
            this.Location = (Point)new Size(x, y);
        }

        private void btnModifyPwd_Click(object sender, EventArgs e)
        {
            //校验用户信息是否正确
            if (this.txtPwd.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入旧密码", "修改提示");
                this.txtPwd.Focus();
                return;
            }
            //原密码正确与否
            if (this.txtPwd.Text.Trim() != Program.onlineAdmin.Password)
            {
                MessageBox.Show("原密码不正确!", "修改提示");
                this.txtPwd.Focus();
                this.txtPwd.SelectAll();
                return;
            }
            //新密码为空?
            if (this.txtNewPwd.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入新密码", "修改提示");
                this.txtPwd.Focus();
                return;
            }
            //确认密码为空?
            if (this.txtConfimPwd.Text.Trim().Length == 0)
            {
                MessageBox.Show("请再次输入密码", "修改提示");
                this.txtPwd.Focus();
                return;
            }
            //验证2次密码是否一致
            if (this.txtNewPwd.Text.Trim() != this.txtConfimPwd.Text.Trim())
            {
                MessageBox.Show("两次输入的密码不一致!", "修改提示");
                return;
            }
            //将新密码提交到数据库
            string  id = Program.onlineAdmin.AdminId.ToString();
            int result = adminService.ModifyPwd(this.txtNewPwd.Text.Trim(), "1");
            if (result ==1)
            {
                MessageBox.Show("新密码修改成功!","修改提示");
                Program.onlineAdmin.Password = txtNewPwd.Text.Trim();
                this.Close();
            }
        }

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

  • 8
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

挑战不可

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值