示例#1
0
        public async Task <IActionResult> Delete([FromBody] Periodos value)
        {
            try
            {
                await _repository.Delete(value);
            }
            catch (Exception ex)
            {
                // Guardar Excepción
                return(BadRequest(ex));
            }

            return(Ok());
        }
示例#2
0
        public async Task <IActionResult> Put([FromBody] Periodos value)
        {
            try
            {
                await _repository.Update(value);
            }
            catch (Exception ex)
            {
                // Guardar Excepción
                return(BadRequest(ex.Message.ToString()));
            }

            return(Ok());
        }
        public HttpResponseMessage Update(Periodos periodos)
        {
            var resultado = new HttpResponseMessage(HttpStatusCode.OK);

            var query = db.Periodos.Single(P => P.Id == periodos.Id);

            query.Codigo        = periodos.Codigo;
            query.Descripcion   = periodos.Descripcion;
            query.FechaApertura = periodos.FechaApertura;
            query.FechaCierre   = periodos.FechaCierre;
            db.SaveChanges();

            return(resultado);
        }
示例#4
0
        // GET: Periodos/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Periodos periodos = db.Periodos.Find(id);

            if (periodos == null)
            {
                return(HttpNotFound());
            }
            return(View(periodos));
        }
示例#5
0
 public void Remove(int id)
 {
     try
     {
         Periodos razonsocial = db.PeriodoAnuncios.Find(id);
         razonsocial.estado          = false;
         db.Entry(razonsocial).State = EntityState.Modified;
         db.SaveChanges();
         ViewInfoMensaje.setMensaje(controller, MensajeBuilder.BorrarMsgSuccess(entidad), Helpers.InfoMensajes.ConstantsLevels.SUCCESS);
     }
     catch (Exception)
     {
         ViewInfoMensaje.setMensaje(controller, MensajeBuilder.BorrarMsgError(entidad), Helpers.InfoMensajes.ConstantsLevels.ERROR);
     }
 }
        public List <Periodos> ActualizarModelo(string id, string cambio, string p)
        {
            List <Periodos>      periodos = new List <Periodos>();
            List <PeriodosModel> datos    = ConnectGET();
            List <Periodos>      datitos  = new List <Periodos>();

            foreach (PeriodosModel t in datos)
            {
                Periodos txt = new Periodos();
                datitos.Add(txt.CargarDatosNuevos(t));
            }

            if (datitos != null)
            {
                foreach (Periodos t in datitos)
                {
                    if (t.Numero.Equals(id))
                    {
                        if (p.Equals("FechaInicial"))
                        {
                            t.FechaInicial = DateTime.Parse(cambio);
                        }
                        else if (p.Equals("FechaFinal"))
                        {
                            t.FechaFinal = DateTime.Parse(cambio);
                        }
                        else if (p.Equals("Activo"))
                        {
                            if (cambio.Equals("0"))
                            {
                                t.activo = "Si";
                            }
                            else
                            {
                                t.activo = "No";
                            }
                        }
                    }

                    periodos.Add(t);
                }
                return(periodos);
            }
            else
            {
                return(periodos);
            }
        }
示例#7
0
        public async Task Delete(Periodos value)
        {
            using (SqlConnection conn = new SqlConnection(_cnx))
            {
                using (SqlCommand cmd = new SqlCommand("Wsp_EliminaPeriodo", conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@pIdPeriodo", value.IdPeriodo));
                    await conn.OpenAsync();

                    await cmd.ExecuteNonQueryAsync();

                    return;
                }
            }
        }
示例#8
0
 public Periodos GetPeriodos()
 {
     try
     {
         Periodos result = EM.GetPeriodos();
         return(result);
     }
     catch (Exception ex)
     {
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)
         {
             Content      = new StringContent(string.Format("Error: {0}", ex.Message)),
             ReasonPhrase = (ex.GetType() == typeof(ArgumentException) ? ex.Message : "Get_Error")
         });
     }
 }
