private void ObtainCardsFromBD()
        {
            TarjetitasDB bd    = new TarjetitasDB();
            string       query = "SELECT tipoDeTarjeta, frente, reverso FROM tarjetas WHERE idBaraja = " + idDeck + " AND elimLogica = 0;"; //obtener todas las cartas de la baraja seleccionada

            cards = bd.consulta(query);
        }
示例#2
0
        private void buttonAddDeck_Click(object sender, EventArgs e)
        {
            TarjetitasDB db      = new TarjetitasDB();
            string       command = "INSERT INTO baraja VALUES(0, '" + textBoxDeckTitle.Text + "', " + (!checkBoxDeckPrivacy.Checked).ToString() + ", 0, '" + labelUser.Text + "');";

            db.ejecutarComando(command);

            RemoveAllDecksFromFlowLayotPanel();
            ObtainDecksFromUser();
        }
示例#3
0
        private void pictureBoxFavourite_Click(object sender, EventArgs e)
        {
            //Quitar de favoritos la baraja seleccionada.
            TarjetitasDB db      = new TarjetitasDB();
            string       command = "DELETE FROM baraja_usuario_favoritiza WHERE idBaraja = " + this.Id + " AND usuario = '" + this.CurrentUser + "';";

            db.ejecutarComando(command);

            pictureBoxFavourite.Visible    = false;
            pictureBoxNotFavourite.Visible = true;
        }
示例#4
0
        private void pictureBoxNotFavourite_Click(object sender, EventArgs e)
        {
            //Agregar a favoritos la baraja seleccionada.
            TarjetitasDB db      = new TarjetitasDB();
            string       command = "INSERT INTO baraja_usuario_favoritiza VALUES(0, " + this.Id + ", '" + this.CurrentUser + "');";

            db.ejecutarComando(command);

            pictureBoxFavourite.Visible    = true;
            pictureBoxNotFavourite.Visible = false;
        }
示例#5
0
        private void Card_Leave(object sender, EventArgs e)
        {
            if (!edit)
            {
                return;
            }

            TarjetitasDB bd      = new TarjetitasDB();
            string       command = "UPDATE tarjetas SET tipoDeTarjeta = '" + this.CardType + "', frente = '" + AddSlashToRoute(front.content) + "', reverso = '" + AddSlashToRoute(reverse.content) + "' WHERE numTarjeta = " + this.CardNumber + ";"; //update tarjeta por todos los cambios realizados.

            bd.ejecutarComando(command);
        }
示例#6
0
        public EditDeck(int _idTheme, Color _colorButtons, Color _colorPanels, Color _colorBackground, string user, int _idDeck)
        {
            InitializeComponent();
            idTheme         = _idTheme;
            idDeck          = _idDeck;
            colorButtons    = _colorButtons;
            colorPanels     = _colorPanels;
            colorBackground = _colorBackground;
            labelUser.Text  = user;

            cardSelected = new SelectedCard();  //inicializar valores de la carta a seleccionar
            bd           = new TarjetitasDB();
        }
        public RecycleCards(int _idTheme, Color _colorButtons, Color _colorPanels, Color _colorBackground, string user, int _idDeck = 0)
        {
            InitializeComponent();
            idTheme         = _idTheme;
            colorButtons    = _colorButtons;
            colorPanels     = _colorPanels;
            colorBackground = _colorBackground;
            labelUser.Text  = user;
            idDeck          = _idDeck;

            cardSelected   = new SelectedCard();
            idAviableDecks = new List <int>();
            db             = new TarjetitasDB();

            labelRecycleCards.Text = idDeck == 0 ? "Tarjetas Eliminadas Sueltas" : "Tarjetas Eliminadas Asociadas a una Baraja";
        }
示例#8
0
        private void DeckButton_Load(object sender, EventArgs e)
        {
            TarjetitasDB db    = new TarjetitasDB();
            string       query = "SELECT id FROM baraja_usuario_favoritiza WHERE usuario = '" + this.CurrentUser + "' AND idBaraja = " + this.Id + ";";

            DataTable result = db.consulta(query);

            if (result.Rows.Count == 0)
            {
                pictureBoxNotFavourite.Visible = true;
                pictureBoxFavourite.Visible    = false;
            }
            else
            {
                pictureBoxNotFavourite.Visible = false;
                pictureBoxFavourite.Visible    = true;
            }
        }
