private void btnEnviar_Click(object sender, EventArgs e)
        {
            MySqlConnection CONEXAO = new MySqlConnection(Vars.Cfg);



            if (
                true
                )
            {
                string anexoNome = "";
                if (anexo != "")
                {
                    try
                    {
                        using (var w = new WebClient())
                        {
                            /*string clientID = "7596799570c2677";
                             * w.Headers.Add("Authorization", "Client-ID " + clientID);
                             * var values = new NameValueCollection
                             * {
                             *  { "image", Convert.ToBase64String(File.ReadAllBytes(anexo)) }
                             * };
                             * byte[] response = w.UploadValues("https://api.imgur.com/3/upload.xml", values);
                             * XmlDocument doc = new XmlDocument();
                             * Stream stream = new MemoryStream(response);
                             * var document = XDocument.Load(stream);
                             * var arr = document.Descendants("link").Select(x => (string)x).ToArray();
                             * anexoNome = arr[0];*/

                            System.Net.WebClient Client = new System.Net.WebClient();
                            Client.Headers.Add("Content-Type", "binary/octet-stream");
                            byte[] result = Client.UploadFile("http://localhost/upload.php", "POST", anexo);
                            String s      = System.Text.Encoding.UTF8.GetString(result, 0, result.Length);
                            anexoNome = "http://localhost/upload/" + s;
                        }
                    }
                    catch (Exception erro)
                    {
                        if (Properties.Settings.Default.permInt == 3 || Properties.Settings.Default.permInt == 9)
                        {
                            MessageBox.Show("Houve um erro no Imgur:\r\n" + erro.Message);
                        }
                    }
                }
                Vars.atualizarData();
                string data = Vars.ano + "-" + Vars.mes + "-" + Vars.dia + " " + Vars.hora + ":" + Vars.minuto + ":" + Vars.segundo;

                if (!Properties.Settings.Default.phpLocal)
                {
                    try
                    {
                        MySqlCommand enviar = new MySqlCommand("INSERT INTO licoes VALUES (null, @Licao, @Resumo, @DiaEntrega, @MesEntrega, @AdicionadoPor, @AdicionadoEm, @Sala, @Disc, '" + anexoNome + "', @Avaliado)", CONEXAO);
                        CONEXAO.Open();
                        enviar.Parameters.AddWithValue("@Licao", txtTarefa.Text);
                        enviar.Parameters.AddWithValue("@Resumo", txtResumo.Text);
                        enviar.Parameters.AddWithValue("@AdicionadoEm", data);
                        enviar.Parameters.AddWithValue("@Avaliado", Properties.Settings.Default.permInt);
                        if (Properties.Settings.Default.permInt == 2)
                        {
                            checarSelec();
                        }
                        enviar.Parameters.AddWithValue("@Disc", Vars.discSelec);
                        if (Vars.diaSelec != "")
                        {
                            enviar.Parameters.AddWithValue("@DiaEntrega", Vars.diaSelec);
                            enviar.Parameters.AddWithValue("@MesEntrega", Vars.mesSelec);
                        }
                        else
                        {
                            enviar.Parameters.AddWithValue("@DiaEntrega", Vars.diaSelec);
                            enviar.Parameters.AddWithValue("@MesEntrega", Vars.mesSelec);
                        }
                        if (Properties.Settings.Default.permInt == 2)
                        {
                            enviar.Parameters.AddWithValue("@AdicionadoPor", "Professor(a) " + Properties.Settings.Default.nome);
                            enviar.Parameters.AddWithValue("@Sala", Vars.addSalaSelec(cbTurma));
                        }
                        else
                        {
                            enviar.Parameters.AddWithValue("@AdicionadoPor", Properties.Settings.Default.nome);
                            enviar.Parameters.AddWithValue("@Sala", Properties.Settings.Default.codSala);
                        }
                        enviar.ExecuteNonQuery();
                        CONEXAO.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);
                        }
                    }
                    finally
                    {
                        CONEXAO.Close();
                        MessageBox.Show("Tarefa Cadastrada!");
                        //this.Close();
                    }
                }
                else
                {
                    WebClient kj = new WebClient();
                    kj.Encoding = System.Text.Encoding.UTF8;
                    string nome = Properties.Settings.Default.nome;
                    if (Properties.Settings.Default.permInt == 2)
                    {
                        nome = "Professor(a) " + Properties.Settings.Default.nome;
                    }
                    string licao  = txtTarefa.Text;
                    string resumo = txtResumo.Text;
                    if (Properties.Settings.Default.permInt == 2)
                    {
                        checarSelec();
                    }
                    string disc    = Vars.discSelec;
                    int    codSala = 0;
                    if (Properties.Settings.Default.permInt == 2)
                    {
                        codSala = Vars.addSalaSelec(cbTurma);
                    }
                    else
                    {
                        codSala = Properties.Settings.Default.codSala;
                    }
                    MessageBox.Show("http://" + Vars.cfgPhp + "/add/addLicao.php?nome=" + nome + "&licao=" + licao + "&resumo=" + resumo
                                    + "&dia=" + Vars.diaSelec + "&mes=" + Vars.mesSelec + "&codSala=" + codSala.ToString() + "&data=" + data + "&disc=" + disc + "&anexo=" + anexoNome + "&aval=" +
                                    Properties.Settings.Default.permInt);
                    string resultado = kj.DownloadString("http://" + Vars.cfgPhp + "/add/addLicao.php?nome=" + nome + "&licao=" + licao + "&resumo=" + resumo
                                                         + "&dia=" + Vars.diaSelec + "&mes=" + Vars.mesSelec + "&codSala=" + codSala.ToString() + "&data=" + data + "&disc=" + disc + "&anexo=" + anexoNome + "&aval=" +
                                                         Properties.Settings.Default.permInt).Trim();
                    if (resultado[0] == '1')
                    {
                        MessageBox.Show("Tarefa Cadastrada!");
                    }
                    else
                    {
                        MessageBox.Show("Ocorreu um erro...");
                    }
                }
            }
            else
            {
#pragma warning disable CS0162 // Código inacessível detectado
                MessageBox.Show("Existem campos vazios!");
#pragma warning restore CS0162 // Código inacessível detectado
            }
        }
 private void panel2_Resize(object sender, EventArgs e)
 {
     Vars.resize(label1);
 }
