資源簡介
大一末小學期.net課作業程序,可以借鑒到一些東西,BUG不太多,界面有美化,+關注找我嘮唄,沙雕網友也很無聊
代碼片段和文件信息
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;
using?MySql.Data.MySqlClient;
namespace?STUMG
{
????public?partial?class?Loginform?:?Form
????{
????????public?Loginform()
????????{
????????????InitializeComponent();
????????}
????????//窗體加載
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????MessageBox.Show(“歡迎使用學生信息管理系統~“?“提示“);
????????}
????????//登錄按鈕功能
????????private?void?btn_login_Click(object?sender?EventArgs?e)
????????{
????????????string?username?=?this.txt_usr.Text;
????????????string?userpassword?=?this.txt_pwd.Text;
????????????if?(username.Equals(““)?||?userpassword.Equals(““))
????????????{
????????????????MessageBox.Show(“用戶名或密碼不能為空!“);
????????????}
????????????else//驗證是否和數據庫密碼對應
????????????{???//連接到要用的學生信息管理數據庫
????????????????string?strcon?=?“server?=?localhost;port=3306;database?=?student;user=root;password=159753abcDEF“;
????????????????MySqlConnection?con?=?new?MySqlConnection(strcon);//一個參數連接數據庫的
????????????????try
????????????????{
????????????????????con.Open();//打開通道
????????????????????string?sqlSel?=?“Select?*?from?student.user?where?userid=‘“?+?username?+?“‘?and?userpwd=‘“+userpassword+“‘;“;
????????????????????MySqlCommand?com?=?new?MySqlCommand(sqlSelcon);//用來執行查詢命令
????????????????????
????????????????????MySqlDataAdapter?check?=?new?MySqlDataAdapter(com);//數據適配器
?????????????????
????????????????????DataSet?datacheck?=?new?DataSet();??//建立虛擬數據庫
????????????????????int?n?=?check.Fill(datacheck“user“);//在student.user?中執行查詢命令返回值
???????????????????//?MySqlDataReader?sqldr?=?com.ExecuteReader();//數據讀取進行比對
????????????????????if?(n!=0)//說明的確存在
????????????????????{?
????????????????????????MessageBox.Show(“登陸成功!“);
????????????????????????this.DialogResult?=?DialogResult.OK;
????????????????????}
????????????????????else
????????????????????{
????????????????????????MessageBox.Show(“用戶名或或密碼錯誤請重新輸入!“);
????????????????????}
????????????????}
????????????????catch?(Exception?ex)
????????????????{
????????????????????MessageBox.Show(ex.Message.ToString()?+?“打開數據庫失敗“);
????????????????}
????????????}
????????}
????????//密碼顯示方式
????????private?void?checkBox1_CheckedChanged(object?sender?EventArgs?e)
????????{
????????????if?(checkBox1.Checked)
????????????{
????????????????txt_pwd.PasswordChar?=?new?char();
????????????}???????????else
????????????????txt_pwd.PasswordChar?=?‘*‘;
????????}
????????//回車鍵登陸
????????private?void?txt_pwd_KeyDown(object?sender?KeyEventArgs?e)
????????{
????????????if?(e.KeyCode?==?Keys.Enter)
????????????{
????????????????this.Focus();
????????????????btn_login_Click(this?new?EventArgs());
????????????}
????????}
????????private?void?btn_bk_Click(object?sender?EventArgs?e)
????????{
????????????M
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-07-11?07:50??STUCH\
?????目錄???????????0??2019-07-06?07:36??STUCH\STUMG\
?????目錄???????????0??2019-07-05?07:23??STUCH\STUMG\.vs\
?????目錄???????????0??2019-07-05?07:23??STUCH\STUMG\.vs\STUMG\
?????目錄???????????0??2019-07-05?07:23??STUCH\STUMG\.vs\STUMG\v15\
?????文件???????71680??2019-07-11?08:37??STUCH\STUMG\.vs\STUMG\v15\.suo
?????目錄???????????0??2019-07-05?07:23??STUCH\STUMG\.vs\STUMG\v15\Server\
?????目錄???????????0??2019-07-05?17:38??STUCH\STUMG\.vs\STUMG\v15\Server\sqlite3\
?????文件???????????0??2019-07-05?07:23??STUCH\STUMG\.vs\STUMG\v15\Server\sqlite3\db.lock
?????文件??????651264??2019-07-10?21:46??STUCH\STUMG\.vs\STUMG\v15\Server\sqlite3\storage.ide
?????文件???????32768??2019-07-11?07:55??STUCH\STUMG\.vs\STUMG\v15\Server\sqlite3\storage.ide-shm
?????文件?????4128272??2019-07-10?21:47??STUCH\STUMG\.vs\STUMG\v15\Server\sqlite3\storage.ide-wal
?????文件???????15387??2019-07-06?07:31??STUCH\STUMG\1.ico
?????目錄???????????0??2019-07-10?21:47??STUCH\STUMG\STUMG\
?????文件??????579519??2019-04-08?16:12??STUCH\STUMG\STUMG\5cac0eeb33463.jpg
?????文件????60423378??2019-04-08?16:12??STUCH\STUMG\STUMG\5cac0eeb33463.psd
?????文件?????????189??2019-07-05?07:23??STUCH\STUMG\STUMG\App.config
?????目錄???????????0??2019-07-11?08:37??STUCH\STUMG\STUMG\Connected?Services\
?????文件???????10806??2019-07-10?17:37??STUCH\STUMG\STUMG\Form1.Designer.cs
?????文件????????3687??2019-07-10?18:10??STUCH\STUMG\STUMG\Form1.cs
?????文件???????20940??2019-07-10?17:37??STUCH\STUMG\STUMG\Form1.resx
?????文件???????37998??2019-07-10?21:47??STUCH\STUMG\STUMG\Form2.Designer.cs
?????文件???????24969??2019-07-10?21:47??STUCH\STUMG\STUMG\Form2.cs
?????文件???????85871??2019-07-10?21:47??STUCH\STUMG\STUMG\Form2.resx
?????文件????????6422??2019-07-10?18:03??STUCH\STUMG\STUMG\Form3.Designer.cs
?????文件????????3536??2019-07-10?21:13??STUCH\STUMG\STUMG\Form3.cs
?????文件???????18502??2019-07-10?18:03??STUCH\STUMG\STUMG\Form3.resx
?????文件????????2369??2019-07-09?15:26??STUCH\STUMG\STUMG\FunSql.cs
?????文件????????4874??2019-07-09?17:33??STUCH\STUMG\STUMG\Login.csproj
?????文件?????????821??2019-07-05?20:18??STUCH\STUMG\STUMG\Program.cs
?????目錄???????????0??2019-07-05?07:23??STUCH\STUMG\STUMG\Properties\
............此處省略58個文件信息
評論
共有 條評論