public MV_Exception GuardarMunicipios(TBC_MUNICIPIO municipio, int idUsuario)
        {
            var result = new MV_Exception();

            try
            {
                result = H_LogErrorEXC.resultToException(_context.SP_TBC_MUNICIPIO_Insert(municipio.ID_DEPARTAMENTO,
                                                                                          municipio.COD_MUNICIPIO,
                                                                                          municipio.NOMBRE,
                                                                                          idUsuario).FirstOrDefault());
                if (result.IDENTITY == null)
                {
                    throw new Exception(result.ERROR_MESSAGE);
                }
            }
            catch (Exception e)
            {
                H_LogErrorEXC.GuardarRegistroLogError(e);
            }
            return(result);
        }
Exemple #2
0
        public void agregarMunicipio()
        {
            try
            {
                //Creamos la accion del departamento
                A_MUNICIPIO a_municipio = new A_MUNICIPIO();

                var id_departamento     = Request.Form["select_id_departamento"];
                var codigo_departamento = Request.Form["txt_codigo_municipio"];
                var nombre_departamento = Request.Form["txt_nombre_municipio"];

                if (string.IsNullOrWhiteSpace(codigo_departamento) || string.IsNullOrWhiteSpace(nombre_departamento) || string.IsNullOrWhiteSpace(id_departamento))
                {
                    errores = "Municipio no guardado. Los campos no puede estar vacíos ni contener solo espacios";
                    return;
                }

                //Construyendo Departamento
                TBC_MUNICIPIO municipio = new TBC_MUNICIPIO();
                municipio.ID_DEPARTAMENTO = int.Parse(Request.Form["select_id_departamento"]);
                municipio.COD_MUNICIPIO   = Request.Form["txt_codigo_municipio"];
                municipio.NOMBRE          = Request.Form["txt_nombre_municipio"];

                MV_Exception res = a_municipio.GuardarMunicipios(municipio, ((MV_DetalleUsuario)Session["usuario"]).ID_USUARIO);

                if (res.IDENTITY == null)
                {
                    throw new Exception(res.ERROR_MESSAGE);
                }

                municipio.ID_DEPARTAMENTO = int.Parse(res.IDENTITY.ToString());

                info = "Municipio agregado correctamente";
            }
            catch (Exception e)
            {
                errores = e.Message;
                H_LogErrorEXC.GuardarRegistroLogError(e);
            }
        }
        public MV_Exception editarMunicipios(TBC_MUNICIPIO municipio, int usuario_actualiza)
        {
            try
            {
                MV_Exception res = H_LogErrorEXC.resultToException(_context.SP_TBC_MUNICIPIO_Update(municipio.ID_MUNICIPIO,
                                                                                                    municipio.ID_DEPARTAMENTO,
                                                                                                    municipio.COD_MUNICIPIO,
                                                                                                    municipio.NOMBRE,
                                                                                                    usuario_actualiza).FirstOrDefault());

                if (res.IDENTITY == null)
                {
                    throw new Exception(res.ERROR_MESSAGE);
                }

                return(res);
            }
            catch (Exception)
            {
                throw;
            }
        }