Esempio n. 1
0
    public string getActionId()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string  querySQL = "select max(ac_id) from act;";
        DataSet ds       = mysql.SimpleSql(querySQL);
        string  res_id   = "";

        if (ds != null)
        {
            if (ds.Tables[0].Rows.Count == 1)
            {
                if (ds.Tables[0].Rows[0][0].ToString() == "")
                {
                    res_id = "400001";
                }
                else
                {
                    string cur_max_id = ds.Tables[0].Rows[0][0].ToString();
                    //Debug.Log("max id is: "  + cur_max_id );
                    int next_id = int.Parse(cur_max_id) + 1;
                    res_id = next_id.ToString();
                    //Debug.Log("next id is: " + res_id);
                }
            }
            else
            {
                Debug.Log("Error");
                res_id = "error";
            }
        }
        mysql.Close();
        return(res_id);
    }
Esempio n. 2
0
    /// <summary>
    /// 按下登录按钮
    /// </summary>
    public void OnClickedLoginButton()
    {
        mysql.OpenSql();
        string  loginMsg = "登录成功";
        DataSet ds       = mysql.Select("usertable", new string[] { "level" }, new string[] { "`" + "account" + "`", "`" + "password" + "`" }, new string[] { "=", "=" }, new string[] { userNameInput.text, passwordInput.text });

        if (ds != null)
        {
            DataTable table = ds.Tables[0];
            if (table.Rows.Count > 0)
            {
                loginMsg           = "登陆成功!";
                loginMessage.color = Color.green;
                Debug.Log("用户权限等级:" + table.Rows[0][0]);
                SceneManager.LoadScene(2);
                Time.timeScale = 1f;
            }
            else
            {
                loginMsg           = "用户名或密码错误!";
                loginMessage.color = Color.red;
            }
            loginMessage.text = loginMsg;
        }
        mysql.CloseSql();
    }
Esempio n. 3
0
    public string HistoryRecord(string Date, string actID, int Hand)
    {
        string ptID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            ptID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + ptID);

        string date   = Date;
        string act_id = actID;
        int    hand   = Hand;

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string query = "select rec_link from rec where rec_ptID = '" + ptID + "' and rec_hand = " + hand +
                       " and rec_actID = '" + act_id + "' and rec_date = '" + date + "'";
        DataSet   ds    = mysql.QuerySet(query);
        DataTable table = ds.Tables [0];
        string    res   = "";

        Debug.Log(table.Rows.Count);
        if (table.Rows.Count == 1)
        {
            res = table.Rows [0] [0].ToString();
        }
        Debug.Log(res);
        mysql.Close();
        return(res);
    }
Esempio n. 4
0
    //查
    public string[,] findStandardActions()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        string[,] res;
        res = new string[1, 1];
        mysql.OpenSql();
        Debug.Log("database name: " + databaseName);
        string querySql = "select ac_id, ac_name, ac_pic from act";
        //string querySql = "select trp_ptID from trp";
        DataSet ds      = mysql.SimpleSql(querySql);
        int     row_num = ds.Tables[0].Rows.Count;

        //Debug.Log("aaaa" + row_num);
        if (row_num != 0)
        {
            int col_num = ds.Tables[0].Rows[0].ItemArray.Length;
            //Debug.Log("rows num: " + row_num);
            //Debug.Log("cols_num: " + col_num);
            res = new string[row_num, col_num];
            for (int i = 0; i < row_num; i++)
            {
                for (int j = 0; j < col_num; j++)
                {
                    //Debug.Log("content: " + ds.Tables[0].Rows[i][j]);
                    res[i, j] = ds.Tables[0].Rows[i][j].ToString();
                }
            }
        }
        else
        {
            res[0, 0] = "null";
        }
        mysql.Close();
        return(res);
    }
