VS2012實現(xiàn)簡單登錄界面
本文實例為大家分享了VS2012實現(xiàn)登錄界面的具體代碼,供大家參考,具體內(nèi)容如下
這個是第一個界面的代碼:
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 System.Data.SqlClient;
namespace 登錄x
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void userInfoBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.userInfoBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.studentRecordDataSet);
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: 這行代碼將數(shù)據(jù)加載到表“studentRecordDataSet1.UserInfo”中。您可以根據(jù)需要移動或刪除它。
this.userInfoTableAdapter1.Fill(this.studentRecordDataSet1.UserInfo);
// TODO: 這行代碼將數(shù)據(jù)加載到表“studentRecordDataSet.UserInfo”中。您可以根據(jù)需要移動或刪除它。
this.userInfoTableAdapter.Fill(this.studentRecordDataSet.UserInfo);
}
private void passwordLabel_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string connString = @"Data Source=.;Initial Catalog=studentrecord;Integrated Security=True";
SqlConnection conn = new SqlConnection(connString);
string sql = "select count(*) from UserInfo where username='" + userNameComboBox.Text + "'and password='" + passwordTextBox.Text + "'";
conn.Open();
SqlCommand comm = new SqlCommand(sql, conn);
int num = (int)comm.ExecuteScalar();
if (num > 0)
{
Form2 frm2 = new Form2();
frm2.Show();
}
else
{
MessageBox.Show("對不起,用戶名和密碼并不匹配!", "登陸失敗");
}
conn.Close();
}
private void userNameComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void passwordTextBox_TextChanged(object sender, EventArgs e)
{
}
}
}
這個是第二個界面的代碼:
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 登錄x
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}
運行結(jié)果如圖:

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
GridView中checkbox"全選/取消"完美兼容IE和Firefox
GridView中checkbox的的"全選/取消"使用還是比較頻繁的,本文有個不錯的示例完美兼容IE和Firefox,感興趣的朋友可以參考下,希望對大家有所幫助2013-10-10
MVC+EasyUI+三層新聞網(wǎng)站建立 驗證碼生成(三)
這篇文章主要為大家詳細介紹了MVC+EasyUI+三層新聞網(wǎng)站建立的第三篇,教大家如何生成驗證碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-07-07
.Net Core 下使用ZKWeb.System.Drawing實現(xiàn)驗證碼功能(圖形驗證碼)
本文介紹.Net Core下用第三方ZKWeb.System.Drawing實現(xiàn)驗證碼功能。非常不錯具有參考借鑒價值,感興趣的朋友一起看看吧2016-11-11
Asp.net之TextBox只允許輸入數(shù)字的方法總結(jié)
Asp.net之TextBox只允許輸入數(shù)字的方法總結(jié),需要的朋友可以參考一下2013-02-02
Microsoft SQL Server 2005 Express 遠程訪問設置詳述,100%成功篇
Microsoft SQL Server 2005 Express Edition是Microsoft數(shù)據(jù)庫的低端解決方案,是免費的,并且可以隨軟件免費發(fā)布,而就其數(shù)據(jù)庫功能對于一般的企業(yè)級應用已足夠了。但 默認安裝時只允許本地訪問,而不能遠程訪問。2009-03-03
ASP.NET WebAPi(selfhost)實現(xiàn)文件同步或異步上傳
這篇文章主要介紹了ASP.NET WebAPi(selfhost)實現(xiàn)文件同步或異步上傳,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-11-11

