zoukankan      html  css  js  c++  java
  • 注册 登录

    using System;
    using System.Collections.Generic;
    using System.Data.SqlClient;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                //读取用户名密码
                string name = textBox1.Text;
                string upass = textBox2.Text;
                //连接数据库
                SqlConnection conn = new SqlConnection("server=.;database='进销存';user=sa;pwd=123456");
                conn.Open();
                //写执行语句
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "select * from users where name like @name and upass like @upass";
                cmd.Parameters.Add("@name",name);
                cmd.Parameters.Add("upass", upass);
                //执行sql语句返回查询内容
                SqlDataReader dr = cmd.ExecuteReader();
                //读取dr
                if (dr.Read())
                {
                    采购入库单 m = new 采购入库单();
                    this.Owner = m;
                    this.Visible = false;
                    m.Show();
                }
                else
                {
                    MessageBox.Show("登陆失败!");
                }
                conn.Close();
    
                
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                //添加数据到数据库
                string username = textBox1.Text;
                string upass = textBox2.Text;
                //连接数据库
                SqlConnection conn = new SqlConnection("server=.;database='进销存';user=sa;pwd=123456");
                conn.Open();
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "insert into users values(' " + username + "','" + upass + "')";
                //增删改
                int count= cmd.ExecuteNonQuery();
                if (count > 0)
                {
                    MessageBox.Show("注册成功!");
                }
                else
                {
                    MessageBox.Show("注册失败!");
                }
            }
  • 相关阅读:
    接口测试工具 — jmeter(关联)
    接口测试工具 — jmeter(参数化)
    接口测试工具 — jmeter(header与cookie的添加)
    【多态】重写与重载的区别
    【面试】软件测试面试题
    【Jenkins】testng+testNgXslt+ant优化测试报告
    【ANT】输入中文格式为乱码
    【Sql】经典sql语句
    【log4j】使用注意事项
    【问题】用ant编译时,提示编码utf为不可映射字符
  • 原文地址:https://www.cnblogs.com/zxm1002/p/4939721.html
Copyright © 2011-2022 走看看