Esempio n. 5
0
    //删
    public string[] deleteStandardAction(string hand_id)
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        string[] res = new string[1];
        res[0] = "null";
        mysql.OpenSql();
        string  querySql = "select * from act where ac_id = '" + hand_id + "'";
        DataSet ds       = mysql.SimpleSql(querySql);

        if (ds.Tables[0].Rows.Count != 0)
        {
            res    = new string[2];
            res[0] = ds.Tables[0].Rows[0][0].ToString();
            res[1] = ds.Tables[0].Rows[0][1].ToString();
            string picName   = ds.Tables[0].Rows[0][2].ToString();
            string leftData  = ds.Tables[0].Rows[0][3].ToString();
            string rightData = ds.Tables[0].Rows[0][4].ToString();
            querySql = "delete from act where ac_id = '" + hand_id + "'";
            Debug.Log(querySql);
            deletePicture(picName);
            deleteActions(leftData);
            deleteActions(rightData);
            mysql.SimpleSql(querySql);
            Debug.Log("delete!!!!");
        }

        mysql.Close();
        return(res);
    }
Esempio n. 6
0
    //查看病人训练方案
    public string [,] getPatientPlans(string pat_id)
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        string[,] res;
        res = new string[1, 1];
        mysql.OpenSql();
        string querySql = "select act.ac_id, act.ac_name, trp.trp_hand, trp.trp_num, trp.trp_time, trp.trp_totl, trp.trp_finish " +
                          "from trp, act where trp.trp_actID = act.ac_id and trp.trp_ptID = '" + pat_id + "'";
        DataSet ds      = mysql.SimpleSql(querySql);
        int     row_num = ds.Tables[0].Rows.Count;

        if (row_num != 0)
        {
            int col_num = ds.Tables[0].Rows[0].ItemArray.Length;
            res = new string[row_num, col_num];
            for (int i = 0; i < row_num; i++)
            {
                for (int j = 0; j < col_num; j++)
                {
                    //Debug.Log("content: " + ds.Tables[0].Rows[i][j]);
                    res[i, j] = ds.Tables[0].Rows[i][j].ToString();
                }
            }
        }
        else
        {
            res[0, 0] = "null";
        }
        return(res);
    }
Esempio n. 7
0
    /// <summary>
    /// 初始化管理员表(将人员表中所有的管理员添加到管理员表中)
    /// </summary>
    public void InitialAdmin()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string  query = "select ppl_id from ppl where ppl_role = '管理员'";
        DataSet ds1   = mysql.QuerySet(query);

        if (ds1 != null)
        {
            DataTable table = ds1.Tables [0];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                Debug.Log(table.Rows [i] [0]);
                // 把激活改成1
                string  actquery = "update ppl set ppl_act = 1 where ppl_id = " + table.Rows[i][0];
                DataSet ds2      = mysql.QuerySet(actquery);
                // 往管理员表里加
                string  dupliquery = "select * from adm where adm_id = " + table.Rows[i][0];
                DataSet ds3        = mysql.QuerySet(dupliquery);
                if (ds3 == null)
                {
                    string  addquery = "insert into adm values ('" + table.Rows[i][0] + "', '" + table.Rows[i][0] + "')";
                    DataSet ds4      = mysql.QuerySet(addquery);
                }
            }
            Debug.Log("管理员表初始化完成!");
        }
        else
        {
            Debug.Log("人员表中没有管理员身份的用户!");
        }
        mysql.Close();
    }
Esempio n. 8
0
    //获取病人信息
    public string[,] getPatientInfos()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        string[,] res;
        res = new string[1, 1];
        //res[0, 0] = "null";
        mysql.OpenSql();
        string  querySql = "select pat.pt_id, pat.pt_name, pat.pt_sex, doc.dc_id, doc.dc_name, doc.dc_pro from pat, doc where pat.pt_dcID = doc.dc_id order by doc.dc_id";
        DataSet ds       = mysql.SimpleSql(querySql);
        int     row_num  = ds.Tables[0].Rows.Count;

        if (row_num != 0)
        {
            int col_num = ds.Tables[0].Rows[0].ItemArray.Length;
            res = new string[row_num, col_num];
            for (int i = 0; i < row_num; i++)
            {
                for (int j = 0; j < col_num; j++)
                {
                    //Debug.Log("content: " + ds.Tables[0].Rows[i][j]);
                    res[i, j] = ds.Tables[0].Rows[i][j].ToString();
                }
            }
        }
        else
        {
            res[0, 0] = "null";
        }
        return(res);
    }
Esempio n. 9
0
    /// <summary>
    /// 查询未完成的训练计划
    /// </summary>
    public static DataSet findUnfinishedTrainingPlan(string trp_ptID)
    {
        MySqlAccess mysql = new MySqlAccess(host, port, userName, password, databaseName);

        mysql.OpenSql();
        string  querySql = "select * from trp where trp_ptID = '" + trp_ptID + "' and trp_totl > trp_finish";
        DataSet ds       = mysql.SimpleSql(querySql);

        mysql.Close();
        return(ds);
    }
