コード例 #1
0
ファイル: AlteraAula.cs プロジェクト: Kyoro93/GestaoDeAulas
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            string strNovoHorario   = cbbHorario.Text;
            string strNovoProfessor = cbbProfessor.Text;
            string strNovaTurma     = cbbTurma.Text.Split('/')[0];
            string strNovoBloco     = cbbTurma.Text.Split('/')[1];
            string strNovoConteudo  = rtbConteudo.Text;
            string strNovaData      = mtcCalendario.SelectionStart.ToString("yyyy-MM-dd H:mm:ss");

            if (!(strNovoHorario.Equals(strAntigoHorario) &&
                  strNovoProfessor.Equals(strAntigoProfessor) &&
                  strNovaTurma.Equals(strAntigaTurma) &&
                  strNovoBloco.Equals(strAntigoBloco) &&
                  strNovoConteudo.Equals(strAntigoConteudo) &&
                  strNovaData.Equals(strAntigaData)))
            {
                try
                {
                    ConexaoMySQL conn   = new ConexaoMySQL();
                    bool         result = conn.UpdateAula(strNovoHorario, strNovoProfessor, strNovaTurma, strNovoBloco, strNovoConteudo, strNovaData, this.intIDAula);

                    if (!result)
                    {
                        MessageBox.Show("Erro ao atualizar.");
                    }
                    else
                    {
                        MessageBox.Show("Alterado com sucesso.");
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this.Name + " - Error: " + ex.Message);
                }
            }
            else
            {
                this.Close();
            }
        }