protected void btnDelete_Click(object sender, EventArgs e) { Int32 records = ScheduleBLL.getInstance().delete(schedule_id); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "confirmMessage", "$('#confirmMessage').modal('toggle');", true); if (records > 0) { lblMessage.Text = "Horario eliminado correctamente."; } loadData(); }
protected void loadData() { int code = oUser.oProgram.code; if (code == 1) { gvSchedule.DataSource = ScheduleBLL.getInstance().getAll(); } else { gvSchedule.DataSource = ScheduleBLL.getInstance().getAllByPrgrams(code); } gvSchedule.DataBind(); }
protected void gvSchedule_RowEditing(object sender, GridViewEditEventArgs e) { unlockControls(); Int32 code = Convert.ToInt32(gvSchedule.Rows[e.NewEditIndex].Cells[0].Text); Entities.Schedule oSchedule = ScheduleBLL.getInstance().getSchedule(code); txtCode.Text = oSchedule.code.ToString(); txtDescription.Text = oSchedule.name; cboTypeSchedule.SelectedValue = oSchedule.typeSchedule; txtStart.Text = String.Format("{0:t}", oSchedule.startTime); txtEndHour.Text = String.Format("{0:t}", oSchedule.endTime); cboprogram.SelectedValue = oSchedule.oProgram.code.ToString(); cboState.SelectedValue = oSchedule.state.ToString(); SelectchkDays(oSchedule.codday); ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true); }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { Int32 records = -1; if (validateData()) { Entities.Schedule oSchedule = new Entities.Schedule(); oSchedule.code = Convert.ToInt32(txtCode.Text); oSchedule.name = txtDescription.Text; oSchedule.typeSchedule = cboTypeSchedule.SelectedValue; oSchedule.startTime = Convert.ToDateTime(txtStart.Text); oSchedule.endTime = Convert.ToDateTime(txtEndHour.Text); oSchedule.state = Convert.ToInt32(cboState.SelectedValue); oSchedule.oProgram.code = Convert.ToInt32(cboprogram.SelectedValue); oSchedule.codday = codDays; if (ScheduleBLL.getInstance().exists(oSchedule.code)) { records = ScheduleBLL.getInstance().modify(oSchedule); } else { records = ScheduleBLL.getInstance().insert(oSchedule); } blockControls(); loadData(); if (records > 0) { lblMessage.Text = "Datos almacenados correctamente."; } } //no c para que es esto else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "comboBox", "comboBox();", true); } }
protected void btnReport_Click(object sender, EventArgs e) { try { List <Entities.Schedule> listSchedule = ScheduleBLL.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 Justificación de Apertura\n\n"); pdfDoc.Add(title); PdfPTable oPTable = new PdfPTable(2); oPTable.TotalWidth = 100; oPTable.SpacingBefore = 20f; oPTable.SpacingAfter = 30f; oPTable.AddCell("Profesor: " + oJustification.oAcademic.oteacher.name + " " + oJustification.oAcademic.oteacher.lastName); oPTable.AddCell("Curso: " + oJustification.oAcademic.oCourse.description); oPTable.AddCell("Categoría: " + oJustification.oInternal.description); oPTable.AddCell("Nombramiento: " + oJustification.oAcademic.hours.ToString()); oPTable.AddCell("Anualidade: " + oJustification.CauntAnualities); oPTable.AddCell("Salario: " + oJustification.Salary.ToString("0.00")); oPTable.AddCell("Anualidades: " + oJustification.Anuality.ToString("0.00")); oPTable.AddCell("Cargos Sociales: " + oJustification.CCSS.ToString("0.00")); oPTable.AddCell("Publicidad: " + oJustification.publicity.ToString("0.00")); oPTable.AddCell("Otros: " + oJustification.Others.ToString("0.00")); oPTable.AddCell("Total Mensual: " + oJustification.TotalMensual.ToString("0.00")); oPTable.AddCell("Tatal Bimensual: " + oJustification.TotalBimensual.ToString("0.00")); oPTable.AddCell("Valor del curso: " + oJustification.oAcademic.price.ToString("0.00")); oPTable.AddCell("Estudiantes: " + oJustification.Students); oPTable.AddCell("Ingresos: " + oJustification.TotalIncome.ToString("0.00")); oPTable.AddCell("Diferencia: " + oJustification.Diference.ToString("0.00")); pdfDoc.Add(oPTable); pdfDoc.Close(); byte[] bytes = memoryStream.ToArray(); memoryStream.Close(); Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", "attachment; filename=JustificaciónApertura.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()); } }
protected void btnNew_Click(object sender, ImageClickEventArgs e) { unlockControls(); txtCode.Text = ScheduleBLL.getInstance().getNextCode().ToString(); }
protected void btnReport_Click(object sender, EventArgs e) { try { int code = oUser.oProgram.code; List <Entities.Schedule> listSchedule; if (code == 1) { listSchedule = ScheduleBLL.getInstance().getAll(); } else { listSchedule = ScheduleBLL.getInstance().getAllByPrgrams(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 Horarios\n\n"); pdfDoc.Add(title); PdfPTable oPTable = new PdfPTable(6); oPTable.TotalWidth = 100; oPTable.SpacingBefore = 20f; oPTable.SpacingAfter = 30f; oPTable.AddCell("Días"); oPTable.AddCell("Horarios"); oPTable.AddCell("Hora de Inicio"); oPTable.AddCell("Hora de Fin"); oPTable.AddCell("Programa"); oPTable.AddCell("Estado"); if (listSchedule.Count > 0) { foreach (Entities.Schedule pSchedule in listSchedule) { oPTable.AddCell(pSchedule.name); oPTable.AddCell(pSchedule.typeSchedule); oPTable.AddCell(pSchedule.startTime.ToShortTimeString()); oPTable.AddCell(pSchedule.endTime.ToShortTimeString()); oPTable.AddCell(pSchedule.oProgram.name); oPTable.AddCell((pSchedule.state == 1 ? "Activo" : "Inactivo")); } } else { PdfPCell cell = new PdfPCell(new text::Phrase("No existen horarios 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=Horarios.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()); } }