Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     username.Value = Session["username"].ToString();
     roomID.Value   = Request.Form["roomID"];
     if (!IsPostBack)
     {
         SqlDataSource.SelectParameters["ownerID"].DefaultValue = Session["id"].ToString();
         DropdownOfDecks.DataBind();
     }
     if (Session[roomID.Value + "ID"] != null)
     {
         playerID.Text = Session[roomID.Value + "ID"].ToString();
     }
 }
Exemplo n.º 2
0
        //creates a new deck
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            //check if deck with name exists
            using (var conn = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = new SqlCommand("SelectDeckByName"))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@deckName", DeckName.Text);
                    cmd.Parameters.AddWithValue("@ownerID", (int)Session["id"]);
                    cmd.Connection = conn;
                    conn.Open();
                    if (cmd.ExecuteScalar() != null)
                    {
                        Response.Write("Deck with given name already exists");
                        return;
                    }
                    conn.Close();
                }
            }

            using (var conn = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = new SqlCommand("newDeck"))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@deckName", DeckName.Text);
                    cmd.Parameters.AddWithValue("@ownerID", (int)Session["id"]);
                    cmd.Connection = conn;
                    conn.Open();
                    Session["currentDeckID"]   = cmd.ExecuteScalar();
                    Session["currentDeckName"] = DeckName.Text;
                    conn.Close();
                }
            }
            newDeckDiv.Visible        = true;
            cardSelectionDiv.Visible  = true;
            currentDeckDiv.Visible    = true;
            currentDeckNameLabel.Text = (string)Session["currentDeckName"];
            SqlDataSource3.SelectParameters["deckID"].DefaultValue  = Session["currentDeckID"].ToString();
            SqlDataSource2.SelectParameters["ownerID"].DefaultValue = Session["id"].ToString();
            DropdownOfDecks.DataBind();
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["id"] == null)
            {
                newDeckDiv.Visible       = false;
                cardSelectionDiv.Visible = false;
                currentDeckDiv.Visible   = false;
                loginDiv.Visible         = true;
                return;
            }
            if (!IsPostBack)
            {
                SqlDataSource2.SelectParameters["ownerID"].DefaultValue = Session["id"].ToString();
                DropdownOfDecks.DataBind();
            }

            //setting visibilities
            if (Session["currentDeckID"] != null)
            {
                newDeckDiv.Visible       = true;
                cardSelectionDiv.Visible = true;
                currentDeckDiv.Visible   = true;
                loginDiv.Visible         = false;
            }
            if (DropdownOfDecks.Items.Count == 0)
            {
                DropdownOfDecks.Visible = false;
                SelectButton.Visible    = false;
                noDecksLabel.Visible    = true;
            }
            else
            {
                DropdownOfDecks.Visible = true;
                SelectButton.Visible    = true;
                noDecksLabel.Visible    = false;
            }
        }