private void aviso_DoWork(object sender, DoWorkEventArgs e)
        {
            Invoke(new Action(() =>
            {
                flowLayoutPanel2.Controls.Clear();
            }));
            if (!Properties.Settings.Default.phpLocal)
            {
                try
                {
                    MySqlConnection CONEXAObw    = new MySqlConnection(Vars.Cfg);
                    MySqlCommand    checarAvisos = new MySqlCommand("SELECT * FROM avisos WHERE excluido_avisos = 0 AND sala_aviso = '" + Properties.Settings.Default.codSala + "' OR sala_aviso = 0 ORDER BY adicionadoem_aviso DESC;", CONEXAObw);
                    CONEXAObw.Open();
                    MySqlDataReader lerAvisos = checarAvisos.ExecuteReader();
                    while (lerAvisos.Read())
                    {
                        if (!Vars.af.aAviso2.Contains(lerAvisos["cod_aviso"].ToString()))
                        {
                            Vars.af.aAviso2.Add(lerAvisos["cod_aviso"].ToString());
                        }

                        string aviso = lerAvisos["texto_aviso"].ToString();
                        if (aviso.Substring(aviso.Length - 1, 1) != "." && aviso.Substring(aviso.Length - 1, 1) != "!" && aviso.Substring(aviso.Length - 1, 1) != "?" && aviso.Substring(aviso.Length - 1, 1) != "\r\n")
                        {
                            aviso += ".";
                        }
                        avisoTxt avisoTxt = new avisoTxt(aviso);
                        Invoke(new Action(() =>
                        {
                            flowLayoutPanel2.Controls.Add(avisoTxt);
                        }));
                        AddPor licaoAddPor = new AddPor(lerAvisos["adicionadopor_aviso"].ToString(), lerAvisos["cod_aviso"].ToString());
                        Invoke(new Action(() =>
                        {
                            flowLayoutPanel2.Controls.Add(licaoAddPor);
                        }));
                        AddEm licaoAddEm = new AddEm(lerAvisos["adicionadoem_aviso"].ToString());
                        Bunifu.Framework.UI.BunifuSeparator sep = new Bunifu.Framework.UI.BunifuSeparator();
                        sep.Width = flowLayoutPanel2.Width - 30;
                        Invoke(new Action(() =>
                        {
                            flowLayoutPanel2.Controls.Add(licaoAddEm);
                            flowLayoutPanel2.Controls.Add(sep);
                        }));
                    }
                    lerAvisos.Close();
                    CONEXAObw.Close();
                }
                catch (Exception ee)
                {
                    if (Properties.Settings.Default.permInt == 3 || Properties.Settings.Default.permInt == 9)
                    {
                        MessageBox.Show(ee.Message);
                    }
                }
            }
            else
            {
                WebClient kj = new WebClient();
                kj.Encoding = System.Text.Encoding.UTF8;
                string   resultado = kj.DownloadString("http://" + Vars.cfgPhp + "/principal/avisos.php?sala=" + Properties.Settings.Default.codSala).Trim();
                string[] reps      = resultado.Split(new string[] { "&&&" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string teste in reps)
                {
                    string[] codes = teste.Split(new string[] { "@#@" }, StringSplitOptions.RemoveEmptyEntries);
                    if (codes.Length > 3)
                    {
                        string txtAviso    = codes[2];
                        string addPorAviso = codes[0];
                        string addEmAviso  = codes[1];
                        string codAviso    = codes[3];

                        if (!Vars.af.aAviso2.Contains(codAviso))
                        {
                            Vars.af.aAviso2.Add(codAviso);
                        }

                        string aviso = txtAviso;
                        if (aviso.Substring(aviso.Length - 1, 1) != "." && aviso.Substring(aviso.Length - 1, 1) != "!" && aviso.Substring(aviso.Length - 1, 1) != "?" && aviso.Substring(aviso.Length - 1, 1) != "\r\n")
                        {
                            aviso += ".";
                        }
                        avisoTxt avisoTxt = new avisoTxt(aviso);
                        Invoke(new Action(() =>
                        {
                            flowLayoutPanel2.Controls.Add(avisoTxt);
                        }));
                        AddPor licaoAddPor = new AddPor(addPorAviso, codAviso);
                        Invoke(new Action(() =>
                        {
                            flowLayoutPanel2.Controls.Add(licaoAddPor);
                        }));
                        AddEm licaoAddEm = new AddEm(addEmAviso);
                        Bunifu.Framework.UI.BunifuSeparator sep = new Bunifu.Framework.UI.BunifuSeparator();
                        sep.Width = flowLayoutPanel2.Width - 30;
                        Invoke(new Action(() =>
                        {
                            flowLayoutPanel2.Controls.Add(licaoAddEm);
                            flowLayoutPanel2.Controls.Add(sep);
                        }));
                    }
                }
            }
            Vars.trabAviso = false;

            /*Invoke(new Action(() =>
             * {
             *  carregando.Visible = false;
             *  this.Visible = true;
             * }));*/
        }
Ejemplo n.º 2
0
        private void aviso_DoWork(object sender, DoWorkEventArgs e)
        {
            Invoke(new Action(() =>
            {
                flowLayoutPanel1.Controls.Clear();
            }));
            if (!Properties.Settings.Default.phpLocal)
            {
                try
                {

                    MySqlConnection CONEXAObw = new MySqlConnection(Vars.Cfg);
                    MySqlCommand checarAvisos;
                    if (Properties.Settings.Default.permInt == 2)
                        checarAvisos = new MySqlCommand("SELECT * FROM avisos INNER JOIN info_salas ON cod_sala = sala_aviso WHERE excluido_avisos = 0 AND adicionadopor_aviso LIKE '%" + Properties.Settings.Default.nome + "%';", CONEXAObw);
                    else
                        checarAvisos = new MySqlCommand("SELECT * FROM avisos WHERE excluido_avisos = 0 AND sala_aviso = '" + Properties.Settings.Default.codSala + "';", CONEXAObw);
                    CONEXAObw.Open();
                    Bunifu.Framework.UI.BunifuSeparator sep1 = new Bunifu.Framework.UI.BunifuSeparator();
                    sep1.Width = flowLayoutPanel1.Width - 30;
                    int cod = Convert.ToInt32(checarAvisos.ExecuteScalar());

                    if (cod > 0)
                    {
                        Invoke(new Action(() =>
                        {
                            flowLayoutPanel1.Controls.Add(sep1);
                        }));
                    }
                    MySqlDataReader lerAvisos = checarAvisos.ExecuteReader();
                    while (lerAvisos.Read())
                    {
                        string aviso = lerAvisos["texto_aviso"].ToString();
                        if (aviso.Substring(aviso.Length - 1, 1) != "." && aviso.Substring(aviso.Length - 1, 1) != "!" && aviso.Substring(aviso.Length - 1, 1) != "?" && aviso.Substring(aviso.Length - 1, 1) != "\r\n")
                            aviso += ".";
                        /*
                        Label avisoSub = new Label();
                        avisoSub.Font = new System.Drawing.Font("Trajan Pro", 13F, FontStyle.Bold);
                        avisoSub.ForeColor = Vars.corTit;
                        avisoSub.Size = new System.Drawing.Size(flowLayoutPanel2.Width - 30, 30);
                        avisoSub.Text = "Lição de " + lerAvisos["nome_disc"].ToString() + ":";
                        avisoSub.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                        flowLayoutPanel2.Controls.Add(avisoSub);*/

                        TableLayoutPanel painel = new TableLayoutPanel();
                        painel.AutoSize = true;


                        if (Properties.Settings.Default.permInt == 2)
                        {
                            licaoTit avisoTit = new licaoTit(lerAvisos["nome_sala"].ToString(), flowLayoutPanel1.Width - 31);
                            painel.Controls.Add(avisoTit);
                        }

                        avisoTxt avisoTxt = new avisoTxt(aviso);
                        avisoTxt.MaximumSize = new System.Drawing.Size(flowLayoutPanel1.Width - 25, 999999);
                        painel.Controls.Add(avisoTxt);
                        /*
                        if (lerAvisos["link_anexo"].ToString() != "")
                        {
                            string link = lerAvisos["link_anexo"].ToString();
                            PictureBox pic = new PictureBox();
                            pic.Size = new System.Drawing.Size(321, 170);
                            pic.SizeMode = PictureBoxSizeMode.StretchImage;
                            pic.Load(link);
                            pic.Tag = link;
                            pic.Cursor = Cursors.Hand;
                            pic.Click += new System.EventHandler(go);
                            flowLayoutPanel2.Controls.Add(pic);
                        }
                        */

                        AddPor avisoAddPor = new AddPor(lerAvisos["adicionadopor_aviso"].ToString(), lerAvisos["cod_aviso"].ToString());
                        avisoAddPor.AutoSize = false;
                        avisoAddPor.Width = flowLayoutPanel1.Width - 31;
                        painel.Controls.Add(avisoAddPor);


                        AddEm avisoAddEm = new AddEm(lerAvisos["adicionadoem_aviso"].ToString());
                        painel.Controls.Add(avisoAddEm);

                        if (lerAvisos["adicionadopor_aviso"].ToString() != "Equipe")
                        {
                            Bunifu.Framework.UI.BunifuTileButton btnExcluir = new Bunifu.Framework.UI.BunifuTileButton();
                            btnExcluir.BackColor = Color.Transparent;
                            btnExcluir.color = Color.Transparent;
                            btnExcluir.colorActive = System.Drawing.Color.DodgerBlue;
                            btnExcluir.Cursor = System.Windows.Forms.Cursors.Hand;
                            btnExcluir.Image = Properties.Resources.icons8_Trash_Can_64px;
                            btnExcluir.ImagePosition = 0;
                            btnExcluir.ImageZoom = 100;
                            btnExcluir.LabelPosition = 0;
                            btnExcluir.LabelText = "";
                            btnExcluir.Location = new System.Drawing.Point(349, 254);
                            btnExcluir.Margin = new System.Windows.Forms.Padding(6);
                            btnExcluir.Size = new System.Drawing.Size(40, 40);
                            btnExcluir.TabIndex = 0;
                            btnExcluir.Tag = lerAvisos["cod_aviso"].ToString();
                            btnExcluir.Click += new System.EventHandler(this.btnExcluir_Click);
                            btnExcluir.Anchor = AnchorStyles.Right;
                            painel.Controls.Add(btnExcluir);
                        }

                        Bunifu.Framework.UI.BunifuSeparator sep = new Bunifu.Framework.UI.BunifuSeparator();
                        sep.Width = flowLayoutPanel1.Width - 30;

                        Invoke(new Action(() =>
                        {
                            flowLayoutPanel1.Controls.Add(painel);
                            flowLayoutPanel1.Controls.Add(sep);
                        }));
                    }
                    lerAvisos.Close();
                    CONEXAObw.Close();
                }
                catch (Exception ee)
                {
                    if (Properties.Settings.Default.permInt == 3 || Properties.Settings.Default.permInt == 9)
                    MessageBox.Show(ee.Message);
                }
            }

            else
            {
                WebClient kj = new WebClient();
                kj.Encoding = System.Text.Encoding.UTF8;
                string resultado = kj.DownloadString("http://" + Vars.cfgPhp + "/avisos/avisos.php?sala=" + Properties.Settings.Default.codSala + "&perm=" + Properties.Settings.Default.permInt + 
                    "&nome=" + Properties.Settings.Default.nome).Trim();
                string[] reps = resultado.Split(new string[] { "&&&" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string teste in reps)
                {
                    string[] codes = teste.Split(new string[] { "@#@" }, StringSplitOptions.RemoveEmptyEntries);
                    if (codes.Length > 3)
                    {
                        string txtAviso = codes[2];
                        string addPorAviso = codes[0];
                        string addEmAviso = codes[1];
                        string codAviso = codes[3];

                        string aviso = txtAviso;
                        if (aviso.Substring(aviso.Length - 1, 1) != "." && aviso.Substring(aviso.Length - 1, 1) != "!" && aviso.Substring(aviso.Length - 1, 1) != "?" && aviso.Substring(aviso.Length - 1, 1) != "\r\n")
                            aviso += ".";

                        TableLayoutPanel painel = new TableLayoutPanel();
                        painel.AutoSize = true;


                        if (Properties.Settings.Default.permInt == 2)
                        {
                            licaoTit avisoTit = new licaoTit(codes[4], flowLayoutPanel1.Width - 31);
                            painel.Controls.Add(avisoTit);
                        }

                        avisoTxt avisoTxt = new avisoTxt(aviso);
                        avisoTxt.MaximumSize = new System.Drawing.Size(flowLayoutPanel1.Width - 31, 999999);
                        painel.Controls.Add(avisoTxt);
                        /*
                        if (lerAvisos["link_anexo"].ToString() != "")
                        {
                            string link = lerAvisos["link_anexo"].ToString();
                            PictureBox pic = new PictureBox();
                            pic.Size = new System.Drawing.Size(321, 170);
                            pic.SizeMode = PictureBoxSizeMode.StretchImage;
                            pic.Load(link);
                            pic.Tag = link;
                            pic.Cursor = Cursors.Hand;
                            pic.Click += new System.EventHandler(go);
                            flowLayoutPanel2.Controls.Add(pic);
                        }
                        */

                        AddPor avisoAddPor = new AddPor(addPorAviso, codAviso);
                        avisoAddPor.AutoSize = false;
                        avisoAddPor.Width = flowLayoutPanel1.Width - 31;
                        painel.Controls.Add(avisoAddPor);


                        AddEm avisoAddEm = new AddEm(addEmAviso);
                        painel.Controls.Add(avisoAddEm);

                        if (addPorAviso != "Equipe")
                        {
                            Bunifu.Framework.UI.BunifuTileButton btnExcluir = new Bunifu.Framework.UI.BunifuTileButton();
                            btnExcluir.BackColor = Color.Transparent;
                            btnExcluir.color = Color.Transparent;
                            btnExcluir.colorActive = System.Drawing.Color.DodgerBlue;
                            btnExcluir.Cursor = System.Windows.Forms.Cursors.Hand;
                            btnExcluir.Image = Properties.Resources.icons8_Trash_Can_64px;
                            btnExcluir.ImagePosition = 0;
                            btnExcluir.ImageZoom = 100;
                            btnExcluir.LabelPosition = 0;
                            btnExcluir.LabelText = "";
                            btnExcluir.Location = new System.Drawing.Point(349, 254);
                            btnExcluir.Margin = new System.Windows.Forms.Padding(6);
                            btnExcluir.Size = new System.Drawing.Size(40, 40);
                            btnExcluir.TabIndex = 0;
                            btnExcluir.Tag = codAviso;
                            btnExcluir.Click += new System.EventHandler(this.btnExcluir_Click);
                            btnExcluir.Anchor = AnchorStyles.Right;
                            painel.Controls.Add(btnExcluir);
                        }

                        Bunifu.Framework.UI.BunifuSeparator sep = new Bunifu.Framework.UI.BunifuSeparator();
                        sep.Width = flowLayoutPanel1.Width - 30;

                        Invoke(new Action(() =>
                        {
                            flowLayoutPanel1.Controls.Add(painel);
                            flowLayoutPanel1.Controls.Add(sep);
                        }));
                    }
                }
            }
        }