Beispiel #1
0
    protected void TextBox_Fechas_TextChanged(object sender, EventArgs e)
    {
        DateTime fechaInicial = new DateTime();
        DateTime fechaFinal   = new DateTime();
        Boolean  correcto     = true;

        GridViewRow filaGrilla        = ((GridViewRow)((Control)sender).Parent.Parent);
        Int32       indexSeleccionado = filaGrilla.RowIndex;

        Decimal ID_PROGRAMA = Convert.ToDecimal(GridView_RESULTADOS_BUSQUEDA.DataKeys[indexSeleccionado].Values["ID_PROGRAMA"]);

        TextBox textoFechaInicial = filaGrilla.FindControl("TextBox_FechaInicial") as TextBox;

        try
        {
            fechaInicial = Convert.ToDateTime(textoFechaInicial.Text);
        }
        catch
        {
            Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, "La fecha inicial esta vacio o no tiene el formato correcto (dd/mm/yyyy).", Proceso.Advertencia);
            fechaInicial = new DateTime();
            correcto     = false;
        }

        TextBox textoFechaFinal = filaGrilla.FindControl("TextBox_FechaFinal") as TextBox;

        try
        {
            fechaFinal = Convert.ToDateTime(textoFechaFinal.Text);
        }
        catch
        {
            Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, "La fecha final esta vacio o no tiene el formato correcto (dd/mm/yyyy).", Proceso.Advertencia);
            fechaFinal = new DateTime();
            correcto   = false;
        }

        TextBox textoConclusiones = filaGrilla.FindControl("TextBox_Conclusiones") as TextBox;

        if (correcto == true)
        {
            if (fechaInicial <= fechaFinal)
            {
                Programa _prog = new Programa(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());

                DataTable tablaPeriodo = _prog.ObtenerCorteinformeClientePorIdProgramaYPeriodo(ID_PROGRAMA, fechaInicial, fechaFinal);

                if (tablaPeriodo.Rows.Count <= 0)
                {
                    if (_prog.MensajeError != null)
                    {
                        Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, _prog.MensajeError, Proceso.Error);
                    }

                    textoConclusiones.Text    = "";
                    textoConclusiones.Enabled = true;
                }
                else
                {
                    DataRow filaPeriodo = tablaPeriodo.Rows[0];

                    textoConclusiones.Text    = filaPeriodo["CONCLUSIONES"].ToString().Trim();
                    textoConclusiones.Enabled = true;
                }
            }
            else
            {
                Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, "La fecha inical debe ser menor o igual que la fecha final.", Proceso.Advertencia);
                textoConclusiones.Text    = "";
                textoConclusiones.Enabled = false;
            }
        }
        else
        {
            textoConclusiones.Text    = "";
            textoConclusiones.Enabled = false;
        }
    }