public bool L_EliminarRepresentanteLegal(int IdRepresentante) { bool Resultado = false; CatUsuarios UsuarioDelRepresentante = new CatUsuarios(); LogicaUsuarios LogicaUsuario = new LogicaUsuarios(); UsuarioDelRepresentante = LogicaUsuario.L_DetallesUsuarioPorRepresentante(IdRepresentante); LogicaUsuario.L_EliminarUsuario(UsuarioDelRepresentante.U_IdUsuario); Resultado = DatosAuxiliar.D_EliminarRepresentanteLegal(IdRepresentante); return(Resultado); }
public ActionResult ValidarSolicitud(int IdRepresentante) { CatUsuarios Usuario = (CatUsuarios)Session["Usuario"]; if (Usuario != null && Usuario.U_IdUsuario > 0 && Usuario.U_IdTipoUsuario == 4) { try { LogicaUsuarios LogicaUsuarios = new LogicaUsuarios(); LogicaEmpresas LogicaEmpresa = new LogicaEmpresas(); LogicaRepresentantesLegales LogicaRepresentante = new LogicaRepresentantesLegales(); CatRepresentantesLegales Representante = LogicaRepresentante.L_DetallesRepresentanteLegal(IdRepresentante); CatEmpresas Empresa = LogicaEmpresa.L_DetallesEmpresa(Representante.RL_IdEmpresa); CatUsuarios UsuarioRepresentante = LogicaUsuarios.L_DetallesUsuarioPorRepresentante(IdRepresentante); ViewBag.DatosEmpresa = Empresa; string ruta = @"C:\\inetpub\\RepositorioVER\\Representantes\\" + Representante.RL_IdRepresentanteLegal.ToString(); DirectoryInfo di = new DirectoryInfo(ruta); DateTime FechaPoderNotarial = DateTime.Parse("01/01/1900"); DateTime FechaCedulaRFC = DateTime.Parse("01/01/1900"); DateTime FechaActaConstitutiva = DateTime.Parse("01/01/1900"); DateTime FechaIdentificacionOficial = DateTime.Parse("01/01/1900"); foreach (var fi in di.GetFiles()) { try { string[] Varibales = fi.Name.Split('_'); string TipoDocumento = Varibales[0]; try { FechaDocumento = Varibales[2].Substring(0, 19).Replace('-', '/').Replace('.', ':'); } catch (Exception ex) { } DateTime Fecha = DateTime.Parse(FechaDocumento); switch (TipoDocumento) { case "PoderNotarial": if (FechaPoderNotarial < Fecha) { FechaPoderNotarial = Fecha; } break; case "CedulaRFC": if (FechaCedulaRFC < Fecha) { FechaCedulaRFC = Fecha; } break; case "ActaConstitutiva": if (FechaActaConstitutiva < Fecha) { FechaActaConstitutiva = Fecha; } break; case "NumIdenOficial": if (FechaIdentificacionOficial < Fecha) { FechaIdentificacionOficial = Fecha; } break; default: break; } } catch (Exception exc) { } } ViewBag.PoderNotarial = ruta + "\\PoderNotarial_PDF_" + FechaPoderNotarial.ToString("yyyy-MM-dd HH.mm.ss") + ".pdf"; ViewBag.CedulaRFC = ruta + "\\CedulaRFC_PDF_" + FechaCedulaRFC.ToString("yyyy-MM-dd HH.mm.ss") + ".pdf"; ViewBag.ActaConstitutiva = ruta + "\\ActaConstitutiva_PDF_" + FechaActaConstitutiva.ToString("yyyy-MM-dd HH.mm.ss") + ".pdf"; ViewBag.IdentificacionOficial = ruta + "\\NumIdenOficial_PDF_" + FechaIdentificacionOficial.ToString("yyyy-MM-dd HH.mm.ss") + ".pdf"; ViewBag.DatosRepresentante = Representante; if (Empresa.E_RFC.Length == 12) { ViewBag.MostrarCarta = true; } else { ViewBag.MostrarCarta = false; } return(View()); } catch (Exception ex) { TempData["notice"] = "Se produjo un error en la consulta"; Session["TipoAlerta"] = "Error"; return(RedirectToAction("GestionarSolicitudesRegistro")); } } else { return(RedirectToAction("Logout", "Home")); } }
public ActionResult AceptarResprepresentanteLegal(int IdEmpresa, int IdRepresentante) { LogicaUsuarios LogicaUsuarios = new LogicaUsuarios(); LogicaRepresentantesLegales LogicaRepresentantesLegales = new LogicaRepresentantesLegales(); LogicaHome LogicaHome = new LogicaHome(); try { CatUsuarios Usuario = (CatUsuarios)Session["Usuario"]; if (Usuario == null || Usuario.U_IdTipoUsuario != 4) { TempData["notice"] = "La sesión ha experiado."; return(RedirectToAction("Logout", "Home")); } else { CatUsuarios UsuarioRepresentante = LogicaUsuarios.L_DetallesUsuarioPorRepresentante(IdRepresentante); UsuarioRepresentante.U_Activo = true; CatRepresentantesLegales Representante = LogicaRepresentantesLegales.L_DetallesRepresentanteLegal(IdRepresentante); string CorreoRepresentante = Representante.RL_CorreoElectronico; Representante.RL_FechaRegistro = DateTime.Now.ToString(); Representante.RL_Observaciones = "Validado"; Representante.RL_IdEstatusSolicitudRepresentante = 3; Representante.RL_Activo = true; Guid DatoAleatorio = new Guid(); DatoAleatorio = Guid.NewGuid(); string clave = "C"; clave = clave + DatoAleatorio.ToString().Substring(0, 8); clave = clave + DatoAleatorio.ToString().Substring(9, 4); string ContraseniaUsuarioRepresentante = MetodoGeneral.EncriptarPassword(clave); LogicaHome.L_ValidarRegistro(Representante, ContraseniaUsuarioRepresentante, clave); new Task(() => { try { MailMessage email = new MailMessage("*****@*****.**", CorreoRepresentante); email.To.Add(new MailAddress(ConfigurationManager.AppSettings["CorreoAdministrador"].ToString())); email.Subject = "Solicitud ENREL aprobada"; //Obtener la plantilla en HTML: string path = ConfigurationManager.AppSettings["Html_AceptarSolicitud"].ToString(); string ContenidoCorreo = System.IO.File.ReadAllText(path); string NombreRepresentanteLegal = Representante.RL_Nombre + " " + Representante.RL_PrimerApellido + " " + Representante.RL_SegundoApellido; ContenidoCorreo = ContenidoCorreo.Replace("#NombreRepresentanteLegal#", NombreRepresentanteLegal); ContenidoCorreo = ContenidoCorreo.Replace("#UsuarioAcreditado#", UsuarioRepresentante.U_Nombre); ContenidoCorreo = ContenidoCorreo.Replace("#Contraseña#", clave); string Enlace = ConfigurationManager.AppSettings["EnlaceENREL"].ToString(); ContenidoCorreo = ContenidoCorreo.Replace("#EnlaceENREL#", Enlace); AlternateView htmlView = AlternateView.CreateAlternateViewFromString(ContenidoCorreo, null, "text/html"); //Obtener imágenes: LinkedResource Logotipo_SENER = new LinkedResource(ConfigurationManager.AppSettings["Logotipo_SENER"].ToString()); Logotipo_SENER.ContentId = "Logotipo_SENER"; htmlView.LinkedResources.Add(Logotipo_SENER); LinkedResource Logotipo_MEXICO = new LinkedResource(ConfigurationManager.AppSettings["Logotipo_MEXICO"].ToString()); Logotipo_MEXICO.ContentId = "Logotipo_MEXICO"; htmlView.LinkedResources.Add(Logotipo_MEXICO); email.AlternateViews.Add(htmlView); email.IsBodyHtml = true; email.Priority = MailPriority.High; SmtpClient smtp = new SmtpClient(); smtp.Host = "172.16.70.110"; smtp.Port = 25; smtp.EnableSsl = false; smtp.UseDefaultCredentials = false; smtp.Send(email); email.Dispose(); } catch (Exception ex) { MetodoGeneral.RegistroDeError(ex.Message, "Registro de inversionista: Quinto Paso - Envío de correo"); } }).Start(); TempData["notice"] = "Se validó el registro"; Session["TipoAlerta"] = "Correcto"; return(RedirectToAction("GestionarSolicitudesRegistro", "Administrador")); } } catch (Exception ex) { CatRepresentantesLegales Representante = new CatRepresentantesLegales(); Representante = LogicaRepresentantesLegales.L_DetallesRepresentanteLegal(IdRepresentante); Representante.RL_FechaRegistro = DateTime.Now.ToString(); Representante.RL_IdEstatusSolicitudRepresentante = 1; Representante.RL_Activo = true; Representante.RL_Observaciones = "Error, es necesario volver a validar"; LogicaRepresentantesLegales.L_ActualizarRepresentanteLegal(Representante); LogicaEmpresas LogicaEmpresa = new LogicaEmpresas(); CatEmpresas Empresa = LogicaEmpresa.L_DetallesEmpresa(Representante.RL_IdEmpresa); ViewBag.DatosEmpresa = Empresa; ViewBag.DatosRepresentante = Representante; string ruta = @"C:\inetpub\RepositorioVER\" + Representante.RL_IdRepresentanteLegal.ToString() + "-"; ViewBag.PoderNotarial = ruta + "PoderNotarial.pdf"; ViewBag.CedulaRFC = ruta + "CedulaRFC.pdf"; ViewBag.ActaConstitutiva = ruta + "ActaConstitutiva.pdf"; ViewBag.IdentificacionOficial = ruta + "Identificacion.pdf"; ViewBag.DatosRepresentante = Representante; TempData["notice"] = ConfigurationManager.AppSettings["MensajeError"].ToString(); Session["TipoAlerta"] = "Error"; MetodoGeneral.RegistroDeError(ex.Message, "RepresentantesLegales: Insertar"); return(View("ValidarSolicitud", new { IdRepresentante = IdRepresentante })); } }
public ActionResult EliminarRepresentanteLegal(CatRepresentantesLegales Representante, string Accion, IEnumerable <HttpPostedFileBase> files) { CatEmpresas Empresa = new CatEmpresas(); MetodosGenerales MetodoGeneral = new MetodosGenerales(); CatUsuarios Usuario = (CatUsuarios)Session["Usuario"]; if (Usuario == null || Usuario.U_IdTipoUsuario != 2) { TempData["notice"] = "La sesión ha expirado."; return(RedirectToAction("Logout", "Home")); } try { LogicaEmpresas LogicaEmpresa = new LogicaEmpresas(); Empresa = LogicaEmpresa.L_DetallesEmpresa(Usuario.U_IdEmpresa); string Validacion = ""; string RFCAsociado = ""; RFCAsociado = Session["RFCAsociado"].ToString(); Validacion = MetodoGeneral.ValidarFIEL(files, Representante.RL_ClavePrivada, RFCAsociado); if (Validacion == "Validación exitosa") { if (LogicaRepresentanteLegal.L_EliminarRepresentanteLegal(Representante.RL_IdRepresentanteLegal)) { CatUsuarios UsuarioDelRepresentante = new CatUsuarios(); LogicaUsuarios LogicaUsuario = new LogicaUsuarios(); UsuarioDelRepresentante = LogicaUsuario.L_DetallesUsuarioPorRepresentante(Representante.RL_IdRepresentanteLegal); if (Usuario.U_IdUsuario == UsuarioDelRepresentante.U_IdUsuario) { TempData["notice"] = "El representante ha sido eliminado de manera existosa."; Session["TipoAlerta"] = "Correcto"; return(RedirectToAction("Logout", "Home")); } else { TempData["notice"] = "Se ha deshabilitado un representante legal para esta empresa."; Session["TipoAlerta"] = "Correcto"; Usuario = (CatUsuarios)Session["Usuario"]; if (Usuario == null || Usuario.U_IdTipoUsuario != 2) { TempData["notice"] = "La sesión ha expirado."; return(RedirectToAction("Logout", "Home")); } else { List <CatRepresentantesLegales> ListaRepresentantesLegales = new List <CatRepresentantesLegales>(); ListaRepresentantesLegales = LogicaRepresentanteLegal.L_SeleccionarRepresentantesLegalesPorEmpresa(Usuario.U_IdEmpresa); ViewBag.CantidadRL = ListaRepresentantesLegales.Count(); return(View("Index", ListaRepresentantesLegales)); } } } else { TempData["notice"] = "Operación no concluida, favor de comunicarse con un administrador de SENER."; Session["TipoAlerta"] = "Error"; return(View("Eliminar", Representante)); } } else { TempData["notice"] = Validacion; Session["TipoAlerta"] = "Error"; return(View("Eliminar", Representante)); } } catch (Exception ex) { TempData["notice"] = ConfigurationManager.AppSettings["MensajeError"].ToString(); Session["TipoAlerta"] = "Error"; MetodoGeneral.RegistroDeError(ex.Message, "RepresentantesLegales: EliminarRepresentanteLegal"); return(View("Eliminar", Representante)); } }