VS2012完成简易登陆页面

本文关键为大伙儿详尽详细介绍了VS2012完成简易登陆页面,具备一定的参照使用价值,很感兴趣的小伙子伴们能够参照一下

文中案例为大伙儿共享了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();
 m = new SqlCommand(sql, conn);
 int num = (m.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)

运作結果如图所示:

之上便是文中的所有內容,期待对大伙儿的学习培训有一定的协助,也期待大伙儿多多的适用