protected void btnDelete_Click(object sender, EventArgs e) { Int32 records = ClassRoomBLL.getInstance().delete(classRoom_id); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "confirmMessage", "$('#confirmMessage').modal('toggle');", true); if (records > 0) { lblMessage.Text = "Sede eliminada correctamente."; } loadData(); }
protected void loadData() { int code = oUser.oProgram.code; if (code == 1) { gvClassRoom.DataSource = ClassRoomBLL.getInstance().getAll(); } else { gvClassRoom.DataSource = ClassRoomBLL.getInstance().getAllByProgram(code); } gvClassRoom.DataBind(); }
protected void gvClassRoom_RowEditing(object sender, GridViewEditEventArgs e) { unlockControls(); Int32 code = Convert.ToInt32(gvClassRoom.Rows[e.NewEditIndex].Cells[0].Text); Entities.ClassRoom oClassRoom = ClassRoomBLL.getInstance().getClassRoom(code); txtCode.Text = oClassRoom.code.ToString(); txtDescription.Text = oClassRoom.num_room; txtSize.Text = oClassRoom.size.ToString(); cboState.SelectedValue = oClassRoom.state.ToString(); try { cboClassRoomType.SelectedValue = oClassRoom.oClassRoomsType.code.ToString(); } catch (Exception) { cboClassRoomType.SelectedValue = "0"; } try { cboLocation.SelectedValue = oClassRoom.oLocation.code.ToString(); } catch (Exception) { cboLocation.SelectedValue = "0"; } try { cboprogram.SelectedValue = oClassRoom.oProgram.code.ToString(); } catch (Exception) { cboprogram.SelectedValue = "0"; } ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true); }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { Int32 records = 0; if (validateData()) { Entities.ClassRoom oClassRoom = new Entities.ClassRoom(); Entities.ClassRoomsType oClassRoomsType = new Entities.ClassRoomsType(); Entities.Location oLocation = new Entities.Location(); Entities.Program oProgram = new Entities.Program(); oClassRoom.code = Convert.ToInt32(txtCode.Text); oClassRoom.num_room = txtDescription.Text; oClassRoomsType.code = Convert.ToInt32(cboClassRoomType.SelectedValue); oLocation.code = Convert.ToInt32(cboLocation.SelectedValue); oClassRoom.size = Convert.ToInt32(txtSize.Text); oProgram.code = Convert.ToInt32(cboprogram.SelectedValue); oClassRoom.state = Convert.ToInt16(cboState.SelectedValue); oClassRoom.oClassRoomsType = oClassRoomsType; oClassRoom.oLocation = oLocation; oClassRoom.oProgram = oProgram; if (ClassRoomBLL.getInstance().exists(oClassRoom.code)) { records = ClassRoomBLL.getInstance().modify(oClassRoom); } else { records = ClassRoomBLL.getInstance().insert(oClassRoom); } blockControls(); loadData(); if (records > 0) { lblMessage.Text = "Datos almacenados correctamente"; } } }
protected void btnNew_Click(object sender, ImageClickEventArgs e) { unlockControls(); txtCode.Text = ClassRoomBLL.getInstance().getNextCode().ToString(); }
protected void btnReport_Click(object sender, EventArgs e) { try { int code = oUser.oProgram.code; List <Entities.ClassRoom> listRoom; if (code == 1) { listRoom = ClassRoomBLL.getInstance().getAll(); } else { listRoom = ClassRoomBLL.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 Aulas\n\n\n\n"); pdfDoc.Add(title); PdfPTable oPTable = new PdfPTable(6); oPTable.TotalWidth = 100; oPTable.SpacingBefore = 20f; oPTable.SpacingAfter = 30f; oPTable.AddCell("Descripción"); oPTable.AddCell("Capacidad"); oPTable.AddCell("Programa"); oPTable.AddCell("Tipo de Aula"); oPTable.AddCell("Localizacion"); oPTable.AddCell("Estado"); if (listRoom.Count > 0) { foreach (Entities.ClassRoom pRoom in listRoom) { oPTable.AddCell(pRoom.num_room); oPTable.AddCell(pRoom.size.ToString()); oPTable.AddCell(pRoom.oProgram.name); oPTable.AddCell(pRoom.oClassRoomsType.description); oPTable.AddCell(pRoom.oLocation.oHeadquarters.description + " - " + pRoom.oLocation.building + " - " + pRoom.oLocation.module); oPTable.AddCell((pRoom.state == 1 ? "Activo" : "Inactivo")); } } else { PdfPCell cell = new PdfPCell(new text::Phrase("No existen aulas 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=Aulas.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()); } }