private void ReporteTabla(Anexo anexo) { anexo = AnexoService.AnexoDao. ConsultaAnexo(anexo.NumeroAnexo, anexo.Almacen); var anexoDs = new AnexoDS(); decimal? totalAsignadoMin = 0, totalAsignadoMax = 0; int renglonesDesiertos = 0; foreach (var detalle in anexo.AnexoDetalle) { var filaDetalle = anexoDs.Tables["AnexoDetalleTabla"].NewRow(); filaDetalle["Anexo"] = detalle.Anexo; filaDetalle["Presupuesto"] = detalle.Anexo.TechoPresupuestal; filaDetalle["AsignadoConIvaEtiquetaMin"] = "ASIGNADO MIN CON " + detalle.Anexo.Iva.Id.Porcentaje + " % DE IVA:"; if (anexo.TipoContrato == Contrato.ABIERTO){ filaDetalle["AsignadoConIvaEtiquetaMax"] = "ASIGNADO MAX CON " + detalle.Anexo.Iva.Id.Porcentaje + " % DE IVA:"; } else if (anexo.TipoContrato == Contrato.CERRADO) { filaDetalle["AsignadoConIvaEtiquetaMax"] = "ASIGNADO CON " + detalle.Anexo.Iva.Id.Porcentaje + " % DE IVA:"; } var renglonesLicitados = anexo.AnexoDetalle.Max(d => d.RenglonAnexo); filaDetalle["RenglonesLicitados"] = renglonesLicitados; filaDetalle["ClaveArticulo"] = detalle.Articulo.Id.CveArt; var articulo = detalle.Articulo; filaDetalle["Renglon"] = detalle.RenglonAnexo; filaDetalle["Descripcion"] = articulo.Id.CveArt + " / " + articulo.DesArticulo; filaDetalle["Unidad"] = articulo.Unidad; filaDetalle["Presentacion"] = articulo.Presentacion; filaDetalle["CantidadMaximo"] = detalle.CantidadMaximo; filaDetalle["CantidadMinimo"] = detalle.CantidadMinimo??0; var cotizacionDetalles = CotizacionService.CotizacionDao. CargarCotizacionDetalle(anexo, detalle.Articulo, anexo.Almacen); if (cotizacionDetalles.Count > 0) { AsignarProveedores(cotizacionDetalles); var count = 0; foreach (var subdetalle in cotizacionDetalles) { if (count == 0) { totalAsignadoMin += subdetalle.Precio*detalle.CantidadMinimo??0; totalAsignadoMax += subdetalle.Precio * detalle.CantidadMaximo; } var asterisco = subdetalle.Ganador ? "* " : ""; var filaSubDetalle = anexoDs.Tables["Proveedor"].NewRow(); filaSubDetalle["ClaveArticulo"] = subdetalle.Articulo.Id.CveArt; filaSubDetalle["Descripcion"] = asterisco + subdetalle.Cotizacion.Proveedor.NombreFiscal; filaSubDetalle["Precio"] = subdetalle.Precio; filaSubDetalle["TotalMax"] = subdetalle.Precio*detalle.CantidadMaximo; filaSubDetalle["TotalMin"] = subdetalle.Precio*detalle.CantidadMinimo??0; filaSubDetalle["Marca"] = subdetalle.Marca; filaSubDetalle["Porcentaje"] = subdetalle.Porcentaje; filaSubDetalle["Observaciones"] = subdetalle.Observaciones; anexoDs.Tables["Proveedor"].Rows.Add(filaSubDetalle); ++count; } } else { var filaSubDetalle = anexoDs.Tables["Proveedor"].NewRow(); filaSubDetalle["ClaveArticulo"] = detalle.Articulo.Id.CveArt; filaSubDetalle["Descripcion"] = "<<<<< D E S I E R T O >>>>>"; anexoDs.Tables["Proveedor"].Rows.Add(filaSubDetalle); ++renglonesDesiertos; } filaDetalle["RenglonesDesiertos"] = renglonesDesiertos; var renglonesAdjudicados = renglonesLicitados - renglonesDesiertos; filaDetalle["RenglonesAdjudicados"] = renglonesAdjudicados; var asignadoConIvaMin = (totalAsignadoMin * detalle.Anexo.Iva.Id.Porcentaje/100) + totalAsignadoMin; var asignadoConIvaMax = (totalAsignadoMax * detalle.Anexo.Iva.Id.Porcentaje / 100) + totalAsignadoMax; filaDetalle["AsignadoConIvaMin"] = asignadoConIvaMin; filaDetalle["AsignadoConIvaMax"] = asignadoConIvaMax; var diferenciaMin = detalle.Anexo.TechoPresupuestal - asignadoConIvaMin; var diferenciaMax = detalle.Anexo.TechoPresupuestal - asignadoConIvaMax; filaDetalle["DiferenciaMin"] = diferenciaMin; filaDetalle["DiferenciaMax"] = diferenciaMax; anexoDs.Tables["AnexoDetalleTabla"].Rows.Add(filaDetalle); } anexoDs.Tables["Proveedor"].AcceptChanges(); anexoDs.Tables["AnexoDetalle"].AcceptChanges(); if (anexo.TipoContrato == Contrato.ABIERTO){ ReporteTablaAbierto1.SetDataSource(anexoDs); crystalReportViewer.ReportSource = ReporteTablaAbierto1; } else if (anexo.TipoContrato == Contrato.CERRADO){ ReporteTablaCerrado1.SetDataSource(anexoDs); crystalReportViewer.ReportSource = ReporteTablaCerrado1; } crystalReportViewer.Refresh(); Text = @"ReporteTablaComparativa"; }
private void ReporteAnexo(Anexo anexo) { var anexoDs = new AnexoDS(); anexo = AnexoService.ConsultarAnexo(anexo.NumeroAnexo, anexo.Almacen); DataRow filaMain = anexoDs.Tables["Anexo"].NewRow(); filaMain["Id"] = anexo.IdAnexo; filaMain["Numero"] = anexo.NumeroAnexo; filaMain["Descripcion"] = anexo.DesAnexo; filaMain["Fecha"] = String.Format("{0:dd/MM/yyyy}", anexo.FechaAnexo); filaMain["Presupuesto"] = anexo.TechoPresupuestal.Value.ToString("C"); anexoDs.Tables["Anexo"].Rows.Add(filaMain); anexoDs.Tables["Anexo"].AcceptChanges(); foreach (AnexoDetalle detalle in anexo.AnexoDetalle) { DataRow filaDetalle = anexoDs.Tables["AnexoDetalle"].NewRow(); filaDetalle["Id"] = anexo.IdAnexo; filaDetalle["Renglon"] = detalle.RenglonAnexo; filaDetalle["Articulo"] = detalle.Articulo.Id.CveArt; filaDetalle["Descripcion"] = detalle.Articulo.DesArticulo; filaDetalle["Unidad"] = detalle.Articulo.Unidad; filaDetalle["CantidadMinimo"] = detalle.CantidadMinimo??0; filaDetalle["CantidadMaximo"] = detalle.CantidadMaximo; anexoDs.Tables["AnexoDetalle"].Rows.Add(filaDetalle); } anexoDs.Tables["AnexoDetalle"].AcceptChanges(); if (anexo.TipoContrato == Contrato.ABIERTO) { ReporteAnexoAbierto1.SetDataSource(anexoDs); crystalReportViewer.ReportSource = ReporteAnexoAbierto1; } else if (anexo.TipoContrato == Contrato.CERRADO) { ReporteAnexoCerrado1.SetDataSource(anexoDs); crystalReportViewer.ReportSource = ReporteAnexoCerrado1; } crystalReportViewer.Refresh(); Text = @"ReporteAnexo"; }