示例#9
0
        private void ObtainDecksFromUser()
        {
            TarjetitasDB bd    = new TarjetitasDB();
            string       query = "SELECT * FROM baraja WHERE usuario = '" + labelUser.Text + "' AND elimLogica = 0;";

            DataTable result = bd.consulta(query);

            if (result.Rows.Count == 0)
            {
                return;
            }

            for (int i = 0; i < result.Rows.Count; i++)
            {
                query = "SELECT COUNT(numTarjeta) FROM tarjetas WHERE idBaraja = " + result.Rows[i]["id"] + " AND elimLogica = 0;";
                DataTable cards = bd.consulta(query);
                AddDeckToFlowLayout(result.Rows[i]["titulo"].ToString(), int.Parse(cards.Rows[0]["COUNT(numTarjeta)"].ToString()), int.Parse(result.Rows[i]["id"].ToString()), bool.Parse(result.Rows[i]["privacidad"].ToString()));
            }
        }
        private void ObtainThemeFromUser()
        {
            TarjetitasDB bd = new TarjetitasDB(); //declarar conexion a BD

            string query = "SELECT id, rgb_boton, rgb_panel, rgb_fondo FROM tema" +
                           " INNER JOIN usuario ON usuario.idTema = tema.id WHERE usuario = '" + labelUser.Text + "';";

            DataTable result = bd.consulta(query); //obtener la tupla deseada

            if (result.Rows.Count == 0)
            {
                MessageBox.Show("Error al cargar temas de usuario.");
                this.Close();
            }

            idTheme         = int.Parse(result.Rows[0]["id"].ToString());
            colorButtons    = System.Drawing.ColorTranslator.FromHtml(result.Rows[0]["rgb_boton"].ToString());
            colorPanels     = System.Drawing.ColorTranslator.FromHtml(result.Rows[0]["rgb_panel"].ToString());
            colorBackground = System.Drawing.ColorTranslator.FromHtml(result.Rows[0]["rgb_fondo"].ToString());
        }
示例#11
0
        private void buttonDeleteDeck_Click(object sender, EventArgs e)
        {
            if (labelDeckTitle.Text == "" && labelDeckAuthor.Text == "")
            {
                return;
            }

            TarjetitasDB db      = new TarjetitasDB();
            string       command = "DELETE FROM tarjetas WHERE idBaraja = " + deckSelected.Id + ";"; //eliminar todas las cartas asociadas a la baraja

            db.ejecutarComando(command);

            //eliminar la baraja seleccionada
            command = "DELETE FROM baraja WHERE id = " + deckSelected.Id + ";";
            db.ejecutarComando(command);

            labelDeckTitle.Text = labelDeckAuthor.Text = ""; //vacíar objeto seleccionado
            deckSelected.Clear();

            RemoveDecksFromFlowLayotPanelDecks(); //actualizar data
            ObtainDecksFromUser();
        }
示例#12
0
        private void buttonRecoverDeck_Click(object sender, EventArgs e)
        {
            if (labelDeckTitle.Text == "" && labelDeckAuthor.Text == "")
            {
                return;
            }

            TarjetitasDB db      = new TarjetitasDB();
            string       command = "UPDATE baraja SET elimLogica = 0 WHERE id = " + deckSelected.Id + ";";

            db.ejecutarComando(command);

            //recuperar lógicamente las tarjetas de dicha baraja.... si, no?
            command = "UPDATE tarjetas SET elimLogica = 0 WHERE idBaraja = " + deckSelected.Id + ";";
            db.ejecutarComando(command);

            labelDeckTitle.Text = labelDeckAuthor.Text = ""; //vacíar objeto seleccionado
            deckSelected.Clear();

            RemoveDecksFromFlowLayotPanelDecks(); //actualizar data
            ObtainDecksFromUser();
        }
示例#13
0
        private void ObtainDecksFromUser()
        {
            TarjetitasDB bd = new TarjetitasDB();

            string query = labelDecksTitle.Text == "Barajas Públicas"
                ? "SELECT * FROM baraja WHERE privacidad = 0 AND elimLogica = 0;"
                : "SELECT B.* FROM baraja_usuario_favoritiza BF INNER JOIN baraja B ON B.id = BF.idBaraja WHERE BF.usuario = '" + labelUser.Text + "' AND B.elimLogica = 0;";

            DataTable result = bd.consulta(query);

            if (result.Rows.Count == 0)
            {
                return;
            }

            for (int i = 0; i < result.Rows.Count; i++)
            {
                query = "SELECT COUNT(numTarjeta) FROM tarjetas WHERE idBaraja = " + result.Rows[i]["id"] + " AND elimLogica = 0;";
                DataTable cards = bd.consulta(query);
                AddDeckToFlowLayout(result.Rows[i]["titulo"].ToString(), result.Rows[i]["usuario"].ToString(), int.Parse(cards.Rows[0]["COUNT(numTarjeta)"].ToString()), int.Parse(result.Rows[i]["id"].ToString()), bool.Parse(result.Rows[i]["privacidad"].ToString()));
            }
        }