public frmAvControlar(Usuario user) { InitializeComponent(); msmDia = true; ava = new Avaliacao(); status = "Todas"; ttbAluno.Enabled = false; ttbAvaliador.Enabled = false; chAllAluno.Checked = true; rbTodas.Checked = true; dtpFim.Value = DateTime.Today; dtpInicio.Value = DateTime.Today; func = new Funcionario(); alu = new Aluno(); this.user = user; chkPeriodo.Checked = true; atualizaInfo(); if (!user.hasPermissionField("escolher funcionário")) { isADM = false; func = func.getFuncByUser(user.Id); this.Text = "Agenda " + func.Nome; ttbAvaliador.Text = func.Nome; ava.FuncId = func.Id; gpbAvaliador.Enabled = false; gpbInfo.Visible = false; } else isADM = true; buscar(); }
private void btnConfirmar_Click(object sender, EventArgs e) { if (ttbAluno.Text == "") ttbAluno.BackColor = Color.Red; if (ttbModalidade.Text == "") ttbModalidade.BackColor = Color.Red; if (ttbAluno.Text != "" && ttbModalidade.Text != "") { mat.Obs = ttbObs.Text; mat.AluId = "" + aluno.Id; mat.ModId = mod.Id; mat.DtIni = DateTime.Today.ToShortDateString(); mat.QtdeDias = "" + ttbQtdeDias.Value; mat.DtVcmto = "" + ttbDtVcmto.Value; mat.Tolerancia = "" + ttbTolerancia.Value; if (mat.Id == "") { String lastId = mat.nova(); if (lastId != "") { MessageBox.Show("Matrícula efetuada com sucesso!", "Sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Information); if (mat.Tipo.Equals("m")) { if (MessageBox.Show("Deseja efetuar pagamento da primeira mensalidade agora?", "Mensalidade", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { new frmMensalidadePgmto(user, lastId).ShowDialog(); } catch { } } } if (ttbModalidade.Text.Equals("Musculação")) { if (MessageBox.Show("Deseja agendar avaliação física agora?", "Avaliação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { if (user.hasPermissionField("escolher funcionário")) new frmAgendaAvNova("", "", mat.AluId).ShowDialog(); else { Funcionario func = new Funcionario(); func = func.getFuncByUser(user.Id); new frmAgendaAvNova(func.Id, "", mat.AluId).ShowDialog(); } } catch { MessageBox.Show("Você não tem acesso a essa opção!", "Acesso não permitido!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } this.Close(); } else MessageBox.Show("Ocorreram problemas ao realizar a matrícula!", "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (chkEncerrar.Checked) { if (MessageBox.Show("Esta é uma operação irreversível! A matrícula não poderá mais ser reativada!", "Deseja realmente encerrar?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { mat.DtFim = DateTime.Today.ToShortDateString(); if (mat.atualiza()) { MessageBox.Show("Matrícula alterada com sucesso!", "Sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { mat.DtFim = ""; MessageBox.Show("Ocorreram problemas ao alterar a matrícula!", "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { if (mat.atualiza()) { MessageBox.Show("Matrícula alterada com sucesso!", "Sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else MessageBox.Show("Ocorreram problemas ao alterar a matrícula!", "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }