protected void GridView2_SelectedIndexChanged(object sender, EventArgs e) { string user = (string)Session["userName"]; string pass = (string)Session["passWord"]; int iduser = int.Parse(GridView2.SelectedDataKey.Value.ToString()); GWSiteClassLibrary.IUser deluser = GWSiteClassLibrary.Factory.CreateUserService(); GWSiteClassLibrary.GWSiteStatusEnum status = deluser.DeleteUser(user, pass, iduser); Label2.Visible = true; Label2.Text = status.ToString(); }
protected void GridView2_SelectedIndexChanged(object sender, EventArgs e) { string user = Session["userName"].ToString(); string pass = (string)Session["passWord"]; Label3.Visible = true; int idmap = int.Parse(GridView2.SelectedDataKey.Value.ToString()); GWSiteClassLibrary.IMap delmap = GWSiteClassLibrary.Factory.CreateMapService(); GWSiteClassLibrary.GWSiteStatusEnum status = delmap.DeleteMap(user, pass, idmap); Label3.Text = status.ToString(); DataSet ds = delmap.GetAll(user, pass); GridView2.DataSource = ds; GridView2.DataBind(); }
protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e) { string user = Session["userName"].ToString(); string pass = (string)Session["passWord"]; Label4.Visible = true; GWSiteClassLibrary.IMap dvmap = GWSiteClassLibrary.Factory.CreateMapService(); int id = int.Parse(DetailsView1.Rows[0].Cells[1].Text); string descr = ((TextBox)DetailsView1.Rows[1].Cells[1].Controls[0]).Text; GWSiteClassLibrary.GWSiteStatusEnum status = dvmap.UpdateMap(user, pass, id, descr); Label4.Text = status.ToString(); DetailsView1.Visible = false; DataSet ds = dvmap.GetAll(user, pass); GridView1.DataSource = ds; GridView1.DataBind(); }
protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e) { string user = (string)Session["userName"]; string pass = (string)Session["passWord"]; GWSiteClassLibrary.IPlayer dvpl = GWSiteClassLibrary.Factory.CreatePlayerService(); int plid = int.Parse(GridView1.Rows[0].Cells[0].Text); string nome = ((TextBox)DetailsView1.Rows[0].Cells[1].Controls[0]).Text; int idade = int.Parse(((TextBox)DetailsView1.Rows[1].Cells[1].Controls[0]).Text); char genero = char.Parse(((TextBox)DetailsView1.Rows[2].Cells[1].Controls[0]).Text); string morada = ((TextBox)DetailsView1.Rows[3].Cells[1].Controls[0]).Text; string pais = ((TextBox)DetailsView1.Rows[4].Cells[1].Controls[0]).Text; string mail = ((TextBox)DetailsView1.Rows[5].Cells[1].Controls[0]).Text; string[] value = { nome, idade.ToString(), genero.ToString(), mail, morada, pais }; Label2.Text = plid.ToString() + "," + nome + "," + idade.ToString() + "," + genero.ToString() + "," + mail + "," + morada + "," + pais; //string nome = ((TextBox)DetailsView1.Rows[0].Cells[1].Controls[0]).Text; GWSiteClassLibrary.GWSiteStatusEnum statusX = dvpl.UpdatePlayerX(user, pass, plid, value); Label2.Text = statusX.ToString(); //GWSiteClassLibrary.GWSiteStatusEnum status = dvpl.UpdatePlayer(user, pass, plid, nome, idade, genero, mail, morada, pais); DetailsView1.ChangeMode(DetailsViewMode.ReadOnly); bindDetalhesPlayers(plid); }
protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e) { // Parametro querystring contendo o return URL const String QS_RETURN_URL = "ReturnURL"; FormsAuthenticationTicket ticket = null; HttpCookie cookie = null; String encryptedStr = null; String nextPage = null; //Login l = (Login)LoginView1.Controls[0].Controls[1].FindControl("Login1"); GWSiteClassLibrary.IUser us = GWSiteClassLibrary.Factory.CreateUserService(); GWSiteClassLibrary.GWSiteStatusEnum tipo = us.Validate(Login1.UserName, Login1.Password); if (tipo.ToString() == "OK") { //variavel de sessao e na pagina admin vai ver s ta la o user senao reencaminha paki outra vez Session["userName"] = Login1.UserName; Session["passWord"] = Login1.Password; Session["UserID"] = us.GetUserID(Login1.UserName, Login1.Password); //GET PAGE THEME Session["Theme"] = "Bright"; //GET ROLE //string urole = "User"; string urole = us.GetUserRole(Login1.UserName, Login1.Password, Int32.Parse(Session["UserID"].ToString())); //Label1.Text = Session["UserID"].ToString(); //Label2.Text = urole; //Label3.Text = Session["Theme"].ToString(); ticket = new FormsAuthenticationTicket(1, (String)(Login1.UserName), DateTime.Now, DateTime.Now.AddMinutes(30), Login1.RememberMeSet, urole); encryptedStr = FormsAuthentication.Encrypt(ticket); cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedStr); if (Login1.RememberMeSet) { cookie.Expires = ticket.IssueDate.AddYears(10); } Response.Cookies.Add(cookie); if (Request.QueryString[QS_RETURN_URL] != null) { // user attempted to access a page without logging in so redirect // them to their originally requested page nextPage = Request.QueryString[QS_RETURN_URL]; } else { // user came straight to the login page so just send them to the // home page if (urole == "User") { nextPage = "~/zuser/User.aspx"; } else if (urole == "Admin") { nextPage = "~/zadmin/Admin.aspx"; } else { nextPage = "~/Default.aspx"; } } Response.Redirect(nextPage, true); } else { // user credentials do not exist in the database so output error // message indicating the problem Login1.FailureText = "Erro: Por favor verifique o UserName e PassWord."; } }