Beispiel #1
0
 // botao excluir
 private void btnExcluir_Click(object sender, RoutedEventArgs e)
 {
     try {
         MessageBoxResult resultado = MessageBox.Show("Tem certeza que deseja excluir o registro ? ", "Excluir",
                                                      MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (resultado == MessageBoxResult.Yes)
         {
             cr             = conexao.CONTAS_RECEBER.Remove(cr);
             cr.descricao   = null;
             cr.data_pagto  = null;
             cr.data_vencto = null;
             cr.vl_unitario = null;
             cr.vl_total    = null;
             conexao.SaveChanges();
             int?codigo = conexao.CONTAS_RECEBER.Max(a => (int?)a.codigo);
             Util.redefinirPK_AutoIncremento("CONTAS_RECEBER", codigo);
             MessageBox.Show("Registro excluido com sucesso!", "Excluir", MessageBoxButton.OK, MessageBoxImage.Exclamation);
             carregaGrid();
             limpaCampos();
             carregaPesquisa();
         }
         else
         {
             limpaCampos();
             return;
         }
         btnGravar.IsEnabled = true;
     }catch (Exception ex) {
         MessageBox.Show("Erro imprevisto ou campos vazios", "Erro", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Beispiel #2
0
 // botao pesquisar
 private void btnPesquisar_Click(object sender, RoutedEventArgs e)
 {
     btnGravar.IsEnabled = false;
     try {
         if (cbPesquisar.Text != null)
         {
             int codigo = int.Parse(cbPesquisar.Text.Substring(0, 4).Trim());
             cr                = conexao.CONTAS_RECEBER.Find(codigo);
             txtCodigo.Text    = cr.codigo.ToString();
             txtDescricao.Text = cr.descricao;
             dpPagto.Text      = cr.data_pagto.ToString();
             dpVencto.Text     = cr.data_vencto.ToString();
             txtUnitario.Text  = cr.vl_unitario.ToString();
             lblTotal.Content  = cr.vl_total.ToString();
         }
         else
         {
             MessageBox.Show("Registro não encontrado!", "Informação", MessageBoxButton.OK, MessageBoxImage.Information);
             limpaCampos();
         }
     }
     catch (Exception a) {
         MessageBox.Show("Campo vazio ou código invalido!" + "\n" + a.StackTrace, "Erro", MessageBoxButton.OK,
                         MessageBoxImage.Exclamation);
         limpaCampos();
     }
 }
Beispiel #3
0
        public async Task <ActionResult> CriarAdiantamento(CONTAS_RECEBER cr)
        {
            var ossb = await _db.OSSB
                       .FirstOrDefaultAsync(os => os.ID == cr.OSSB);

            if (ossb == null)
            {
                return(HttpNotFound());
            }

            _db.CONTAS_RECEBER.Add(cr);

            await _db.SaveChangesAsync();

            return(RedirectToAction("Index", "ContasReceber"));
        }
Beispiel #4
0
        public ActionResult Edit(CONTAS_RECEBER cr)
        {
            if (Session.IsFuncionario())
            {
                if (ModelState.IsValid)
                {
                    _db.Entry(cr).State = EntityState.Modified;

                    _db.SaveChanges();

                    return(RedirectToAction("Index", "ContasReceber"));
                }

                return(View(cr));
            }
            else
            {
                return(RedirectToAction("", ""));
            }
        }
        public async Task <ActionResult> Edit(CONTAS_RECEBER cr)
        {
            if (cr.DATA_RECEBIMENTO != null && cr.DATA_RECEBIMENTO < DateTime.Today.AddDays(-1))
            {
                ModelState.AddModelError("", "A data de recebimento não pode ser inferior a data atual.");
            }

            if (ModelState.IsValid)
            {
                _db.Entry(cr).State = EntityState.Modified;

                _db.SaveChanges();

                return(RedirectToAction("Index", "ContasReceber"));
            }


            ViewBag.CONTA_BANCARIA = new SelectList(await _db.CONTA_BANCARIA.Include(cb => cb.BANCO1).ToArrayAsync(), "ID", "DESCRICAO", cr.CONTA_BANCARIA);


            return(View(cr));
        }
Beispiel #6
0
        public async Task <ActionResult> MudarParaCobranca(CONTAS_RECEBER cr)
        {
            if (cr.DATA_RECEBIMENTO != null && cr.DATA_RECEBIMENTO < DateTime.Today.AddDays(-1))
            {
                return(Content("A data de recebimento não pode ser inferior a data atual."));
            }
            ;

            var ossb = await _db.OSSB
                       .FirstOrDefaultAsync(os => os.ID == cr.OSSB);

            if (ossb == null)
            {
                return(HttpNotFound());
            }

            ossb.SITUACAO = "K";

            _db.CONTAS_RECEBER.Add(cr);

            await _db.SaveChangesAsync();

            return(RedirectToAction("Index", "ContasReceber"));
        }