Beispiel #1
0
    protected void btn_Buscar_Click(object sender, EventArgs e)
    {
        if (HayErrores())
        {
            return;
        }
        try
        {
            DateTime?fd = null;
            if (txt_Fecha_D.Value != DateTime.MinValue)
            {
                fd = txt_Fecha_D.Value;
            }

            DateTime?fh = null;
            if (txt_Fecha_H.Value != DateTime.MinValue)
            {
                fh = txt_Fecha_H.Value;
            }

            long?id_Benf = null;
            if (!string.IsNullOrEmpty(txt_NroBeneficio.Text))
            {
                id_Benf = Convert.ToInt64(txt_NroBeneficio.Text);
            }

            long?id_Nov = null;
            if (!string.IsNullOrEmpty(txt_idnovedad.Text))
            {
                id_Nov = Convert.ToInt64(txt_idnovedad.Text);
            }

            int?   id_Estado   = ddl_EstadoDocumentacion.SelectedItem.Value.Equals("-1") ? (int?)null : int.Parse(ddl_EstadoDocumentacion.SelectedItem.Value);
            string rutaArchivo = string.Empty;

            log.DebugFormat("Ejectuto consulta NovedadDocumentacion_Traer_x_Estado({0},{1},{2},{3},{4},{5},{6},{7},{8})",
                            NovedadDocumentacionWS.enum_ConsultaBatch_NombreConsulta.NOVEDADES_DOCUMENTACION.ToString(),
                            long.Parse(ddl_Prestador.SelectedItem.Value), txt_Fecha_D.Value, txt_Fecha_D.Value,
                            ddl_EstadoDocumentacion.SelectedItem.Value, id_Benf, id_Nov, true, true);

            lst_Novedades = Novedad.NovedadDocumentacion_Traer_x_Estado(NovedadDocumentacionWS.enum_ConsultaBatch_NombreConsulta.NOVEDADES_DOCUMENTACION,
                                                                        long.Parse(ddl_Prestador.SelectedItem.Value),
                                                                        fd,
                                                                        fh,
                                                                        id_Estado,
                                                                        id_Benf,
                                                                        id_Nov,
                                                                        true, true, out rutaArchivo);


            log.DebugFormat("Obtuve {0} registros", lst_Novedades.Count);

            if (string.IsNullOrEmpty(rutaArchivo))
            {
                Mensaje1.DescripcionMensaje = "No se obtuvieron datos con los parámetros ingresados";
                Mensaje1.Mostrar();
                return;
            }
            else
            {
                Mensaje1.DescripcionMensaje = "Se generó correctamente el archivo";
                Mensaje1.Mostrar();
            }

            btn_Regresar.Text = "Cancelar";

            CargaArchivos();
        }
        catch (Exception err)
        {
            if (err.Message.IndexOf("MSG_ERROR") >= 0)
            {
                int posInicial = err.Message.IndexOf("MSG_ERROR") + ("MSG_ERROR").Length;
                int posFinal   = err.Message.IndexOf("FIN_MSG_ERROR", posInicial);

                string mens = err.Message.Substring(posInicial, posFinal - posInicial);

                Mensaje1.DescripcionMensaje = mens;
                Mensaje1.Mostrar();
            }
            else
            {
                if (err.Message == "The operation has timed-out.")
                {
                    Mensaje1.DescripcionMensaje = "Reingrese en unos minutos. Su archivo se esta procesando.";
                    Mensaje1.Mostrar();
                }
                else
                {
                    //CargaGrillaArchivosExistentes();
                    log.ErrorFormat("Al buscar las novedades se gentero error: ", err.Message);

                    Mensaje1.DescripcionMensaje = "No se pudo obtener los datos.<br />reintente en otro momento.";
                    Mensaje1.Mostrar();
                }
            }
        }
        finally
        {
            CargaArchivos();
        }
    }