Esempio n. 10
0
    /// <summary>
    /// 查询所有医生,返回医生编号、姓名、性别、职称、电话
    /// </summary>
    public DataTable QueryDoctor()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string    query = "select dc_id, dc_name, dc_sex, dc_pro, dc_tele from doc where dc_ex = 1";
        DataSet   ds    = mysql.QuerySet(query);
        DataTable table = ds.Tables [0];

        mysql.Close();
        return(table);
    }
Esempio n. 11
0
    //封装好的数据库类

    public static void addTrainingPlan(string trp_ptID, string trp_actID, int trp_hand, int trp_num, int trp_time, int trp_totl)
    {
        MySqlAccess mysql = new MySqlAccess(host, port, userName, password, databaseName);

        mysql.OpenSql();
        string querySql = "insert into trp(trp_ptID, trp_actID, trp_hand, trp_num, trp_time, trp_totl) values(";

        querySql = querySql + "'" + trp_ptID + "', '" + trp_actID + "', '" + trp_hand + "', '" + trp_num + "', '" + trp_time + "', '" + trp_totl + "')";
        Debug.Log(querySql);
        mysql.SimpleSql(querySql);
        mysql.Close();
    }
Esempio n. 12
0
    /// <summary>
    /// 删除医生
    /// </summary>
//	public void DeleteDoctor(string[] dc_id) {
    public void DeleteDoctor()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        //		string[] dcID = dc_id;
        string[] dcID = { "200001", "200002" };
        for (int i = 0; i < dcID.Length; i++)
        {
            string  query = "update doc set dc_ex = 0 where dc_id = '" + dcID [i] + "'";
            DataSet ds    = mysql.QuerySet(query);
        }
        mysql.Close();
    }
Esempio n. 13
0
 public void OnLogInBtnClick()
 {
     if (userNameInput.text == "")
     {
         Message("请输入用户名");
     }
     else if (passwordInput.text == "")
     {
         Message("请输入密码");
     }
     else
     {
         mysql.OpenSql();
         //获取数据
         DataSet ds = mysql.Select("users", new string[] { "user_password", "user_id" }, new string[] { "user_name" }, new string[] { "=" }, new string[] { userNameInput.text, });
         if (ds != null)
         {
             DataTable     table = ds.Tables[0];
             List <string> data  = new List <string>();
             foreach (DataRow row in table.Rows)
             {
                 foreach (DataColumn col in table.Columns)
                 {
                     data.Add(row[col].ToString());
                 }
             }
             if (data[0] == passwordInput.text)
             {
                 mes.color = Color.green;
                 Message("登录成功");
                 Manager.manager.FeaturesPanelDisplay();
             }
             else
             {
                 mes.color = Color.red;
                 Message("登陆失败");
             }
         }
         else
         {
             mes.color = Color.red;
             Message("登陆失败");
         }
         mysql.CloseSql();
     }
 }
Esempio n. 14
0
    /// <summary>
    /// 更改训练计划,只能改次数、时长、总天数
    /// </summary>
    public static void changeTrainingPlan(string trp_ptID, string trp_actID, int trp_hand, int trp_num, int trp_time, int trp_totl)
    {
        MySqlAccess mysql = new MySqlAccess(host, port, userName, password, databaseName);

        mysql.OpenSql();
        string querySql = "select trp_ptID, trp_actID, trp_hand from trp where trp_ptID = '"
                          + trp_ptID + "' and trp_actID = '" + trp_actID + "' and trp_hand = '" + trp_hand + "'";
        DataSet ds = mysql.SimpleSql(querySql);

        if (ds.Tables[0].Rows.Count != 0)
        {
            querySql = "update trp set trp_num='" + trp_num + "' and trp_time='" + trp_time + "' and trp_totl='" + trp_totl +
                       "' where trp_ptID = '" + trp_ptID + "' and trp_actID = '" + trp_actID + "' and trp_hand = '" + trp_hand + "'";
            Debug.Log(querySql);
            mysql.SimpleSql(querySql);
        }
        mysql.Close();
    }
Esempio n. 15
0
    /// <summary>
    /// 按下Add Patient按钮
    /// </summary>
    public void AddPatient(string pt_id, string pt_name, string pt_sex, string pt_tele)
    {
        string dcID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            dcID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + dcID);

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string ptID   = pt_id;
        string ptName = pt_name;
        string ptSex  = pt_sex;
        string ptTele = pt_tele;
        int    flag   = 1;    // 1可添加,0不可添加

        if (ptID == "" | ptName == "")
        {
            flag = 0;
            Debug.Log("患者编号和姓名不能为空");
        }
        if (ptID != "")
        {
            string    query = "select * from ppl where ppl_id = " + ptID;
            DataSet   ds    = mysql.QuerySet(query);
            DataTable table = ds.Tables [0];
            if (table.Rows.Count == 0)
            {
                flag = 0;
                Debug.Log("患者编号不在人员表中");
            }
        }
        if (flag == 1)
        {
            string  query  = "insert into pat values ('" + ptID + "','" + ptName + "','" + ptSex + "','" + ptTele + "','" + ptID + "','" + dcID + "',1)";
            DataSet ds     = mysql.QuerySet(query);
            string  query1 = "update ppl set ppl_act = 1 where ppl_id = '" + ptID + "'";
            DataSet ds1    = mysql.QuerySet(query1);
            Debug.Log("添加患者账号成功,患者编号:" + ptID);
        }
        mysql.Close();
    }
Esempio n. 16
0
    //增
    public void addStandardAction(string next_id, string actionName, string picPath)
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        string next_pic   = next_id + ".jpg";
        string next_left  = next_id + "0.json";
        string next_right = next_id + "1.json";

        mysql.OpenSql();
        uploadPicture(next_id, picPath);
        uploadActions(next_id, "0");
        uploadActions(next_id, "1");
        string querySql = "insert into act(ac_id, ac_name, ac_pic, ac_left, ac_right) values(";

        querySql = querySql + "'" + next_id + "', '" + actionName + "', '" + next_pic + "', '" + next_left + "', '" + next_right + "')";
        Debug.Log(querySql);
        //Debug.Log("next_pic: " + next_pic + " next left: " + next_left + " next right: " + next_right);
        mysql.SimpleSql(querySql);
        mysql.Close();
    }
Esempio n. 17
0
    /// <summary>
    /// 查询某个医生的所有患者,返回患者编号、姓名、性别、电话
    /// </summary>
    public DataTable QueryPatient()
    {
        string dcID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            dcID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + dcID);

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string    query = "select pt_id, pt_name, pt_sex, pt_tele from pat where pt_dcID = '" + dcID + "' and pt_ex = 1";
        DataSet   ds    = mysql.QuerySet(query);
        DataTable table = ds.Tables [0];

        mysql.Close();
        return(table);
    }
Esempio n. 18
0
    /// <summary>
    /// 删除患者
    /// </summary>
//	public void DeletePatient(string[] pt_id) {
    public void DeletePatient()
    {
        string dcID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            dcID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + dcID);

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
//		string[] ptID = pt_id;
        string[] ptID = { "300002", "300003" };
        for (int i = 0; i < ptID.Length; i++)
        {
            string  query = "update pat set pt_ex = 0 where pt_dcID = '" + dcID + "' and pt_id = '" + ptID [i] + "'";
            DataSet ds    = mysql.QuerySet(query);
        }
        mysql.Close();
    }
Esempio n. 19
0
    /// <summary>
    /// 按下Change Info按钮
    /// </summary>
    public void ChangeInfo(string pt_name, string pt_sex, string pt_tele)
    {
        string ptID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            ptID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + ptID);

        string ptName = pt_name;
        string ptSex  = pt_sex;
        string ptTele = pt_tele;

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string    query = "update pat set pt_name = '" + ptName + "', pt_sex = '" + ptSex + "', pt_tele = '" + ptTele + "' where pt_id = '" + ptID + "'";
        DataSet   ds    = mysql.QuerySet(query);
        DataTable table = ds.Tables [0];

        mysql.Close();
    }
Esempio n. 20
0
    /// <summary>
    /// 按下AddDoctor按钮
    /// </summary>
    public void AddDoctor(string dc_id, string dc_name, string dc_sex, string dc_pro, string dc_tele)
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string dcID   = dc_id;
        string dcName = dc_name;
        string dcSex  = dc_sex;
        string dcPro  = dc_pro;
        string dcTele = dc_tele;

        int flag = 1;         // 1可添加,0不可添加

        if (dcID == "" | dcName == "")
        {
            flag = 0;
            Debug.Log("医生编号和姓名不能为空");
        }
        if (dcID != "")
        {
            string    query = "select * from ppl where ppl_id = " + dcID;
            DataSet   ds    = mysql.QuerySet(query);
            DataTable table = ds.Tables [0];
            if (table.Rows.Count == 0)
            {
                flag = 0;
                Debug.Log("医生编号不在人员表中");
            }
        }
        if (flag == 1)
        {
            string  query = "insert into doc values ('" + dcID + "','" + dcName + "','" + dcSex + "','" + dcPro + "','" + dcTele + "','" + dcID + "',1)";
            DataSet ds    = mysql.QuerySet(query);
            //			DataTable table = ds.Tables [0];
            string  query1 = "update ppl set ppl_act = 1 where ppl_id = '" + dcID + "'";
            DataSet ds1    = mysql.QuerySet(query1);
            Debug.Log("添加医生账号成功,医生编号:" + dcID);
        }
        mysql.Close();
    }
Esempio n. 21
0
    //改
    public void changeStandardAction(string hand_id, string actionName, string picPath)
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string  querySql = "select ac_id from act where ac_id = '" + hand_id + "'";
        DataSet ds       = mysql.SimpleSql(querySql);

        if (ds.Tables[0].Rows.Count == 1)
        {
            uploadPicture(hand_id, picPath);
            uploadActions(hand_id, "0");
            uploadActions(hand_id, "1");
            querySql = "update act set ac_name = '" + actionName + "' where ac_id = '" + hand_id + "'";
            mysql.SimpleSql(querySql);
            Debug.Log("change already");
        }
        else
        {
            Debug.Log("无指定动作");
        }
        mysql.Close();
    }
Esempio n. 22
0
    /// <summary>
    /// 按下Change Info按钮
    /// </summary>
    public void ChangeInfo(string dc_name, string dc_sex, string dc_pro, string dc_tele)
    {
        string dcID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            dcID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + dcID);

        string dcName = dc_name;
        string dcSex  = dc_sex;
        string dcPro  = dc_pro;
        string dcTele = dc_tele;

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string    query = "update doc set dc_name = '" + dcName + "', dc_sex = '" + dcSex + "', dc_pro = '" + dcPro + "', dc_tele = '" + dcTele + "' where dc_id = '" + dcID + "'";
        DataSet   ds    = mysql.QuerySet(query);
        DataTable table = ds.Tables [0];

        mysql.Close();
    }
Esempio n. 23
0
    public static string[] deleteTrainingPlan(string trp_ptID, string trp_actID, int trp_hand)
    {
        string[] res = new string[1];
        res[0] = "null";
        MySqlAccess mysql = new MySqlAccess(host, port, userName, password, databaseName);

        mysql.OpenSql();
        string querySql = "select trp_ptID, trp_actID, trp_hand from trp where trp_ptID = '"
                          + trp_ptID + "' and trp_actID = '" + trp_actID + "' and trp_hand = '" + trp_hand + "'";
        DataSet ds = mysql.SimpleSql(querySql);

        if (ds.Tables[0].Rows.Count != 0)
        {
            res      = new string[3];
            res[0]   = ds.Tables[0].Rows[0][0].ToString();
            res[1]   = ds.Tables[0].Rows[0][1].ToString();
            res[2]   = ds.Tables[0].Rows[0][2].ToString();
            querySql = "delete from trp where trp_ptID = '" + trp_ptID + "' and trp_actID = '" + trp_actID + "' and trp_hand = '" + trp_hand + "'";
            Debug.Log(querySql);
            mysql.SimpleSql(querySql);
        }
        mysql.Close();
        return(res);
    }
    /// <summary>
    /// 按下登录按钮
    /// 返回值的类型是DataSet(类似一张表格)
    // DataSet name_ds=mysql.Select(sql);
    // for (int i = 0; i < name_ds.Tables[0].Columns.Count; i++)
    //     {
    //            Debug.Log(name_ds.Tables[0].Rows[0][i]);
    //     }
    /// UI 填充的时候,用for循环就能拿到每个表的每个信息
    /// </summary>
    public DataSet NameSearch(string input)
    {
        mysql.OpenSql();
        string sql = "SELECT * FROM player Left Join player_winrate on player.ID=player_winrate.playerID WHERE NAME LIKE '%" + input + "%' ORDER BY ID;";

        Debug.Log("sql:" + sql);
        DataSet name_ds = mysql.Select(sql);

        if (name_ds != null)
        {
            Debug.Log("结果不为空");
            for (int i = 0; i < name_ds.Tables[0].Columns.Count; i++)
            {
                Debug.Log(name_ds.Tables[0].Rows[0][i]);
            }
        }
        else
        {
            Debug.Log("结果为空");
        }
        return(name_ds);
    }
Esempio n. 25
0
    private void Awake()
    {
        Debug.Log("start database");
        m_player = new PlayerConfig[3];
        for (int i = 0; i < 3; i++)
        {
            m_player[i] = new PlayerConfig();
        }
        mySql = new MySqlAccess("localhost", "root", "klcklc", "gamedata");
        mySql.Close();
        mySql.OpenSql();
        DataSet ds = mySql.SelectAll("user");

        if (ds != null)
        {
            DataTable table = ds.Tables[0];
            foreach (DataRow row in table.Rows)
            {
                int    p   = 0;
                string log = "";
                foreach (DataColumn column in table.Columns)
                {
                    p++;
                    log += (" " + row[column]);
                    if (p == 1)
                    {
                        Debug.Log(log);
                        m_player[playernum].idUser = (int)row[column];
                    }
                    else if (p == 2)
                    {
                        Debug.Log(log);
                        m_player[playernum].Int_Gold = (int)row[column];
                    }
                    else if (p == 3)
                    {
                        Debug.Log(log);
                        m_player[playernum].int_Lvl = (int)row[column];
                    }
                    // gold = (int)row[column];
                }
                playernum++;
                Debug.Log(log + "row end!");
            }
        }
        mySql.Close();

        /*
         * mySql.OpenSql();
         * ds = mySql.Select("user", new string[] { "User_Gold" }, new string[] { "" }, new string[] { "" }, new string[] { "" });
         * if (ds != null)
         * {
         *  DataTable table = ds.Tables[0];
         *  foreach (DataRow row in table.Rows)
         *  {
         *      playernum++;
         *      foreach (DataColumn column in table.Columns)
         *      {
         *          Debug.Log(row[column]);
         *          gold = (int)row[column];
         *      }
         *  }
         * }
         * mySql.Close();*/
    }
Esempio n. 26
0
    /// <summary>
    /// 按下Login按钮
    /// </summary>
    public void LoginButton()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string id   = userNameField.text;
        string pswd = passwordNameField.text;

        if (id [0] == '1')
        {
            //管理员
            string    query = "select * from adm where adm_id = " + id + " and adm_pswd = " + pswd;
            DataSet   ds    = mysql.QuerySet(query);
            DataTable table = ds.Tables [0];
            if (table.Rows.Count != 0)
            {
                Debug.Log("管理员" + id + ",登录成功!");
                PlayerPrefs.SetString("userID", userNameField.text);
            }
            else
            {
                Debug.Log("管理员,登录失败,没有此账号或密码错误!");
            }
        }
        else if (id [0] == '2')
        {
            //医生
            string    query = "select * from doc where dc_id = " + id + " and dc_pswd = " + pswd;
            DataSet   ds    = mysql.QuerySet(query);
            DataTable table = ds.Tables [0];
            if (table.Rows.Count != 0)
            {
                Debug.Log("医生" + id + ",登录成功!");
                PlayerPrefs.SetString("userID", userNameField.text);
            }
            else
            {
                Debug.Log("医生,登录失败,没有此账号或密码错误!");
            }
        }
        else if (id [0] == '3')
        {
            //患者
            string    query = "select * from pat where pt_id = " + id + " and pt_pswd = " + pswd;
            DataSet   ds    = mysql.QuerySet(query);
            DataTable table = ds.Tables [0];
            if (table.Rows.Count != 0)
            {
                Debug.Log("患者" + id + ",登录成功");
                PlayerPrefs.SetString("userID", userNameField.text);
            }
            else
            {
                Debug.Log("患者,登录失败,没有此账号或密码错误!");
            }
        }
        else
        {
            Debug.Log("用户账号类型错误!");
        }
        mysql.Close();
    }
