Exemplo n.º 1
0
        public static string  ActualizRL(RelacionLaboral rl)
        {
            try

            {
                SqlCommand     cmd   = new SqlCommand();
                SqlDataAdapter da    = new SqlDataAdapter(cmd);
                Coneccion      param = Parameter.Leer_parametros();
                cmd.Connection = new SqlConnection(param.ConString);
                cmd.Connection.Open();
                cmd.Parameters.Clear();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "SP_RELACION_LABORAL_ACTUALIZA";
                cmd.Parameters.AddWithValue("@correlativo", rl.correlativo);
                if (rl.idContrato == null || rl.idContrato == "0")
                {
                    cmd.Parameters.AddWithValue("@idContrato", System.DBNull.Value);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@idContrato", rl.idContrato);
                }

                cmd.Parameters.AddWithValue("respuesta", rl.Respuesta);
                cmd.ExecuteNonQuery();
                return("ok");
            }
            catch (SqlException exp)
            {
                return(exp.Message.ToString());
            }
        }
Exemplo n.º 2
0
        public async Task <Response> PostRelacionLaboral([FromBody] RelacionLaboral RelacionLaboral)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = ""
                    });
                }

                var respuesta = Existe(RelacionLaboral);
                if (!respuesta.IsSuccess)
                {
                    db.RelacionLaboral.Add(RelacionLaboral);
                    await db.SaveChangesAsync();

                    return(new Response
                    {
                        IsSuccess = true,
                        Message = Mensaje.Satisfactorio
                    });
                }

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro,
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Error,
                });
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create(RelacionLaboral relacionLaboral)
        {
            if (!ModelState.IsValid)
            {
                InicializarMensaje(null);
                return(View(relacionLaboral));
            }
            Response response = new Response();

            try
            {
                response = await apiServicio.InsertarAsync(relacionLaboral,
                                                           new Uri(WebApp.BaseAddress),
                                                           "api/RelacionesLaborales/InsertarRelacionLaboral");

                if (response.IsSuccess)
                {
                    var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                        ExceptionTrace       = null,
                        Message              = "Se ha creado una relación laboral",
                        UserName             = "******",
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                        EntityID             = string.Format("{0} {1}", "Relación Laboral:", relacionLaboral.IdRelacionLaboral),
                    });

                    return(RedirectToAction("Index"));
                }

                ViewData["Error"]            = response.Message;
                ViewData["IdRegimenLaboral"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <RegimenLaboral>(new Uri(WebApp.BaseAddress), "api/RegimenesLaborales/ListarRegimenesLaborales"), "IdRegimenLaboral", "Nombre");

                return(View(relacionLaboral));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Creando relación laboral",
                    ExceptionTrace       = ex.Message,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
Exemplo n.º 4
0
        public async Task CargarTipoNombramientoPorRelacion(int IdRelacionLaboral)
        {
            try
            {
                var relacionLaboral = new RelacionLaboral
                {
                    IdRelacionLaboral = IdRelacionLaboral,
                };
                var listarTipoNombramientos = await apiServicio.Listar <TipoNombramiento>(relacionLaboral, new Uri(WebApp.BaseAddress), "api/TiposDeNombramiento/ListarTiposDeNombramientoPorRelacion");

                ViewData["IdTipoNombramiento"] = new SelectList(listarTipoNombramientos, "IdTipoNombramiento", "Nombre");
            }
            catch (Exception ex) { }
        }
Exemplo n.º 5
0
        public async Task <JsonResult> ListarTipoNombramientoRelacion(int relacion)
        {
            try
            {
                var relacionLaboral = new RelacionLaboral
                {
                    IdRelacionLaboral = relacion,
                };
                var listarelacionesLaborales = await apiServicio.Listar <TipoNombramiento>(relacionLaboral, new Uri(WebApp.BaseAddress), "api/TiposDeNombramiento/ListarTiposDeNombramientoPorRelacion");

                return(Json(listarelacionesLaborales));
            }
            catch (Exception)
            {
                return(Json(Mensaje.Error));
            }
        }
