protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { string parametro; parametro = Request.QueryString.Get("reporte"); if (parametro == "FACTURA") { Negocio.serviciobrindadoNegocio dc1 = new Negocio.serviciobrindadoNegocio(); Entidad.Cat_Servicio_Brindado fac = dc1.GetBy_NumFactura("2014000001"); //Negocio.DatosImpresion dcimpresion = new Negocio.DatosImpresion(); rv_reportes.LocalReport.ReportEmbeddedResource = "Clinica.Reportes.rpt_Factura.rdlc"; /*rv_reporte.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dcimpresion.DatosFactura(fac))); rv_reporte.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet2", dcimpresion.DatosFacturaDet(fac.Id)));*/ rv_reportes.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("nro_factura", "2014000001")); rv_reportes.LocalReport.Refresh(); } if (parametro == "CLINICAACTIVA") { Negocio.clinicaNegocio dc = new Negocio.clinicaNegocio(); rv_reportes.LocalReport.ReportEmbeddedResource = "Clinica.Reportes.rpt_ClinicaActiva.rdlc"; rv_reportes.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dc.ClinicaActiva())); rv_reportes.LocalReport.Refresh(); } } } catch (Exception err) { throw new Exception(err.Message); } }
protected void btn_facturar_Click(object sender, EventArgs e) { try { Negocio.serviciobrindadoNegocio dc = new Negocio.serviciobrindadoNegocio(); Entidad.Cat_Servicio_Brindado fac = new Entidad.Cat_Servicio_Brindado(); fac.IdPaciente = int.Parse(ddl_paciente.SelectedValue); fac.Monto = int.Parse(lb_total.Text); Entidad.Validar_Login_Result login = null; login = (Entidad.Validar_Login_Result)Session["S_Login"]; string user = ""; if (login != null) { user = login.Usuario; } fac.Usuario = user; //fac.Usuario = (string)Session["S_Login"]; //fac.Usuario = "Jimmy"; fac.Fecha = DateTime.Now; List<Entidad.Detalle_Servicio_Brindado> fdetalle = new List<Entidad.Detalle_Servicio_Brindado>(); List<DetalleFactura> dfactura = (List<DetalleFactura>)Session["S_DetalleFac"]; foreach (var item in dfactura) { Entidad.Detalle_Servicio_Brindado fd = new Entidad.Detalle_Servicio_Brindado(); fd.IdServicio = item.id; fd.Cantidad = item.cantidad; fd.Valor = item.precio; fdetalle.Add(fd); } //dc.InsertServicioBrindado(fac, fdetalle); /*****************************************************************************/ /*HABILITAMOS EL BOTON IMPRIMIR*/ btn_imprimir.Enabled = true; /*PONEMOS EN VACIO EL CONTENIDO DE LB_TOTAL PARA NO TOMAR DATOS ANTERIORES QUE ESTE POSEA*/ lb_total.Text = ""; /*Removemos la variable session*/ Session.Remove("S_DetalleFac"); ddl_paciente.Enabled = true; /*INABILITAMOS EL BOTON FACTURAR*/ btn_facturar.Enabled = false; } catch (Exception err) { cv_informacion.IsValid = false; cv_informacion.ErrorMessage = "Error al guardar en factura y detalle de la factura!!!" + err.Message; } }