public async Task <IHttpActionResult> Get(DtoEmpresa filtros) { try { List <DtoEmpresa> empresas = new List <DtoEmpresa>(); await Task.Run(() => { empresas = LogicaEmpresas.GetEmpresas(filtros); }); if (empresas != null) { return(Ok(empresas)); } else { return(NotFound()); } } catch (Exception ex) { ClsVisorEventos.LogEvent(ex); return(BadRequest($"Incorrect call:{ex.Message}")); } }
public async Task <IHttpActionResult> Putempresa([FromBody] DtoEmpresa empresa) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (empresa != null) { await Task.Run(() => { LogicaEmpresas.ActualizarEmpresa(empresa); }); return(Ok("Actualizado con éxito")); } else { return(BadRequest("Incorrect call")); } } catch (Exception ex) { ClsVisorEventos.LogEvent(ex); return(BadRequest($"Incorrect call:{ex.Message}")); } }
public SelectList CargarEmpresas() { List <CatEmpresas> ListaEmpresas = new List <CatEmpresas>(); LogicaEmpresas LogicaEmpresa = new LogicaEmpresas(); ListaEmpresas = LogicaEmpresa.L_SeleccionarEmpresas(); return(new SelectList(ListaEmpresas, "E_IdEmpresa", "E_NombreComercial")); }
public Login() { List<string> empresas = LogicaEmpresas.obtenerNombreEmpresas(); InitializeComponent(); string[] nombres = new string[empresas.Count]; for (int i = 0; i < empresas.Count; i++) { nombres[i] = empresas[i]; } this.comboBoxEmpresaLogin.Items.AddRange(nombres); }
public ControlPanel() { InitializeComponent(); List <string> empresas = LogicaEmpresas.obtenerNombreEmpresas(); string[] nombres = new string[empresas.Count]; for (int i = 0; i < empresas.Count; i++) { nombres[i] = empresas[i]; } this.Moneda.HeaderText = "Moneda"; this.Moneda.Items.AddRange(nombres); this.comboBoxEmpresaUsuario.Items.AddRange(nombres); this.comboBoxEmpresaManejoPeriodos.Items.AddRange(nombres); List <Moneda> monedas = AccesoMonedas.obtenerMonedas(); string[] nombresMoneda = new string[monedas.Count]; for (int i = 0; i < monedas.Count; i++) { nombresMoneda[i] = monedas[i].Nombre; } this.comboBoxMonedaSistemaEmpresa.Items.AddRange(nombresMoneda); this.comboBoxMonedaLocalEmpresa.Items.AddRange(nombresMoneda); comboBoxMonedaLocalEmpresa.SelectedIndex = 0; comboBoxPeriodoManejoPeriodos.Items.Clear(); comboBoxPeriodoManejoPeriodos.Items.Add("2012-10-01 / 2012-10-31"); comboBoxPeriodoManejoPeriodos.Items.Add("2012-11-01 / 2012-11-30"); comboBoxPeriodoManejoPeriodos.Items.Add("2012-12-01 / 2013-12-31"); comboBoxPeriodoManejoPeriodos.Items.Add("2013-01-01 / 2012-01-31"); comboBoxPeriodoManejoPeriodos.Items.Add("2013-02-01 / 2013-02-28"); comboBoxPeriodoManejoPeriodos.Items.Add("2013-03-01 / 2013-03-31"); comboBoxPeriodoManejoPeriodos.Items.Add("2013-04-01 / 2013-04-30"); comboBoxPeriodoManejoPeriodos.Items.Add("2013-05-01 / 2013-05-31"); comboBoxPeriodoManejoPeriodos.Items.Add("2013-06-01 / 2013-06-30"); comboBoxPeriodoManejoPeriodos.Items.Add("2013-07-01 / 2013-07-31 "); comboBoxPeriodoManejoPeriodos.Items.Add("2013-08-01 / 2013-08-31"); comboBoxPeriodoManejoPeriodos.Items.Add("2013-09-01 / 2013-09-30"); comboBoxPeriodoManejoPeriodos.SelectedIndex = 0; comboBoxEstadoManejoPeriodos.Items.Add("Abierto"); comboBoxEstadoManejoPeriodos.Items.Add("Cerrado"); comboBoxEstadoManejoPeriodos.Items.Add("Cerrado Excepto Ventas"); comboBoxEstadoManejoPeriodos.SelectedIndex = 0; }
public ActionResult DatosRepresentante(CatEmpresas Empresa) { try { if (Session["Registrando"] == null) { TempData["notice"] = "La sesión ha expirado."; return(RedirectToAction("Logout", "Home")); } Representante = (CatRepresentantesLegales)Session["NuevoAcceso_Representante"]; Session.Add("NuevoAcceso_Empresa", Empresa); LogicaEmpresas LogicaEmpresa = new LogicaEmpresas(); CatEmpresas EmpresaExistente = LogicaEmpresa.L_DetallesEmpresaPorRFC(Empresa.E_RFC); if (EmpresaExistente.E_RFC == null) { if (Representante == null) { CargarListasDesplegables(null, null, null, null); return(View()); } else { //Cambio de Código Póstal //if (Empresa.E_CodigoPostal == 0 || Empresa.E_CodigoPostal == null) { Empresa.E_CodigoPostal = null; } CargarListasDesplegables(Representante.RL_CodigoPostal, Representante.RL_IdEntidadFederativa, Representante.RL_IdMunicipio, Representante.RL_IdLocalidad); return(View("DatosRepresentante", Representante)); } } else { TempData["notice"] = "Ya existe una empresa con el mismo RFC en la base de datos."; Session["TipoAlerta"] = "Error"; CargarListasDesplegables(Empresa.E_CodigoPostal, Empresa.E_IdEntidadFederativa, Empresa.E_IdMunicipio, Empresa.E_IdLocalidad); return(View("Index", Empresa)); } } catch (Exception ex) { TempData["notice"] = ConfigurationManager.AppSettings["MensajeError"].ToString(); Session["TipoAlerta"] = "Error"; MetodoGeneral.RegistroDeError(ex.Message, "Registro de inversionista: Segundo Paso"); return(View("Index", "Home")); } }
private void buttonGuardarPeriodo_Click(object sender, EventArgs e) { Periodo periodoNuevo = new Periodo(); string nuevoEstado = this.comboBoxPeriodoManejoPeriodos.SelectedItem.ToString(); string[] tokens = nuevoEstado.Split('/'); periodoNuevo.TipoPeriodo = this.comboBoxEstadoManejoPeriodos.SelectedItem.ToString(); string fecha = tokens[0]; DateTimeFormatInfo dtfi = new DateTimeFormatInfo(); dtfi.ShortDatePattern = "yyyy-MM-dd"; dtfi.DateSeparator = "-"; DateTime objDate = Convert.ToDateTime(fecha, dtfi); periodoNuevo.FechaInicio = objDate; periodoNuevo.NombreEmpresa = this.comboBoxEmpresaManejoPeriodos.SelectedItem.ToString(); LogicaEmpresas.actualizarPeriodo(periodoNuevo); MessageBox.Show("El periodo ha sido actualizado", "Información", MessageBoxButtons.OK); }
private void buttonCrearEmpresa_Click(object sender, EventArgs e) { // Stream usado como buffer System.IO.MemoryStream ms = new System.IO.MemoryStream(); // Se guarda la imagen en el buffer pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); // Se extraen los bytes del buffer para asignarlos como valor para el // parámetro. Empresa empresaNueva = new Empresa(); empresaNueva.Nombre = textBoxNombreEmpresa.Text; empresaNueva.CedulaJuridica = Convert.ToInt64(textBoxCedulaJuridica.Text); empresaNueva.Telefono = Convert.ToInt64(textBoxTelefono.Text); empresaNueva.Fax = Convert.ToInt64(textBoxFax.Text); empresaNueva.MonedaLocal = comboBoxMonedaLocalEmpresa.SelectedItem.ToString(); empresaNueva.MonedaSistema = comboBoxMonedaSistemaEmpresa.SelectedItem.ToString(); empresaNueva.Imagen = ms.GetBuffer(); LogicaEmpresas.introducirEmpresa(empresaNueva); MessageBox.Show("La empresa ha sido insertada", "Información", MessageBoxButtons.OK); }
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 RechazarRepresentanteLegal(FormCollection form) { LogicaUsuarios LogicaUsuarios = new LogicaUsuarios(); int IdRepresentante = Int32.Parse(form["IdRepresentante"]); string Observaciones = form["Observaciones"]; LogicaRepresentantesLegales LogicaRepresentantesLegales = new LogicaRepresentantesLegales(); CatRepresentantesLegales Representante = new CatRepresentantesLegales(); Representante = LogicaRepresentantesLegales.L_DetallesRepresentanteLegal(IdRepresentante); string CorreoRepresentante = Representante.RL_CorreoElectronico; Representante.RL_Observaciones = Observaciones; Representante.RL_IdEstatusSolicitudRepresentante = 2; Representante.RL_Activo = true; LogicaRepresentantesLegales.L_ActualizarRepresentanteLegal(Representante); try { new Task(() => { try { MailMessage email = new MailMessage("*****@*****.**", CorreoRepresentante); email.To.Add(new MailAddress(ConfigurationManager.AppSettings["CorreoAdministrador"].ToString())); email.Subject = "Solicitud ENREL no aprobada"; //Obtener la plantilla en HTML: string path = ConfigurationManager.AppSettings["Html_RechazarSolicitud"].ToString(); string ContenidoCorreo = System.IO.File.ReadAllText(path); string NombreRepresentanteLegal = Representante.RL_Nombre + " " + Representante.RL_PrimerApellido + " " + Representante.RL_SegundoApellido; ContenidoCorreo = ContenidoCorreo.Replace("#NombreRL#", NombreRepresentanteLegal); ContenidoCorreo = ContenidoCorreo.Replace("#Observaciones#", Observaciones); 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.Body = ContenidoCorreo; 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(); return(RedirectToAction("GestionarSolicitudesRegistro", "Administrador")); } catch (Exception ex) { Representante.RL_Observaciones = "Ha ocurrido un error en el servicio y no se pudo enviar el correo con estatus rechazado."; Representante.RL_IdEstatusSolicitudRepresentante = 1; LogicaRepresentantesLegales.L_ActualizarRepresentanteLegal(Representante); LogicaEmpresas LogicaEmpresa = new LogicaEmpresas(); CatEmpresas Empresa = LogicaEmpresa.L_DetallesEmpresa(Representante.RL_IdEmpresa); ViewBag.DatosEmpresa = Empresa; ViewBag.DatosRepresentante = Representante; TempData["notice"] = ConfigurationManager.AppSettings["MensajeError"].ToString(); Session["TipoAlerta"] = "Error"; MetodoGeneral.RegistroDeError(ex.Message, "RepresentantesLegales: Insertar"); return(RedirectToAction("GestionarSolicitudesRegistro", "Administrador")); } }
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 InsertarPrimerusuario(IEnumerable <HttpPostedFileBase> files, FormCollection form) { LogicaUsuarios Logicausuarios = new LogicaUsuarios(); LogicaEmpresas LogicaEmpresas = new LogicaEmpresas(); LogicaRepresentantesLegales LogicaRepresentantesLegales = new LogicaRepresentantesLegales(); LogicaHome LogicaHome = new LogicaHome(); string FechaActual = DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss"); try { if (Session["Registrando"] == null) { TempData["notice"] = "La sesión ha expirado."; return(RedirectToAction("Logout", "Home")); } Empresa = (CatEmpresas)Session["NuevoAcceso_Empresa"]; Representante = (CatRepresentantesLegales)Session["NuevoAcceso_Representante"]; string ClavePrivada = form["RL_ClavePrivada"]; string Validacion = MetodoGeneral.ValidarFIEL(files, ClavePrivada, Representante.RL_RFC); if (Validacion == "Validación exitosa") { CatEmpresas EmpresaSession = (CatEmpresas)Session["NuevoAcceso_Empresa"]; EmpresaSession.E_CompartirDatos = false; if (form["CompartirDatos"].Equals("2")) { EmpresaSession.E_CompartirDatos = true; } CatUsuarios UsuarioOperativoSession = (CatUsuarios)Session["NuevoAcceso_Usuario"]; //LogicaHome.L_InsertarRegistroSolicitud(EmpresaSession, Representante, UsuarioOperativoSession); string GUID = LogicaHome.L_InsertarRegistroSolicitud(Empresa, Representante, UsuarioOperativoSession); string ext = ""; X509Certificate2 CertificadoParaFirma = new X509Certificate2(); CatRepresentantesLegales NuevoRepresentante = (CatRepresentantesLegales)Session["NuevoAcceso_Representante"]; if (!Directory.Exists(@"C:\inetpub\RepositorioVER\Representantes\" + NuevoRepresentante.RL_IdRepresentanteLegal.ToString())) { DirectoryInfo di = Directory.CreateDirectory(@"C:\inetpub\RepositorioVER\Representantes\" + NuevoRepresentante.RL_IdRepresentanteLegal.ToString()); } int num_archivo = 0; foreach (string inputTagName in Request.Files) { HttpPostedFileBase file = Request.Files[num_archivo]; num_archivo = num_archivo + 1; ext = Path.GetExtension(file.FileName); if (ext != ".cer" && ext != ".key") { bool PdfValido = MetodoGeneral.ReadByteArrayFromFile(file); if ((file.ContentType.ToString().ToLower() == "application/pdf" && PdfValido) || file.ContentType.ToString().ToLower() == "application/x-zip-compressed") { string path = @"C:\inetpub\RepositorioVER\Representantes\" + NuevoRepresentante.RL_IdRepresentanteLegal.ToString() + "\\" + inputTagName + "_PDF_" + FechaActual + ext; using (Stream fs = file.InputStream) { fs.Flush(); fs.Position = 0; CertificadoParaFirma = MetodoGeneral.ObtenerCertificadoParaFirmar(files, ClavePrivada); MetodoGeneral.SignWithThisCert(CertificadoParaFirma, fs, path); } } } } TempData["notice"] = "Los datos han sido registrados exitosamente."; Session.Clear(); Session["TipoAlerta"] = "Correcto"; string target = @"C:\inetpub\RepositorioVER\Representantes\" + NuevoRepresentante.RL_IdRepresentanteLegal.ToString() + "\\" + "AcuseRegistroInversionista_PDF_" + FechaActual; CatRepresentantesLegales DatosRepresentante = LogicaRepresentantesLegales.L_DetallesRepresentanteLegal(NuevoRepresentante.RL_IdRepresentanteLegal); CatEmpresas DatosEmpresa = LogicaEmpresas.L_DetallesEmpresa(DatosRepresentante.RL_IdEmpresa); CrearAcuseRegistroInversionista(GUID, target, DatosEmpresa, DatosRepresentante); //Enviar acuse: new System.Threading.Tasks.Task(() => { try { string CorreoRepresentante = Representante.RL_CorreoElectronico; Representante.RL_FechaRegistro = DateTime.Now.ToString(); Representante.RL_Observaciones = "Solicitud de registro enviada"; //CatRepresentantesLegales DatosRepresentante = LogicaRepresentantesLegales.L_DetallesRepresentanteLegal(NuevoRepresentante.RL_IdRepresentanteLegal); //CatEmpresas DatosEmpresa = LogicaEmpresas.L_DetallesEmpresa(DatosRepresentante.RL_IdEmpresa); System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage("*****@*****.**", CorreoRepresentante); email.To.Add(new MailAddress(ConfigurationManager.AppSettings["CorreoAdministrador"].ToString())); email.Subject = "Acuse de registro"; email.Attachments.Add(new Attachment(target + ".pdf")); //Obtener la plantilla en HTML: string pathCorreo = ConfigurationManager.AppSettings["Html_AcuseRegistroENREL"].ToString(); string ContenidoCorreo = System.IO.File.ReadAllText(pathCorreo); //Reemplazar información string ContactoEmpresa = "Teléfono (" + DatosEmpresa.E_Lada + ") " + DatosEmpresa.E_TelefonoFijo.ToString(); string NombreRepresentante = DatosRepresentante.RL_Nombre + " " + DatosRepresentante.RL_PrimerApellido + " " + DatosRepresentante.RL_SegundoApellido; string ContactoRepresentanteLegal = "Teléfono (" + DatosRepresentante.RL_Lada + ") " + DatosRepresentante.RL_TelefonoFijo.ToString() + " Ext. " + DatosRepresentante.RL_ExtensionTelefonica + ", Teléfono móvil: " + DatosRepresentante.RL_TelefonoCelular; string EmpresaNumeroInterior = ""; try { EmpresaNumeroInterior = DatosEmpresa.E_NumeroInterior.ToString(); } catch { } string EmpresaCodigoPostal = ""; try { EmpresaCodigoPostal = DatosEmpresa.E_CodigoPostal.ToString(); } catch { } string RepresentanteNumeroInterior = ""; try { RepresentanteNumeroInterior = DatosRepresentante.RL_NumeroInterior.ToString(); } catch { } string RepresentanteCodigoPostal = ""; try { RepresentanteCodigoPostal = DatosRepresentante.RL_CodigoPostal.ToString(); } catch { } ContenidoCorreo = ContenidoCorreo.Replace("#NombreEmpresa#", DatosEmpresa.E_NombreComercial); ContenidoCorreo = ContenidoCorreo.Replace("#RFCEmpresa#", DatosEmpresa.E_RFC); ContenidoCorreo = ContenidoCorreo.Replace("#ContactoEmpresa#", ContactoEmpresa); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioEmpresaCalle#", DatosEmpresa.E_Calle); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioEmpresaNExterior#", DatosEmpresa.E_NumeroExterior.ToString()); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioEmpresaNInterior#", EmpresaNumeroInterior); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioEmpresaColonia#", DatosEmpresa.E_Colonia); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioEmpresaCP#", EmpresaCodigoPostal); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioEmpresaMunicipio#", DatosEmpresa.E_Municipio); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioEmpresaEstado#", DatosEmpresa.E_EntidadFederativa); ContenidoCorreo = ContenidoCorreo.Replace("#NombreRepresentanteLegal#", NombreRepresentante); ContenidoCorreo = ContenidoCorreo.Replace("#RFCRepresentanteLegal#", DatosRepresentante.RL_RFC); ContenidoCorreo = ContenidoCorreo.Replace("#ContactoRepresentanteLegal#", ContactoRepresentanteLegal); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioRepresentanteCalle#", DatosRepresentante.RL_Calle); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioRepresentanteNExterior#", DatosRepresentante.RL_NumeroExterior.ToString()); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioRepresentanteNInterior#", RepresentanteNumeroInterior); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioRepresentanteColonia#", DatosRepresentante.RL_Colonia); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioRepresentanteCP#", RepresentanteCodigoPostal); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioRepresentanteMunicipio#", DatosRepresentante.RL_Municipio); ContenidoCorreo = ContenidoCorreo.Replace("#DomicilioRepresentanteEstado#", DatosRepresentante.RL_EntidadFederativa); 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(); return(View()); } else { TempData["notice"] = Validacion; Session["TipoAlerta"] = "Error"; MetodoGeneral.RegistroDeError(Validacion, "Registro de inversionista: Quinto Paso"); Representante = (CatRepresentantesLegales)Session["NuevoAcceso_Representante"]; ViewBag.RFCRepresentante = Representante.RL_RFC; if (Empresa.E_RFC.Length == 12) { ViewBag.MostrarDocumento = true; } else { ViewBag.MostrarDocumento = false; } return(View("DatosAcreditacion")); } } catch (Exception ex) { TempData["notice"] = ConfigurationManager.AppSettings["MensajeError"].ToString(); Session["TipoAlerta"] = "Error"; MetodoGeneral.RegistroDeError(ex.InnerException.ToString(), "Registro de inversionista: Quinto Paso"); if (Empresa.E_IdEmpresa > 0) { LogicaHome.L_EliminarIntentoRegistro(Empresa.E_IdEmpresa); } ViewBag.RFCRepresentante = Representante.RL_RFC; if (Empresa.E_RFC.Length == 12) { ViewBag.MostrarDocumento = true; } else { ViewBag.MostrarDocumento = false; } return(View("DatosAcreditacion")); } }
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)); } }
public ActionResult ActualizarRepresentanteLegal(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."; 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") { Representante.RL_IdEstatusSolicitudRepresentante = 1; Representante.RL_Activo = true; if (LogicaRepresentanteLegal.L_ActualizarRepresentanteLegal(Representante)) { try { string ext = ""; int num_archivo = 0; foreach (string inputTagName in Request.Files) { HttpPostedFileBase file = Request.Files[num_archivo]; num_archivo = num_archivo + 1; ext = Path.GetExtension(file.FileName); if (ext != ".cer" && ext != ".key") { if (file.ContentType.ToString().ToLower() == "application/pdf") { var fileName = Path.GetFileName(file.FileName); //string path = @"C:\Users\jesusalejandro.ramos\Desktop\repositorio\" + Representante.RL_IdRepresentanteL.ToString() + "-" + inputTagName + ext; string path = @"C:\inetpub\RepositorioVER\" + Representante.RL_IdRepresentanteLegal.ToString() + "-" + inputTagName + ext; file.SaveAs(path); } } } TempData["notice"] = "El representante ha sido actualizado, deberá esperar un correo con el resultado de la nueva validación."; Session["TipoAlerta"] = "Correcto"; } catch (Exception ex) { TempData["notice"] = "La información se ha actualizado pero uno o varios archivos no han sido enviados, comunícate con algun administrador de SENER."; Session["TipoAlerta"] = "Error"; } } else { TempData["notice"] = "El representante no ha sido actualizado, por favor revise la información."; Session["TipoAlerta"] = "Error"; } } else { TempData["notice"] = Validacion; Session["TipoAlerta"] = "Error"; } //Despliegue de vista if (Session["TipoAlerta"] == "Error") { CargarListasDesplegables(Representante.RL_CodigoPostal, Representante.RL_IdEntidadFederativa, Representante.RL_IdMunicipio, Representante.RL_IdLocalidad); return(View("Actualizar", Representante)); } else { return(RedirectToAction("Logout", "Home")); } } catch (Exception ex) { TempData["notice"] = ConfigurationManager.AppSettings["MensajeError"].ToString(); Session["TipoAlerta"] = "Error"; MetodoGeneral.RegistroDeError(ex.Message, "RepresentantesLegales: ActualizarRepresentanteLegal"); return(View("Actualizar", Representante)); } }
public ActionResult InsertarRepresentanteLegal(CatRepresentantesLegales Representante, string Accion, IEnumerable <HttpPostedFileBase> files) { CatEmpresas Empresa = new CatEmpresas(); MetodosGenerales MetodoGeneral = new MetodosGenerales(); string FechaActual = DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss"); CatUsuarios Usuario = (CatUsuarios)Session["Usuario"]; if (Usuario == null || Usuario.U_IdTipoUsuario != 2) { TempData["notice"] = "La sesión ha expirado."; 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") { int IdRepresentanteLegal = LogicaRepresentanteLegal.L_InsertarRepresentanteLegal(Representante, Usuario.U_IdEmpresa); if (IdRepresentanteLegal > 0) { string ext = ""; if (!Directory.Exists(@"C:\inetpub\RepositorioVER\Representantes\" + IdRepresentanteLegal.ToString())) { DirectoryInfo di = Directory.CreateDirectory(@"C:\inetpub\RepositorioVER\Representantes\" + IdRepresentanteLegal.ToString()); } int num_archivo = 0; foreach (string inputTagName in Request.Files) { HttpPostedFileBase file = Request.Files[num_archivo]; num_archivo = num_archivo + 1; ext = Path.GetExtension(file.FileName); if (ext != ".cer" && ext != ".key") { var fileName = Path.GetFileName(file.FileName); bool PdfValido = MetodoGeneral.ReadByteArrayFromFile(file); if (file.ContentType.ToString().ToLower() == "application/pdf" && PdfValido) { string path = @"C:\inetpub\RepositorioVER\Representantes\" + IdRepresentanteLegal.ToString() + "\\" + inputTagName + "_PDF_" + FechaActual + ext; //string path = @"C:\inetpub\RepositorioVER\" + IdRepresentanteLegal.ToString() + "-" + inputTagName + ext; file.SaveAs(path); } } } TempData["notice"] = "Se ha solicitado la autorización de un nuevo representante al cual, se le hará llegar un correo con la resolución del administrador. "; Session["TipoAlerta"] = "Correcto"; } else { TempData["notice"] = "No se pudo registrar el representante legal, por favor revise la información."; Session["TipoAlerta"] = "Error"; } } else { TempData["notice"] = Validacion; Session["TipoAlerta"] = "Error"; } //Despliegue de vista if (Session["TipoAlerta"] == "Error") { CargarListasDesplegables(Representante.RL_CodigoPostal, Representante.RL_IdEntidadFederativa, Representante.RL_IdMunicipio, Representante.RL_IdLocalidad); return(View("Insertar", Representante)); } else { Usuario = (CatUsuarios)Session["Usuario"]; if (Usuario == null || Usuario.U_IdTipoUsuario != 2) { TempData["notice"] = "La sesión ha expirado."; return(RedirectToAction("Logout", "Home")); } List <CatRepresentantesLegales> ListaRepresentantesLegales = new List <CatRepresentantesLegales>(); ListaRepresentantesLegales = LogicaRepresentanteLegal.L_SeleccionarRepresentantesLegalesPorEmpresa(Usuario.U_IdEmpresa); ViewBag.CantidadRL = ListaRepresentantesLegales.Count(); return(View("Index", ListaRepresentantesLegales)); } } catch (Exception ex) { TempData["notice"] = ConfigurationManager.AppSettings["MensajeError"].ToString(); Session["TipoAlerta"] = "Error"; MetodoGeneral.RegistroDeError(ex.Message, "RepresentantesLegales: InsertarRepresentanteLegal"); return(View("Insertar", Representante)); } }
//[HttpPost] public ActionResult EjecutarAccionUsuarioSENER(CatUsuarios UsuarioPorEditar, string Accion, int IdUsuarioPorEditar, bool IdEstatusUsuario) { CatUsuarios Usuario = (CatUsuarios)Session["Usuario"]; CatEmpresas Empresa = new CatEmpresas(); MetodosGenerales MetodoGeneral = new MetodosGenerales(); try { if (Usuario == null || Usuario.U_IdTipoUsuario != 4) { TempData["notice"] = "La sesión ha expirado."; return(RedirectToAction("Logout", "Home")); } LogicaEmpresas LogicaEmpresa = new LogicaEmpresas(); LogicaUsuarios LogicaUsuario = new LogicaUsuarios(); Empresa = LogicaEmpresa.L_DetallesEmpresa(Usuario.U_IdEmpresa); switch (Accion) { case "Insertar": CatUsuarios UsuarioExistente = LogicaUsuario.L_DetallesUsuarioPorNombreUnicamente(UsuarioPorEditar.U_Nombre); if (UsuarioExistente.U_IdUsuario != null && UsuarioExistente.U_IdUsuario > 0) { TempData["notice"] = "Ya existe una usuario con el mismo nombre, por favor elige otro."; Session["TipoAlerta"] = "Error"; CargarListasDesplegables(null, null); return(View("InsertarUsuarioSENER", UsuarioPorEditar)); } else { if (UsuarioPorEditar.U_Password != UsuarioPorEditar.U_ConfirmarPassword) { TempData["notice"] = "La contraseñas no coinciden."; Session["TipoAlerta"] = "Error"; CargarListasDesplegables(null, null); return(View("InsertarUsuarioSENER", UsuarioPorEditar)); } else { UsuarioPorEditar.U_Activo = true; if (LogicaUsuario.L_InsertarUsuarioSENER(UsuarioPorEditar, Usuario.U_IdEmpresa)) { TempData["notice"] = "El usuario ha sido creado."; Session["TipoAlerta"] = "Correcto"; return(RedirectToAction("GestionUsuariosSENER", "Administrador")); } else { TempData["notice"] = "Error de sistema."; Session["TipoAlerta"] = "Error"; CargarListasDesplegables(null, null); return(View("InsertarUsuarioSENER", UsuarioPorEditar)); } } } case "CambiarEstatus": UsuarioPorEditar.U_IdUsuario = IdUsuarioPorEditar; UsuarioPorEditar.U_Activo = !IdEstatusUsuario; if (LogicaUsuario.L_ActualizarEstatusUsuarioSENER(UsuarioPorEditar.U_IdUsuario, UsuarioPorEditar.U_Activo)) { if (UsuarioPorEditar.U_IdUsuario == Usuario.U_IdUsuario) { return(RedirectToAction("GestionUsuariosSENER", "Administrador")); } else { TempData["notice"] = "Se realizó el cambio de estatus."; Session["TipoAlerta"] = "Correcto"; return(RedirectToAction("GestionUsuariosSENER", "Administrador")); } } else { TempData["notice"] = "Operación no concluida."; Session["TipoAlerta"] = "Error"; return(RedirectToAction("Eliminar", new { IdUsuario = UsuarioPorEditar.U_IdUsuario })); } default: return(RedirectToAction("GestionUsuariosSENER", "Administrador")); } } catch (Exception ex) { TempData["notice"] = ConfigurationManager.AppSettings["MensajeError"].ToString(); Session["TipoAlerta"] = "Error"; MetodoGeneral.RegistroDeError(ex.Message, "Usuarios: EjecutarAccionUsuario(" + Accion + ")"); return(RedirectToAction("Actualizar", "Administrador")); } }