示例#9
0
        private void dateTimePickerFechaFinal_ValueChanged(object sender, EventArgs e)
        {
            Periodos periodo = (Periodos)Convert.ToInt32(comboPeriodo.SelectedValue);

            if (periodo == Periodos.Manual)
            {
                if (dateTimePickerFechaInicio.Value > dateTimePickerFechaFinal.Value)
                {
                    MessageBox.Show("La fecha de inicio no puede ser mayor que la fecha final", "Fechas incorrectas", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    dateTimePickerFechaFinal.Value = dateTimePickerFechaInicio.Value;
                }
                else
                {
                    CargarDatos();
                }
            }
        }
        public HttpResponseMessage Create(Periodos periodo)
        {
            var resultado = new HttpResponseMessage(HttpStatusCode.OK);


            var StatuPendienteAbrirId = (from S in db.Statuses
                                         where S.Codigo == Constante.Statuses.PendienteAbrir
                                         select S.Id).FirstOrDefault();

            periodo.EstaActivo = false;
            periodo.StatusId   = StatuPendienteAbrirId;


            db.Periodos.Add(periodo);
            db.SaveChanges();

            return(resultado);
        }
        public ActionResult Crear(Periodos periodo)
        {
            ModelPeriodosPot temp = new ModelPeriodosPot();

            temp.cargarDatosNuevos(periodo);

            string res = api.ConnectPOST(temp.ToJsonString(), "/Periodos");

            if (res.Equals("1"))
            {
                return(RedirectToAction("Periodos", "Periodos"));
            }
            else
            {
                ViewBag.opciones = cargarOpcionesModificar();
                ViewBag.error    = res;
                return(View());
            }
        }
示例#12
0
        public int ActualizarPeriodo(int idPeriodo, string numero, DateTime FechaInicio, DateTime FechaFinal, bool activo)
        {
            try
            {
                Periodos periodo = entities.Periodos.First <Periodos>(x => x.idPeriodo == idPeriodo);
                periodo.Numero      = numero;
                periodo.FechaInicio = FechaInicio;
                periodo.FechaFinal  = FechaFinal;
                periodo.activo      = activo;

                entities.Entry(periodo).State = EntityState.Modified;

                return(entities.SaveChanges());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#13
0
        public async Task Insert(Periodos value)
        {
            using (SqlConnection conn = new SqlConnection(_cnx))
            {
                using (SqlCommand cmd = new SqlCommand("Wsp_InsertaPeriodo", conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@pFechaInicio", value.FechaInicio));
                    cmd.Parameters.Add(new SqlParameter("@pFechaFin", value.FechaFin));
                    cmd.Parameters.Add(new SqlParameter("@pNombre", value.Nombre));
                    cmd.Parameters.Add(new SqlParameter("@pDescripcion", value.Descripcion));
                    cmd.Parameters.Add(new SqlParameter("@pRegCreateIdUsuario", value.RegCreateIdUsuario));
                    await conn.OpenAsync();

                    await cmd.ExecuteNonQueryAsync();

                    return;
                }
            }
        }
示例#14
0
 public Periodos GetPeriodos()
 {
     try
     {
         connection = new SqlServerConnection();
         var obj = new Periodos();
         obj.periodos = new List <Periodo>();
         obj.periodos = connection.GetArray <Periodo>("spGetPeriodos", null, System.Data.CommandType.StoredProcedure).ToList();
         return(obj);
     }
     catch (Exception ex)
     {
         throw;
     }
     finally
     {
         connection.Close();
         connection = null;
     }
 }
示例#15
0
        public override double consultaVolume(string pairName, Periodos periodo)
        {
            String url       = this.BaseUrl + "v1/stats/" + pairName;
            String resultado = Requests.getRequest(url);



            resultado = Regex.Replace(resultado, "\\[", "");
            resultado = Regex.Replace(resultado, "\"", "");
            resultado = Regex.Replace(resultado, "]", "");
            resultado = Regex.Replace(resultado, "{", "");

            List <String> teste = new List <String>(Regex.Split(resultado, "},"));

            foreach (String t in teste)
            {
                Console.WriteLine(Regex.Replace(t, "}", ""));
            }
            //Terminar aqui, verificar a possibilidade de usar uma lib para JSon
        }
示例#16
0
        public PeriodosDTO Find(int?id)
        {
            try
            {
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <Periodos, PeriodosDTO>();
                });

                IMapper mapper = config.CreateMapper();
                //Mapeo de clase
                Periodos    model    = db.PeriodoAnuncios.Find(id);
                PeriodosDTO response = mapper.Map <Periodos, PeriodosDTO>(model);
                return(response);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#17
0
        public List <Periodos> SeleccionarTodos()
        {
            // SqlConnection requiere el using System.Data.SqlClient;
            SqlConnection   conexion = new SqlConnection(Conexion.Cadena);
            List <Periodos> lista    = new List <Periodos>();

            try
            {
                conexion.Open(); // un error aca: revisar cadena de conexion
                // El command permite ejecutar un comando en la conexion establecida
                SqlCommand comando = new SqlCommand("PA_SeleccionarPeriodo", conexion);
                // Como es en Store Procedure se debe indicar el tipo de comando
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                // NO recibe parametros
                // Finalmente ejecutamos el comando
                // al ser una consulta debemos usar ExecuteReader
                SqlDataReader reader = comando.ExecuteReader();
                // es necesario recorrer el reader para extraer todos los registros
                while (reader.Read()) // cada vez que se llama el Read retorna una tupla
                {
                    Periodos s = new Periodos();
                    s.Codigo      = Convert.ToInt32(reader["Codigo"]);
                    s.Nombre      = reader["Nombre"].ToString();
                    s.FechaFinal  = (DateTime)(reader["FechaFinal"]);
                    s.FechaInicio = (DateTime)(reader["FechaInicio"]);


                    lista.Add(s);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conexion.Close();
            }

            return(lista);
        }
 public void cargarDatosNuevos(Periodos periodo)
 {
     try
     {
         this.Numero      = periodo.Numero;
         this.FechaInicio = periodo.FechaInicial;
         this.FechaFinal  = periodo.FechaFinal;
         if (periodo.activo.Equals("Si"))
         {
             this.activo = true;
         }
         else
         {
             this.activo = false;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#19
0
        public static void GuardarPeriodos(Periodos objPeriodos, ref string Verificador)
        {
            OracleCommand    cmd     = null;
            ExeProcedimiento exeProc = new ExeProcedimiento();

            try
            {
                OracleDataReader dr            = null;
                string[]         Parametros    = { "P_DEPENDENCIA", "P_PERIODO", "P_DESCRIPCION", "P_STATUS", "P_EJERCICIO", "P_INICIO", "P_FIN" };
                object[]         Valores       = { objPeriodos.Dependencia, objPeriodos.Periodo, objPeriodos.Descripcion, objPeriodos.Status, objPeriodos.Ejercicio, objPeriodos.Inicio, objPeriodos.Fin };
                string[]         ParametrosOut = { "P_BANDERA" };
                cmd = exeProc.GenerarOracleCommand("INS_PLA_PERIODOS", ref Verificador, ref dr, Parametros, Valores, ParametrosOut);
            }
            catch (Exception ex)
            {
                Verificador = ex.Message;
            }
            finally
            {
                exeProc.LimpiarOracleCommand(ref cmd);
            }
        }
示例#20
0
 public int establecerPeriodoActual(Periodos actual)
 {
     try
     {
         var query = from temp in entities.Periodos
                     where temp.activo == true
                     select temp;
         List <Periodos> periodo = query.ToList <Periodos>();
         foreach (Periodos p in periodo)
         {
             if (p.idPeriodo != actual.idPeriodo && actual.FechaInicio > p.FechaFinal && actual.Año == p.Año)
             {
                 return(p.idPeriodo);
             }
         }
         return(0);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public IHttpActionResult PutPeriodos(string id, Periodos periodos)
 {
     try
     {
         string resp = validaciones.validarcodigoPeriodo(id);
         if (resp.Equals("1"))
         {
             resp = validaciones.validarDatosPeriodo(periodos);
             if (resp.Equals("1"))
             {
                 resp = db.modificarPeriodos(id, periodos.Numero, periodos.FechaInicio, periodos.FechaFinal, periodos.activo);
                 if (resp.Equals("1"))
                 {
                     return(StatusCode(HttpStatusCode.NoContent));
                 }
                 else if (resp.Equals("No existe"))
                 {
                     return(NotFound());
                 }
                 else
                 {
                     throw new Exception(resp);
                 }
             }
             else
             {
                 throw new Exception(resp);
             }
         }
         else
         {
             throw new Exception(resp);
         }
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
示例#22
0
        public static void EliminarPeriodo(Periodos objPeriodos, ref string Verificador)
        {
            OracleCommand    cmd     = null;
            ExeProcedimiento exeProc = new ExeProcedimiento();

            try
            {
                OracleDataReader dr            = null;
                string[]         Parametros    = { "P_ID" };
                object[]         Valores       = { objPeriodos.Id };
                string[]         ParametrosOut = { "P_BANDERA" };
                cmd = exeProc.GenerarOracleCommand("DEL_PLA_PERIODOS", ref Verificador, ref dr, Parametros, Valores, ParametrosOut);
            }
            catch (Exception ex)
            {
                Verificador = ex.Message;
            }
            finally
            {
                exeProc.LimpiarOracleCommand(ref cmd);
            }
        }
 public ActionResult Edit(Periodos model, string habilitarSnr)
 {
     try
     {
         if (habilitarSnr == "on")
         {
             model.SnrHabilitados = true;
         }
         else
         {
             model.SnrHabilitados = false;
         }
         _db.Periodos.Attach(model);
         _db.Entry(model).State = System.Data.Entity.EntityState.Modified;
         _db.SaveChanges();
         return(JsonExito());
     }
     catch (Exception e)
     {
         return(JsonError("ocurrió un problema con su solicitud", e));
     }
 }
        public IEnumerable <PlanillaRemuneracion> PlanillasEnPeriodoPorGrati(int Mes, int Anio)
        {
            var Periodos = new string[] { };

            string PeriodoHasta = Anio.ToString();

            if (Mes == 7)
            {
                Periodos = new string[] { Anio.ToString() + "01", Anio.ToString() + "02", Anio.ToString() + "03", Anio.ToString() + "04", Anio.ToString() + "05", Anio.ToString() + "06" };
            }
            else
            {
                Periodos = new string[] { Anio.ToString() + "07", Anio.ToString() + "08", Anio.ToString() + "09", Anio.ToString() + "10", Anio.ToString() + "11", Anio.ToString() + "12" };
            }

            using (PlanillaContext entityContext = new PlanillaContext())
            {
                var planilla = (from e in entityContext.PlanillaRemuneracionSet
                                where Periodos.Contains(e.Periodo)
                                select e).ToFullyLoaded();
                return(planilla);
            }
        }
        public void CarregarDadosCombosAgendamento(IList <Espaco> espacos, IList <FormaPagamento> formaPagamentos)
        {
            foreach (Periodo p in Enum.GetValues(typeof(Periodo)))
            {
                Periodos.Add(new ViewModelBase {
                    Id = (int)p, Nome = ((Periodo)p).ToString()
                });
            }

            foreach (var e in espacos)
            {
                Espacos.Add(new ViewModelBase {
                    Id = e.Id, Nome = e.Nome
                });
            }

            foreach (var fp in formaPagamentos)
            {
                FormasPagamento.Add(new ViewModelBase {
                    Id = fp.Id, Nome = fp.Nome
                });
            }
        }
示例#26
0
        public void Add(PeriodosDTO periodo)
        {
            try
            {
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <PeriodosDTO, Periodos>();
                });

                IMapper mapper = config.CreateMapper();
                //Mapeo de clase

                Periodos response = mapper.Map <PeriodosDTO, Periodos>(periodo);
                db.PeriodoAnuncios.Add(response);
                db.SaveChanges();
                ViewInfoMensaje.setMensaje(controller, MensajeBuilder.CrearMsgSuccess(entidad), Helpers.InfoMensajes.ConstantsLevels.SUCCESS);
            }

            catch (Exception)
            {
                throw;
            }
        }
示例#27
0
        public static List <Periodos> ObtenerPeriodos(string Dependencia)
        {
            //
            OracleCommand    cmd     = null;
            ExeProcedimiento exeProc = new ExeProcedimiento();

            try
            {
                string[]         Parametros = { "P_Dependencia" };
                object[]         Valores    = { Dependencia };
                OracleDataReader dr         = null;
                cmd = exeProc.GenerarOracleCommandCursor("PKG_PLANEACION.Obt_Grid_Periodos", ref dr, Parametros, Valores);
                List <Periodos> listarPeriodos = new List <Periodos>();
                while (dr.Read())
                {
                    Periodos objPeriodos = new Periodos();
                    objPeriodos.Id          = Convert.ToInt32(dr[0]);
                    objPeriodos.Dependencia = Convert.ToString(dr[1]);
                    objPeriodos.Periodo     = Convert.ToString(dr[2]);
                    objPeriodos.Descripcion = Convert.ToString(dr[3]);
                    objPeriodos.Status      = Convert.ToString(dr[4]);
                    objPeriodos.Ejercicio   = Convert.ToString(dr[5]);
                    objPeriodos.Inicio      = Convert.ToString(dr[6]);
                    objPeriodos.Fin         = Convert.ToString(dr[7]);
                    listarPeriodos.Add(objPeriodos);
                }
                return(listarPeriodos);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                exeProc.LimpiarOracleCommand(ref cmd);
            }
        }
 public ActionResult create(Periodos model, string habilitarSnr, int id_cliente)
 {
     try
     {
         //var id_cliente = SesionCliente().id_cliente;
         model.id_cliente = id_cliente;
         if (habilitarSnr == "on")
         {
             model.SnrHabilitados = true;
         }
         else
         {
             model.SnrHabilitados = false;
         }
         //obtengo el mes del ultimo registro ingresado y lo comparo con el registro que se intenta crear
         var fechaEntrada = Convert.ToDateTime(model.fecha_fin_novedades).Month;
         var ultimaFecha  = Convert.ToDateTime(_db.Periodos.OrderByDescending(x => x.fecha_fin_novedades).FirstOrDefault(x => x.id_cliente == id_cliente).fecha_fin_novedades).Month;
         if (fechaEntrada == ultimaFecha)
         {
             throw new InvalidOperationException("Can't insert duplicate object");
         }
         else
         {
             _db.Periodos.Add(model);
             _db.SaveChanges();
             return(JsonExito());
         }
     }
     catch (InvalidOperationException e)
     {
         return(JsonError("Ya existe un periodo vigente para este mes", e));
     }
     catch (Exception e)
     {
         return(JsonError("ocurrió un problema con su solicitud", e));
     }
 }
示例#29
0
        public List <Periodos> obtenerPeriodosFiltrado(string numero)
        {
            try
            {
                List <Periodos> periodos = new List <Periodos>();
                List <Periodos> data     = periodo.obtenerPeriodosFiltrado(numero);
                foreach (Periodos periodo in data)
                {
                    Periodos temp = new Periodos();
                    temp.Numero      = periodo.Numero;
                    temp.FechaInicio = periodo.FechaInicio;
                    temp.FechaFinal  = periodo.FechaFinal;
                    temp.activo      = periodo.activo;

                    periodos.Add(temp);
                }

                return(periodos);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#30
0
        public PeriodosDTO Update(PeriodosDTO periodos)
        {
            try
            {
                var config = new MapperConfiguration(cfg => {
                    cfg.CreateMap <PeriodosDTO, Periodos>();
                });
                IMapper  mapper        = config.CreateMapper();
                Periodos periodosModel = mapper.Map <PeriodosDTO, Periodos>(periodos);

                db.Entry(periodosModel).State = EntityState.Modified;
                db.SaveChanges();

                periodos = this.Find(periodos.id);

                ViewInfoMensaje.setMensaje(controller, MensajeBuilder.EditarMsgSuccess(entidad), Helpers.InfoMensajes.ConstantsLevels.SUCCESS);
                return(periodos);
            }
            catch (Exception)
            {
                ViewInfoMensaje.setMensaje(controller, MensajeBuilder.EditarMsgError(entidad), Helpers.InfoMensajes.ConstantsLevels.ERROR);
                return(periodos);
            }
        }