?? form2.cs
字號:
?using System;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Register : Form
{
private bool flag;
private string limit;
public string name;
public bool flag1;
public string getlimit
{
get
{
return limit;
}
}
public bool setFlag
{
set
{
flag=value;
}
}
public string getname
{
get
{
return name;
}
}
public Register()
{
limit = "1";
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
DataSet ds = new DataSet();
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
MessageBox.Show("User-name can not null!");
else if (textBox2.Text == "")
MessageBox.Show("Password can not null!");
else try
{
textBox1.Enabled = true;
SqlConnection conn = new SqlConnection("server=;database=ll;uid=sa;pwd=;");
string insert = "insert into users(username,password,limit,sex,phone) values('" + textBox1.Text + "','" + textBox2.Text + "','" + limit + "','" + comboBox1.Text + "','" + textBox4.Text + "') ";
SqlDataAdapter q = new SqlDataAdapter(insert, conn);
q.Fill(ds, "users");
}
catch (IndexOutOfRangeException)
{
MessageBox.Show("Input data error or User has existed!");
textBox2.Text = "";
textBox1.Text = "";
textBox4.Text = "";
comboBox1.Text = "";
return;
}
name = textBox1.Text;
MessageBox.Show("Insert successful! ");
flag1 = true;
this.Close();
}
private void Register_Load(object sender, EventArgs e)
{
flag1 = false;
if (flag)
{
limit = "2";
textBox1.Text = "admin";
name = "admin";
textBox1.Enabled = false;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -