Example #1
0
        //metodo para insertar o actualizar
        public ResponseModel SaveVacacion()
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new MaximaContext())
                {
                    this.estado = "A";
                    if (this.id_vacacion > 0)
                    {
                        ctx.Entry(this).State = EntityState.Modified;
                    }
                    else
                    {
                        ctx.Entry(this).State = EntityState.Added;
                    }

                    ctx.SaveChanges();

                    rm.SetResponse(true);
                }
            }
            catch (Exception e)
            {
                rm.SetResponse(false, "no se ha podido insertar las vacaciones");
            }

            return(rm);
        }
        //metodo para insertar o actualizar
        public tbl_registro_pago SaveRegistro()
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new MaximaContext())
                {
                    this.estado = "A";
                    if (this.id_registro_pago > 0)
                    {
                        ctx.Entry(this).State = EntityState.Modified;
                    }
                    else
                    {
                        ctx.Entry(this).State = EntityState.Added;
                    }

                    ctx.SaveChanges();

                    rm.SetResponse(true);
                }
            }
            catch (Exception e)
            {
                rm.SetResponse(false, "no se ha podido insertar el registro");
            }

            return(this);
        }
Example #3
0
        //metodo para elimiar un cargo a nivel logico
        public ResponseModel EliminarVacacion(int id)
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new MaximaContext())
                {
                    var vacacion = ctx.tbl_vacacion.Where(x => x.id_vacacion == id).SingleOrDefault();
                    vacacion.estado = "I";

                    ctx.Entry(vacacion).State = EntityState.Modified;
                    ctx.SaveChanges();
                    rm.SetResponse(true);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(rm);
        }
        //metodo para elimiar un cargo a nivel logico
        public ResponseModel CierrePlanilla(string num_planilla)
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new MaximaContext())
                {
                    var planilla = ctx.tbl_planilla.Where(x => x.num_planilla == num_planilla).SingleOrDefault();
                    planilla.cerrada = 1;

                    ctx.Entry(planilla).State = EntityState.Modified;
                    ctx.SaveChanges();
                    rm.SetResponse(true);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(rm);
        }
        //metodo para elimiar un cargo a nivel logico
        public ResponseModel EliminarRegistro(int id)
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new MaximaContext())
                {
                    var registro = ctx.tbl_registro_pago.Where(x => x.id_registro_pago == id).SingleOrDefault();
                    registro.estado = "I";

                    ctx.Entry(registro).State = EntityState.Modified;
                    ctx.SaveChanges();
                    rm.SetResponse(true);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(rm);
        }