Beispiel #1
0
        private void RefreshGrid()
        {
            try
            {
                CommonUtils.ConexionBD.AbrirConexion();
                string sqlQuery = " Select FacturaId,FacturaAutorizacion,FacturaNro,FacturaContenido, FacturaCodigoControl, FacturaAnulada, FechaTransaccion, MontoTotal from Factura WHERE Factura.FechaTransaccion BETWEEN CONVERT(VARCHAR,'" + dateEditInit.DateTime.ToString("yyyy-MM-dd H:mm:ss.fff") + "',7) AND CONVERT(varchar,'" + dateEditFinal.DateTime.ToString("yyyy-MM-dd H:mm:ss.fff") + "',7) order by Factura.FechaTransaccion";
                // DataTable t = CommonUtils.ConexionBD.EjecutarConsulta(sqlQuery);
                //this.loadDataGridReportes(t);
                SqlDataReader reader        = CommonUtils.ConexionBD.EjecutarConsultaReader(sqlQuery);
                ArrayList     listaFacturas = new ArrayList();

                if (reader.HasRows)
                {
                    CommonUtils.FacturaReporte fact;
                    while (reader.Read())
                    {
                        fact                      = new CommonUtils.FacturaReporte();
                        fact.FacturaId            = (int)reader.GetDecimal(0);
                        fact.FacturaAutorizacion  = Convert.ToDecimal(reader.GetString(1));
                        fact.FacturaNro           = Convert.ToInt64(reader.GetString(2));
                        fact.FacturaNit           = Convert.ToUInt64(this.getNitValue(reader.GetString(3)));
                        fact.FacturaCodigoControl = reader.GetString(4);
                        fact.FacturaAnulada       = reader.GetString(5);
                        fact.FechaTransaccion     = reader.GetDateTime(6);//.ToString();
                        fact.FacturaNombre        = this.getNombreValue(reader.GetString(3));
                        fact.FacturaMontoParcial  = Convert.ToDecimal(this.getMontoValue(reader.GetString(3)));
                        fact.FacturaMontoTotal    = Convert.ToDecimal(!reader.IsDBNull(7) ? reader.GetDouble(7).ToString( ) : "0");
                        listaFacturas.Add(fact);
                    }
                }

                CommonUtils.ConexionBD.CerrarConexion();
                this.loadDataGridReportes(listaFacturas);

                MessageBarValue = "El reporte fue generado satisfactoriamente.";
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
                MessageBarValue = "No se pudo generar reporte. Hubo un error: " + ex.Message;
            }
            finally
            {
                alertControl.Show(this.FindForm(),
                                  "Reportes.",
                                  MessageBarValue, this.GetImage());
            }
        }
Beispiel #2
0
        private void RefreshGrid()
        {
            try
            {
                CommonUtils.ConexionBD.AbrirConexion();
                string sqlQuery = " Select FacturaId,FacturaAutorizacion,FacturaNro,FacturaContenido, FacturaCodigoControl, FacturaAnulada, FechaTransaccion, MontoTotal from Factura WHERE Factura.FechaTransaccion BETWEEN CONVERT(VARCHAR,'" + dateEditInit.DateTime.ToString( "yyyy-MM-dd H:mm:ss.fff" ) + "',7) AND CONVERT(varchar,'" + dateEditFinal.DateTime.ToString( "yyyy-MM-dd H:mm:ss.fff" ) + "',7) order by Factura.FechaTransaccion";
               // DataTable t = CommonUtils.ConexionBD.EjecutarConsulta(sqlQuery);
                //this.loadDataGridReportes(t);
                SqlDataReader reader = CommonUtils.ConexionBD.EjecutarConsultaReader(sqlQuery);
                ArrayList listaFacturas = new ArrayList();

                if (reader.HasRows)
                {
                    CommonUtils.FacturaReporte fact;
                    while (reader.Read())
                    {
                        fact = new CommonUtils.FacturaReporte();
                        fact.FacturaId = (int)reader.GetDecimal(0);
                        fact.FacturaAutorizacion = Convert.ToDecimal( reader.GetString( 1 ) );
                        fact.FacturaNro = Convert.ToInt64( reader.GetString( 2 ) );
                        fact.FacturaNit = Convert.ToUInt64( this.getNitValue( reader.GetString( 3 ) ) );
                        fact.FacturaCodigoControl =  reader.GetString(4);
                        fact.FacturaAnulada = reader.GetString(5);
                        fact.FechaTransaccion =  reader.GetDateTime(6);//.ToString();
                        fact.FacturaNombre = this.getNombreValue(reader.GetString(3));
                        fact.FacturaMontoParcial = Convert.ToDecimal( this.getMontoValue( reader.GetString( 3 ) ) );
                        fact.FacturaMontoTotal = Convert.ToDecimal( !reader.IsDBNull( 7 ) ? reader.GetDouble( 7 ).ToString( ) : "0" );
                        listaFacturas.Add(fact);                      
                    }
                }

                CommonUtils.ConexionBD.CerrarConexion();
                this.loadDataGridReportes(listaFacturas);
               
                MessageBarValue = "El reporte fue generado satisfactoriamente.";
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
                MessageBarValue = "No se pudo generar reporte. Hubo un error: " + ex.Message;
            }
            finally
            {
                alertControl.Show(this.FindForm(),
                        "Reportes.",
                        MessageBarValue, this.GetImage());

            }
        }