コード例 #1
0
 // GET: Estabelecimentos
 public ActionResult Index()
 {
     try
     {
         List <Estabelecimento> lista = EstabelecimentoDAL.Lista();
         return(View(lista));
     }
     catch (Exception e)
     {
         TempData["Status"] = e.Message;
         return(View());
     }
 }
コード例 #2
0
        // GET: Estabelecimentos/Details/5
        public ActionResult Details(int id)
        {
            Estabelecimento cadastro = EstabelecimentoDAL.Obter(id);

            if (cadastro.IDEstabelecimento != 0)
            {
                return(View(cadastro));
            }
            else
            {
                TempData["Status"]  = 1;
                TempData["Message"] = "Estabelecimento não encontrado";
                return(RedirectToAction("index"));
            }
        }
コード例 #3
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            Estabelecimento cadastro = EstabelecimentoDAL.Obter(id);

            if (cadastro != null)
            {
                Retorno retorno = EstabelecimentoDAL.Excluir(cadastro.IDEstabelecimento);
                TempData["Status"]  = retorno.IDRetorno;
                TempData["Message"] = retorno.Mensagem;

                if (retorno.IDRetorno == 1)
                {
                    return(View(cadastro));
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        public ActionResult Edit(Estabelecimento cadastro)
        {
            if (ModelState.IsValid)
            {
                Retorno retorno = EstabelecimentoDAL.Atualizar(cadastro);

                TempData["Status"]  = retorno.IDRetorno;
                TempData["Message"] = retorno.Mensagem;

                if (retorno.IDRetorno == 1)
                {
                    ViewBagCategoria();
                    return(View(cadastro));
                }
            }

            return(RedirectToAction("index"));
        }
コード例 #5
0
        public JsonResult ProcessarArquivo()
        {
            var model = new ArquivosEstabelecimentos();

            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];


                if (file != null && file.ContentLength > 0)
                {
                    try
                    {
                        model.ds_arquivo = file.FileName;

                        var    arquivo    = new ConciliacaoArquivoManipular(new StreamReader(file.InputStream));
                        String first_line = arquivo.LerLinha(true);



                        bool   md5_encontrado = false;
                        string lsArquivomd5   = "";
                        string is_linha_atual = "";
                        var    i = 0;
                        while ((is_linha_atual = arquivo.LerLinha()) != null)
                        {
                            i++;
                            if (i > 500)
                            {
                                break;
                            }
                            lsArquivomd5 = lsArquivomd5 + is_linha_atual;
                        }

                        arquivo.Seek(0);
                        string     lsretornomd5 = CriarMD5.RetornarMD5(lsArquivomd5);
                        var        conta        = new BaseID();
                        ArquivoMD5 md5          = DAL.GetObjeto <ArquivoMD5>(string.Format("arquivo_md5='{0}' and id_conta={1}", lsretornomd5, conta.IdConta)) ?? new ArquivoMD5();
                        if (md5.arquivo_md5.Equals(""))
                        {
                            md5.arquivo_md5 = lsretornomd5;
                        }
                        else
                        {
                            md5_encontrado = true;
                        }

                        var bancario = new ConciliacaoEstabelecimentoDesmontar(arquivo, first_line);

                        model.ArquivoEstabelecimento = bancario.GetListTransacaoEstabelecimento();
                        if (!md5_encontrado)
                        {
                            DAL.GravarList(model.ArquivoEstabelecimento);
                            EstabelecimentoDAL.ExcluirDuplicados(Convert.ToInt32(UsuarioLogado.IdConta));
                            DAL.Gravar(md5);
                        }
                        ViewBag.BotaoProcessar = "Gravar";
                    }
                    catch (Exception ex)
                    {
                        this.AddNotification(ex.Message, NotificationType.Erro);
                    }
                }
            }
            var result = Json(model, JsonRequestBehavior.AllowGet);

            result.MaxJsonLength = int.MaxValue;
            return(result);
        }