Exemplo n.º 6
0
        public async Task <JsonResult> ListarModalidadPartidaRelacion(int relacion)
        {
            try
            {
                var relacionLaboral = new RelacionLaboral
                {
                    IdRelacionLaboral = relacion,
                };
                var listaremodalidadPartida = await apiServicio.Listar <ModalidadPartida>(relacionLaboral, new Uri(WebApp.BaseAddress), "api/ModalidadesPartida/ListarModalidadesPartidaPorRelacionLaboral");

                return(Json(listaremodalidadPartida));
            }
            catch (Exception)
            {
                return(Json(Mensaje.Error));
            }
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Edit(string id, RelacionLaboral relacionLaboral)
        {
            Response response = new Response();

            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    response = await apiServicio.EditarAsync(id, relacionLaboral, new Uri(WebApp.BaseAddress),
                                                             "api/RelacionesLaborales");

                    if (response.IsSuccess)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                            EntityID             = string.Format("{0} : {1}", "Relación Laboral", id),
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                            Message  = "Se ha actualizado un registro relación laboral",
                            UserName = "******"
                        });

                        return(RedirectToAction("Index"));
                    }
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Editando una relación laboral",
                    ExceptionTrace       = ex.Message,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
Exemplo n.º 8
0
        private Response Existe(RelacionLaboral RelacionLaboral)
        {
            var bdd = RelacionLaboral.Nombre.ToUpper().TrimEnd().TrimStart();
            var RelacionLaboralrespuesta = db.RelacionLaboral.Where(p => p.Nombre.ToUpper().TrimStart().TrimEnd() == bdd && p.IdRegimenLaboral == RelacionLaboral.IdRegimenLaboral).FirstOrDefault();

            if (RelacionLaboralrespuesta != null)
            {
                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.ExisteRegistro,
                    Resultado = RelacionLaboralrespuesta,
                });
            }

            return(new Response
            {
                IsSuccess = false,
                Resultado = RelacionLaboralrespuesta,
            });
        }
Exemplo n.º 9
0
        public async Task <List <ModalidadPartida> > ListarModalidadesPartidaPorRelacionLaboral([FromBody] RelacionLaboral relacionLaboral)
        {
            try
            {
                return(await db.ModalidadPartida.Where(x => x.IdRelacionLaboral == relacionLaboral.IdRelacionLaboral).OrderBy(x => x.Nombre).ToListAsync());
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new List <ModalidadPartida>());
            }
        }
Exemplo n.º 10
0
        public async Task <Response> PutRelacionLaboral([FromRoute] int id, [FromBody] RelacionLaboral RelacionLaboral)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var existe = Existe(RelacionLaboral);
                var RelacionLaboralActualizar = (RelacionLaboral)existe.Resultado;
                if (existe.IsSuccess)
                {
                    if (RelacionLaboralActualizar.IdRelacionLaboral == RelacionLaboral.IdRelacionLaboral)
                    {
                        return(new Response
                        {
                            IsSuccess = true,
                        });
                    }
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }
                var capacitacionac = db.RelacionLaboral.Find(RelacionLaboral.IdRelacionLaboral);

                capacitacionac.IdRegimenLaboral = RelacionLaboral.IdRegimenLaboral;
                capacitacionac.Nombre           = RelacionLaboral.Nombre;
                db.RelacionLaboral.Update(capacitacionac);
                await db.SaveChangesAsync();

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Satisfactorio,
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.Excepcion,
                });
            }
        }
