Example #1
0
 private void loseButton(object sender, RoutedEventArgs e)
 {
     if (decks.SelectedIndex == -1)
     {
         return;
     }
     DatabaseControl.ExecuteNonQuerryCommand("Exec usp_addWin " + ((DeckListing)decks.SelectedItem).DeckID + ", " + this.deck_id);
     setWinsOrLossesLists();
 }
Example #2
0
        private void star_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            int    ratingToGive = int.Parse(((Image)sender).Name.Substring(4)) + 1;
            string cs           = ConfigurationManager.ConnectionStrings["magicConnect"].ConnectionString;

            using (SqlConnection conn = new SqlConnection(@cs))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("usp_RatedBySelect", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    // set up the parameters
                    cmd.Parameters.Add("@deck", SqlDbType.Int);
                    cmd.Parameters.Add("@user", SqlDbType.VarChar, 255);

                    // set parameter values
                    cmd.Parameters["@deck"].Value = deck_id;
                    cmd.Parameters["@user"].Value = App.User;
                    try
                    {
                        SqlDataReader dr = cmd.ExecuteReader();
                        dr.Read();
                        string userRating = dr["rating"].ToString();
                        if (int.Parse(userRating) != ratingToGive)
                        {
                            MessageBoxResult result = MessageBox.Show("Previously you rated this deck with " + int.Parse(userRating) + " stars. Are you sure you wanna rate this deck with " + ratingToGive + " stars?", "Rating", MessageBoxButton.YesNo, MessageBoxImage.Question);
                            if (result == MessageBoxResult.Yes)
                            {
                                DatabaseControl.ExecuteNonQuerryCommand("EXEC usp_rate '" + App.User + "', " + deck_id + ", " + ratingToGive);
                            }
                        }

                        dr.Close();
                    }
                    catch (InvalidOperationException io)
                    {
                        Console.WriteLine(io);
                        DatabaseControl.ExecuteNonQuerryCommand("EXEC usp_rate '" + App.User + "', " + deck_id + ", " + ratingToGive);
                        MessageBox.Show("You gave this deck " + ratingToGive + " stars.", "Rating", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    setCurrentRating();
                }
            }
        }
        private void addCardSell(object sender, RoutedEventArgs e)
        {
            if (listBox_cards.SelectedIndex == -1 || listBox_myS.SelectedIndex == -1)
            {
                return;
            }
            int index1 = listBox_cards.SelectedIndex, index2 = listBox_myS.SelectedIndex;

            try
            {
                DatabaseControl.ExecuteNonQuerryCommand("EXEC usp_addCardToListing " + ((Listing)listBox_myS.SelectedItem).Id + ", " + ((Card2)listBox_cards.SelectedItem).Id + ", " + price.Text + ", '" + condition.Text + "'");
            }catch (SqlException sqlE) { Console.Write("" + sqlE); }

            updateCardsList();
            updateVisual();
            listBox_cards.SelectedIndex = index1;
            listBox_myS.SelectedIndex   = index2;
        }
        private void removeCardSell(object sender, RoutedEventArgs e)
        {
            if (listBox_cardsInListingSelling.SelectedIndex == -1)
            {
                return;
            }

            try
            {
                Listing       listing     = ((Listing)listBox_myS.SelectedItem);
                CardInListing cardListing = ((CardInListing)listBox_cardsInListingSelling.SelectedItem);
                DatabaseControl.ExecuteNonQuerryCommand("EXEC usp_rmCardToListing " + listing.Id + ", " + cardListing.Card + ", " + cardListing.Priceperunit + ", '" + cardListing.Condition + "'");
            }
            catch (SqlException sqlE) { Console.Write("" + sqlE); }

            updateCardsList();
            updateVisual();
        }
 public void insertListing(bool sell)
 {
     DatabaseControl.ExecuteNonQuerryCommand("EXEC usp_ListingInsert '" + App.User + "', null, " + (sell ? 1 : 0));
     updateVisual();
 }