コード例 #1
0
        /************************************************ Alterar Estabelecimento  ************************************************/
        public ActionResult AlterarEstabelecimento(Int32 ID)
        {
            if (Request.HttpMethod.Equals("POST"))
            {
                try
                {
                    Estabelecimento ES = new Estabelecimento();
                    ES.razaoSocial     = Request.Form["razaoSocial"].ToString();
                    ES.nomeFantasia    = Request.Form["nomeFantasia"].ToString();
                    ES.CNPJ            = Request.Form["CNPJ"].ToString();
                    ES.Status.idStatus = Convert.ToInt32(Request.Form["status"].ToString());

                    Endereco EN = new Endereco();
                    EN.Cidade.id_UF    = Convert.ToInt32(Request.Form["UF"].ToString());
                    EN.idEndereco      = Convert.ToInt32(Request.Form["idEndereco"].ToString());
                    EN.Cidade.idCidade = Convert.ToInt32(Request.Form["idCidade"].ToString());
                    EN.Logradouro      = Request.Form["logradouro"].ToString();

                    Conta CO = new Conta();
                    CO.Conta_  = Request.Form["conta"].ToString();
                    CO.Agencia = Request.Form["agencia"].ToString();

                    Categoria CA = new Categoria();
                    CA.id_Categoria = Convert.ToInt32(Request.Form["categoria"].ToString());

                    /***CADASTRA DE FATO***/
                    try
                    {
                        EN.AlteraEndereco(EN.idEndereco);
                        ES.AlterarEstabelecimento(ID);
                        CA.AlterarCategoria(ID);
                        CO.AlterarConta(ID);
                        ViewBag.Sucesso  = true;
                        ViewBag.Mensagem = "Informações alteradas com sucesso.";
                    }
                    catch
                    {
                        ViewBag.Mensagem = "Erro durante o cadastro.";
                        ViewBag.Erro     = true;
                        return(View());
                    }
                }
                catch
                {
                    ViewBag.Alerta   = true;
                    ViewBag.Mensagem = "Verifique se todos os campos Obrigatórios foram preenchidos.";
                    return(View());
                }
            }
            return(RedirectToAction("DetalhesEstabelecimento", "Estabelecimento", new { @id = ID }));
        }