public ActionResult UploadFile(int id) { if (id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Asegurado asegurado = db.Asegurados.Find(id); if (asegurado == null) { return(HttpNotFound()); } Movimiento movimiento = new Movimiento(); DateTime date = DateTime.Today; movimiento.Asegurado = asegurado; movimiento.aseguradoId = id; movimiento.fechaTransaccion = date; movimiento.tipo = "A"; ViewBag.Asegurado = asegurado; return(View(movimiento)); }
public JsonResult GetAsegurado(string rfc, string razonSocial) { string id = string.Empty, mensaje = string.Empty; Regex regex = new Regex(@"^([A-ZÑ\x26]{3,4}([0-9]{2})(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])[A-Z|\d]{3})$"); Match match = regex.Match(rfc.ToUpper()); if (!match.Success) { mensaje = MessagesValidation.Error(Messages.dataFormat_Error).ToString(); } if (string.IsNullOrEmpty(mensaje)) { Asegurado a = _AseguradoService.FindwsAseguradobyRFC(rfc, Helper.GetUserData().UserId); if (a == null) { id = "0"; } else { id = a.AseguradoID.ToString(); } } Session["AseguradoID"] = id; return(this.Json(new { id = id, error = mensaje }, JsonRequestBehavior.AllowGet)); }
public IHttpActionResult PutAsegurado(int id, Asegurado asegurado) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != asegurado.id) { return(BadRequest()); } db.Entry(asegurado).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AseguradoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public int BuscarOFAC(Asegurado asegurado) { if (Convert.ToBoolean(_catalogoRepository.GetGlobalParam((int)globalParam.OFACAvailable))) { OfacClient ofac = new OfacClient(_catalogoRepository.GetGlobalParam((int)globalParam.DSIK), _catalogoRepository.GetGlobalParam((int)globalParam.ServerOFAC)); string request, response; int respuesta = ofac.SearchHitInquiry(asegurado.NombreCompleto, asegurado.RFC, asegurado.DomicilioFiscal_Calle + ' ' + asegurado.DomicilioFiscal_NroExterior, "Mexico", asegurado.CodigoPostal, "MX", out request, out response); if (respuesta == 0) { asegurado.isOFAC = false; } if (respuesta >= 1) { asegurado.isOFAC = true; } return(respuesta); } else { asegurado.isOFAC = false; return(0); } //asegurado.isOFAC = true; //return 20; }
public ActionResult UploadPDFFile([Bind(Include = "id,aseguradoId,lote,fechaTransaccion,tipo,nombreArchivo")] Movimiento movimiento, String aseguradoId) { if (!aseguradoId.Equals("")) { Asegurado asegurado = db.Asegurados.Find(Int32.Parse(aseguradoId)); if (Request.Files.Count > 0) { movimiento.aseguradoId = Int32.Parse(aseguradoId); movimiento.Asegurado = asegurado; var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { String path = "C:\\SUA\\Asegurados\\" + asegurado.numeroAfiliacion + "\\" + movimiento.tipo + "\\"; //Path.Combine("C:\\SUA\\", uploadModel.subFolder); if (!System.IO.File.Exists(path)) { System.IO.Directory.CreateDirectory(path); } //var fileName = Path.GetFileName(file.FileName); var fileName = "Acuse" + Path.GetExtension(file.FileName.Trim()); var pathFinal = Path.Combine(path, fileName); file.SaveAs(pathFinal); movimiento.nombreArchivo = fileName; //Move(); String answer = movimiento.tipo; ViewBag.dbUploaded = true; //Validamos la acción realizada if (answer.Equals("A")) { asegurado.alta = "S"; } else if (answer.Equals("B")) { asegurado.baja = "S"; } else if (answer.Equals("M")) { asegurado.modificacion = "S"; } else { asegurado.permanente = "S"; } movimiento.fechaCreacion = DateTime.Now; db.Entry(asegurado).State = EntityState.Modified; db.Movimientos.Add(movimiento); db.SaveChanges(); } } } return(RedirectToAction("Index", "Asegurados")); }
public ActionResult Edit([Bind(Include = "registroaseguradoal,numeroAfiliacion,CURP,RFC,nombre,salarioImss,salarioInfo,fechaAlta,fechaBaja,tipoTrabajo,semanaJornada,paginaInfo,tipoDescuento,valorDescuento,claveUbicacion,nombreTemporal,fechaDescuento,finDescuento,articulo33,salarioArticulo33,trapeniv,estado,claveMunicipio")] Asegurado asegurado) { if (ModelState.IsValid) { db.Entry(asegurado).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(asegurado)); }
public IHttpActionResult GetAsegurado(int id) { Asegurado asegurado = db.asegurado.Find(id); if (asegurado == null) { return(NotFound()); } return(Ok(asegurado)); }
public IHttpActionResult PostAsegurado(Asegurado asegurado) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.asegurado.Add(asegurado); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = asegurado.id }, asegurado)); }
// GET: Aseguradoes/Edit/5 public ActionResult Edit(int id) { if (id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Asegurado asegurado = db.Asegurados.Find(id); if (asegurado == null) { return(HttpNotFound()); } return(View(asegurado)); }
public IHttpActionResult DeleteAsegurado(int id) { Asegurado asegurado = db.asegurado.Find(id); if (asegurado == null) { return(NotFound()); } db.asegurado.Remove(asegurado); db.SaveChanges(); return(Ok(asegurado)); }
// GET: Aseguradoes/Details/5 public ActionResult Details(int id) { if (id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Asegurado asegurado = db.Asegurados.Find(id); if (asegurado == null) { return(HttpNotFound()); } TempData["idAsegurado"] = id; return(View(asegurado)); }
public ActionResult Index(string id, string rfc) { ViewBag.SICDivisionList = _CatalogoService.AllSICDivisiones(); if (string.IsNullOrEmpty(id) && string.IsNullOrEmpty(rfc)) { id = Session["AseguradoID"].ToString(); } int i; if (int.TryParse(id, out i)) { Asegurado asegurado; if (i == 0 && rfc == null) { return(RedirectToAction("List")); } if (i == 0 && (rfc.Length == 13 || rfc.Length == 12)) { asegurado = new Asegurado(rfc.ToUpper()); } else { asegurado = _AseguradoService.FindAseguradobyID(i); Session["AseguradoID"] = i; } if (asegurado == null) { return(View()); } asegurado.TipoPersonaList = new SelectList(_CatalogoService.AllTipoPersonas(), "TipoPersonaID", "Descripcion"); asegurado.GeneroList = new SelectList(_CatalogoService.AllGeneros(), "GeneroID", "nombre"); asegurado.EstadoCivilList = new SelectList(_CatalogoService.AllEstadoCiviles(), "EstadoCivilID", "Descripcion"); asegurado.TipoTelefonoList = new SelectList(_CatalogoService.AllTipoTelefonos(), "TipoTelefonoID", "Descripcion"); ViewBag.OFAC = MessagesValidation.Error(asegurado.ErrorOFAC()); return(View(asegurado)); } return(View()); }
public ActionResult Index(Asegurado asegurado, string colonia) { asegurado.TipoPersonaList = new SelectList(_CatalogoService.AllTipoPersonas(), "TipoPersonaID", "Descripcion"); asegurado.GeneroList = new SelectList(_CatalogoService.AllGeneros(), "GeneroID", "nombre"); asegurado.EstadoCivilList = new SelectList(_CatalogoService.AllEstadoCiviles(), "EstadoCivilID", "Descripcion"); asegurado.TipoTelefonoList = new SelectList(_CatalogoService.AllTipoTelefonos(), "TipoTelefonoID", "Descripcion"); ViewBag.SICDivisionList = _CatalogoService.AllSICDivisiones(); ViewBag.OFAC = MessagesValidation.Error(asegurado.ErrorOFAC()); int coloniaID; if (!Int32.TryParse(colonia, out coloniaID)) { ModelState.Remove("ColoniaID"); ModelState.AddModelError("ColoniaID", "La Colonia es requerida"); } int ofac = _AseguradoService.BuscarOFAC(asegurado); if (ofac == 1) { ModelState.Remove("AseguradoID"); ModelState.AddModelError("AseguradoID", "OFAC!!!"); } if (ofac == -1) { ModelState.Remove("AseguradoID"); ModelState.AddModelError("AseguradoID", "ERROR OFAC!!!"); } if (ModelState.IsValid) { asegurado.usuarioid = Helper.GetUserData().UserId; asegurado.ColoniaID = coloniaID; _AseguradoService.SavewsAsegurado(asegurado); Session["AseguradoID"] = asegurado.AseguradoID; ViewBag.Mensaje = Resources.Messages.successful_general; } return(View(asegurado)); }
public ActionResult ViewAttachment(int id, String option, String carga) { if (carga != null) { Asegurado asegurado = db.Asegurados.Find(id); var movtosTemp = db.Movimientos.Where(x => x.aseguradoId == id && x.tipo.Equals(option)).OrderByDescending(x => x.fechaTransaccion).ToList(); Movimiento movto = new Movimiento(); if (movtosTemp != null && movtosTemp.Count > 0) { foreach (var movtosItem in movtosTemp) { movto = movtosItem; break; }//Definimos los valores para la plaza var fileName = "C:\\SUA\\Asegurados\\" + asegurado.numeroAfiliacion + "\\" + option + "\\" + movto.nombreArchivo.Trim(); if (System.IO.File.Exists(fileName)) { FileStream fs = new FileStream(fileName, FileMode.Open); return(File(fs, "application/pdf")); } else { return(RedirectToAction("Index")); } } else { return(RedirectToAction("Index")); } } else { return(RedirectToAction("Index")); } }
public Asegurado obtenerAseguradoPorNSS(String NSS) { Asegurado asegurado = db.Asegurados.Where(s => s.numeroAfiliacion.Trim().Equals(NSS)).First(); return(asegurado); }
public ActionResult DeleteConfirmed(int id) { Movimiento movimiento = db.Movimientos.Find(id); if (movimiento.aseguradoId != null) { Asegurado asegurado = db.Asegurados.Find(movimiento.aseguradoId); switch (movimiento.tipo.Trim()) { case "A": asegurado.alta = null; break; case "B": asegurado.baja = null; break; case "M": asegurado.modificacion = null; break; case "P": asegurado.permanente = null; break; case "I": Incapacidade incapacidad = db.Incapacidades.Find(movimiento.acreditadoId); incapacidad.alta = null; db.Entry(incapacidad).State = EntityState.Modified; break; } db.Entry(asegurado).State = EntityState.Modified; } else { Acreditado acreditado = db.Acreditados.Find(movimiento.acreditadoId); switch (movimiento.tipo.Trim()) { case "A": acreditado.alta = null; break; case "B": acreditado.baja = null; break; case "M": acreditado.modificacion = null; break; case "P": acreditado.permanente = null; break; } db.Entry(acreditado).State = EntityState.Modified; } db.Movimientos.Remove(movimiento); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Upload(String patronesId, String periodoId, String ejercicioId, String usuarioId) { if (!String.IsNullOrEmpty(patronesId) && !String.IsNullOrEmpty(periodoId) && !String.IsNullOrEmpty(ejercicioId) && !String.IsNullOrEmpty(usuarioId)) { int userId = int.Parse(usuarioId.Trim()); String periodo = ejercicioId.Trim() + periodoId.Trim(); int mes = int.Parse(periodoId.Trim()); int patronTemp = int.Parse(patronesId); Patrone patron = db.Patrones.Find(patronTemp); String path = this.UploadFile(patron.direccionArchivo); bool esBimestral = ((mes % 2) == 0); if (!path.Equals("")) { Boolean existe = false; SUAHelper suaHelper = new SUAHelper(path); String sSQL = "SELECT * FROM RESUMEN" + " WHERE Reg_Patr = '" + patron.registro + "'" + " AND Mes_Ano = '" + periodo + "'" + " ORDER BY Reg_Patr"; DataTable dt2 = suaHelper.ejecutarSQL(sSQL); foreach (DataRow rows in dt2.Rows) { Pago pago = new Pago(); pago = db.Pagos.Where(p => p.patronId.Equals(patron.Id) && p.mes.Trim().Equals(periodoId.Trim()) && p.anno.Trim().Equals(ejercicioId.Trim())).FirstOrDefault(); Boolean actualizar = false; if (pago != null) { actualizar = true; } else { pago = new Pago(); pago.mes = periodoId; pago.anno = ejercicioId; } pago.imss = Decimal.Parse(rows["CTA_FIJ"].ToString()) + Decimal.Parse(rows["CTA_EXC"].ToString()) + Decimal.Parse(rows["PRE_DIN"].ToString()) + Decimal.Parse(rows["PRE_ESP"].ToString()) + Decimal.Parse(rows["RIE_TRA"].ToString()) + Decimal.Parse(rows["INV_VID"].ToString()) + Decimal.Parse(rows["GUA_DER"].ToString()); pago.rcv = Decimal.Parse(rows["RET_SAR"].ToString()) + Decimal.Parse(rows["CEN_VEJPat"].ToString()) + Decimal.Parse(rows["Cen_VEJObr"].ToString()); pago.infonavit = Decimal.Parse(rows["VIV_SIN"].ToString()) + Decimal.Parse(rows["VIV_CON"].ToString()) + Decimal.Parse(rows["AMO_INF"].ToString()); pago.total = pago.imss + pago.rcv + pago.infonavit; pago.recargos = Decimal.Parse(rows["REC_IMS"].ToString()) + Decimal.Parse(rows["REC_SAR"].ToString()) + Decimal.Parse(rows["REC_VIV"].ToString()); pago.actualizaciones = Decimal.Parse(rows["ACT_IMS"].ToString()) + Decimal.Parse(rows["ACT_SAR"].ToString()) + Decimal.Parse(rows["ACT_VIV"].ToString()); pago.granTotal = pago.recargos + pago.actualizaciones; sSQL = "SELECT COUNT(*) FROM RELTRA" + " WHERE Reg_Pat = '" + patron.registro + "'" + " AND Periodo = '" + periodo + "'"; DataTable dt3 = suaHelper.ejecutarSQL(sSQL); foreach (DataRow rows1 in dt3.Rows) { pago.nt = int.Parse(rows1[0].ToString()); } if (pago.nt == 0) { break; } pago.patronId = patron.Id; pago.Patrone = patron; pago.fechaCreacion = DateTime.Now; pago.usuarioId = userId; // Guardamos el pago. if (actualizar) { db.Entry(pago).State = EntityState.Modified; } else { db.Pagos.Add(pago); } db.SaveChanges(); existe = true; if (existe) { //Preparamos el query del resúmen sSQL = "SELECT * FROM RELTRA " + " WHERE Reg_Pat = '" + patron.registro + "'" + " AND Periodo = '" + periodo + "'" + " ORDER BY Reg_Pat"; DataTable dt4 = suaHelper.ejecutarSQL(sSQL); foreach (DataRow row2 in dt4.Rows) { Boolean actualizarDetalle = false; DetallePago detallePago = new DetallePago(); String nss = row2["Num_Afi"].ToString().Trim(); Asegurado asegurado = db.Asegurados.Where(a => a.numeroAfiliacion.Equals(nss.Trim())).FirstOrDefault(); detallePago = db.DetallePagoes.Where(dp => dp.pagoId.Equals(pago.id) && dp.aseguradoId.Equals(asegurado.id)).FirstOrDefault(); if (detallePago != null) { actualizarDetalle = true; } else { detallePago = new DetallePago(); detallePago.pagoId = pago.id; detallePago.Pago = pago; detallePago.aseguradoId = asegurado.id; detallePago.Asegurado = asegurado; detallePago.patronId = patron.Id; detallePago.Patrone = patron; } detallePago.diasCotizados = int.Parse(row2["dia_cot"].ToString().Trim()); detallePago.sdi = decimal.Parse(row2["sal_dia"].ToString().Trim()); if (String.IsNullOrEmpty(row2["Dia_Inc"].ToString())) { detallePago.diasIncapacidad = 0; } else { detallePago.diasIncapacidad = int.Parse(row2["Dia_Inc"].ToString().Trim()); } if (String.IsNullOrEmpty(row2["Dia_Aus"].ToString())) { detallePago.diasAusentismo = 0; } else { detallePago.diasAusentismo = int.Parse(row2["Dia_Aus"].ToString().Trim()); } if (String.IsNullOrEmpty(row2["CF"].ToString())) { detallePago.cuotaFija = 0; } else { detallePago.cuotaFija = decimal.Parse(row2["CF"].ToString().Trim()); } if (String.IsNullOrEmpty(row2["EXPA"].ToString())) { detallePago.expa = 0; } else { detallePago.expa = decimal.Parse(row2["EXPA"].ToString().Trim()); } if (String.IsNullOrEmpty(row2["EXO"].ToString())) { detallePago.exO = 0; } else { detallePago.exO = decimal.Parse(row2["EXO"].ToString().Trim()); } if (String.IsNullOrEmpty(row2["PDP"].ToString())) { detallePago.pdp = 0; } else { detallePago.pdp = decimal.Parse(row2["PDP"].ToString().Trim()); } if (String.IsNullOrEmpty(row2["PDO"].ToString())) { detallePago.pdo = 0; } else { detallePago.pdo = decimal.Parse(row2["PDO"].ToString().Trim()); } if (String.IsNullOrEmpty(row2["GMPP"].ToString())) { detallePago.gmpp = 0; } else { detallePago.gmpp = decimal.Parse(row2["GMPP"].ToString().Trim()); } if (String.IsNullOrEmpty(row2["GMPO"].ToString())) { detallePago.gmpo = 0; } else { detallePago.gmpo = decimal.Parse(row2["GMPO"].ToString().Trim()); } if (String.IsNullOrEmpty(row2["RT"].ToString())) { detallePago.rt = 0; } else { detallePago.rt = decimal.Parse(row2["RT"].ToString().Trim()); } if (String.IsNullOrEmpty(row2["IVP"].ToString())) { detallePago.ivp = 0; } else { detallePago.ivp = decimal.Parse(row2["IVP"].ToString().Trim()); } if (String.IsNullOrEmpty(row2["IVO"].ToString())) { detallePago.ivo = 0; } else { detallePago.ivo = decimal.Parse(row2["IVO"].ToString().Trim()); } if (String.IsNullOrEmpty(row2["GPS"].ToString())) { detallePago.gps = 0; } else { detallePago.gps = decimal.Parse(row2["GPS"].ToString().Trim()); } detallePago.patronal = detallePago.cuotaFija + detallePago.expa + detallePago.pdp + detallePago.gmpp + detallePago.rt + detallePago.ivp + detallePago.gps; detallePago.obrera = detallePago.exO + detallePago.pdo + detallePago.gmpo + detallePago.ivo; detallePago.imss = detallePago.patronal + detallePago.obrera; if (esBimestral) { // Se guardan los datos bimestrales. sSQL = "SELECT * FROM RELTRABIM " + " WHERE Reg_Pat = '" + patron.registro + "'" + " AND Periodo = '" + periodo + "'" + " AND Num_Afi = '" + asegurado.numeroAfiliacion.Trim() + "'" + " ORDER BY Reg_Pat"; DataTable dt5 = suaHelper.ejecutarSQL(sSQL); foreach (DataRow row5 in dt5.Rows) { if (String.IsNullOrEmpty(row5["Retiro"].ToString())) { detallePago.retiro = 0; } else { detallePago.retiro = decimal.Parse(row5["Retiro"].ToString().Trim()); } if (String.IsNullOrEmpty(row5["CyVP"].ToString())) { detallePago.patronalBimestral = 0; } else { detallePago.patronalBimestral = decimal.Parse(row5["CyVP"].ToString().Trim()); } if (String.IsNullOrEmpty(row5["CyVO"].ToString())) { detallePago.obreraBimestral = 0; } else { detallePago.obreraBimestral = decimal.Parse(row5["CyVO"].ToString().Trim()); } detallePago.rcv = detallePago.retiro + detallePago.patronal + detallePago.obrera; if (String.IsNullOrEmpty(row5["Aportasc"].ToString())) { detallePago.aportacionsc = 0; } else { detallePago.aportacionsc = decimal.Parse(row5["Aportasc"].ToString().Trim()); } if (String.IsNullOrEmpty(row5["Aportacc"].ToString())) { detallePago.aportacioncc = 0; } else { detallePago.aportacioncc = decimal.Parse(row5["Aportacc"].ToString().Trim()); } if (String.IsNullOrEmpty(row5["Amortiza"].ToString())) { detallePago.amortizacion = 0; } else { detallePago.amortizacion = decimal.Parse(row5["Amortiza"].ToString().Trim()); } detallePago.infonavit = detallePago.aportacionsc + detallePago.aportacioncc + detallePago.amortizacion; } } //El periodo es bimestre detallePago.usuarioId = userId; detallePago.fechaCreacion = DateTime.Now; try { if (actualizarDetalle) { db.Entry(detallePago).State = EntityState.Modified; } else { db.DetallePagoes.Add(detallePago); } db.SaveChanges(); } catch (DbEntityValidationException ex) { StringBuilder sb = new StringBuilder(); foreach (var failure in ex.EntityValidationErrors) { sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType()); foreach (var error in failure.ValidationErrors) { sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage); sb.AppendLine(); } } } } } } // path = path + "\\SUA.mdb"; // System.IO.File.Delete(path); } } return(RedirectToAction("UploadPagos")); }
public Asegurado FindwsAseguradobyRFC(string rfc, int usuarioID) { //Buscamos la base local RFCSpecification rfcSpec = new RFCSpecification(rfc); Asegurado localAsegurado = _aseguradoRepository.FindAsegurado(rfcSpec); //Buscamos en el servicio Asegurado wsAsegurado; if (Convert.ToBoolean(_catalogoRepository.GetGlobalParam((int)globalParam.WSSiseAvailable))) { Integration.WsAsegurado ws = new Integration.WsAsegurado(); wsAsegurado = ws.ConsultarAsegurado(rfc); } else { wsAsegurado = null; } if (wsAsegurado == null) //No lo encontró en el WS { return(localAsegurado); } else //tenemos que actualizar los datos locales con lo que se encuentra en el WS { IUnitOfWork unitOfWork = _aseguradoRepository.UnitOfWork as IUnitOfWork; if (localAsegurado == null) //No lo encontró en el local { localAsegurado = new Asegurado(rfc); localAsegurado.SIC = string.Empty; } localAsegurado.ColoniaID = _catalogoRepository.GetColoniabySISEid(Convert.ToInt32(wsAsegurado.Cod_colonia)).ColoniaID; localAsegurado.EstadoCivilID = _catalogoRepository.GetEstadoCivilbySISEid(Convert.ToInt32(wsAsegurado.Cod_est_civil)).EstadoCivilID; localAsegurado.TipoTelefonoID = _catalogoRepository.GetTipoTelefonobySISEid(Convert.ToInt32(wsAsegurado.Cod_tipo_telef)).TipoTelefonoID; localAsegurado.GeneroID = _catalogoRepository.GetGenerobySISEid(wsAsegurado.Cod_sexo).GeneroID; localAsegurado.TipoPersonaID = _catalogoRepository.GetTipoPersonabiSISEid(Convert.ToInt32(wsAsegurado.Cod_TipoPersona)).TipoPersonaID; localAsegurado.Apellido1 = wsAsegurado.Apellido1; localAsegurado.Apellido2 = wsAsegurado.Apellido2; localAsegurado.CodigoPostal = wsAsegurado.CodigoPostal; localAsegurado.CURP = wsAsegurado.CURP; localAsegurado.DomicilioFiscal_Calle = wsAsegurado.DomicilioFiscal_Calle; localAsegurado.DomicilioFiscal_NroExterior = wsAsegurado.DomicilioFiscal_NroExterior; localAsegurado.DomicilioFiscal_NroInterior = wsAsegurado.DomicilioFiscal_NroInterior; localAsegurado.FechaNacimiento = wsAsegurado.FechaNacimiento; localAsegurado.LugarNacimiento = wsAsegurado.LugarNacimiento; localAsegurado.Nombres = wsAsegurado.Nombres; localAsegurado.RazonSocial = wsAsegurado.RazonSocial; localAsegurado.RFC = wsAsegurado.RFC; localAsegurado.Telefono = wsAsegurado.Telefono; localAsegurado.usuarioid = usuarioID; if (localAsegurado.AseguradoID == 0) { localAsegurado.AseguradoID = _aseguradoRepository.LastAseguradoID() + 1; _aseguradoRepository.Add(localAsegurado); } else { _aseguradoRepository.Modify(localAsegurado); } unitOfWork.Commit(); localAsegurado = FindAseguradobyID(localAsegurado.AseguradoID); } return(localAsegurado); }
public ActionResult Create([Bind(Include = "id,solicitudId,nss,fechaAltaImss,apellidoMaterno,apellidoPaterno,nombre,nombreCompleto,rfc,homoclave,curp,sexoId,sdiId,esquemaPagoId,salarioReal,categoria,tieneInfonavit,creditoInfonavit,estadoCivilId,fechaNacimiento,nacionalidadId,estadoNacimientoId,municipioNacimientoId,calleNumero,colonia,edoMunicipio,codigoPostal,tramitarTarjeta,bancoId,cuentaBancaria,email,observaciones,usuarioId,fechaCreacion,estatus")] Empleado empleado) { if (ModelState.IsValid) { ToolsHelper th = new ToolsHelper(); Usuario usuario = Session["UsuarioData"] as Usuario; empleado.fechaCreacion = DateTime.Now; empleado.usuarioId = usuario.Id; empleado.nombreCompleto = empleado.nombre + " " + empleado.apellidoPaterno + " " + empleado.apellidoMaterno; empleado.estatus = "A"; empleado.rfc = empleado.rfc.Trim(); empleado.homoclave = empleado.homoclave.Trim(); if (!String.IsNullOrEmpty(empleado.nss)) { Asegurado asegurado = th.obtenerAseguradoPorNSS(empleado.nss.Trim()); if (!(asegurado == null) && !String.IsNullOrEmpty(asegurado.nombre)) { empleado.aseguradoId = asegurado.id; } } //Obtenemos el sexo del empleado empleado.Sexo = db.Sexos.Find(empleado.sexoId); if (empleado.Sexo.descripcion.ToLower().Trim().Contains("femenino") || empleado.Sexo.descripcion.ToLower().Trim().Contains("mujer")) { empleado.foto = "~/Content/Images/girl.png"; } else { empleado.foto = "~/Content/Images/male.png"; } empleado.foto = empleado.foto.Trim(); db.Empleados.Add(empleado); try { db.SaveChanges(); //Obtenemos la solicitud par modificar el noTrabjadores //a su vez con ella obtener el folio de Solicitud para generar el folioEmpleado Solicitud solicitud = db.Solicituds.Find(empleado.solicitudId); solicitud.noTrabajadores = solicitud.noTrabajadores + 1; empleado.folioEmpleado = solicitud.folioSolicitud.Trim() + "-" + empleado.id.ToString().PadLeft(5, '0'); //Preparamos las entidades para guardar db.Entry(empleado).State = EntityState.Modified; db.Entry(solicitud).State = EntityState.Modified; db.SaveChanges(); } catch (DbEntityValidationException ex) { StringBuilder sb = new StringBuilder(); foreach (var failure in ex.EntityValidationErrors) { sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType()); foreach (var error in failure.ValidationErrors) { sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage); sb.AppendLine(); } } } return(RedirectToAction("Index", "Solicitudes", new { id = empleado.solicitudId })); } ViewBag.bancoId = new SelectList(db.Bancos, "id", "descripcion", empleado.bancoId); ViewBag.esquemaPagoId = new SelectList(db.EsquemasPagoes, "id", "descripcion", empleado.esquemaPagoId); ViewBag.estadoCivilId = new SelectList(db.EstadoCivils, "id", "descripcion", empleado.estadoCivilId); ViewBag.estadoNacimientoId = new SelectList(db.Estados, "id", "descripcion", empleado.estadoNacimientoId); ViewBag.municipioNacimientoId = new SelectList(db.Municipios, "id", "descripcion", empleado.municipioNacimientoId); ViewBag.nacionalidadId = new SelectList(db.Paises, "id", "descripcion", empleado.nacionalidadId); ViewBag.sdiId = new SelectList(db.SDIs, "id", "descripcion", empleado.sdiId); ViewBag.sexoId = new SelectList(db.Sexos, "id", "descripcion", empleado.sexoId); return(View(empleado)); }
public List <string> GetDiferenciaAsegurado(int aseguradoID) { List <string> listErrores = new List <string>(); //Base de Datos AseguradIDSpecification aseguradoSpec = new AseguradIDSpecification(aseguradoID); Asegurado ase = _aseguradoRepository.FindAsegurado(aseguradoSpec); //Web Services Integration.WsAsegurado ws = new Integration.WsAsegurado(); Asegurado wsAsegurado = null; if (Convert.ToBoolean(_catalogoRepository.GetGlobalParam((int)globalParam.WSSiseAvailable))) { wsAsegurado = ws.ConsultarAsegurado(ase.RFC); } if (wsAsegurado == null) { listErrores.Add("Asegurado|" + ase.ErrorSISE() + "|" + ase.ErrorSISE()); } else { if (ase.NombreCompleto != wsAsegurado.NombreCompleto) { listErrores.Add("NombreCompleto|" + ase.NombreCompleto + "|" + wsAsegurado.NombreCompleto); } if (ase.CURP != wsAsegurado.CURP) { listErrores.Add("CURP|" + ase.CURP + "|" + wsAsegurado.NombreCompleto); } if (ase.FechaNacimiento != wsAsegurado.FechaNacimiento) { listErrores.Add("FechaNacimiento|" + ase.FechaNacimiento.ToString("dd/MM/yyyy") + "|" + wsAsegurado.FechaNacimiento.ToString("dd/MM/yyyy")); } if (ase.DomicilioFiscal_Calle != wsAsegurado.DomicilioFiscal_Calle) { listErrores.Add("DomicilioFiscal_Calle|" + ase.DomicilioFiscal_Calle + "|" + wsAsegurado.DomicilioFiscal_Calle); } if (ase.DomicilioFiscal_NroExterior != wsAsegurado.DomicilioFiscal_NroExterior) { listErrores.Add("DomicilioFiscal_NroExterior|" + ase.DomicilioFiscal_NroExterior + "|" + wsAsegurado.DomicilioFiscal_NroExterior); } if (ase.DomicilioFiscal_NroInterior != wsAsegurado.DomicilioFiscal_NroInterior) { listErrores.Add("DomicilioFiscal_NroInterior|" + ase.DomicilioFiscal_NroInterior + "|" + wsAsegurado.DomicilioFiscal_NroInterior); } if (ase.LugarNacimiento != wsAsegurado.LugarNacimiento) { listErrores.Add("LugarNacimiento|" + ase.LugarNacimiento + "|" + wsAsegurado.LugarNacimiento); } if (ase.CodigoPostal != wsAsegurado.CodigoPostal) { listErrores.Add("CodigoPostal|" + ase.CodigoPostal + "|" + wsAsegurado.CodigoPostal); } if (ase.SIC != wsAsegurado.SIC) { listErrores.Add("SIC|" + ase.SIC + "|" + wsAsegurado.SIC); } } return(listErrores); }
public void SavewsAsegurado(Asegurado asegurado) { if (asegurado.TipoPersonaID == 2) //Moral { asegurado.Nombres = null; asegurado.Apellido1 = null; asegurado.Apellido2 = null; } else { asegurado.RazonSocial = null; } TransactionOptions txSettings = new TransactionOptions() { Timeout = TransactionManager.DefaultTimeout, IsolationLevel = IsolationLevel.Serializable // review this option }; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, txSettings)) { IUnitOfWork unitOfWork = _aseguradoRepository.UnitOfWork as IUnitOfWork; IUnitOfWork ubicOfWork = _ubicacionRepository.UnitOfWork as IUnitOfWork; if (asegurado.AseguradoID == 0) { asegurado.AseguradoID = _aseguradoRepository.LastAseguradoID() + 1; _aseguradoRepository.Add(asegurado); } else { _aseguradoRepository.Modify(asegurado); } if (_ubicacionRepository.LastNroUbicacion(asegurado.AseguradoID) == 0) { //Crear una ubicacion por default con los datos del asegurado Ubicacion ubic = new Ubicacion(); ubic.UbicacionID = _ubicacionRepository.LastUbicacionID() + 1; ubic.AseguradoID = asegurado.AseguradoID; ubic.CodigoPostal = asegurado.CodigoPostal; ubic.Domicilio_Calle = asegurado.DomicilioFiscal_Calle; ubic.Domicilio_NroExterior = asegurado.DomicilioFiscal_NroExterior; ubic.Domicilio_NroInterior = asegurado.DomicilioFiscal_NroInterior; ubic.ColoniaID = asegurado.ColoniaID; ubic.SIC = asegurado.SIC; ubic.nroPiso = 1; ubic.nroSotano = 0; ubic.TipoConstructivoIncendioID = _catalogoRepository.GetTipoConstructivoIncendioDefault(asegurado.SIC).Value; ubic.TipoConstructivoTerremotoID = _catalogoRepository.GetTipoConstructivoTerremotoDefault(ubic.TipoConstructivoIncendioID).Value; SelectCodigoPostalDatos_Result datosCP = _catalogoRepository.GetDatosCodigoPostal(ubic.CodigoPostal); ubic.Latitud = datosCP.latitud; ubic.Longitud = datosCP.longitud; ubic.ZonaHidroID = datosCP.ZonaHidroID.Value; ubic.ZonaTEVID = datosCP.ZonaTEVID.Value; ubic.UbicacionCosta = datosCP.esCosta.Value; ubic.añoConstruccion = asegurado.FechaNacimiento.Year; ubic.nroUbicacion = 1; _ubicacionRepository.Add(ubic); } unitOfWork.CommitAndRefreshChanges(); ubicOfWork.CommitAndRefreshChanges(); //Commit the transaction scope.Complete(); } asegurado = FindAseguradobyID(asegurado.AseguradoID); //Integration.WsAsegurado ws = new Integration.WsAsegurado(); //string dato = ws.GrabarAsegurado(asegurado); }