예제 #3
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            int solicPerm = 0;

            if (rbRep.Checked == true)
            {
                solicPerm = 1;
            }
            if (rbProf.Checked == true)
            {
                solicPerm = 2;
            }

            //int contasNoIp = 0;


            if (txtUsuario.Text != "" && txtNome.Text != "" && txtSenha.Text != "" && cbSala.selectedValue != "Sua sala:" &&
                txtEmail.Text != "" && txtEmail.Text.Contains("@") && txtSenha.Text == txtSenha2.Text)
            {
                MySqlConnection CONEXAO = new MySqlConnection(Vars.Cfg);
                try
                {
                    MySqlCommand registrar   = new MySqlCommand("INSERT INTO login VALUES (null, @Nome, @Usuario, @Senha, @Sala, @Cadastro, 0, @SolicPerm, @IP, null, @Email)", CONEXAO);
                    MySqlCommand checarSalas = new MySqlCommand("SELECT * FROM info_salas", CONEXAO);

                    try
                    {
                        CONEXAO.Open();

                        MySqlDataReader lerSalas = checarSalas.ExecuteReader();

                        while (lerSalas.Read())
                        {
                            if (cbSala.selectedValue == lerSalas["nome_sala"].ToString())
                            {
                                registrar.Parameters.AddWithValue("@Sala", lerSalas["cod_sala"]);
                            }
                        }
                        lerSalas.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);
                        }
                    }
                    finally
                    {
                        CONEXAO.Close();
                    }

                    CONEXAO.Open();
                    registrar.Parameters.AddWithValue("@Nome", txtNome.Text);
                    registrar.Parameters.AddWithValue("@Usuario", txtUsuario.Text);
                    registrar.Parameters.AddWithValue("@Senha", txtSenha.Text);
                    Vars.atualizarData();
                    registrar.Parameters.AddWithValue("@Cadastro", Vars.ano + "-" + Vars.mes + "-" + Vars.dia + " " + Vars.hora + ":" + Vars.minuto + ":" + Vars.segundo);
                    registrar.Parameters.AddWithValue("@SolicPerm", solicPerm.ToString());
                    registrar.Parameters.AddWithValue("@IP", Properties.Settings.Default.ip);
                    registrar.Parameters.AddWithValue("@Email", txtEmail.Text);
                    registrar.ExecuteNonQuery();
                    CONEXAO.Close();
                    MessageBox.Show("Registrado!");
                }

                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);
                    }
                }

                finally
                {
                    CONEXAO.Close();
                }
            }
            else
            {
                MessageBox.Show("Existem campos vazios!");
            }
        }
예제 #4
0
 private void panel1_Resize(object sender, EventArgs e)
 {
     Vars.resize(lblDiaa);
 }