Exemplo n.º 11
0
        public static string Contrato(CredencialesWS CR, RelacionLaboral RL)
        {
            string         ruta_WS = Parameter.LeerRutaws("RLABORAL");
            String         resp;
            StringBuilder  xmlenvia        = new StringBuilder("");
            HttpWebRequest request         = CreateWebRequest(ruta_WS);
            XmlDocument    soapEnvelopeXml = new XmlDocument();

            xmlenvia.Append(@"<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:scc=""https://sccnlp.com/"">");
            xmlenvia.Append(@"<soapenv:Header>");
            xmlenvia.Append(@"<scc:UserCredentials>");
            xmlenvia.Append(@"<scc:userName>");
            xmlenvia.Append(CR.user);
            xmlenvia.Append(@"</scc:userName>");
            xmlenvia.Append(@"<scc:password>" + CR.pass + "</scc:password>");
            xmlenvia.Append(@"</scc:UserCredentials>");
            xmlenvia.Append(@"</soapenv:Header>");
            xmlenvia.Append(@"<soapenv:Body>");
            xmlenvia.Append(@"<scc:registrarContratos>");
            xmlenvia.Append(@"<scc:rutEmpresa>" + CR.rutEmpr + "</scc:rutEmpresa>");
            xmlenvia.Append(@"<scc:idPuerto>" + RL.idPuerto + "</scc:idPuerto>");
            xmlenvia.Append(@"<scc:contratos>");
            xmlenvia.Append(@"<scc:Contrato>");
            xmlenvia.Append(@"<scc:trabajador>");
            xmlenvia.Append(@"<scc:rut>" + RL.rut + "</scc:rut>");
            xmlenvia.Append(@"<scc:dv>" + RL.dv + "</scc:dv>");
            xmlenvia.Append(@"<scc:pasaporte></scc:pasaporte>");
            xmlenvia.Append(@"<scc:nombres></scc:nombres>");
            xmlenvia.Append(@"<scc:apellidoPaterno></scc:apellidoPaterno>");
            xmlenvia.Append(@"<scc:apellidoMaterno></scc:apellidoMaterno>");
            xmlenvia.Append(@"<scc:idEstadoCivil>" + RL.idEstadoCivil + "</scc:idEstadoCivil>");
            xmlenvia.Append(@"<scc:idSexo>" + RL.idSexo + "</scc:idSexo>");
            xmlenvia.Append(@"<scc:domicilio>");
            xmlenvia.Append(@"<scc:idRegion>" + RL.idRegion + "</scc:idRegion>");
            xmlenvia.Append(@"<scc:idComuna>" + RL.idComuna + "</scc:idComuna>");
            xmlenvia.Append(@"<scc:calle>" + RL.calle + "</scc:calle>");
            xmlenvia.Append(@"<scc:numero>" + RL.numero + "</scc:numero>");
            xmlenvia.Append(@"<scc:depto></scc:depto>");
            xmlenvia.Append(@"<scc:block></scc:block>");
            xmlenvia.Append(@"</scc:domicilio>");
            xmlenvia.Append(@"<scc:email>" + RL.email + "</scc:email>");
            xmlenvia.Append(@"<scc:idIsapre>" + RL.idIsapre + "</scc:idIsapre>");
            xmlenvia.Append(@"<scc:idAFP>" + RL.idAFP + "</scc:idAFP>");
            xmlenvia.Append(@"</scc:trabajador>");
            xmlenvia.Append(@"<scc:fechaCelebContrato>" + RL.fecha + "</scc:fechaCelebContrato>");
            xmlenvia.Append(@"<scc:idTipoContrato>" + RL.idTipoContrato + "</scc:idTipoContrato>");
            xmlenvia.Append(@"<scc:fechaInicioContrato>" + RL.fechaInicioContrato + "</scc:fechaInicioContrato>");
            xmlenvia.Append(@"<scc:fechaTerminoContrato>" + RL.fechaTerminoContrato + "</scc:fechaTerminoContrato>");
            xmlenvia.Append(@"<scc:idModalidad>" + RL.idModalidad + "</scc:idModalidad>");
            xmlenvia.Append(@"<scc:horasExtraAutorizadas>" + RL.horasExtraAutorizadas + "</scc:horasExtraAutorizadas>");
            xmlenvia.Append(@"<scc:remuneracionBruta>" + RL.remuneracionBruta + "</scc:remuneracionBruta>");
            xmlenvia.Append(@"<scc:labores>");
            xmlenvia.Append(@"<scc:idLabor>" + RL.idLabor + "</scc:idLabor>");
            xmlenvia.Append(@"<scc:idFuncion>" + RL.idFuncion + "</scc:idFuncion>");
            xmlenvia.Append(@"<scc:idLocacion>" + RL.idLocacion + "</scc:idLocacion>");
            xmlenvia.Append(@"<scc:idJornada>" + RL.idJornada + "</scc:idJornada>");
            xmlenvia.Append(@"<scc:horario>");
            xmlenvia.Append(@"<scc:ContratoHorario>");

            if (RL.turno.Equals("3"))
            {
                xmlenvia.Append(@"<scc:dia>" + RL.dia + "</scc:dia>");
                xmlenvia.Append(@"<scc:horaDesde>" + RL.horaDesde + "</scc:horaDesde>");
                xmlenvia.Append(@"<scc:horaHasta>23:59</scc:horaHasta>");

                int nextDia   = 0;
                int DiaActual = 0;
                DiaActual = int.Parse(RL.dia);
                if (DiaActual == 6)
                {
                    nextDia = 0;
                }
                else
                {
                    nextDia = DiaActual + 1;
                }

                xmlenvia.Append(@"<scc:dia>" + nextDia.ToString() + "</scc:dia>");
                xmlenvia.Append(@"<scc:horaDesde>00:00</scc:horaDesde>");
                xmlenvia.Append(@"<scc:horaHasta>" + RL.horaHasta + "</scc:horaHasta>");
            }
            else
            {
                xmlenvia.Append(@"<scc:dia>" + RL.dia + "</scc:dia>");
                xmlenvia.Append(@"<scc:horaDesde>" + RL.horaDesde + "</scc:horaDesde>");
                xmlenvia.Append(@"<scc:horaHasta>" + RL.horaHasta + "</scc:horaHasta>");
            }

            xmlenvia.Append(@"</scc:ContratoHorario>");
            xmlenvia.Append(@"</scc:horario>");
            xmlenvia.Append(@"<scc:acuerdoDescanso>");
            xmlenvia.Append(@"<scc:horaDesde>" + RL.horaDescansoDesde + "</scc:horaDesde>");
            xmlenvia.Append(@"<scc:horaHasta>" + RL.horaDescansoHasta + "</scc:horaHasta>");
            xmlenvia.Append(@"</scc:acuerdoDescanso>");
            xmlenvia.Append(@"</scc:labores>");
            xmlenvia.Append(@"</scc:Contrato>");
            xmlenvia.Append(@"</scc:contratos>");
            xmlenvia.Append(@"</scc:registrarContratos>");
            xmlenvia.Append(@"</soapenv:Body>");
            xmlenvia.Append(@"</soapenv:Envelope>");

            soapEnvelopeXml.LoadXml(xmlenvia.ToString());



            using (Stream stream = request.GetRequestStream())
            {
                soapEnvelopeXml.Save(stream);
            }

            using (WebResponse response = request.GetResponse())
            {
                using (StreamReader rd = new StreamReader(response.GetResponseStream()))
                {
                    string soapResult = rd.ReadToEnd();
                    resp = soapResult;
                }
            }


            XmlDocument doc = new XmlDocument();

            doc.LoadXml(resp);



            XmlElement  root     = doc.DocumentElement;
            XmlNodeList elemList = root.GetElementsByTagName("registrarContratosResult");

            string Estado = elemList[0].ChildNodes[0].InnerXml;

            XmlElement  root1     = doc.DocumentElement;
            XmlNodeList elemList1 = root1.GetElementsByTagName("ContratoCreadoDetalle");


            if (Estado.Equals("0"))
            {
                RL.idContrato = elemList1[0].ChildNodes[5].InnerXml;
                RL.Respuesta  = "OK";
            }
            else
            {
                RL.idContrato = "0";
                RL.Respuesta  = elemList1[0].ChildNodes[5].InnerXml;
            }


            return(RelacionLaboralDAL.ActualizRL(RL));
        }