⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form2.cs

📁 C#编写的
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace 成绩管理系统_new
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("请输入用户名或密码");
            }
            else
            {
                try
                {
                    string connstr, selectcmd;
                    connstr = "provider=microsoft.jet.oledb.4.0;data source=成绩管理系统.mdb";
                    selectcmd = "select * from 登录信息 where 用户名 = '" + this.textBox1.Text + "' and 密码 = '" + this.textBox2.Text + "'";
                    OleDbConnection conn;
                    OleDbCommand cmd;
                    OleDbDataReader reader;

                    conn = new OleDbConnection(connstr);
                    conn.Open();
                    cmd = new OleDbCommand(selectcmd, conn);
                    reader = cmd.ExecuteReader();

                    if (reader.Read())
                    {
                        From1 newForm1 = new From1();
                        newForm1.Show();
                        this.Hide();
                        //隐藏当前窗体
                    }
                    else
                    {
                        MessageBox.Show("用户名或者密码错误");
                    }

                    reader.Close();
                    conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -