void LoginUser(Control sender) { string username = ((TextBox) this.GetControlByID("theUsername")).text; string password = ((TextBox) this.GetControlByID("thePassword")).text; myUser u = new myUser(); if (u.GetUserByUserName(username)) { if (u.Password != password) { ((Label) this.GetControlByID("theError")).text = "The password was incorrect"; return; } } else { u.UserName = username; u.Password = password; u.InsertData(); } setUsername(u); myGameRoom g = new myGameRoom(); if (!g.GetGameRoomByGameRoomName("Home")) { g.GameRoomName = "Home"; g.InsertData(); } g.AddUser_(u); this.Page.Request.TransferToPage("Chat*GameRoomID="+g.GameRoomID); }
public bool UpdateData() { myUser n = new myUser(); n.GetUserBySessionID(mySessionID); if (n.UserID != 0 && n.UserID != myUserID) { return false; } n = new myUser(); n.GetUserByUserName(myUserName); if (n.UserID != 0 && n.UserID != myUserID) { return false; } myUserData data = new myUserData(); List<SqlParameter> tempAL = new List<SqlParameter>(); SqlParameter tempP; tempP = new SqlParameter(); tempP.ParameterName = "@UserID"; tempP.Size = 4; tempP.SqlDbType = SqlDbType.Int; tempP.Value = myUserID; tempP.Direction = ParameterDirection.Input; tempAL.Add(tempP); tempP = new SqlParameter(); tempP.ParameterName = "@SessionID"; tempP.Size = 200; tempP.SqlDbType = SqlDbType.VarChar; tempP.Value = mySessionID; tempP.Direction = ParameterDirection.Input; tempAL.Add(tempP); tempP = new SqlParameter(); tempP.ParameterName = "@UserName"; tempP.Size = 200; tempP.SqlDbType = SqlDbType.VarChar; tempP.Value = myUserName; tempP.Direction = ParameterDirection.Input; tempAL.Add(tempP); tempP = new SqlParameter(); tempP.ParameterName = "@Password"; tempP.Size = 200; tempP.SqlDbType = SqlDbType.VarChar; tempP.Value = myPassword; tempP.Direction = ParameterDirection.Input; tempAL.Add(tempP); data.RunProcedure("csp_UpdateUser", tempAL); return true; }
public bool InsertData() { myUser n = new myUser(); n.GetUserBySessionID(mySessionID); if (n.UserID != 0) return false; n = new myUser(); n.GetUserByUserName(myUserName); if (n.UserID != 0) return false; myUserData data = new myUserData(); List<SqlParameter> tempAL = new List<SqlParameter>(); SqlParameter tempP; DataSet tempDS; tempP = new SqlParameter(); tempP.ParameterName = "@SessionID"; tempP.Size = 200; tempP.SqlDbType = SqlDbType.VarChar; tempP.Value = mySessionID; tempP.Direction = ParameterDirection.Input; tempAL.Add(tempP); tempP = new SqlParameter(); tempP.ParameterName = "@UserName"; tempP.Size = 200; tempP.SqlDbType = SqlDbType.VarChar; tempP.Value = myUserName; tempP.Direction = ParameterDirection.Input; tempAL.Add(tempP); tempP = new SqlParameter(); tempP.ParameterName = "@Password"; tempP.Size = 200; tempP.SqlDbType = SqlDbType.VarChar; tempP.Value = myPassword; tempP.Direction = ParameterDirection.Input; tempAL.Add(tempP); tempDS = data.RunProcedure("csp_InsertUser", tempAL); myUserID = int.Parse(tempDS.Tables[0].Rows[0][0].ToString()); tempDS.Dispose(); return true; }