Exemple #1
0
        //SALVAR NOTÍCIA
        private void btnSalvaNoticiaYes_Click(object sender, EventArgs e)
        {
            //COLETANDO OS DADOS
            string[] arrDados = { txtTituloNovaNoticia.Text, txtTextoNovaNoticia.Text, txtCaminhoImgNoticiaPrincipal.Text };

            //FAZ VALIDAÇÃO
            bool flagOk = true;

            for (int i = 0; i < arrDados.Length; i++)
            {
                if (arrDados[i] == "")
                {
                    flagOk = false;
                }
            }


            if (flagOk == true)
            {
                string[] newArrDados = new string[7];

                DateTime agora = DateTime.Now;

                newArrDados[0] = "noticias";
                newArrDados[1] = arrDados[0];
                newArrDados[2] = arrDados[1];
                newArrDados[3] = objSql.formataUrl(arrDados[0]);
                newArrDados[4] = agora.ToString("dd/MM/yyyy");
                newArrDados[5] = agora.ToString("HH:mm:ss");
                newArrDados[6] = arrDados[2];
                bool exSql = objSql.insert(newArrDados);


                if (exSql)
                {
                    MessageBox.Show("Notícia salva com sucesso.");
                    txtTituloNovaNoticia.Text          = "";
                    txtTextoNovaNoticia.Text           = "";
                    txtCaminhoImgNoticiaPrincipal.Text = "";
                }
                else
                {
                    MessageBox.Show("Erro no servidor, tente novamente.");
                }
            }
        }
        //PUBLICAR ARTIGO
        private void publicarArtigo_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(txtTituloEditaArt.Text + " | " + richTextBox1.Text);
            if (MessageBox.Show("Tem certeza que deseja publicar este artigo?", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                bool flagOk = true;

                //DEFINE ENTIDADE A INSERIR MAIS SEUS VALORES

                //Formata título para Url
                string url = sqlInstruction.formataUrl(txtTituloEditaArt.Text.ToString());

                string[] dadosArtigo = { "artigo", txtTituloEditaArt.Text, txtArtigo.Text, url };

                for (int i = 0; i < dadosArtigo.Length; i++)
                {
                    if (dadosArtigo[i] == "")
                    {
                        flagOk = false;
                    }
                }

                if (flagOk == false)
                {
                    MessageBox.Show("Insira todos os campos para atualizar.");
                }
                else
                {
                    string[] newDadosArtigo = { "artigo", "COD_ART = " + codArtSel, "TIT_ART = '" + txtTituloEditaArt.Text + "'", "TXT_ART = '" + richTextBox1.Text + "'", "LINK_ART = '" + url + "'", "FLAG_ART_AP = '1', COD_CTG = '" + codCateSel + "'" };

                    // EXECUTA QUERY
                    bool exSql = sqlInstruction.update(newDadosArtigo);

                    if (exSql)
                    {
                        MessageBox.Show("Artigo publicado com sucesso.");
                        //ALTERNA VISUALIZAÇÃO PAINEIS
                        pnArtigo1.Visible = true;
                        pnArtigo2.Visible = false;
                        pnArtigo3.Visible = false;

                        //OCULTAO BOTÕES
                        ocumosBotoes("artigo");

                        //"FOCUS AO ATUAL"
                        btnNaoLidosArtigo.Image = ((System.Drawing.Image)(Properties.Resources.hnot_read));
                        //RETIRA "FOCUS"
                        btnPublicadosArtigo.Image = ((System.Drawing.Image)(Properties.Resources.published));

                        //LISTA NÃO PUBLICADOS
                        ds1 = null;
                        dtGrListArt.Columns.Clear();
                        ds1 = objArtigo.listaNaoPublicados();
                        dtGrListArt.DataSource = ds1.Tables[0];

                        //INSERE O CONTEÚDO AO CARREGAR
                        ds1 = sqlInstruction.databaseconnection(
                            "SELECT COD_ART as 'Código', DT_POST_ART as 'Data',PTS_ART as 'Pontos', categoria.TIT_CTG as 'Categoria' " +
                            "FROM artigo INNER JOIN categoria ON categoria.COD_CTG = artigo.COD_CTG WHERE FLAG_ART_AP = 0 ORDER BY DT_POST_ART,PTS_ART");
                        dtGrListArt.DataSource = ds1.Tables[0];
                        //ADICIONA GRID
                        colunaDatagrid();
                    }
                    else
                    {
                        MessageBox.Show("Desculpe, falha no servidor. Tente novamente.");
                    }
                }
            }
        }
        //PUBLICA NOTÍCIA DESTAQUE
        private void publicarNotDest_Click(object sender, EventArgs e)
        {
            //EXPLODE PALAVRAS-CHAVE
            string[] arrPalavraChave = txtNoticiaDestacadaPchave.Text.Split(';');

            //FLAGS
            string[] arrFlags = new string[3] {
                "0", "0", "0"
            };

            //VERIFICA QUAL É O TIPO DO DESTAQUE
            if (codTpDestaque == 0)
            {
                arrFlags[0] = "1";                    //Análise
            }
            else if (codTpDestaque == 1)
            {
                arrFlags[1] = "1";                         //Imagens
            }
            else
            {
                arrFlags[2] = "1"; //Vídeos
            }
            //DATA E HORA
            DateTime agora = DateTime.Now;

            string[] arrDadosUpdate = new string[1] {
                "1"
            };

            switch (codTpDestaque)
            {
            case 0:    //Análise
                arrDadosUpdate = new string[] {
                    "destaque",
                    "COD_DEST = '" + codSel + "'",
                    "TIT_DEST = '" + txtNoticiaDestacadaTitulo.Text + "'",                     //Título
                    "TXT_DEST = '" + txtNoticiaDestacadaSinopse.Text + "'",                    //Texto
                    "LINK_DEST = '" + objSql.formataUrl(txtNoticiaDestacadaTitulo.Text) + "'", //Link
                    "DT_DEST = '" + agora.ToString("dd/MM/yyyy") + "'",                        //Data
                    "HR_DEST = '" + agora.ToString("HH:mm:ss") + "'",                          //Hora
                    "PATH_IMG_INI_DEST = '" + arrFotosFinais[0] + "'",                         //ImgIni
                    //PALAVRAS-CHAVE
                    "PLV_CHV_DEST1 = '" + arrPalavraChave[0] + "'",
                    "PLV_CHV_DEST2 = '" + arrPalavraChave[1] + "'",
                    "PLV_CHV_DEST3 = '" + arrPalavraChave[2] + "'"
                };
                break;

            case 1:    //IMAGENS
                arrDadosUpdate = new string[] {
                    "destaque",
                    "COD_DEST = '" + codSel + "'",
                    "TIT_DEST = '" + txtNoticiaDestacadaTitulo.Text + "'",                     //Título
                    "TXT_DEST = '" + txtNoticiaDestacadaSinopse.Text + "'",                    //Texto
                    "LINK_DEST = '" + objSql.formataUrl(txtNoticiaDestacadaTitulo.Text) + "'", //Link
                    "DT_DEST = '" + agora.ToString("dd/MM/yyyy") + "'",                        //Data
                    "HR_DEST = '" + agora.ToString("HH:mm:ss") + "'",                          //Hora
                    "PATH_IMG_INI_DEST = '" + arrFotosFinais[0] + "'",                         //ImagIni
                    //CAMINHO IMAGENS
                    "PATH_IMG1_DEST = '" + arrFotosFinais[1] + "'",
                    "PATH_IMG2_DEST = '" + arrFotosFinais[2] + "'",
                    "PATH_IMG3_DEST = '" + arrFotosFinais[3] + "'",
                    "PATH_IMG4_DEST = '" + arrFotosFinais[4] + "'",
                    "PATH_IMG5_DEST = '" + arrFotosFinais[5] + "'",
                    "PATH_IMG6_DEST = '" + arrFotosFinais[6] + "'",
                    "PATH_IMG7_DEST = '" + arrFotosFinais[7] + "'",
                    "PATH_IMG8_DEST = '" + arrFotosFinais[8] + "'",
                    "PATH_IMG9_DEST = '" + arrFotosFinais[9] + "'",
                    //PALAVRAS-CHAVE
                    "PLV_CHV_DEST1 = '" + arrPalavraChave[0] + "'",
                    "PLV_CHV_DEST2 = '" + arrPalavraChave[1] + "'",
                    "PLV_CHV_DEST3 = '" + arrPalavraChave[2] + "'"
                };
                break;

            case 2:    //VÍDEOS
                arrDadosUpdate = new string[] {
                    "destaque",
                    "COD_DEST = '" + codSel + "'",
                    "TIT_DEST = '" + txtNoticiaDestacadaTitulo.Text + "'",                     //Título
                    "TXT_DEST = '" + txtNoticiaDestacadaSinopse.Text + "'",                    //Texto
                    "LINK_DEST = '" + objSql.formataUrl(txtNoticiaDestacadaTitulo.Text) + "'", //Link
                    "DT_DEST = '" + agora.ToString("dd/MM/yyyy") + "'",                        //Data
                    "HR_DEST = '" + agora.ToString("HH:mm:ss") + "'",                          //Hora
                    "PATH_IMG_INI_DEST = '" + arrFotosFinais[0] + "'",                         //ImagIni
                    //CAMINHOS VÍDEOS
                    "LINK1_VID_DEST = '" + txtCaminhoVidNotDest1.Text + "'",
                    "LINK2_VID_DEST = '" + txtCaminhoVidNotDest2.Text + "'",
                    "LINK3_VID_DEST = '" + txtCaminhoVidNotDest3.Text + "'",
                    "LINK4_VID_DEST = '" + txtCaminhoVidNotDest4.Text + "'",
                    //PALAVRAS-CHAVE
                    "PLV_CHV_DEST1 = '" + arrPalavraChave[0] + "'",
                    "PLV_CHV_DEST2 = '" + arrPalavraChave[1] + "'",
                    "PLV_CHV_DEST3 = '" + arrPalavraChave[2] + "'"
                };
                break;
            }

            bool exSql = objSql.update(arrDadosUpdate);

            if (exSql)
            {
                MessageBox.Show("Notícia Destaque alterada com sucesso.");
                showHidePanelsNot(false);
            }
            else
            {
                MessageBox.Show("Erro no servidor, tente novamente.");
            }
        }