protected void OnRowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "zatrudnij") { string[] data = e.CommandArgument.ToString().Split(','); dane.odswiezDane(); int konto = Int32.Parse(Session["User_konto"].ToString()); int dzialkaId = Int32.Parse(Session["User_id_hotelu"].ToString()); int pracownikId = Int32.Parse(data[0]); int pensja = Int32.Parse(data[1]); int userId = Int32.Parse(Session["User_id"].ToString()); if (konto > pensja) { tools.zatrudnij(dzialkaId, pracownikId, pensja, userId); Response.Redirect(Request.RawUrl); Label3.Visible = true; Label3.Text = "Poprawnie zatrudniono pracownika"; } else { Label3.Visible = true; Label3.Text = "Nie masz wystarczającej ilości pieniędzy."; } } }
protected void OnRowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "wybuduj") { string[] data = e.CommandArgument.ToString().Split(','); dane.odswiezDane(); int konto = Int32.Parse(Session["User_konto"].ToString()); int pokojId = Int32.Parse(data[0]); int koszt = Int32.Parse(data[1]); int zysk = Int32.Parse(data[2]); int userId = Int32.Parse(Session["User_id"].ToString()); if (konto > koszt) { tools.zbudujPokoj(idHot, pokojId, koszt, userId, zysk); Response.Redirect(Request.RawUrl); komunikatLabel.Visible = true; komunikatLabel.Text = "Poprawnie zbudowano pokój"; } else { komunikatLabel.Visible = true; komunikatLabel.Text = "Nie masz wystarczającej ilości pieniędzy."; } } if (e.CommandName == "cena") { Session["User_pokoj_id"] = Convert.ToInt32(e.CommandArgument); zmianaCeny.Visible = true; } }
protected void OnRowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "kup") { String[] daneDzialki = new String[3]; int index = Convert.ToInt32(e.CommandArgument); dane.odswiezDane(); daneDzialki = tools.pobierzDzialke(index); if (Int32.Parse(Session["User_konto"].ToString()) > Int32.Parse(daneDzialki[0]) && daneDzialki[1] == "aktywny") { int wydatek = Int32.Parse(daneDzialki[0]); tools.kupDzialka(index, Session["User_id"].ToString(), wydatek); Response.Redirect(Request.RawUrl); komunikatLabel.Visible = true; komunikatLabel.Text = "Poprawnie zakupiono działkę"; } else { komunikatLabel.Visible = true; komunikatLabel.Text = "Nie masz wystarczającej ilości pieniędzy."; } } }
protected void OnRowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "reklama") { string[] data = e.CommandArgument.ToString().Split(','); string reklamaId = data[0]; string koszt = data[1]; string czas = data[2]; dane.odswiezDane(); int konto = Int32.Parse(Session["User_konto"].ToString()); if (konto > Int32.Parse(koszt)) { tools.kupReklama(userId, reklamaId, czas, koszt); komunikatLabel.Visible = true; komunikatLabel.Text = "Poprawnie wykupiono reklamę."; } else { komunikatLabel.Visible = true; komunikatLabel.Text = "Nie masz wystarczającej ilości pieniędzy."; } } }
protected void OnRowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "zbuduj") { string[] data = e.CommandArgument.ToString().Split(','); dane.odswiezDane(); int atrakcja = Int32.Parse(data[0]); int konto = Int32.Parse(Session["User_konto"].ToString()); int koszt = Int32.Parse(data[1]); int userId = Int32.Parse(Session["User_id"].ToString()); if (konto > koszt) { tools.zbuduj(dzialkaId, atrakcja, koszt, userId); Response.Redirect(Request.RawUrl); komunikatLabel.Visible = true; komunikatLabel.Text = "Poprawnie zbudowano atrakcję"; } else { komunikatLabel.Visible = true; komunikatLabel.Text = "Nie masz wystarczającej ilości pieniędzy."; } } }
protected void Page_Load(object sender, EventArgs e) { skryptCzas.InnerHtml = "<script type=\"text/javascript\">zegar(" + (int)Application["czas"] + "," + (int)Application["jednostka_czasu"] + "," + (int)Application["status_gry"] + ");</script>"; if ((int)Application["status_gry"] == 1) { if (Session["User_uprawnienie"] != null) { if (Session["User_uprawnienie"].ToString() == "student" || Session["User_uprawnienie"].ToString() == "admin") { dane.odswiezDane(); Label1.Text = "Jesteś zalogowany jako: <br/><b>" + Session["User_imie"].ToString() + Session["User_nazwisko"].ToString() + " - " + Session["User_login"].ToString() + "</b>"; menuLogin.Visible = false; menuAfterLogin.Visible = true; loginHyperLink.Visible = false; linkNiezalogowany.Visible = false; linkZalogowany.Visible = true; ustawienia.Visible = true; nazwaUzytkownikaLabel.Text = Session["User_login"].ToString(); stanKontaLabel.Text = Session["User_konto"].ToString() + " $"; statystykiDiv.Visible = true; middlePost.Visible = true; } } else { Label1.Text = "Zaloguj się!"; linkNiezalogowany.Visible = true; linkZalogowany.Visible = false; ustawienia.Visible = false; //statystykiDiv.Visible = false; menuLogin.Visible = true; menuAfterLogin.Visible = false; loginHyperLink.Visible = true; middlePost.Visible = false; //Label3.Text = "Aby zacząć grę należy się zarejestrować i poczekać, aż administrator zaakceptuje konto."; Server.Transfer("~/index.aspx", true); } } else { Label2.Text = "Gra jest wyłączona!"; Label2.Visible = true; linkNiezalogowany.Visible = true; linkZalogowany.Visible = false; ustawienia.Visible = false; //statystykiDiv.Visible = false; menuLogin.Visible = true; menuAfterLogin.Visible = false; loginHyperLink.Visible = true; //if (IsPostBack) //{ // if (Context.Items["Transferred"] == null) // { // // Initialize to prevent stackover // Context.Items["Transferred"] = new object(); // // TransferToSelf // Server.Transfer("~/index.aspx", true); // } //} } }