Exemplo n.º 1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            Int32 records = PeriodBLL.getInstance().delete(period_id);

            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "confirmMessage", "$('#confirmMessage').modal('toggle');", true);

            if (records > 0)
            {
                lblMessage.Text = "Tipo de periodo eliminado correctamente.";
            }
            loadData();
        }
Exemplo n.º 2
0
        protected void gvPeriod_RowEditing(object sender, GridViewEditEventArgs e)
        {
            unlockControls();
            Int32 code = Convert.ToInt32(gvPeriod.Rows[e.NewEditIndex].Cells[0].Text);

            Entities.Period oPeriod = PeriodBLL.getInstance().getPeriod(code);
            txtCode.Text              = oPeriod.code.ToString();
            txtDescription.Text       = oPeriod.name;
            cboModality.SelectedValue = oPeriod.oPeriodType.code.ToString();
            txtStartDate.Text         = oPeriod.startDate.ToShortDateString();
            txtFinishDate.Text        = oPeriod.finalDate.ToShortDateString();
            cboState.SelectedValue    = oPeriod.state.ToString();
            ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true);
        }
Exemplo n.º 3
0
        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            Int32 records = 0;

            if (validateData())
            {
                Entities.Period     oPeriod     = new Entities.Period();
                Entities.PeriodType oPeriodType = new Entities.PeriodType();
                oPeriod.code        = Convert.ToInt32(txtCode.Text);
                oPeriod.name        = txtDescription.Text;
                oPeriod.startDate   = DateTime.Parse(txtStartDate.Text);
                oPeriod.finalDate   = DateTime.Parse(txtFinishDate.Text);
                oPeriod.state       = Convert.ToInt16(cboState.SelectedValue);
                oPeriodType.code    = Convert.ToInt32(cboModality.SelectedValue);
                oPeriod.oPeriodType = oPeriodType;

                if (PeriodBLL.getInstance().exists(oPeriod.code))
                {
                    records = PeriodBLL.getInstance().modify(oPeriod);
                }
                else
                {
                    records = PeriodBLL.getInstance().insert(oPeriod);
                }
                blockControls();
                loadData();

                if (records > 0)
                {
                    lblMessage.Text = "Datos almacenados correactamente";
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "comboBox", "comboBox();", true);
            }
        }
Exemplo n.º 4
0
 protected void loadData()
 {
     gvPeriod.DataSource = PeriodBLL.getInstance().getAll();
     gvPeriod.DataBind();
 }
Exemplo n.º 5
0
        protected void btnReport_Click(object sender, EventArgs e)
        {
            try
            {
                List <Entities.Period> listPeriod   = PeriodBLL.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 Períodos\n\n");
                pdfDoc.Add(title);

                PdfPTable oPTable = new PdfPTable(5);
                oPTable.TotalWidth    = 100;
                oPTable.SpacingBefore = 20f;
                oPTable.SpacingAfter  = 30f;
                oPTable.AddCell("Descripción");
                oPTable.AddCell("Modalidad");
                oPTable.AddCell("Inicio");
                oPTable.AddCell("Fin");
                oPTable.AddCell("Estado");

                if (listPeriod.Count > 0)
                {
                    foreach (Entities.Period pPeriod in listPeriod)
                    {
                        oPTable.AddCell(pPeriod.name);
                        oPTable.AddCell(pPeriod.oPeriodType.description);
                        oPTable.AddCell(pPeriod.startDate.ToShortDateString());
                        oPTable.AddCell(pPeriod.finalDate.ToShortDateString());
                        oPTable.AddCell((pPeriod.state == 1 ? "Activo" : "Inactivo"));
                    }
                }
                else
                {
                    PdfPCell cell = new PdfPCell(new text::Phrase("No existen períodos 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=Periodo.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());
            }
        }
Exemplo n.º 6
0
 protected void btnNew_Click(object sender, ImageClickEventArgs e)
 {
     unlockControls();
     txtCode.Text = PeriodBLL.getInstance().getNextCode().ToString();
 }