예제 #5
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            Vars.atualizarData();
            string data = Vars.ano + "-" + Vars.mes + "-" + Vars.dia + " " + Vars.hora + ":" + Vars.minuto + ":" + Vars.segundo;
            if (!Properties.Settings.Default.phpLocal)
                    {
            MySqlConnection CONEXAO = new MySqlConnection(Vars.Cfg);
            try
            {
                MySqlCommand enviar = new MySqlCommand("INSERT INTO avisos VALUES (null, @Aviso, @Sala, @Nome, @Data, 0)", CONEXAO);
                enviar.Parameters.AddWithValue("@Aviso", txtAviso.Text);
                enviar.Parameters.AddWithValue("@Data", data);
                if (Properties.Settings.Default.permInt == 2)
                {
                    enviar.Parameters.AddWithValue("@Nome", "Professor(a) " + Properties.Settings.Default.nome);
                    enviar.Parameters.AddWithValue("@Sala", Vars.addSalaSelec(cbTurma));
                }
                else
                {
                    enviar.Parameters.AddWithValue("@Nome", Properties.Settings.Default.nome);
                    enviar.Parameters.AddWithValue("@Sala", Properties.Settings.Default.codSala);
                }
                CONEXAO.Open();
                enviar.ExecuteNonQuery();
            }

            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);
            }

            finally
            {
                CONEXAO.Close();
                iniciarBw();
            }
                    }
            else
            {
                WebClient kj = new WebClient();
                kj.Encoding = System.Text.Encoding.UTF8;
                string nome = Properties.Settings.Default.nome;
                if (Properties.Settings.Default.permInt == 2)
                    nome = "Professor(a) " + Properties.Settings.Default.nome;
                string disc = Vars.discSelec;
                int codSala = 0;
                if (Properties.Settings.Default.permInt == 2)
                    codSala = Vars.addSalaSelec(cbTurma);
                else
                    codSala = Properties.Settings.Default.codSala;

                string resultado = kj.DownloadString("http://" + Vars.cfgPhp + "/avisos/addAviso.php?nome=" + nome + "&aviso=" + txtAviso.Text + "&sala=" + codSala.ToString() + "&data=" + data).Trim();
                if (resultado[0] == '1')
                {
                    MessageBox.Show("Aviso Cadastrado!");
                    iniciarBw();
                }
                else
                    MessageBox.Show("Ocorreu um erro...");
            }
        }
예제 #6
0
 private void tableLayoutPanel3_Resize(object sender, EventArgs e)
 {
     Vars.resize(label4);
 }
예제 #7
0
 private void btnVoltar_Resize(object sender, EventArgs e)
 {
     Vars.resize((Control)sender);
 }
예제 #8
0
 private void panel3_Resize(object sender, EventArgs e)
 {
     Vars.resize(txtUser);
 }
예제 #9
0
 private void panel4_Resize(object sender, EventArgs e)
 {
     Vars.resize(txtPass);
 }
예제 #10
0
 private void panel8_Resize(object sender, EventArgs e)
 {
     Vars.resize(lblVersao);
 }
예제 #11
0
 private void lblTit_Resize(object grr, EventArgs e)
 {
     Vars.resize(lblTit);
 }
