?? form2.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 + -