예제 #1
0
        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            Int32 records = 0;

            if (validateData())
            {
                Entities.PeriodType oPeriodType = new Entities.PeriodType();
                oPeriodType.code        = Convert.ToInt32(txtCode.Text);
                oPeriodType.description = txtName.Text;
                oPeriodType.state       = Convert.ToInt16(cboState.SelectedValue);
                if (PeriodTypeBLL.getInstance().exists(oPeriodType.code))
                {
                    records = PeriodTypeBLL.getInstance().modify(oPeriodType);
                }
                else
                {
                    records = PeriodTypeBLL.getInstance().insert(oPeriodType);
                }
                blockControls();
                loadData();

                if (records > 0)
                {
                    lblMessage.Text = "Datos almacenados correactamente";
                }
            }
        }
예제 #2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            Int32 records = PeriodTypeBLL.getInstance().delete(periodType_id);

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

            if (records > 0)
            {
                lblMessage.Text = "Tipo de periodo eliminado correctamente.";
            }
            loadData();
        }
예제 #3
0
        protected void loadPeriodType()
        {
            List <Entities.PeriodType> listPeriodType = new List <Entities.PeriodType>();

            listPeriodType = PeriodTypeBLL.getInstance().getAllActived();
            ListItem oItemS = new ListItem("Seleccione", "0");

            cboModality.Items.Add(oItemS);
            foreach (Entities.PeriodType oPeriodType in listPeriodType)
            {
                ListItem oItem = new ListItem(oPeriodType.description, oPeriodType.code.ToString());
                cboModality.Items.Add(oItem);
            }
        }
예제 #4
0
        protected void gvPeriodType_RowEditing(object sender, GridViewEditEventArgs e)
        {
            unlockControls();
            Int32 code = Convert.ToInt32(gvPeriodType.Rows[e.NewEditIndex].Cells[0].Text);

            Entities.PeriodType oPeriodType = PeriodTypeBLL.getInstance().getPeriod(code);
            txtCode.Text = oPeriodType.code.ToString();
            txtName.Text = oPeriodType.description.ToString();
            try
            {
                cboState.SelectedValue = oPeriodType.state.ToString();
            }
            catch (Exception)
            {
                cboState.SelectedValue = "1";
            }
            ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true);
        }
예제 #5
0
 protected void btnNew_Click(object sender, ImageClickEventArgs e)
 {
     unlockControls();
     txtCode.Text = PeriodTypeBLL.getInstance().getNextCode().ToString();
 }
예제 #6
0
        protected void btnReport_Click(object sender, EventArgs e)
        {
            try
            {
                List <Entities.PeriodType> listPeriodType = PeriodTypeBLL.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 Tipo de Períodos\n\n\n\n");
                pdfDoc.Add(title);

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

                if (listPeriodType.Count > 0)
                {
                    foreach (Entities.PeriodType pPeriodType in listPeriodType)
                    {
                        oPTable.AddCell(pPeriodType.description);
                        oPTable.AddCell((pPeriodType.state == 1 ? "Activo" : "Inactivo"));
                    }
                }
                else
                {
                    PdfPCell cell = new PdfPCell(new text::Phrase("No existen tipo de 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=Tipo_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());
            }
        } //End clearControls()
예제 #7
0
 /**
  * Method to get period types registered in the database and to load in a GridView
  */
 protected void loadData()
 {
     gvPeriodType.DataSource = PeriodTypeBLL.getInstance().getAll();
     gvPeriodType.DataBind();
 } //End loadData()