Ejemplo n.º 1
0
        private bool VerificarCampos(string COND)
        {
            SQLiteConnection conn = new SQLiteConnection(conexao);
            if (conn.State == ConnectionState.Closed)
                conn.Open();

            SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM tb_games " + COND, conn);
            SQLiteDataReader dr = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                return true;
            }
            else
            {
                return false;
            }

            conn.Clone();
        }
Ejemplo n.º 2
0
        public void SaveData()
        {
            conn = new System.Data.SQLite.SQLiteConnection(@"Data Source=CoreInkLib.dll");
            conn.Open();
            SQLiteCommand sqc = new SQLiteCommand("DELETE FROM character", conn);

            sqc.ExecuteNonQuery();
            sqc = new SQLiteCommand("DELETE FROM strokes", conn);
            sqc.ExecuteNonQuery();
            sqc = new SQLiteCommand("DELETE FROM variant", conn);
            sqc.ExecuteNonQuery();
            foreach (Character c in chars)
            {
                sqc = new SQLiteCommand("SELECT ifnull(max(char_id),0) FROM character", conn);
                int id = Convert.ToInt32(sqc.ExecuteScalar());
                id++;
                sqc = new SQLiteCommand("INSERT INTO character VALUES (" + id.ToString() + ",'" + c.charx + "'," + c.lang.ToString() + ")", conn);
                sqc.ExecuteNonQuery();
                foreach (Variant v in c.variants)
                {
                    sqc = new SQLiteCommand("SELECT ifnull(max(vid),0) FROM variant", conn);
                    int vid = Convert.ToInt32(sqc.ExecuteScalar());
                    vid++;
                    sqc = new SQLiteCommand("INSERT INTO variant VALUES (" + vid.ToString() + "," + id.ToString() + ")", conn);
                    sqc.ExecuteNonQuery();
                    int sti = 0;
                    foreach (Stroke st in v.Strokes)
                    {
                        sqc = new SQLiteCommand("SELECT ifnull(max(s_id),0) FROM strokes", conn);
                        int sid = Convert.ToInt32(sqc.ExecuteScalar());
                        sid++;
                        sqc = new SQLiteCommand("INSERT INTO strokes VALUES (" + sid.ToString() + "," + vid.ToString() + "," + id.ToString() + ",'" + Stroke2Int(st).ToString() + "','" + st.quadrant + "'," + sti.ToString() + ")", conn);
                        sqc.ExecuteNonQuery();
                        sti++;
                    }
                }
            }
            conn.Clone();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// ADICIONANDO UM NOVO RAP
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbAdd_Click(object sender, RoutedEventArgs e)
        {
            if (tbID.Text != "" && tbNome.Text != "" && tbRapCode.Text != "" && tbRapNome.Text != "")
            {
                SQLiteConnection conn = new SQLiteConnection(conexao);
                if (conn.State == ConnectionState.Closed)
                    conn.Open();

                SQLiteCommand cmd = new SQLiteCommand("INSERT INTO tb_raps (ID, NOME, RAPCODE, RAPNOME) VALUES (@ID, @NOME, @RAPCODE, @RAPNOME)", conn);

                cmd.Parameters.AddWithValue("ID", tbID.Text.Trim());
                cmd.Parameters.AddWithValue("NOME", tbNome.Text.Trim());
                cmd.Parameters.AddWithValue("RAPCODE", tbRapCode.Text.Trim());
                cmd.Parameters.AddWithValue("RAPNOME", tbRapNome.Text.Trim());

                try
                {
                    cmd.ExecuteNonQuery();
                    MsgBox.Show("Rap adicionado com sucesso!", "Sucesso", MsgBox.Buttons.OK);

                    tbID.Text = String.Empty;
                    tbNome.Text = String.Empty;
                    tbRapCode.Text = String.Empty;
                    tbRapNome.Text = String.Empty;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro ao cadastrar:\n" + ex.Message);
                }

                conn.Clone();
            }
            else
            {
                MsgBox.Show("Você precisa preencher todos os campos", "Atenção", MsgBox.Buttons.OK);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// ENVIAR OS JOGOS
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEnviar_Click(object sender, RoutedEventArgs e)
        {
            if (VerificarCampos("WHERE ID = '" + tbID.Text + "'"))
            {
                MessageBox.Show("Você já cadastrou um jogo com esse ID");
                return;
            }

            if (tbID.Text != "" && tbTitulo.Text != "" && tbTipo.Text != "" && tbRegiao.Text != "" && tbLink1.Text != "")
            {
                SQLiteConnection conn = new SQLiteConnection(conexao);
                if (conn.State == ConnectionState.Closed)
                    conn.Open();

                SQLiteCommand cmd = new SQLiteCommand("INSERT INTO tb_games (ID, TITULO, TIPO, REGIAO, LINK1, LINK2, LINK3, LINK4, LINK5, CAPA) VALUES (@ID, @TITULO, @TIPO, @REGIAO, @LINK1, @LINK2, @LINK3, @LINK4, @LINK5, @CAPA)", conn);

                cmd.Parameters.AddWithValue("ID", tbID.Text.Trim());
                cmd.Parameters.AddWithValue("TITULO", tbTitulo.Text.Trim());
                cmd.Parameters.AddWithValue("TIPO", tbTipo.Text.Trim());
                cmd.Parameters.AddWithValue("REGIAO", tbRegiao.Text.Trim());
                cmd.Parameters.AddWithValue("LINK1", tbLink1.Text.Trim());

                if (tbLink2.Text != "")
                {
                    cmd.Parameters.AddWithValue("LINK2", tbLink2.Text.Trim());
                }
                else
                {
                    cmd.Parameters.AddWithValue("LINK2", "");
                }

                if (tbLink3.Text != "")
                {
                    cmd.Parameters.AddWithValue("LINK3", tbLink3.Text.Trim());
                }
                else
                {
                    cmd.Parameters.AddWithValue("LINK3", "");
                }

                if (tbLink4.Text != "")
                {
                    cmd.Parameters.AddWithValue("LINK4", tbLink4.Text.Trim());
                }
                else
                {
                    cmd.Parameters.AddWithValue("LINK4", "");
                }

                if (tbLink5.Text != "")
                {
                    cmd.Parameters.AddWithValue("LINK5", tbLink5.Text.Trim());
                }
                else
                {
                    cmd.Parameters.AddWithValue("LINK5", "");
                }    

                cmd.Parameters.AddWithValue("CAPA", tbID.Text.Trim() + ".jpg");

                // FAZENDO UPLOAD DA IMAGEM
                if (this.Cimage != "")
                {
                    // MOVER ARQUIVO
                    if (File.Exists(path + "data\\covers\\" + tbID.Text.Trim() + ".jpg"))
                    {
                        File.Delete(path + "data\\covers\\" + tbID.Text.Trim() + ".jpg");
                    }

                    File.Copy(Cimage, path + "data\\covers\\" + tbID.Text.Trim() + ".jpg");
                }

                try
                {
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Registro incluido com sucesso!");
                    LimparCampos();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro ao cadastrar:\n" + ex.Message);
                }

                conn.Clone();
            }
            else
            {
                MessageBox.Show("Você precisa preecher todos os campos!", "OCORREU UM ERRO", MessageBoxButton.OK, MessageBoxImage.Error);
            }// Validação campos vazios
        }
Ejemplo n.º 5
0
 public void SaveData()
 {
     conn = new System.Data.SQLite.SQLiteConnection(@"Data Source=CoreInkLib.dll");
     conn.Open();
     SQLiteCommand sqc = new SQLiteCommand("DELETE FROM character",conn);
     sqc.ExecuteNonQuery();
     sqc = new SQLiteCommand("DELETE FROM strokes", conn);
     sqc.ExecuteNonQuery();
     sqc = new SQLiteCommand("DELETE FROM variant", conn);
     sqc.ExecuteNonQuery();
     foreach (Character c in chars)
     {
         sqc = new SQLiteCommand("SELECT ifnull(max(char_id),0) FROM character", conn);
         int id = Convert.ToInt32(sqc.ExecuteScalar());
         id++;
         sqc = new SQLiteCommand("INSERT INTO character VALUES (" + id.ToString() + ",'" + c.charx + "'," + c.lang.ToString() + ")", conn);
         sqc.ExecuteNonQuery();
         foreach (Variant v in c.variants)
         {
             sqc = new SQLiteCommand("SELECT ifnull(max(vid),0) FROM variant", conn);
             int vid = Convert.ToInt32(sqc.ExecuteScalar());
             vid++;
             sqc = new SQLiteCommand("INSERT INTO variant VALUES (" + vid.ToString() + "," + id.ToString() + ")", conn);
             sqc.ExecuteNonQuery();
             int sti = 0;
             foreach (Stroke st in v.Strokes)
             {
                 sqc = new SQLiteCommand("SELECT ifnull(max(s_id),0) FROM strokes", conn);
                 int sid = Convert.ToInt32(sqc.ExecuteScalar());
                 sid++;
                 sqc = new SQLiteCommand("INSERT INTO strokes VALUES (" + sid.ToString() + "," + vid.ToString() + "," + id.ToString() + ",'" + Stroke2Int(st).ToString() + "','" + st.quadrant + "'," + sti.ToString() + ")", conn);
                 sqc.ExecuteNonQuery();
                 sti++;
             }
         }
     }
     conn.Clone();
 }
Ejemplo n.º 6
0
        /// <summary>
        /// ALTERANDO O REGISTRO
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAlterar_Click(object sender, RoutedEventArgs e)
        {
            tbID.IsReadOnly = true;

            SQLiteConnection conn = new SQLiteConnection(conexao);
            if (conn.State == ConnectionState.Closed)
                conn.Open();

            SQLiteCommand cmd = new SQLiteCommand("UPDATE tb_raps SET NOME = @NOME, RAPCODE = @RAPCODE, RAPNOME = @RAPNOME WHERE ID = @ID", conn);

            cmd.Parameters.AddWithValue("ID", tbID.Text.Trim());
            cmd.Parameters.AddWithValue("NOME", tbNome.Text.Trim());
            cmd.Parameters.AddWithValue("RAPCODE", tbRapCode.Text.Trim());
            cmd.Parameters.AddWithValue("RAPNOME", tbRapNome.Text.Trim());

            try
            {
                cmd.ExecuteNonQuery();
                MsgBox.Show("Registro Alterado com sucesso!",
                "Sucesso", MsgBox.Buttons.OK, MsgBox.Icon.Info, MsgBox.AnimateStyle.SlideDown);
                LeituraDados();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao atualizar:\n" + ex.Message);
            }

            conn.Clone();
        }