Esempio n. 27
0
    /// <summary>
    /// 按下UpdatePswd按钮
    /// </summary>
    public void UpdatePassword(string first_pswd, string second_pswd)
    {
        string userID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            userID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + userID);

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();

        string firstPswd  = first_pswd;
        string secondPswd = second_pswd;

        int flag = 0;

        Debug.Log(firstPswd + " " + secondPswd);
        if (firstPswd.Length < 6 || firstPswd.Length > 20)
        {
            flag = 0;
            Debug.Log("密码长度应为6~20个字符");
        }
        else
        {
            string query = "";
            if (userID[0] == '1')
            {
                query = "select adm_pswd from adm where adm_id = '" + userID + "'";
            }
            else if (userID[0] == '2')
            {
                query = "select dc_pswd from doc where dc_id = '" + userID + "'";
            }
            else if (userID[0] == '3')
            {
                query = "select pt_pswd from pat where pt_id = '" + userID + "'";
            }
            DataSet   ds         = mysql.QuerySet(query);
            DataTable table      = ds.Tables [0];
            string    beforePswd = table.Rows[0][0].ToString();
            Debug.Log("beforePswd" + beforePswd);
            if (beforePswd == firstPswd)
            {
                flag = 0;
                Debug.Log("新密码不可与原密码相同");
            }
            else
            {
                if (firstPswd != secondPswd)
                {
                    flag = 0;
                    Debug.Log("两次密码不一致");
                }
                else
                {
                    flag = 1;
                }
            }
        }
        if (flag == 1)
        {
            string query = "";
            if (userID[0] == '1')
            {
                query = "update adm set adm_pswd = '" + firstPswd + "' where adm_id = '" + userID + "'";
            }
            else if (userID[0] == '2')
            {
                query = "update doc set dc_pswd = '" + firstPswd + "' where dc_id = '" + userID + "'";
            }
            else if (userID[0] == '3')
            {
                query = "update pat set pt_pswd = '" + firstPswd + "' where pt_id = '" + userID + "'";
            }
            DataSet ds = mysql.QuerySet(query);
            Debug.Log("修改密码成功,新密码为:" + firstPswd);
        }
        mysql.Close();
    }
Esempio n. 28
0
    public string[,] SelectRecords(string start_date, string end_date)
    {
        string ptID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            ptID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + ptID);

        string nowTime;

        nowTime = DateTime.Now.ToString("yyyyMMdd");
        int nowTimeInt = Convert.ToInt32(nowTime);

//		Debug.Log ("nowTime" + nowTime);

        string[,] res = new string[1, 1];
        res [0, 0]    = "";
        int startDateInt = Convert.ToInt32(start_date);
        int endDateInt   = Convert.ToInt32(end_date);

        if (startDateInt > endDateInt)
        {
            Debug.Log("开始日期大于结束日期!");
        }
        else if (startDateInt > nowTimeInt || endDateInt > nowTimeInt)
        {
            Debug.Log("开始日期或结束日期大于今日日期!");
        }
        else
        {
            mysql = new MySqlAccess(host, port, userName, password, databaseName);
            mysql.OpenSql();

            string    query   = "select rec_date, ac_id, ac_name, rec_hand from rec,act where ac_id = rec_actID and rec_ptID = '" + ptID + "' and rec_date >= '" + start_date + "' and rec_date <= '" + end_date + "'";
            DataSet   ds      = mysql.QuerySet(query);
            DataTable table   = ds.Tables [0];
            int       row_num = table.Rows.Count;
            if (row_num != 0)
            {
                int col_num = table.Rows [0].ItemArray.Length;
                res = new string[row_num, col_num];
                for (int i = 0; i < row_num; i++)
                {
                    for (int j = 0; j < col_num; j++)
                    {
                        res [i, j] = table.Rows [i] [j].ToString();
                    }
                }
            }
            mysql.Close();
            int row = res.GetLength(0);
            int col = res.GetUpperBound(res.Rank - 1) + 1;
            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < col; j++)
                {
                    Debug.Log(res [i, j]);
                }
            }
        }
        return(res);
    }