示例#1
0
        //CRUD

        public void Salvar(decimal valorInserido, int idCategoria, string descricaoInserida)
        {
            try
            {
                //sbyte tipoTransacao, bool debitada
                using (var bd = new granamizaEntities())
                {
                    //Salvar.
                    DateTime dt      = DateTime.Now;
                    int      user_id = Sessao.IdUsuario;

                    //Preencher os dados da categoria.
                    transacao tr = new transacao
                    {
                        valor          = valorInserido,
                        categoria_id   = idCategoria,
                        descricao      = descricaoInserida,
                        tipo_transacao = 0,
                        debitada       = false,
                        hora_insercao  = dt.Hour.ToString() + ":" + dt.Minute.ToString(),
                        data_insercao  = dt.Day.ToString() + "/" + dt.Month + "/" + dt.Year,
                        data_criacao   = dt,
                        usuario_id     = user_id,
                    };
                    //Adicionar Transacao
                    bd.transacao.Add(tr);
                    bd.SaveChanges();
                }
            }

            catch
            {
                _ = new FrmPopupErro();
            }
        }
示例#2
0
        private void BtnSalvar_Click(object sender, RoutedEventArgs e)
        {
            switch (tras)
            {
            case transacao.Novo:
                ProfessorEnt prof = new ProfessorEnt
                {
                    id_prof         = 0,
                    professor       = txtProf.Text,
                    login           = "",
                    tipo_de_usuario = "",
                    senha           = ""
                };
                CadastrarProfessor(ref prof);
                tras = transacao.Indefinido;
                break;

            case transacao.Alterar:
                ProfessorEnt profe = new ProfessorEnt
                {
                    id_prof         = Professores[LsBx.SelectedIndex].id_prof,
                    professor       = Professores[LsBx.SelectedIndex].professor,
                    tipo_de_usuario = Professores[LsBx.SelectedIndex].tipo_de_usuario,
                    login           = Professores[LsBx.SelectedIndex].login,
                    senha           = Professores[LsBx.SelectedIndex].senha,
                };
                AlterarProfessor(ref profe);
                tras = transacao.Indefinido;
                break;
            }
        }
示例#3
0
        public void Atualizar(int idTransacao, decimal valor, int idCategoria, string descricao)
        {
            try
            {
                using (var bd = new granamizaEntities())
                {
                    transacao tr = (from c in bd.transacao
                                    where c.id == idTransacao
                                    select c).FirstOrDefault();
                    if (tr != null)
                    {
                        tr.valor        = valor;
                        tr.descricao    = descricao;
                        tr.categoria_id = idCategoria;
                    }

                    bd.SaveChanges();
                }
            }

            catch
            {
                _ = new FrmPopupErro();
            }
        }
示例#4
0
 void limpa()
 {
     tras = transacao.Indefinido;
     txtProf.IsEnabled     = false;
     BtnSalvar.IsEnabled   = false;
     BtnCancelar.IsEnabled = false;
     txtProf.Text          = "";
 }
示例#5
0
 private void btnNovo_Click(object sender, RoutedEventArgs e)
 {
     if (tras == transacao.Indefinido)
     {
         tras = transacao.Novo;
         txtProf.IsEnabled     = true;
         BtnSalvar.IsEnabled   = true;
         BtnCancelar.IsEnabled = true;
         txtProf.Text          = "";
         txtProf.Focus();
     }
 }
示例#6
0
        void onIdefinido()
        {
            tras                  = transacao.Indefinido;
            cbano.IsEnabled       = true;
            txtTurma.IsEnabled    = false;
            cbserie.IsEnabled     = false;
            cbNivel.IsEnabled     = false;
            cbturno.IsEnabled     = false;
            cbprofessor.IsEnabled = false;

            BtnSalvar.IsEnabled   = false;
            BtnCancelar.IsEnabled = false;
        }
示例#7
0
        private void btnAlterar_Click(object sender, RoutedEventArgs e)
        {
            if (tras == transacao.Indefinido)
            {
                tras = transacao.Alterar;
                txtProf.IsEnabled     = true;
                BtnSalvar.IsEnabled   = true;
                BtnCancelar.IsEnabled = true;

                txtProf.Text = LsBx.Items[LsBx.SelectedIndex].ToString();
                txtProf.Focus();
            }
        }
示例#8
0
        //Transacoes possimeis=========================
        private void onAlterar()
        {
            tras            = transacao.Alterar;
            cbano.IsEnabled = false;

            txtTurma.IsEnabled = true;

            txtTurma.Focus();
            cbserie.IsEnabled     = true;
            cbNivel.IsEnabled     = true;
            cbturno.IsEnabled     = true;
            cbprofessor.IsEnabled = true;

            BtnSalvar.IsEnabled   = true;
            BtnCancelar.IsEnabled = true;
        }
示例#9
0
        void onNovo()
        {
            tras               = transacao.Novo;
            cbano.IsEnabled    = false;
            txtTurma.IsEnabled = true;
            txtTurma.Text      = "";
            txtTurma.Focus();
            cbserie.IsEnabled     = true;
            cbNivel.IsEnabled     = true;
            cbturno.IsEnabled     = true;
            cbprofessor.IsEnabled = true;

            BtnSalvar.IsEnabled       = true;
            BtnCancelar.IsEnabled     = true;
            cbNivel.SelectedIndex     = 0;
            cbserie.SelectedIndex     = 0;
            cbturno.SelectedIndex     = 0;
            cbprofessor.SelectedIndex = 0;
        }
示例#10
0
        public void Excluir(int idTransacao)
        {
            try
            {
                using (var bd = new granamizaEntities())
                {
                    transacao tr = (from c in bd.transacao
                                    where c.id == idTransacao
                                    select c).FirstOrDefault();
                    if (tr != null)
                    {
                        bd.transacao.Remove(tr);
                    }

                    bd.SaveChanges();
                }
            }
            catch
            {
                _ = new FrmPopupErro();
            }
        }
示例#11
0
        public void Pagar(int idTransacao)
        {
            try
            {
                using (var bd = new granamizaEntities())
                {
                    transacao tr = (from c in bd.transacao
                                    where c.id == idTransacao
                                    select c).FirstOrDefault();
                    //Testar se encontrou.
                    if (tr != null)
                    {
                        tr.debitada = true;
                        bd.SaveChanges();
                    }
                }
            }

            catch
            {
                _ = new FrmPopupErro();
            }
        }
示例#12
0
        void AlterarProfessor(ref ProfessorEnt prof)
        {
            tras = transacao.Alterar;
            string mesg = "";

            prof.professor = txtProf.Text;
            RetornosDoModel ret = turmas.AlterarProfessor(ref prof, ref mesg);

            if (ret == RetornosDoModel.Erro)
            {
                MessageBox.Show(mesg);
            }
            else if (ret == RetornosDoModel.Existe)
            {
                MessageBox.Show(mesg);
            }
            else
            {
                int i = LsBx.SelectedIndex;
                Professores[i] = prof;
                LsBx.Items[i]  = prof.professor;
            }
        }
示例#13
0
 private void onDeletar()
 {
     tras = transacao.Deletar;
     MessageBox.Show("Sugiro que faça a edição de um turma cadastrada, caso presize realmente deletar\n contate o desenvolvedor");
 }
示例#14
0
 private void btnDeletar_Click(object sender, RoutedEventArgs e)
 {
     onDeletar();
     tras = transacao.Indefinido;
 }