private void button1_Click(object sender, EventArgs e)//登陆 { if (cbUser.Text == "") { MessageBox.Show("用户名不能为空!"); return; } if (tbPwd.Text == "") { MessageBox.Show("没有密码就想登陆吗?"); } string constr = "Server=127.0.0.1;Database=tonghua;User Id=root;Password=5120154230;"; MySqlConnection mycon = new MySqlConnection(constr); mycon.Open(); //打开连接 string check = "select user,password from information where user='******'and password='******'"; MySqlDataAdapter da = new MySqlDataAdapter(check, mycon); //创建适配器 DataSet ds = new DataSet(); //创建数据集 if (da.Fill(ds, "information") != 0) //判断同名 { MessageBox.Show("恭喜你,登陆成功!"); //输出信息 this.Hide(); Socket_Server server = new Socket_Server(); server.StartPosition = FormStartPosition.CenterScreen; server.Show(); } else { MessageBox.Show("用户名或密码错误!"); return; } }
private void button5_Click(object sender, EventArgs e)//返回 { this.Hide(); Socket_Server socket_Server = new Socket_Server(); socket_Server.StartPosition = FormStartPosition.CenterScreen; socket_Server.Show(); }