예제 #12
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            Invoke(new Action(() =>
            {
                if (txtPass.Text != "" || txtUser.Text != "")
                {
                    if (!Properties.Settings.Default.phpLocal)
                    {
                        string login             = "******";
                        MySqlConnection CONEXAO  = new MySqlConnection(Vars.Cfg);
                        MySqlCommand checarLogin = new MySqlCommand(login, CONEXAO);
                        checarLogin.Parameters.AddWithValue("@Usuario", txtUser.Text);
                        checarLogin.Parameters.AddWithValue("@Senha", txtPass.Text);
                        try
                        {//////
                            CONEXAO.Open();
                            int cod = Convert.ToInt32(checarLogin.ExecuteScalar());

                            if (cod > 0)
                            {
                                Vars.af.carregando.Show();
                                MySqlDataReader logar = checarLogin.ExecuteReader();

                                while (logar.Read())
                                {
                                    Properties.Settings.Default.senha   = txtPass.Text;
                                    Properties.Settings.Default.cod     = logar["cod_login"].ToString();
                                    Properties.Settings.Default.nome    = logar["nome_login"].ToString();
                                    Properties.Settings.Default.usuario = logar["usuario_login"].ToString();
                                    Properties.Settings.Default.codSala = Convert.ToInt32(logar["sala_login"]);
                                    Properties.Settings.Default.sala    = logar["nome_sala"].ToString();
                                    Properties.Settings.Default.permInt = Convert.ToInt32(logar["perm_login"]);
                                    Vars.checarPermissao();
                                    Properties.Settings.Default.Save();

                                    /*if (logar["aval_login"].ToString() == "")
                                     * {
                                     *  af.timer1.Enabled = true;
                                     * }*/
                                }
                                logar.Close();
                                txtUser.Text = "";
                                txtPass.Text = "";
                                Vars.logado  = true;

                                Vars.af.sideBar.BackColor         = Vars.corFundoSide;
                                Vars.af.btnInicio.Normalcolor     = Vars.corFundoSide;
                                Vars.af.btnHorario.Normalcolor    = Vars.corFundoSide;
                                Vars.af.btnCalendario.Normalcolor = Vars.corFundoSide;
                                Vars.af.btnTurmas.Normalcolor     = Vars.corFundoSide;
                                Vars.af.btnCfg.Normalcolor        = Vars.corFundoSide;
                                Vars.af.panel1.Enabled            = true;
                                if (Properties.Settings.Default.permInt == 2)
                                {
                                    Vars.af.btnHorario.Enabled = false;
                                    Vars.af.btnHorario.Cursor  = Cursors.Default;
                                }
                                else
                                {
                                    Vars.af.btnHorario.Enabled = true;
                                    Vars.af.btnHorario.Cursor  = Cursors.Hand;
                                }

                                if (Properties.Settings.Default.permInt < 1)
                                {
                                    Vars.af.btnCfg.Enabled = false;
                                    Vars.af.btnCfg.Cursor  = Cursors.Default;
                                }
                                else
                                {
                                    Vars.af.btnCfg.Enabled = true;
                                    Vars.af.btnCfg.Cursor  = Cursors.Hand;
                                }
                                this.Hide();
                                Vars.teste = (Panel)this.Parent;
                                Vars.af    = (Form1)Vars.teste.Parent;
                                Vars.af.bunifuFlatButton1_Click(Vars.af.btnInicio, null);
                            }
                            else
                            {
                                MessageBox.Show("Dados incorretos!");
                            }
                        }
                        catch (Exception erro)
                        {
                            if (Properties.Settings.Default.permInt == 3 || Properties.Settings.Default.permInt == 9)
                            {
                                if (!erro.ToString().Contains("Null"))
                                {
                                    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 + "/login.php?user="******"&senha=" + txtPass.Text).Trim();
                        char[] delimiters = new char[] { ',' };
                        string[] codes    = resultado.Split(delimiters, StringSplitOptions.None);
                        //int i = 0;
                        Properties.Settings.Default.senha   = txtPass.Text;
                        Properties.Settings.Default.cod     = codes[0];
                        Properties.Settings.Default.nome    = codes[1];
                        Properties.Settings.Default.usuario = codes[2];
                        Properties.Settings.Default.codSala = Convert.ToInt32(codes[3]);
                        Properties.Settings.Default.sala    = codes[4];
                        Properties.Settings.Default.permInt = Convert.ToInt32(codes[6]);
                        Vars.checarPermissao();
                        Properties.Settings.Default.Save();
                        txtUser.Text = "";
                        txtPass.Text = "";
                        Vars.logado  = true;

                        Vars.af.sideBar.BackColor         = Vars.corFundoSide;
                        Vars.af.btnInicio.Normalcolor     = Vars.corFundoSide;
                        Vars.af.btnHorario.Normalcolor    = Vars.corFundoSide;
                        Vars.af.btnCalendario.Normalcolor = Vars.corFundoSide;
                        Vars.af.btnTurmas.Normalcolor     = Vars.corFundoSide;
                        Vars.af.btnCfg.Normalcolor        = Vars.corFundoSide;
                        Vars.af.panel1.Enabled            = true;
                        if (Properties.Settings.Default.permInt == 2)
                        {
                            Vars.af.btnHorario.Enabled = false;
                            Vars.af.btnHorario.Cursor  = Cursors.Default;
                        }
                        else
                        {
                            Vars.af.btnHorario.Enabled = true;
                            Vars.af.btnHorario.Cursor  = Cursors.Hand;
                        }

                        if (Properties.Settings.Default.permInt < 1)
                        {
                            Vars.af.btnCfg.Enabled = false;
                            Vars.af.btnCfg.Cursor  = Cursors.Default;
                        }
                        else
                        {
                            Vars.af.btnCfg.Enabled = true;
                            Vars.af.btnCfg.Cursor  = Cursors.Hand;
                        }
                        Vars.af.bunifuFlatButton1_Click(Vars.af.btnInicio, null);
                    }
                }
                else
                {
                    MessageBox.Show("Preencha todos os dados!");
                }
            }));
        }