zoukankan      html  css  js  c++  java
  • 实验2 登录系统

    
    using System;
    	using System.Collections.Generic;
    	using System.ComponentModel;
    	using System.Data;
    	using System.Data.SqlClient;
    	using System.Drawing;
    	using System.Linq;
    	using System.Text;
    	using System.Threading.Tasks;
    	using System.Windows.Forms;
    	
    	namespace LoginDemo
    	{
    	    public partial class Form1 : Form
    	    {
    	        public Form1()
    	        {
    	            InitializeComponent();
    	        }
    	
    	        private void label2_Click(object sender, EventArgs e)
    	        {
    	
    	        }
    	
    	        private void textBox2_TextChanged(object sender, EventArgs e)
    	        {
    	
    	        }
    	
    	        private void button1_Click(object sender, EventArgs e)
    	        {
    	            string username = textBoxUserName.Text.Trim();  
    	            string password = textBoxPassWord.Text.Trim();  
    	
    	            //string connstr = ConfigurationManager.ConnectionStrings["connectionString"].ToString();
    	            string myConnString = "Data Source=.;Initial Catalog=Test;Persist Security Info=True;User ID=sa;Password=luoluoluo";
    	
    	            SqlConnection sqlConnection = new SqlConnection(myConnString); 
    	            sqlConnection.Open();
    	
    	            string sql = "select userid,password from usertable where userid = '" + username + "' and password = '" + password + "'";                                          
    	            SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
    	
    	            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
    	
    	            if (sqlDataReader.HasRows)
    	            {
    	                MessageBox.Show("SUCESS!", "notice", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);       
    	                label1.Text = "Log in :" + username;
    	                
    	                FormMain formMain = new FormMain(); 
    	                formMain.Show();
    	                this.Hide();  
    	            }
    	            else
    	            {
    	                MessageBox.Show("FAILED!", "notice", MessageBoxButtons.OK, MessageBoxIcon.Error);
    	            }
    	            sqlConnection.Close();
    	
    	        }
    	
    	        private void textBox1_TextChanged(object sender, EventArgs e)
    	        {
    	
    	        }
    	
    	        private void button2_Click(object sender, EventArgs e)
    	        {
    	            Application.Exit();
    	        }
    	
    	        private void Form1_Load(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 LoginDemo
    	{
    	    public partial class FormMain : Form
    	    {
    	        public FormMain()
    	        {
    	            InitializeComponent();
    	        }
    	
    	        private void FormMain_Load(object sender, EventArgs e)
    	        {
    
    	            this.usertableTableAdapter.Fill(this.testDataSet.usertable);
    	
    	        }
    	
    	        private void button1_Click(object sender, EventArgs e)
    	        {
    	            Application.Exit();
    	        }
    	    }
    	}
    
    
  • 相关阅读:
    linux服务器管理员的12个有用的命令
    登录服务器,首先用到的5个命令
    去掉hive字段中的tab
    html-css实例
    【转】你真的理解Python中MRO算法吗?
    【转】CentOS下expect 安装
    Python|PyCharm安装scrapy包
    Java连接Oracle
    Java连接mysql
    最常用正则表达式
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13285163.html
Copyright © 2011-2022 走看看