private void setUsername(myUser u) { if (this.Page.Session.ContainsKey("LoggedInUser")) this.Page.Session["LoggedInUser"] = u; else this.Page.Session.Add("LoggedInUser", u); }
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 static List<myGameRoom> GetGameRoomByUser(myUser val) { myGameRoomData tempADO = new myGameRoomData(); List<myGameRoom> list=new List<myGameRoom>(); DataSet tempDS = tempADO.GetGameRoomByUserID(val.UserID); if (tempADO.HasData) { foreach (DataRow row in tempDS.Tables[0].Rows) list.Add(new myGameRoom(row)); return list; } return new List<myGameRoom>(); }
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; }
public bool ContainsUser_(myUser val) { foreach(myUser temp in myUser_) { if (val==temp) return true; } return false; }
public void AddUser_(myUser val) { val.UpdateGameRoom(myGameRoomID); myUser_.Add(val); }
public void AddUserID_(int val) { myUser v= new myUser(val); v.UpdateGameRoom(myGameRoomID); myUser_.Add(v); }