Ejemplo n.º 1
0
        private void licao_DoWork(object sender, DoWorkEventArgs e)
        {
            Invoke(new Action(() =>
            {
                flowLayoutPanel1.Controls.Clear();
            }));
            Bunifu.Framework.UI.BunifuSeparator sep1 = new Bunifu.Framework.UI.BunifuSeparator();
            sep1.Width = flowLayoutPanel1.Width - 30;
            if (!Properties.Settings.Default.phpLocal)
            {
                MySqlConnection CONEXAO      = new MySqlConnection(Vars.Cfg);
                MySqlCommand    checarLicoes = new MySqlCommand("SELECT * FROM licoes INNER JOIN profdisc ON disc = cod_disc INNER JOIN profs ON cod_prof = profid_disc INNER JOIN disc ON discid_disc = cod_discs INNER JOIN info_salas ON sala = cod_sala WHERE mesentrega = @Mes AND diaentrega = @Dia AND avaliado > 0 AND nome_prof = @Nome ORDER BY sala ASC;", CONEXAO);
                try
                {
                    CONEXAO.Open();
                    checarLicoes.Parameters.AddWithValue("@Mes", Vars.mesSelec);
                    checarLicoes.Parameters.AddWithValue("@Dia", Vars.diaSelec);
                    checarLicoes.Parameters.AddWithValue("@Nome", Properties.Settings.Default.nome);



                    int cod = Convert.ToInt32(checarLicoes.ExecuteScalar());

                    if (cod > 0)
                    {
                        Invoke(new Action(() =>
                        {
                            flowLayoutPanel1.Controls.Add(sep1);
                        }));
                    }

                    MySqlDataReader lerLicoes = checarLicoes.ExecuteReader();


                    while (lerLicoes.Read())
                    {
                        string textolicao = lerLicoes["licao"].ToString();
                        if (textolicao.Substring(textolicao.Length - 1, 1) != "." && textolicao.Substring(textolicao.Length - 1, 1) != "!" && textolicao.Substring(textolicao.Length - 1, 1) != "?" && textolicao.Substring(textolicao.Length - 1, 1) != "\r\n")
                        {
                            textolicao += ".";
                        }

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



                        licaoTit licaoTit = new licaoTit(lerLicoes["nome_disc"].ToString() + " para " + lerLicoes["nome_sala"].ToString(), flowLayoutPanel1.Width - 31);
                        painel.Controls.Add(licaoTit);



                        licaoTxt licaoTxt = new licaoTxt(textolicao, flowLayoutPanel1.Width - 3);
                        painel.Controls.Add(licaoTxt);

                        if (lerLicoes["link_anexo"].ToString() != "")
                        {
                            string link = lerLicoes["link_anexo"].ToString();
                            pic    pic  = new DiarioDeClasse.pic(link, flowLayoutPanel1.Width - 31); //PictureBox pb = new PictureBox();
                            pic.ImageLocation = link;
                            Image img = pic.Image;
                            pic.Image = img;
                            painel.Controls.Add(pic);
                        }


                        AddPor licaoAddPor = new AddPor(lerLicoes["adicionadopor"].ToString(), lerLicoes["cod"].ToString());
                        painel.Controls.Add(licaoAddPor);


                        AddEm licaoAddEm = new AddEm(lerLicoes["adicionadoem"].ToString());
                        painel.Controls.Add(licaoAddEm);

                        if (Properties.Settings.Default.permInt == 1 || Properties.Settings.Default.permInt == 2 || Properties.Settings.Default.permInt == 3 || Properties.Settings.Default.permInt == 9)
                        {
                            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           = lerLicoes["cod"].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);
                        }));
                    }
                    lerLicoes.Close();
                }
                catch (Exception erro)
                {
                    if (Properties.Settings.Default.permInt == 3 || Properties.Settings.Default.permInt == 9)
                    {
                        if (erro.ToString().ToLower().Contains("system.invalidoperationexception"))
                        {
                        }
                        else
                        {
                            MessageBox.Show("Houve um erro no MySql:\r\n" + erro.ToString());
                        }
                    }
                }
                finally
                {
                    CONEXAO.Close();
                }
            }
            else
            {
                WebClient kj = new WebClient();
                kj.Encoding = System.Text.Encoding.UTF8;


                string   resultado = kj.DownloadString("http://" + Vars.cfgPhp + "/dia/licaoProf.php?nome=" + Properties.Settings.Default.nome + "&dia=" + Vars.diaSelec + "&mes=" + Vars.mesSelec).Trim();
                string[] reps      = resultado.Split(new string[] { "&&&" }, StringSplitOptions.RemoveEmptyEntries);
                if (resultado != "0")
                {
                    Invoke(new Action(() =>
                    {
                        flowLayoutPanel1.Controls.Add(sep1);
                    }));
                }
                foreach (string teste in reps)
                {
                    string[] codes = teste.Split(new string[] { "@#@" }, StringSplitOptions.RemoveEmptyEntries);
                    if (codes.Length > 3)
                    {
                        string discLicao   = codes[0];
                        string codLicao    = codes[1];
                        string txtLicao    = codes[2];
                        string anexoLicao  = "";
                        string addPorLicao = "";
                        string addEmLicao  = "";
                        string nomeSala    = "";
                        if (codes[3].Contains("imgur"))
                        {
                            anexoLicao  = codes[3];
                            addPorLicao = codes[4];
                            addEmLicao  = codes[5];
                            nomeSala    = codes[6];
                        }
                        else
                        {
                            addPorLicao = codes[3];
                            addEmLicao  = codes[4];
                            nomeSala    = codes[5];
                        }

                        string textolicao = txtLicao;
                        if (textolicao.Substring(textolicao.Length - 1, 1) != "." && textolicao.Substring(textolicao.Length - 1, 1) != "!" && textolicao.Substring(textolicao.Length - 1, 1) != "?" && textolicao.Substring(textolicao.Length - 1, 1) != "\r\n")
                        {
                            textolicao += ".";
                        }

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



                        licaoTit licaoTit = new licaoTit(discLicao + " para " + nomeSala, flowLayoutPanel1.Width - 31);
                        painel.Controls.Add(licaoTit);



                        licaoTxt licaoTxt = new licaoTxt(textolicao, flowLayoutPanel1.Width - 3);
                        painel.Controls.Add(licaoTxt);

                        if (anexoLicao != "")
                        {
                            string link = anexoLicao;
                            pic    pic  = new DiarioDeClasse.pic(link, flowLayoutPanel1.Width - 31); //PictureBox pb = new PictureBox();
                            pic.ImageLocation = link;
                            Image img = pic.Image;
                            pic.Image = img;
                            painel.Controls.Add(pic);
                        }


                        AddPor licaoAddPor = new AddPor(addPorLicao, codLicao);
                        painel.Controls.Add(licaoAddPor);


                        AddEm licaoAddEm = new AddEm(addEmLicao);
                        painel.Controls.Add(licaoAddEm);

                        if (Properties.Settings.Default.permInt == 1 || Properties.Settings.Default.permInt == 2 || Properties.Settings.Default.permInt == 3 || Properties.Settings.Default.permInt == 9)
                        {
                            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           = codLicao;
                            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);
                        }));
                    }
                }
            }
        }
        private void rep_DoWork(object sender, DoWorkEventArgs e)
        {
            Invoke(new Action(() =>
            {
                panelVerif.Controls.Clear();
            }));
            if (!Properties.Settings.Default.phpLocal)
            {
                MySqlConnection CONEXAObw     = new MySqlConnection(Vars.Cfg);
                MySqlCommand    checarTarefas = new MySqlCommand("SELECT * FROM licoes INNER JOIN profdisc ON licoes.disc = cod_disc INNER JOIN info_salas ON sala = cod_sala INNER JOIN disc ON discid_disc = cod_discs WHERE avaliado = 0 AND avaliado != -1 AND nome_sala = @Sala", CONEXAObw);
                checarTarefas.Parameters.AddWithValue("@Sala", Properties.Settings.Default.sala);
                try
                {
                    CONEXAObw.Open();
                    MySqlDataReader lerTarefas = checarTarefas.ExecuteReader();
                    while (lerTarefas.Read())
                    {
                        Bunifu.Framework.UI.BunifuSeparator sep = new Bunifu.Framework.UI.BunifuSeparator();

                        if (!Vars.af.aRep2.Contains(lerTarefas["cod"].ToString()))
                        {
                            Vars.af.aRep2.Add(lerTarefas["cod"].ToString());
                        }

                        string licao = lerTarefas["licao"].ToString();
                        if (licao.Substring(licao.Length - 1, 1) != "." && licao.Substring(licao.Length - 1, 1) != "!" && licao.Substring(licao.Length - 1, 1) != "?" && licao.Substring(licao.Length - 1, 1) != "\r\n")
                        {
                            licao += ".";
                        }

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

                        licaoTit licaoTit = new licaoTit(lerTarefas["nome_disc"].ToString(), panelVerif.Width - 31);
                        painel.Controls.Add(licaoTit);

                        licaoTxt licaoTxt = new licaoTxt(licao, panelVerif.Width - 31);
                        painel.Controls.Add(licaoTxt);

                        if (lerTarefas["link_anexo"].ToString() != "")
                        {
                            Invoke(new Action(() =>
                            {
                                string link       = lerTarefas["link_anexo"].ToString();
                                pic pic           = new DiarioDeClasse.pic(link, panelVerif.Width - 31); //PictureBox pb = new PictureBox();
                                pic.ImageLocation = link;
                                Image img         = pic.Image;
                                pic.Image         = img;
                                painel.Controls.Add(pic);
                            }));
                        }

                        AddPor licaoAddPor = new AddPor(lerTarefas["adicionadopor"].ToString(), lerTarefas["cod"].ToString());
                        painel.Controls.Add(licaoAddPor);


                        AddEm licaoAddEm = new AddEm(lerTarefas["adicionadoem"].ToString());
                        painel.Controls.Add(licaoAddEm);

                        Panel grr = new Panel();
                        grr.Height = 40;
                        grr.Width  = 42;
                        grr.Dock   = DockStyle.Fill;

                        Bunifu.Framework.UI.BunifuTileButton btnAceitar = new Bunifu.Framework.UI.BunifuTileButton();
                        btnAceitar.BackColor     = Color.Transparent;
                        btnAceitar.color         = Color.Transparent;
                        btnAceitar.colorActive   = System.Drawing.Color.DodgerBlue;
                        btnAceitar.Cursor        = System.Windows.Forms.Cursors.Hand;
                        btnAceitar.Image         = Properties.Resources.icons8_Ok_64px;
                        btnAceitar.ImagePosition = 0;
                        btnAceitar.ImageZoom     = 100;
                        btnAceitar.LabelPosition = 0;
                        btnAceitar.LabelText     = "";
                        btnAceitar.Size          = new System.Drawing.Size(28, 28);
                        btnAceitar.TabIndex      = 0;
                        btnAceitar.Tag           = lerTarefas["cod"].ToString();
                        btnAceitar.Click        += (s, eee) =>
                        {
                            Bunifu.Framework.UI.BunifuTileButton aa = s as Bunifu.Framework.UI.BunifuTileButton;
                            MySqlConnection CONEXAO = new MySqlConnection(Vars.Cfg);
                            MySqlCommand    aceitar = new MySqlCommand("UPDATE licoes SET avaliado = 1 WHERE cod = @Cod;", CONEXAO);
                            aceitar.Parameters.AddWithValue("@Cod", aa.Tag.ToString());
                            CONEXAO.Open();
                            aceitar.ExecuteNonQuery();
                            CONEXAO.Close();
                            Invoke(new Action(() =>
                            {
                                panelVerif.Controls.Remove(painel);
                                panelVerif.Controls.Remove(sep);
                            }));
                        };
                        btnAceitar.Anchor = AnchorStyles.Left;
                        grr.Controls.Add(btnAceitar);
                        Bunifu.Framework.UI.BunifuTileButton btnNegar = new Bunifu.Framework.UI.BunifuTileButton();
                        btnNegar.BackColor     = Color.Transparent;
                        btnNegar.color         = Color.Transparent;
                        btnNegar.colorActive   = System.Drawing.Color.DodgerBlue;
                        btnNegar.Cursor        = System.Windows.Forms.Cursors.Hand;
                        btnNegar.Image         = Properties.Resources.icons8_Cancel_64px;
                        btnNegar.ImagePosition = 0;
                        btnNegar.ImageZoom     = 100;
                        btnNegar.LabelPosition = 0;
                        btnNegar.LabelText     = "";
                        btnNegar.Size          = new System.Drawing.Size(28, 28);
                        btnNegar.TabIndex      = 0;
                        btnNegar.Tag           = lerTarefas["cod"].ToString();
                        btnNegar.Click        += (s, eee) =>
                        {
                            Bunifu.Framework.UI.BunifuTileButton aa = s as Bunifu.Framework.UI.BunifuTileButton;
                            MySqlConnection CONEXAO = new MySqlConnection(Vars.Cfg);
                            MySqlCommand    negar   = new MySqlCommand("UPDATE licoes SET avaliado = -1 WHERE cod = @Cod;", CONEXAO);
                            negar.Parameters.AddWithValue("@Cod", aa.Tag.ToString());
                            CONEXAO.Open();
                            negar.ExecuteNonQuery();
                            CONEXAO.Close();
                            Invoke(new Action(() =>
                            {
                                panelVerif.Controls.Remove(painel);
                                panelVerif.Controls.Remove(sep);
                            }));
                        };
                        btnNegar.Anchor = AnchorStyles.Right;
                        grr.Controls.Add(btnNegar);
                        painel.Controls.Add(grr);


                        sep.Width = panelVerif.Width - 30;
                        Invoke(new Action(() =>
                        {
                            panelVerif.Controls.Add(painel);
                            panelVerif.Controls.Add(sep);
                        }));
                    }
                    lerTarefas.Close();
                    CONEXAObw.Close();
                }
                catch (Exception erro)
                {
                    if (Properties.Settings.Default.permInt == 3 || Properties.Settings.Default.permInt == 9)
                    {
                        MessageBox.Show("Houve um erro no MySql:\r\n" + erro.Message);
                    }
                }
            }
            else
            {
                WebClient kj = new WebClient();
                kj.Encoding = System.Text.Encoding.UTF8;
                string   resultado = kj.DownloadString("http://" + Vars.cfgPhp + "/principal/rep.php?sala=" + Properties.Settings.Default.sala).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 discLicao   = codes[0];
                        string codLicao    = codes[1];
                        string txtLicao    = codes[2];
                        string anexoLicao  = "";
                        string addPorLicao = "";
                        string addEmLicao  = "";
                        if (codes[3].Contains("imgur"))
                        {
                            anexoLicao  = codes[3];
                            addPorLicao = codes[4];
                            addEmLicao  = codes[5];
                        }
                        else
                        {
                            addPorLicao = codes[3];
                            addEmLicao  = codes[4];
                        }

                        Bunifu.Framework.UI.BunifuSeparator sep = new Bunifu.Framework.UI.BunifuSeparator();
                        string licao = txtLicao;
                        if (licao.Substring(licao.Length - 1, 1) != "." && licao.Substring(licao.Length - 1, 1) != "!" && licao.Substring(licao.Length - 1, 1) != "?" && licao.Substring(licao.Length - 1, 1) != "\r\n")
                        {
                            licao += ".";
                        }

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

                        licaoTit licaoTit = new licaoTit(discLicao, panelVerif.Width - 31);
                        painel.Controls.Add(licaoTit);

                        licaoTxt licaoTxt = new licaoTxt(licao, panelVerif.Width - 31);
                        painel.Controls.Add(licaoTxt);

                        if (anexoLicao != "")
                        {
                            Invoke(new Action(() =>
                            {
                                string link       = anexoLicao;
                                pic pic           = new DiarioDeClasse.pic(link, panelVerif.Width - 31); //PictureBox pb = new PictureBox();
                                pic.ImageLocation = link;
                                Image img         = pic.Image;
                                pic.Image         = img;
                                painel.Controls.Add(pic);
                            }));
                        }

                        AddPor licaoAddPor = new AddPor(addPorLicao, codLicao);
                        painel.Controls.Add(licaoAddPor);


                        AddEm licaoAddEm = new AddEm(addEmLicao);
                        painel.Controls.Add(licaoAddEm);

                        Panel grr = new Panel();
                        grr.Height = 40;
                        grr.Width  = 42;
                        grr.Dock   = DockStyle.Fill;

                        Bunifu.Framework.UI.BunifuTileButton btnAceitar = new Bunifu.Framework.UI.BunifuTileButton();
                        btnAceitar.BackColor     = Color.Transparent;
                        btnAceitar.color         = Color.Transparent;
                        btnAceitar.colorActive   = System.Drawing.Color.DodgerBlue;
                        btnAceitar.Cursor        = System.Windows.Forms.Cursors.Hand;
                        btnAceitar.Image         = Properties.Resources.icons8_Ok_64px;
                        btnAceitar.ImagePosition = 0;
                        btnAceitar.ImageZoom     = 100;
                        btnAceitar.LabelPosition = 0;
                        btnAceitar.LabelText     = "";
                        btnAceitar.Size          = new System.Drawing.Size(28, 28);
                        btnAceitar.TabIndex      = 0;
                        btnAceitar.Tag           = codLicao;
                        btnAceitar.Click        += (s, eee) =>
                        {
                            Bunifu.Framework.UI.BunifuTileButton aa = s as Bunifu.Framework.UI.BunifuTileButton;
                            WebClient kjAceitar = new WebClient();
                            kjAceitar.Encoding = System.Text.Encoding.UTF8;
                            string resultadoAceitar = kjAceitar.DownloadString("http://" + Vars.cfgPhp + "/principal/aceitarLicao.php?cod=" + aa.Tag.ToString()).Trim();
                            if (resultadoAceitar == "1")
                            {
                                Invoke(new Action(() =>
                                {
                                    panelVerif.Controls.Remove(painel);
                                    panelVerif.Controls.Remove(sep);
                                }));
                            }
                        };
                        btnAceitar.Anchor = AnchorStyles.Left;
                        grr.Controls.Add(btnAceitar);
                        Bunifu.Framework.UI.BunifuTileButton btnNegar = new Bunifu.Framework.UI.BunifuTileButton();
                        btnNegar.BackColor     = Color.Transparent;
                        btnNegar.color         = Color.Transparent;
                        btnNegar.colorActive   = System.Drawing.Color.DodgerBlue;
                        btnNegar.Cursor        = System.Windows.Forms.Cursors.Hand;
                        btnNegar.Image         = Properties.Resources.icons8_Cancel_64px;
                        btnNegar.ImagePosition = 0;
                        btnNegar.ImageZoom     = 100;
                        btnNegar.LabelPosition = 0;
                        btnNegar.LabelText     = "";
                        btnNegar.Size          = new System.Drawing.Size(28, 28);
                        btnNegar.TabIndex      = 0;
                        btnNegar.Tag           = codLicao;
                        btnNegar.Click        += (s, eee) =>
                        {
                            Bunifu.Framework.UI.BunifuTileButton aa = s as Bunifu.Framework.UI.BunifuTileButton;
                            WebClient kjNegar = new WebClient();
                            kjNegar.Encoding = System.Text.Encoding.UTF8;
                            string resultadoNegar = kjNegar.DownloadString("http://" + Vars.cfgPhp + "/principal/negarLicao.php?cod=" + aa.Tag.ToString()).Trim();
                            if (resultadoNegar == "1")
                            {
                                Invoke(new Action(() =>
                                {
                                    panelVerif.Controls.Remove(painel);
                                    panelVerif.Controls.Remove(sep);
                                }));
                            }
                        };
                        btnNegar.Anchor = AnchorStyles.Right;
                        grr.Controls.Add(btnNegar);
                        painel.Controls.Add(grr);
                        sep.Width = panelVerif.Width - 30;
                        Invoke(new Action(() =>
                        {
                            panelVerif.Controls.Add(painel);
                            panelVerif.Controls.Add(sep);
                        }));
                    }
                }
            }
            Vars.trabRep = false;
        }
        public void licaoSemana(string dia, string mes)
        {
            if (!Properties.Settings.Default.phpLocal)
            {
                MySqlConnection CONEXAObw    = new MySqlConnection(Vars.Cfg);
                MySqlCommand    checarLicoes = new MySqlCommand("SELECT * FROM licoes INNER JOIN profdisc ON licoes.disc = cod_disc INNER JOIN disc ON discid_disc = cod_discs WHERE mesentrega = @Mes AND diaentrega = @Dia AND avaliado > 0 AND sala = '" + Properties.Settings.Default.codSala + "';", CONEXAObw);
                try
                {
                    checarLicoes.Parameters.AddWithValue("@Mes", mes);
                    checarLicoes.Parameters.AddWithValue("@Dia", dia);

                    CONEXAObw.Open();
                    MySqlDataReader lerLicoes = checarLicoes.ExecuteReader();

                    while (lerLicoes.Read())
                    {
                        if (!Vars.af.aLicao2.Contains(lerLicoes["cod"].ToString()))
                        {
                            Vars.af.aLicao2.Add(lerLicoes["cod"].ToString());
                        }

                        string licao = lerLicoes["licao"].ToString();
                        if (licao.Substring(licao.Length - 1, 1) != "." && licao.Substring(licao.Length - 1, 1) != "!" && licao.Substring(licao.Length - 1, 1) != "?" && licao.Substring(licao.Length - 1, 1) != "\r\n")
                        {
                            licao += ".";
                        }

                        TableLayoutPanel painel = new TableLayoutPanel();
                        painel.AutoSize = true;
                        painel.Dock     = DockStyle.Fill;

                        licaoTit licaoTit = new licaoTit(lerLicoes["nome_disc"].ToString(), flowLayoutPanel1.Width - 31);
                        painel.Controls.Add(licaoTit);

                        DateTime dateValue = new DateTime(2017, Convert.ToInt32(lerLicoes["mesentrega"].ToString()), Int32.Parse(lerLicoes["diaentrega"].ToString()));
                        licaoTit licaoTit2 = new licaoTit("Para a próxima " + checarDia(dateValue.ToString("ddd")) + "!", flowLayoutPanel1.Width - 31);
                        painel.Controls.Add(licaoTit2);

                        licaoTxt licaoTxt = new licaoTxt(licao, flowLayoutPanel1.Width - 31);
                        painel.Controls.Add(licaoTxt);

                        if (lerLicoes["link_anexo"].ToString() != "")
                        {
                            Invoke(new Action(() =>
                            {
                                string link       = lerLicoes["link_anexo"].ToString();
                                pic pic           = new DiarioDeClasse.pic(link, flowLayoutPanel1.Width - 31); //PictureBox pb = new PictureBox();
                                pic.ImageLocation = link;
                                Image img         = pic.Image;
                                pic.Image         = img;
                                painel.Controls.Add(pic);
                            }));
                        }

                        AddPor licaoAddPor = new AddPor(lerLicoes["adicionadopor"].ToString(), lerLicoes["cod"].ToString());
                        painel.Controls.Add(licaoAddPor);


                        AddEm licaoAddEm = new AddEm(lerLicoes["adicionadoem"].ToString());
                        painel.Controls.Add(licaoAddEm);

                        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);
                        }));
                    }
                    lerLicoes.Close();
                    CONEXAObw.Close();
                }
                catch (Exception erro)
                {
                    if (Properties.Settings.Default.permInt == 3 || Properties.Settings.Default.permInt == 9)
                    {
                        MessageBox.Show("Houve um erro no MySql:\r\n" + erro.Message);
                    }
                }
            }
            else
            {
                WebClient kj = new WebClient();
                kj.Encoding = System.Text.Encoding.UTF8;
                string   resultado = kj.DownloadString("http://" + Vars.cfgPhp + "/principal/licao.php?sala=" + Properties.Settings.Default.codSala + "&dia=" + dia + "&mes=" + mes).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 discLicao   = codes[0];
                        string codLicao    = codes[1];
                        string txtLicao    = codes[2];
                        string anexoLicao  = "";
                        string addPorLicao = "";
                        string addEmLicao  = "";
                        if (codes[3].Contains("imgur"))
                        {
                            anexoLicao  = codes[3];
                            addPorLicao = codes[4];
                            addEmLicao  = codes[5];
                        }
                        else
                        {
                            addPorLicao = codes[3];
                            addEmLicao  = codes[4];
                        }

                        if (!Vars.af.aLicao2.Contains(codLicao))
                        {
                            Vars.af.aLicao2.Add(codLicao);
                        }

                        string licao = txtLicao;
                        if (licao.Substring(licao.Length - 1, 1) != "." && licao.Substring(licao.Length - 1, 1) != "!" && licao.Substring(licao.Length - 1, 1) != "?" && licao.Substring(licao.Length - 1, 1) != "\r\n")
                        {
                            licao += ".";
                        }

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

                        licaoTit licaoTit = new licaoTit(discLicao, flowLayoutPanel1.Width - 31);
                        painel.Controls.Add(licaoTit);
                        DateTime dateValue = new DateTime(2017, Convert.ToInt32(mes), Int32.Parse(dia));
                        licaoTit licaoTit2 = new licaoTit("Para a próxima " + checarDia(dateValue.ToString("ddd")) + "!", flowLayoutPanel1.Width - 31);
                        painel.Controls.Add(licaoTit2);

                        licaoTxt licaoTxt = new licaoTxt(licao, flowLayoutPanel1.Width - 31);
                        painel.Controls.Add(licaoTxt);

                        if (anexoLicao != "")
                        {
                            Invoke(new Action(() =>
                            {
                                string link       = anexoLicao;
                                pic pic           = new DiarioDeClasse.pic(link, flowLayoutPanel1.Width - 31); //PictureBox pb = new PictureBox();
                                pic.ImageLocation = link;
                                Image img         = pic.Image;
                                pic.Image         = img;
                                painel.Controls.Add(pic);
                            }));
                        }

                        AddPor licaoAddPor = new AddPor(addPorLicao, codLicao);
                        painel.Controls.Add(licaoAddPor);


                        AddEm licaoAddEm = new AddEm(addEmLicao);
                        painel.Controls.Add(licaoAddEm);

                        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);
                        }));
                    }
                }
            }
        }
Ejemplo n.º 4
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);
                        }));
                    }
                }
            }
        }