public List<Reporte> ObtenerDatosReporte(DateTime fecha) { List<Reporte> lstReporte = new List<Reporte>(); try { Conexion.ConnectionString = @"Data Source=" + rutaSQL + ";Version=3;"; Conexion.Open(); Comando.Connection = Conexion; Comando.CommandText = string.Format(@"SELECT mi.folio_control, p.nombre as chofer, mi.folio_factura, mi.importe_factura, mi.clave_cliente, mi.nombre_cliente FROM manejo_impresiones mi INNER JOIN personal p ON p.id_personal = mi.id_chofer WHERE fecha_impresion = '{0}'", fecha.ToString("yyyy-MM-dd")); Adapter.SelectCommand = Comando; DataTable dtRespuesta = new DataTable(); Adapter.Fill(dtRespuesta); Reporte filaReporte; foreach (DataRow fila in dtRespuesta.Rows) { filaReporte = new Reporte(); filaReporte.FolioControl = Convert.ToInt32(fila["folio_control"]); filaReporte.Chofer = fila["chofer"].ToString(); filaReporte.ClaveCliente = fila["clave_cliente"].ToString(); filaReporte.NombreCliente = fila["nombre_cliente"].ToString(); filaReporte.FolioFactura = fila["folio_factura"].ToString(); filaReporte.Importe = Convert.ToDecimal(fila["importe_factura"]); lstReporte.Add(filaReporte); } Conexion.Close(); } catch (Exception ex) { if (Conexion.State != System.Data.ConnectionState.Closed) Conexion.Close(); throw ex; } return lstReporte; }
public Reporte ObtenerDireccion(string folio) { Reporte datosDireccion = new Reporte(); try { Conexion.ConnectionString = StringDeConexion(); Conexion.Open(); Comando.Connection = Conexion; Comando.CommandText = string.Format(@"SELECT dc.NOMBRE_CALLE, dc.NUM_EXTERIOR, dc.NUM_INTERIOR, dc.COLONIA, dc.CODIGO_POSTAL FROM DOCTOS_VE ve INNER JOIN DIRS_CLIENTES dc ON (ve.DIR_CONSIG_ID = dc.DIR_CLI_ID) WHERE ve.FOLIO LIKE '{0}'", folio); DataTable dtResultado = new DataTable(); Adapter.SelectCommand = Comando; Adapter.Fill(dtResultado); foreach (DataRow fila in dtResultado.Rows) { datosDireccion.Calle = fila["NOMBRE_CALLE"].ToString(); datosDireccion.NumExterior = fila["NUM_EXTERIOR"].ToString(); datosDireccion.NumInterior = fila["NUM_INTERIOR"].ToString(); datosDireccion.Colonia = fila["COLONIA"].ToString(); datosDireccion.CP = fila["CODIGO_POSTAL"].ToString(); } Conexion.Close(); } catch (Exception ex) { if (Conexion.State != ConnectionState.Closed) Conexion.Close(); throw ex; } return datosDireccion; }
private void bgwProceso_DoWork(object sender, DoWorkEventArgs e) { var Configuracion = Properties.Settings.Default; lstReporte = new List<Reporte>(); lstReporte.AddRange(ObtenerDatosSQLite(Configuracion.SQLiteCobranza, dtpFecha.Value)); lstReporte.AddRange(ObtenerDatosSQLite(Configuracion.SQLiteReparto, dtpFecha.Value)); Reporte Direccion = new Reporte(); foreach (Reporte fila in lstReporte) { string FolioNormalizado = NormalizarFolio(fila.FolioFactura); Direccion = ObtenerDireccion(FolioNormalizado); fila.FolioFactura = FolioNormalizado; fila.Calle = Direccion.Calle; fila.NumExterior = Direccion.NumExterior; fila.NumInterior = Direccion.NumInterior; fila.Colonia = Direccion.Colonia; fila.CP = Direccion.CP; } }