/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { try { btnImprimir.Attributes.Add("onClick", "Imprimir();"); btnVolver.Attributes.Add("onClick", "Cerrar();"); if (!Page.IsPostBack) { Persona usuario = new Persona(); usuario.username = ObjSessionDataUI.ObjDTUsuario.Nombre; BLPersona objBLPersona = new BLPersona(usuario); objBLPersona.GetPersonaByEntidad(); usuario = objBLPersona.Data; gvwReporte = UIUtilidades.GenerarGrilla(gvwReporte, dtReporte); lblTitulo.Text = "EDU@R 2.0"; lblInforme.Text = tituloReporte; lblFecha.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0'); lblUsuario.Text = "- Usuario: " + usuario.apellido + " " + usuario.nombre; lblFiltro.Text = filtrosAplicados.Replace("\n", "<br />"); gvwReporte.AllowPaging = false; gvwReporte.PageSize = 1000; gvwReporte.DataSource = dtReporte.DefaultView; gvwReporte.DataBind(); udpReporte.Update(); } } catch (Exception ex) { AvisoMostrar = true; AvisoExcepcion = ex; } }
static void Main() { BLPersona bLPersona = new BLPersona(); if (bLPersona.existeAdmin()) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Login()); } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FrmUsuario()); } }
/// <summary> /// Handles the Click event of the btnValidar control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnValidar_Click(object sender, EventArgs e) { try { Persona persona = new Persona(); persona.idTipoDocumento = Convert.ToInt32(ddlTipoDocumento.SelectedValue); persona.numeroDocumento = Convert.ToInt32(txtNroDocumento.Text); DateTime fecha = new DateTime(); if (DateTime.TryParse(calFechaNacimiento.Fecha.Text, out fecha)) { persona.fechaNacimiento = fecha; BLPersona objBLPersona = new BLPersona(persona); objBLPersona.ValidarRegistroPersona(); if (objBLPersona.Data != null) { propPersona = new Persona(); propPersona = objBLPersona.Data; // Ya tiene usuario registrado if (objBLPersona.Data.username != string.Empty) { AccionPagina = enumAcciones.Redirect; Master.MostrarMensaje("Ya posee usuario", UIConstantesGenerales.MensajeUsuarioExiste, enumTipoVentanaInformacion.Advertencia); } else if (objBLPersona.Data.activo == false) { AccionPagina = enumAcciones.Salir; Master.MostrarMensaje("Usuario no activo", UIConstantesGenerales.MensajeLoginUsuarioNoActivo, enumTipoVentanaInformacion.Advertencia); } else Response.Redirect("~/Private/Account/Register.aspx", false); } } else { AccionPagina = enumAcciones.Error; Master.MostrarMensaje("Datos Faltantes", "Por Favor, ingrese la fecha de nacimiento.", enumTipoVentanaInformacion.Advertencia); } } catch (Exception ex) { Master.ManageExceptions(ex); } }
private void Form2_Load(object sender, EventArgs e) { BLPersona bl = new BLPersona(); if (Form1.accion.Equals("Consultar")) { TOPersona personaConsultada = bl.consultarPersona(Form1.id_Actual); btnIngresar.Visible = false; tituloIngresar.Text = "Consultar Persona"; txtId.Text = personaConsultada.id; txtNombre.Text = personaConsultada.nombre; txtApellido.Text = personaConsultada.apellidos; InfechaNacimiento.Value = personaConsultada.fechaNacimiento; comboSexo.SelectedItem = personaConsultada.sexo.Trim(); comboCivil.SelectedItem = personaConsultada.estadoCivil; txtOficio.Text = personaConsultada.ocupacion; } }
private void btnIngresar_Click(object sender, EventArgs e) { String id = txtId.Text; String nombre = txtNombre.Text; String apellido = txtApellido.Text; DateTime fechaNacimiento = InfechaNacimiento.Value; String sexo = comboSexo.SelectedItem + ""; String oficio = txtOficio.Text; String estadoCivil = comboCivil.SelectedItem + ""; TOPersona persona = new TOPersona(id, nombre, apellido, oficio, estadoCivil, sexo, fechaNacimiento); BLPersona inBL = new BLPersona(); inBL.ingresarPersona(persona); MessageBox.Show("Los datos se guardaron correctamente"); this.Hide(); Form1 frm1 = new Form1(); frm1.Show(); }
/// <summary> /// Cargars the lista. /// </summary> private void CargarLista() { BLPersona objpersona = new BLPersona(); List<Persona> lista = null; ////Docente: a personas o cursos if (HttpContext.Current.User.IsInRole(enumRoles.Docente.ToString())) { divDocente.Visible = true; CargarComboCursos(); rdlDestinatarios.Enabled = false; ddlDestino.Disabled = true; } //Alumno: a SUS docentes o su curso if (HttpContext.Current.User.IsInRole(enumRoles.Alumno.ToString())) { Alumno objAlumno = new Alumno { username = ObjSessionDataUI.ObjDTUsuario.Nombre }; BLAlumno objBLAlumno = new BLAlumno(objAlumno); lista = objBLAlumno.GetDocentesAlumno(cicloLectivoActual); } //Tutor: docentes de sus alumnos if (HttpContext.Current.User.IsInRole(enumRoles.Tutor.ToString())) { Tutor objTutor = new Tutor(); objTutor.username = ObjSessionDataUI.ObjDTUsuario.Nombre; BLTutor objBLTutor = new BLTutor(objTutor); lista = objBLTutor.GetDocentesAlumnos(cicloLectivoActual); } //Administrativo: a tutores if (HttpContext.Current.User.IsInRole(enumRoles.Administrativo.ToString())) { lista = objpersona.GetPersonas(new Persona() { activo = true, idTipoPersona = (int)enumTipoPersona.Tutor }); } //Preceptor: a cualquier persona //Director: a cualquier persona //Psicopedagogo: a cualquier persona if (HttpContext.Current.User.IsInRole(enumRoles.Director.ToString()) || HttpContext.Current.User.IsInRole(enumRoles.Psicopedagogo.ToString()) || HttpContext.Current.User.IsInRole(enumRoles.Administrador.ToString()) || HttpContext.Current.User.IsInRole(enumRoles.Preceptor.ToString()) ) { chkFiltrado.Visible = true; lblFiltrado.Visible = true; CargarComboTodosCursos(); rdlDestinatarios.Enabled = false; ddlDestino.Disabled = true; lista = objpersona.GetPersonas(new Persona() { activo = true }); } if (lista != null) { CargarDestinos(lista); } }
/// <summary> /// Handles the CreatedUser event of the RegisterUser control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void RegisterUser_CreatedUser(object sender, EventArgs e) { propSeguridad = new DTSeguridad(); propSeguridad.Usuario.Nombre = RegisterUser.UserName.Trim(); //Personal = 1, //Alumno = 2, //Tutor = 3 DTRol rol = new DTRol(); switch (propPersona.idTipoPersona) { case 1: rol.Nombre = enumRoles.Administrativo.ToString(); break; case 2: rol.Nombre = enumRoles.Alumno.ToString(); break; case 3: rol.Nombre = enumRoles.Tutor.ToString(); break; } //asigna un rol por defecto, en función de la persona propSeguridad.Usuario.ListaRoles.Add(rol); propSeguridad.Usuario.Aprobado = true; propSeguridad.Usuario.EsUsuarioInicial = false; //encriptar la password propSeguridad.Usuario.PasswordNuevo = BLEncriptacion.Encrypt(RegisterUser.Password); propSeguridad.Usuario.Password = RegisterUser.Password; objBLSeguridad = new BLSeguridad(propSeguridad); objBLSeguridad.ActualizarUsuario(); objBLSeguridad.CambiarPassword(); //actualiza el nombre de usuario en la persona propPersona.username = propSeguridad.Usuario.Nombre; BLPersona objBLPersona = new BLPersona(propPersona); objBLPersona.Save(); //loquea al usuario y lo redirecciona a la pagina de inicio de usuarios logueados Session.Abandon(); FormsAuthentication.SignOut(); FormsAuthentication.Initialize(); FormsAuthentication.SetAuthCookie(propSeguridad.Usuario.Nombre, true /* createPersistentCookie */); ObjSessionDataUI.ObjDTUsuario = propSeguridad.Usuario; string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (string.IsNullOrEmpty(continueUrl)) continueUrl = "~/Private/Account/Welcome.aspx"; Response.Redirect(continueUrl, false); }
/// <summary> /// Guardars the usuario. /// </summary> private void GuardarUsuario() { DTUsuario objUsuario = new DTUsuario(); objUsuario.Nombre = txtUserName.Text; objUsuario.Email = txtEmailUsuario.Text; objUsuario.Aprobado = chkHabilitado.Checked; objUsuario.PaswordPregunta = lblPreguntaUsuario.Text; objUsuario.PaswordRespuesta = lblRespuestaUsuario.Text; objUsuario.EsUsuarioInicial = true; objUsuario.ListaRoles = new List<DTRol>(); objUsuario.ListaRoles.Add(new DTRol() { NombreCorto = ddlListRoles.SelectedValue, Nombre = ddlListRoles.SelectedItem.Text }); DTSeguridad objSeguridad = new DTSeguridad(); objSeguridad.Usuario = objUsuario; atrBLSeguridad = new BLSeguridad(objSeguridad); atrBLSeguridad.CrearUsuario(); Persona objPersona = new Persona(); atrBLPersona = new BLPersona(propPersona); atrBLPersona.GetById(); atrBLPersona.Data.username = objUsuario.Nombre; atrBLPersona.Save(); }
/// <summary> /// Cargars the usuario. /// </summary> private void CargarPersona() { LimpiarCampos(); atrBLPersona = new BLPersona(); //propPersona.username = string.Empty; atrBLPersona.Data = propPersona; atrBLPersona.GetById(); Persona objPersona = atrBLPersona.Data; lblNombreApellido.Text = " - " + objPersona.nombre + " " + objPersona.apellido; txtUserName.Text = string.Empty; txtEmailUsuario.Text = objPersona.email; lblPreguntaUsuario.Text = BLConfiguracionGlobal.ObtenerConfiguracion(enumConfiguraciones.PreguntaDefault); lblRespuestaUsuario.Text = objPersona.numeroDocumento.ToString(); atrBLSeguridad = new BLSeguridad(propSeguridad); UIUtilidades.BindCombo<DTRol>(ddlListRoles, atrBLSeguridad.GetRolesByTipoPersona(objPersona.tipoPersona.idTipoPersona), "NombreCorto", "Nombre", true); udpRoles.Visible = true; udpRoles.Update(); }
/// <summary> /// Obteners the datos. /// </summary> private void BuscarPersona(Persona objPersona) { atrBLPersona = new BLPersona(objPersona); propListaPersonas = atrBLPersona.GetPersonas(objPersona, true); CargarGrilla(); }
/// <summary> /// Cargars the usuario. /// </summary> private void CargarPersona() { LimpiarCampos(); atrBLPersona = new BLPersona(); //propPersona.username = string.Empty; atrBLPersona.Data = propPersona; atrBLPersona.GetById(); Persona objPersona = atrBLPersona.Data; lblNombreApellido.Text = objPersona.nombre + " " + objPersona.apellido; txtUserName.Text = string.Empty; txtEmailUsuario.Text = objPersona.email; lblPreguntaUsuario.Text = BLConfiguracionGlobal.ObtenerConfiguracion(enumConfiguraciones.PreguntaDefault); lblRespuestaUsuario.Text = objPersona.numeroDocumento.ToString(); udpRoles.Visible = true; udpRoles.Update(); }
/// <summary> /// Exportars the grafico PDF. /// </summary> /// <param name="TituloInforme">The titulo informe.</param> /// <param name="username">The username.</param> /// <param name="filtros">The filtros.</param> /// <param name="nombrePNG">The nombre PNG.</param> /// <param name="tablaGrafico">The tabla grafico.</param> public static void ExportarGraficoPDF(string TituloInforme, string username, string filtros, string nombrePNG, List<string> tablaGrafico) { itsEvents ev = new itsEvents(); Persona usuario = new Persona(); usuario.username = username; BLPersona objBLPersona = new BLPersona(usuario); objBLPersona.GetPersonaByEntidad(); usuario = objBLPersona.Data; Document documento = new Document(PageSize.A4, 10, 10, 80, 50); PdfWriter writerPdf = PdfWriter.GetInstance(documento, HttpContext.Current.Response.OutputStream); writerPdf.PageEvent = ev; documento.Open(); string strTitulo = TituloInforme; string fecha = DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0'); Font font24B = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 24, Font.BOLD, BaseColor.GRAY); Phrase Titulo = new Phrase("EDU@R 2.0", font24B); Font font15B = FontFactory.GetFont(FontFactory.HELVETICA, 15, Font.BOLDITALIC); ev.tituloReporte = strTitulo; ev.fechaReporte = fecha; Font font12B = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12, Font.NORMAL); Font font10N = FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.NORMAL); PdfPTable grdTableEncabezado = new PdfPTable(1); grdTableEncabezado.WidthPercentage = 90; grdTableEncabezado.AddCell(new PdfPCell(new Phrase("- Usuario: " + usuario.apellido + " " + usuario.nombre, font12B))); grdTableEncabezado.CompleteRow(); grdTableEncabezado.AddCell(new PdfPCell(new Phrase(filtros, font12B))); grdTableEncabezado.CompleteRow(); documento.Add(grdTableEncabezado); //valido si mando el nombre de un gráfico if (!string.IsNullOrEmpty(nombrePNG)) { //Verifica si existe el archivo if (System.IO.File.Exists(nombrePNG)) { documento.Add(new Paragraph("")); Image grafico = Image.GetInstance(nombrePNG); grafico.ScalePercent(50, 50); grafico.Alignment = Element.ALIGN_CENTER; if (grafico != null) documento.Add(grafico); documento.Add(new Paragraph("")); } } // Recorremos la variable tablaGrafico para agregar información adicional a la exportación del gráfico foreach (var item in tablaGrafico) { if (item.Substring(0, 1).Equals("-")) documento.Add(new iTextSharp.text.Paragraph(item, font12B)); else documento.Add(new iTextSharp.text.Paragraph(item, font10N)); } //Cerramos el Documento documento.Close(); strTitulo = strTitulo.Replace(" ", string.Empty); HttpContext.Current.Response.ContentType = "application/pdf"; HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + strTitulo.Trim().Replace(" ", string.Empty) + "-" + fecha.Replace(' ', '_').Trim() + ".pdf"); HttpContext.Current.Response.Flush(); }
/// <summary> /// Exportars the PDF. /// </summary> /// <param name="TituloPagina">The titulo pagina.</param> /// <param name="dtReporte">The dt reporte.</param> /// <param name="username">The username.</param> /// <param name="filtros">The filtros.</param> /// <param name="nombrePNG">The nombre PNG.</param> public static void ExportarPDF(string TituloInforme, DataTable dtReporte, string username, string filtros, string nombrePNG) { itsEvents ev = new itsEvents(); Persona usuario = new Persona(); usuario.username = username; BLPersona objBLPersona = new BLPersona(usuario); objBLPersona.GetPersonaByEntidad(); usuario = objBLPersona.Data; int columnCount = dtReporte.Columns.Count; int rowCount = dtReporte.Rows.Count; Document documento = new Document(PageSize.A4, 10, 10, 80, 50); PdfWriter writerPdf = PdfWriter.GetInstance(documento, HttpContext.Current.Response.OutputStream); writerPdf.PageEvent = ev; documento.Open(); string strTitulo = TituloInforme; string fecha = DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0'); Font font24B = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 24, Font.BOLD, BaseColor.GRAY); Phrase Titulo = new Phrase("EDU@R 2.0", font24B); Font font15B = FontFactory.GetFont(FontFactory.HELVETICA, 15, Font.BOLDITALIC); ev.tituloReporte = strTitulo; ev.fechaReporte = fecha; Font font12B = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12, Font.NORMAL); PdfPTable grdTableEncabezado = new PdfPTable(1); grdTableEncabezado.WidthPercentage = 90; grdTableEncabezado.AddCell(new PdfPCell(new Phrase("- Usuario: " + usuario.apellido + " " + usuario.nombre, font12B))); grdTableEncabezado.CompleteRow(); grdTableEncabezado.AddCell(new PdfPCell(new Phrase(filtros, font12B))); grdTableEncabezado.CompleteRow(); documento.Add(grdTableEncabezado); //valido si mando el nombre de un gráfico if (!string.IsNullOrEmpty(nombrePNG)) { //Verifica si existe el archivo if (System.IO.File.Exists(nombrePNG)) { string TmpPath = System.Configuration.ConfigurationManager.AppSettings["oTmpPath"]; documento.Add(new Paragraph("")); Image grafico = Image.GetInstance(nombrePNG); grafico.ScalePercent(50, 50); grafico.Alignment = Element.ALIGN_CENTER; if (grafico != null) documento.Add(grafico); documento.Add(new Paragraph("")); } } PdfPTable grdTable = new PdfPTable(columnCount); Font LetraTituloTabla = FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLDITALIC, BaseColor.BLUE); float[] espacios = new float[columnCount]; for (int i = 0; i < columnCount; i++) { espacios[i] = 80 / columnCount; } grdTable.SetWidths(espacios); grdTable.WidthPercentage = 90; //Creamos las cabeceras de la tabla //Adicionamos las cabeceras a la tabla foreach (DataColumn columna in dtReporte.Columns) { grdTable.AddCell(new PdfPCell(new Phrase(columna.ColumnName.ToUpperInvariant(), LetraTituloTabla))); } Font LetraDefecto = FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL); grdTable.CompleteRow(); grdTable.HeaderRows = 1; foreach (DataRow fila in dtReporte.Rows) { for (int i = 0; i < columnCount; i++) { string dato = fila[i].ToString(); if (fila[i].GetType().Name == "DateTime") dato = Convert.ToDateTime(fila[i].ToString()).ToShortDateString(); grdTable.AddCell(new Phrase(HttpUtility.HtmlDecode(dato), LetraDefecto)); } grdTable.CompleteRow(); } //Cerramos el Documento documento.Add(grdTable); documento.Close(); HttpContext.Current.Response.ContentType = "application/pdf"; HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + strTitulo.Trim().Replace(" ", string.Empty) + "-" + fecha.Replace(' ', '_').Trim() + ".pdf"); HttpContext.Current.Response.Flush();//HttpContext.Current.Response.End(); }
/// <summary> /// Método que valida usuario y password, en caso de ser exitoso carga la Data. /// </summary> public void ValidarUsuario() { try { //chequear que el usuario está activo bool personaActiva = new BLPersona().CheckUsuario(Data.Usuario.Nombre); Data.Usuario.UsuarioValido = Membership.ValidateUser(Data.Usuario.Nombre, Data.Usuario.Password); if (!personaActiva) throw new CustomizedException("No se encuentra el usuario.", null, enuExceptionType.SecurityException); if (!Data.Usuario.UsuarioValido) { MembershipUser usuario = Membership.GetUser(Data.Usuario.Nombre); if (usuario != null) { if (usuario.IsLockedOut) { DateTime fechaActual = DateTime.Now; if ((fechaActual.TimeOfDay.Add(usuario.LastLockoutDate.TimeOfDay)).Minutes > 10) { usuario.UnlockUser(); Data.Usuario.UsuarioValido = Membership.ValidateUser(Data.Usuario.Nombre, Data.Usuario.Password); } else throw new CustomizedException("El usuario se encuentra bloqueado.", null, enuExceptionType.SecurityException); } if (usuario.IsApproved) throw new CustomizedException("El usuario y/o la contraseña ingresada es incorrecto.", null, enuExceptionType.SecurityException); } else throw new CustomizedException("No se encuentra el usuario.", null, enuExceptionType.SecurityException); } ObtenerRolesUsuario(); MembershipUser us = Membership.GetUser(Data.Usuario.Nombre); if (us.CreationDate == us.LastPasswordChangedDate || us.GetPassword() == BLConfiguracionGlobal.ObtenerConfiguracion(enumConfiguraciones.PasswordInicial)) Data.Usuario.EsUsuarioInicial = true; } catch (CustomizedException ex) { throw ex; } catch (Exception ex) { throw new CustomizedException(string.Format("Fallo en {0} - ValidarUsuario()", ClassName), ex, enuExceptionType.BusinessLogicException); } }
private void Form1_Load(object sender, EventArgs e) { BLPersona bl = new BLPersona(); gridPersonas.DataSource = bl.listaPersonas(); }