protected void btndelete_click(object sender, EventArgs e) { Int32 records = ActivesBLL.getInstance().delete(actives_id);; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "confirmmessage", "$('#confirmmessage').modal('toggle');", true); if (records > 0) { lblMessage.Text = "Activo eliminado correctamente."; } loadData(); }
private void loadData() { int code = oUser.oProgram.code; if (code == 1) { gvActives.DataSource = ActivesBLL.getInstance().getAll(); } else { gvActives.DataSource = ActivesBLL.getInstance().getAllByProgram(code); } gvActives.DataBind(); }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { Int32 records = 0; if (validateData()) { Entities.ClassRoom oClassRoom = new Entities.ClassRoom(); Entities.Program oProgram = new Entities.Program(); Entities.ActivesStatus oActivesStatus = new Entities.ActivesStatus(); Entities.Actives oActivesState = new Entities.Actives(); oActivesState.code = Convert.ToInt32(txtCode.Text.ToString()); oActivesState.codeAlphaNumeric = txtcodeAlphaNumeric.Text; oActivesState.description = txtDescription.Text; oClassRoom.code = Convert.ToInt32(cboClassroom.SelectedValue.ToString()); oProgram.code = Convert.ToInt32(cboprogram.SelectedValue.ToString()); oActivesStatus.activesSatus_ID = Convert.ToInt32(cboStatus.SelectedValue.ToString()); oActivesState.status = oActivesStatus; oActivesState.oClassRoom = oClassRoom; oActivesState.oProgram = oProgram; if (ActivesBLL.getInstance().exists(oActivesState.code)) { records = ActivesBLL.getInstance().modify(oActivesState); } else { if (ActivesBLL.getInstance().existsCodeAlphanumeric(txtcodeAlphaNumeric.Text)) { lblMessagecodeAlphaNumeric.Text = "Este codigo ya se ha utilizado"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "removeHasErrorcodeAlphaNumeric", "$('#ContentPlaceHolder1_txtcodeAlphaNumeric').removeClass('has-error');", true); return; } else { records = ActivesBLL.getInstance().insert(oActivesState); } } blockControls(); loadData(); if (records > 0) { lblMessage.Text = "Datos almacenados correctamente"; } } }
protected void gvActives_RowEditing(object sender, GridViewEditEventArgs e) { loadCombos(); unlockControls(); Int32 code = Convert.ToInt32(gvActives.Rows[e.NewEditIndex].Cells[0].Text); Entities.Actives oActivesStatus = ActivesBLL.getInstance().getActive(code); getClassRoom(oActivesStatus.oProgram.code); txtCode.Text = oActivesStatus.code.ToString(); txtcodeAlphaNumeric.Text = oActivesStatus.codeAlphaNumeric; txtcodeAlphaNumeric.Enabled = false; txtDescription.Text = oActivesStatus.description; cboprogram.SelectedValue = oActivesStatus.oProgram.code.ToString(); cboClassroom.SelectedValue = oActivesStatus.oClassRoom.code.ToString(); cboStatus.SelectedValue = oActivesStatus.status.activesSatus_ID.ToString(); ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true); }
protected void btnNew_Click(object sender, ImageClickEventArgs e) { loadCombos(); unlockControls(); txtCode.Text = ActivesBLL.getInstance().getNextCode().ToString(); }
protected void btnReport_Click(object sender, EventArgs e) { try { int code = oUser.oProgram.code; List <Entities.Actives> listActives; if (code == 1) { listActives = ActivesBLL.getInstance().getAll(); } else { listActives = ActivesBLL.getInstance().getAllByProgram(code); } 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 Activos\n\n"); pdfDoc.Add(title); PdfPTable oPTable = new PdfPTable(5); oPTable.TotalWidth = 100; oPTable.SpacingBefore = 20f; oPTable.SpacingAfter = 30f; oPTable.AddCell("Código"); oPTable.AddCell("Detalle"); oPTable.AddCell("Aula"); oPTable.AddCell("Prográma"); oPTable.AddCell("Estado"); if (listActives.Count > 0) { foreach (Entities.Actives pActives in listActives) { oPTable.AddCell(pActives.codeAlphaNumeric); oPTable.AddCell(pActives.description); oPTable.AddCell(pActives.oClassRoom.num_room); oPTable.AddCell(pActives.oProgram.name); oPTable.AddCell(pActives.status.description); } } else { PdfPCell cell = new PdfPCell(new text::Phrase("No existen Activos 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=Activos.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()); } }