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 CCWin;
using System.Data.SqlClient;
namespace best
{
public partial class Form1 : CCSkinMain
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void skinLabel3_Click(object sender, EventArgs e)
{
//接受用户输入
string name = this.username.Text;
string pwd = this.password.Text;
//非空验证
if (name == "" || pwd == "")
{
MessageBox.Show("用户名和密码不能为空");
}
else
{
//创建数据库连接
SqlConnection shu = new SqlConnection ("server=.;database=bestr;uid=sa;pwd=123456");
//打开数据库
shu.Open();
//定义新增账号的SQL语句
string sql = string.Format("insert users (username,password) values('{0}','{1}')", name, pwd);
//创建对象
SqlCommand ss = new SqlCommand(sql, shu);
//执行命令
int rows = ss.ExecuteNonQuery();
//关闭数据库
shu.Close();
//根据返回的行数判断是否成功
if (rows > 0)
{
MessageBox.Show("注册成功");
this.Hide();
Form logins = new login();
logins.Show();
}
else
{
MessageBox.Show("注册失败");
}
}
}
}
}
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 CCWin;
using System.Data.SqlClient;
namespace best
{
public partial class Form1 : CCSkinMain
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void skinLabel3_Click(object sender, EventArgs e)
{
//接受用户输入
string name = this.username.Text;
string pwd = this.password.Text;
//非空验证
if (name == "" || pwd == "")
{
MessageBox.Show("用户名和密码不能为空");
}
else
{
//创建数据库连接
SqlConnection shu = new SqlConnection ("server=.;database=bestr;uid=sa;pwd=123456");
//打开数据库
shu.Open();
//定义新增账号的SQL语句
string sql = string.Format("insert users (username,password) values('{0}','{1}')", name, pwd);
//创建对象
SqlCommand ss = new SqlCommand(sql, shu);
//执行命令
int rows = ss.ExecuteNonQuery();
//关闭数据库
shu.Close();
//根据返回的行数判断是否成功
if (rows > 0)
{
MessageBox.Show("注册成功");
this.Hide();
Form logins = new login();
logins.Show();
}
else
{
MessageBox.Show("注册失败");
}
}
}
}
}