protected void btnReset_Click(object sender, EventArgs e) { Entities.UserSystem oUser = (Entities.UserSystem)Session["User"]; if(txtModalUser.Text == oUser.email && txtModalPassword.Text == oUser.Password) { Int32 records = UserSystemBLL.getInstance().resetPasswordSecurity(resetUserSystem_id, resetUserSystemid_id); userAttempts = 0; ScriptManager.RegisterStartupScript(this, this.GetType(), "closeResetPassword", "$('#ResetPassword').modal('toggle');", true); loadData(); if (records > 0) { Entities.Email oEmail = new Entities.Email(); String body = messageDesignReset(oUser.email); oEmail.correoContacto(oUser.email, body, "Restablecer contraseña"); lblMessage.Text = "Se ha restablecido la contraseña correctamente."; } } else { txtModalUser.Text = ""; txtModalPassword.Text = ""; userAttempts++; if (userAttempts>=3) { Response.Redirect("../../logOut.aspx"); } } }
protected void btnDelete_Click(object sender, EventArgs e) { Int32 records = UserSystemBLL.getInstance().delete(userSystem_id); ScriptManager.RegisterStartupScript(this, this.GetType(), "closeConfirmMessage", "$('#confirmMessage').modal('toggle');", true); if (records > 0) { lblMessage.Text = "Usuario eliminado correctamente."; } loadData(); }
protected void gvUserSystem_RowEditing(object sender, GridViewEditEventArgs e) { Int32 code = Convert.ToInt32(gvUserSystem.Rows[e.NewEditIndex].Cells[0].Text); if (code != 1) { unlockControls(); Entities.UserSystem oUser = UserSystemBLL.getInstance().getUserSystem(code); getProgram(); getRole(); txtCode.Text = oUser.code.ToString(); txtId.Text = oUser.id.ToString(); txtName.Text = oUser.name.ToString(); txtLastName.Text = oUser.lastName.ToString(); txtHomePhone.Text = oUser.homePhone.ToString(); txtCellPhone.Text = oUser.cellPhone.ToString(); txtEmail.Text = oUser.email.ToString(); if (oUser.oProgram.code == 1) { cboProgram.SelectedValue = "0"; }else { cboProgram.SelectedValue = oUser.oProgram.code.ToString(); } cboRole.SelectedValue = oUser.oRole.Role_Id.ToString(); try { cboState.SelectedValue = oUser.state.ToString(); } catch (Exception) { cboState.SelectedValue = "1"; } ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true); } else { lblMessage.Text = "Este usuario no se puede modificar."; } }
protected void btnReport_Click(object sender, EventArgs e) { try { List<Entities.UserSystem> listUserSystem = UserSystemBLL.getInstance().getAll(); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); text::Document pdfDoc = new text::Document(text::PageSize.A4, 10, 10, 10, 10); pdfDoc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); PdfWriter.GetInstance(pdfDoc, memoryStream); pdfDoc.Open(); String imagepath = Server.MapPath("../../images/page-icons"); iTextSharp.text.Image deas = iTextSharp.text.Image.GetInstance(imagepath + "/DEAS-logo.jpg"); deas.ScaleToFit(140f, 120f); //Give space before image deas.SpacingBefore = 10f; //Give some space after the image deas.SpacingAfter = 1f; deas.Alignment = text::Element.ALIGN_LEFT; pdfDoc.Add(deas); text::Paragraph title = new text::Paragraph(); title.Font = text::FontFactory.GetFont("dax-black", 32, new text::BaseColor(0, 51, 102)); title.Alignment = text::Element.ALIGN_CENTER; title.Add("\n\n Reporte de Usuarios\n\n"); pdfDoc.Add(title); PdfPTable oPTable = new PdfPTable(5); oPTable.TotalWidth = 100; oPTable.SpacingBefore = 20f; oPTable.SpacingAfter = 30f; oPTable.AddCell("Nombre completo"); oPTable.AddCell("Rol"); oPTable.AddCell("Programa"); oPTable.AddCell("Coreo electrónico"); oPTable.AddCell("Estado"); if (listUserSystem.Count > 0) { foreach (Entities.UserSystem pUserSystem in listUserSystem) { oPTable.AddCell(pUserSystem.name + " " + pUserSystem.lastName); oPTable.AddCell(pUserSystem.oRole.Description); oPTable.AddCell(pUserSystem.oProgram.name); oPTable.AddCell(pUserSystem.email); oPTable.AddCell((pUserSystem.state == 1 ? "Activo" : "Inactivo")); } } else { PdfPCell cell = new PdfPCell(new text::Phrase("No existen usuarios registrados.")); cell.Colspan = 5; cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right oPTable.AddCell(cell); } pdfDoc.Add(oPTable); pdfDoc.Close(); byte[] bytes = memoryStream.ToArray(); memoryStream.Close(); Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", "attachment; filename=Usuarios.pdf"); Response.ContentType = "application/pdf"; Response.Buffer = true; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(bytes); Response.End(); Response.Close(); } catch (Exception ex) { Response.Write(ex.ToString()); } }