您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本篇文章为大家展示了使用VS2012怎么实现一个登录界面,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
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: 这行代码将数据加载到表“studentRecordDataSet1.UserInfo”中。您可以根据需要移动或删除它。
this.userInfoTableAdapter1.Fill(this.studentRecordDataSet1.UserInfo);
// TODO: 这行代码将数据加载到表“studentRecordDataSet.UserInfo”中。您可以根据需要移动或删除它。
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)
{
}
}
}上述内容就是使用VS2012怎么实现一个登录界面,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。