|
本帖最后由 多米诺 于 2012-11-27 18:37 编辑
注册界面
代码如下
注册部分:登录部分:- using UnityEngine;
- using System.Collections;
- using Bitverse.Unity.Gui;
- using System;
- using System.Data.SqlClient;
- public class logsct : MonoBehaviour {
- int temp;
- public GUISkin txtskin;
- BitEditorStage form;
- BitWindow logwindow;
- BitTextField txtname;
- BitTextField txtpwd;
- BitButton btlog;
- BitButton btexit;
- // Use this for initialization
- void Start () {
- form = gameObject.GetComponent<BitEditorStage>();
- logwindow = form.FindControl<BitWindow>("log");
- txtname = logwindow.FindControl<BitTextField>("txtname");
- txtpwd = logwindow.FindControl<BitTextField>("txtpwd");
- btlog = logwindow.FindControl<BitButton>("btlog");
- btlog.MouseClick += bt_log;
- btexit = logwindow.FindControl<BitButton>("btexit");
- btexit.MouseClick += bt_exit;
- }
- private void bt_log(object sender, MouseEventArgs e)
- {
- if (txtname.Text != "" && txtpwd.Text != "")
- {
- SqlConnection sqlcon = new SqlConnection("Data Source=Sql1001.webweb.com,2433;Initial Catalog=DB_98CEEF_test;User Id=DB_98CEEF_test_admin;Password=testtest;");
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = sqlcon;
- cmd.CommandType = System.Data.CommandType.Text;
- cmd.CommandText = "select * from user_ where user_name='"+txtname.Text+"' and user_pwd ='"+txtpwd.Text+"'";
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- da.SelectCommand.Connection.Open();
- temp = int.Parse(da.SelectCommand.ExecuteScalar().ToString());
- da.SelectCommand.Connection.Close();
- if (temp != 0)
- print("login successed!");
- txtname.Text = "";
- txtpwd.Text = "";
- }
- }
- private void bt_exit(object sender, MouseEventArgs e)
- {
- txtname.Text = "";
- txtpwd.Text = "";
- logwindow.Visible = false;
- }
- // Update is called once per frame
- void Update () {
-
- }
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|