private void btnImprimir_Click(object sender, EventArgs e) { if (dtpFecIni.Value == null && dtpFecFin.Value == null) { MessageBox.Show("Debe ingresar el rango de fechas a consultar ...", "Aviso al usuario", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); cmbPerPago.Focus(); return; } int option = 0; string sql = ""; string rptName = ""; string rptTable = ""; string ntext = "Atenciones En" + (cmbConsultorio.SelectedIndex == -1 ? "" : " " + cmbConsultorio.SelectedText + ", "); ntext = ntext + " Consultorio " + cmbBus.SelectedText + ", Periodo " + cmbPerPago.SelectedText; ntext = ntext + "\t" + Operativo.id_oper + " - '" + Operativo.descripcion + "'"; if (rbRecibos.Checked) { sql = sqlResultado + "Order By CB.Fecha_Atencion,T.Nro_Ticket,Pr.Descripcion"; option = 1; rptName = "rptRepTerDet"; rptTable = "RepTerDet"; } if (rbProductos.Checked) { sql = "SELECT X.producto, SUM(X.cantidad) AS cantidad FROM (" + sqlResultado + ") X GROUP BY X.producto ORDER BY X.producto"; option = 2; rptName = "rptRepTerRes"; rptTable = "RepTerRes"; } if (rbFechas.Checked) { sql = sqlResumen; option = 3; rptName = "rptRepTerResDia"; rptTable = "RepTerResDia"; } object result = WaitWindow.Show(WorkerMethodRPT, "Procesando el reporte...", new object[] { option, sql, rptName, rptTable, ntext }); if (result == null) { MessageBox.Show("No se pudo procesar el reporte."); return; } //llama al formulario que muestra el reporte frmCRViewer frg = new frmCRViewer(rpt); frg.ShowDialog(); }
private void btnExportar_Click(object sender, EventArgs e) { //genera reporte y carga los datos object result = WaitWindow.Show(WorkerMethodRPT, "Generando el reporte..."); if (result == null) { MessageBox.Show("No se pudo procesar el reporte."); return; } //llama al formulario que muestra el reporte frmCRViewer frg = new frmCRViewer(rpt); frg.ShowDialog(); }
void exportar() { generateSQL(); //genera reporte y carga los datos object result = WaitWindow.Show(WorkerMethodRPT, "Generando el reporte..."); if (result == null) { MessageBox.Show("No se pudo procesar el reporte."); return; } //llama al formulario que muestra el reporte frmCRViewer frg = new frmCRViewer(rpt); frg.ShowDialog(); }
private void btnImprimir_Click(object sender, EventArgs e) { string fi = dtpicFInicial.Value.ToShortDateString(); string ff = dtpFFinal.Value.ToShortDateString(); string us = cmbUsuario.SelectedIndex == -1 ? "" : usTal[cmbUsuario.SelectedIndex]["Id_Us"]; string op = cmbOperativo.SelectedIndex == -1 ? "" : cmbOperativo.SelectedValue.ToString(); //genera reporte y carga los datos object result = WaitWindow.Show(WorkerMethodRPT, "Generando el reporte...", new string[] { fi, ff, us, op }); if (result == null) { MessageBox.Show("No se pudo procesar el reporte.", "Aviso al usuario", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return; } //llama al formulario que muestra el reporte frmCRViewer frg = new frmCRViewer(rpt); frg.ShowDialog(); }
private void btnSOP_Click(object sender, EventArgs e) { if (txtSOP.Text.Length == 0) { MessageBox.Show("Ingrese monto para Sala de Operaciones ...", "Advertencia"); return; } this.subtitle = (cmbConsultorio.SelectedIndex != -1 ? "CONSULTORIO: " + cmbConsultorio.SelectedText : ""); object result = WaitWindow.Show(WorkerMethodRptProdMedPrcSOP, "Generando el reporte...", new string[] { "SOP" }); if (result == null) { MessageBox.Show("No se pudo procesar el reporte."); return; } frmCRViewer frg = new frmCRViewer(rpt); frg.ShowDialog(); }
private void btnImprimir_Click(object sender, EventArgs e) { if (lstCIE10.Items.Count > 0) { string consul = cmbConsultorio.SelectedIndex == -1 ? "" : cmbConsultorio.SelectedValue.ToString(); string fi = dtpFecIni.Value.ToShortDateString(); string ff = dtpFecFin.Value.ToShortDateString(); object result = WaitWindow.Show(WorkerMethodRpt, "Generando el reporte...", new string[] { consul, fi, ff }); if (result == null) { MessageBox.Show("No se pudo procesar el reporte."); return; } frmCRViewer frg = new frmCRViewer(rpt); frg.ShowDialog(); } else { MessageBox.Show("No hay datos para exportar\n\nDebe de realizar otra consulta", "Aviso"); } }
private void btnVistaPrevia_Click(object sender, EventArgs e) { try { //ingresa fecha del reporte, no debe ser mayor que la fecha actual if (Convert.ToDateTime(txtFecha.Text) > DateTime.Today) { MessageBox.Show("Fecha del reporte no debe ser mayor que la fecha actual.", "Generacion Reportes", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); txtFecha.Focus(); return; } //selecciona opcion de reporte cmbOpciones if (cmbOpciones.SelectedIndex == -1) { MessageBox.Show("Debe seleccionar un tipo de reporte a generar.", "Generacion Reportes", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); cmbOpciones.Focus(); return; } else if (cmbOpciones.SelectedIndex == 0) { //Parte de Atención Diaria vSQL = "Select C.Descripcion AS Especialidad, B.Bus, Serie + '-' + Nro_Ticket AS Ticket, " + "P.Ape_Paterno + ' ' + P.Ape_Materno + ' ' + P.Nombre AS Completo, " + "P.Edad, CASE WHEN P.Sexo = 'M' THEN 'MASCULINO' ELSE 'FEMENINO' END AS Sexo, " + "CB.Nro_Historia,CB.Fecha_Atencion, (SELECT DISTINCT Descripcion FROM TablaTipo T1 " + "WHERE T1.Id_Tipo = CB.turno " + "AND EXISTS (" + " SELECT 1 " + " FROM TablaTipo T2 " + " WHERE T1.Id_Tabla = T2.Id_Tipo " + " AND LTRIM(RTRIM(T2.Descripcion)) = 'TURNOS' " + " AND LTRIM(RTRIM(T2.Id_Tabla)) = '0')) AS Turno, " + " M.Ape_Paterno + ' ' + M.Ape_Materno + ' ' + M.Nombres AS CMP,DC.Cie10 AS prdg, " + " LTrim(RTrim(DC.Procedimiento)) AS prcn " + "FROM Cab_Cie10 CB Inner Join Tickets T " + "On CB.Nro_Historia = T.Nro_Historia " + "Inner Join Pacientes P " + "On T.Id_Paciente = P.Id_Paciente " + "Left Join Det_Cie10 DC " + "On CB.Nro_Historia = DC.Nro_Historia " + "Inner Join Personal M " + "On CB.CMP = M.Id_Personal " + "Inner Join Buses B " + "On CB.Id_Bus = B.Id_Bus " + "Inner Join Consultorios C " + "On B.Id_Esp = C.Id_Consultorio " + "Where CONVERT(VARCHAR,cb.fecha_atencion, 103) = '" + txtFecha.Text + "' " + "And Left(CB.Nro_Historia,3) = '" + Operativo.id_oper + "'"; } else if (cmbOpciones.SelectedIndex == 1) { //Consolidado de Atenciones vSQL = "Select C.Descripcion Consu,B.Bus,X.Descripcion Turn,Ape_Paterno+' ' + Ape_Materno + Case " + "Nombres When '' Then '' Else ', ' End + Nombres Completo,P.Descripcion Producto, " + "Sum(D.Cantidad) Cantidad,D.Monto Precio,Sum(D.Cantidad*D.Monto) Total " + "From Cab_Cie10 CB Inner Join Tickets T " + "On CB.Nro_Historia = T.Nro_Historia " + "Inner Join Detalles D " + "On T.Nro_Historia = D.Nro_Historia " + "Inner Join Productos P " + "On D.Id_Producto = P.Id_Producto " + "Inner Join Buses B " + "On CB.Id_Bus = B.Id_Bus " + "Inner Join Consultorios C " + "On B.Id_Esp = C.Id_Consultorio " + "Inner Join " + "(Select Id_Tipo,Descripcion " + " From TablaTipo " + " Where Id_Tabla In " + " (Select Id_Tipo " + " From TablaTipo " + " Where Descripcion = 'TURNOS' " + " And Id_Tabla = '0')) X " + "On CB.Turno = X.Id_Tipo " + "Inner Join Personal M " + "On CB.CMP = M.Id_Personal " + "Where CONVERT(VARCHAR,fecha_atencion, 103) = '" + txtFecha.Text + "' " + "And Left(CB.Nro_Historia,3) = '" + Operativo.id_oper + "'"; } else if (cmbOpciones.SelectedIndex == 2) { //Consolidado de Atenciones vSQL = "Select C.Descripcion Especialidad,B.Bus Consultorio,X.Descripcion Turno,Ape_Paterno+' '+Ape_Materno+Case" + " Nombres When '' Then '' Else ', ' End + Nombres Especialista,P.Descripcion Producto," + " Sum(D.Cantidad) Cantidad,D.Monto Precio,Sum(D.Cantidad*D.Monto) Total" + " From Cab_Cie10 CB Inner Join Tickets T" + " On CB.Nro_Historia = T.Nro_Historia" + " Inner Join Detalles D" + " On T.Nro_Historia = D.Nro_Historia" + " Inner Join Productos P" + " On D.Id_Producto = P.Id_Producto" + " Inner Join Buses B" + " On CB.Id_Bus = B.Id_Bus" + " Inner Join Consultorios C" + " On B.Id_Esp = C.Id_Consultorio" + " Inner Join" + " (Select Id_Tipo,Descripcion" + " From TablaTipo" + " Where Id_Tabla" + " In (Select Id_Tipo" + " From TablaTipo"+ " Where Descripcion = 'TURNOS'" + " And Id_Tabla = '0')) X" + " On CB.Turno = X.Id_Tipo" + " Inner Join" + " (Select Ape_Paterno,Ape_Materno,Nombres,Id_Personal" + " From Personal" + " Union All Select Descripcion,'','', Id_Tipo " + " From TablaTipo" + " Where Id_Tabla In" + " (Select Id_Tipo" + " From TablaTipo" + " Where Descripcion = 'VAR_EXTRAS'" + " And Id_Tabla = '0')) M" + " On T.CMP = M.Id_Personal" + " Where CONVERT(VARCHAR,fecha_atencion, 103) = '" + txtFecha.Text + "' " + " And Left(CB.Nro_Historia,3) = '" + Operativo.id_oper + "'"; } //si la especialidad esta en 'ECOGRAFIA', 'RAYOS X', 'MAMOGRAFIA' entonces D.Pagado <> '' int iCantE = CuentaEspecialidad(Operativo.id_oper, txtFecha.Text); if (cmbOpciones.SelectedIndex > 0 && iCantE > 0) { vSQL = vSQL + "And NOT D.Pagado = '' "; } //selecciona especialidad cmbEspecialidad if (cmbEspecialidad.SelectedIndex == -1) { MessageBox.Show("Debe seleccionar una especialidad.", "Generacion Reportes", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); cmbEspecialidad.Focus(); return; } else { vEspecialidad = (Combos)cmbEspecialidad.SelectedItem; } //selecciona consultorio cmbConsultorio if (cmbConsultorio.SelectedIndex == -1) { MessageBox.Show("Debe seleccionar un consultorio.", "Generacion Reportes", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); cmbConsultorio.Focus(); return; } else { vConsultorio = (Combos)cmbConsultorio.SelectedItem; } //selecciona especialista cmbEspecialista if (cmbEspecialista.SelectedIndex == -1) { MessageBox.Show("Debe seleccionar un especialista.", "Generacion Reportes", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); cmbEspecialista.Focus(); return; } else { vEspecialista = (Combos)cmbEspecialista.SelectedItem; } //selecciona turno cmbTurno if (cmbTurno.SelectedIndex == -1) { MessageBox.Show("Debe seleccionar un turno.", "Generacion Reportes", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); cmbTurno.Focus(); return; } else { vTurno = (Combos)cmbTurno.SelectedItem; } //agrega especialidad al query de los 3 tipos if (vEspecialidad.id_tipo != "TODOS") { vSQL = vSQL + "And C.Id_Consultorio = '" + vEspecialidad.id_tipo + "' "; } //agrega consultorio al query de los 3 tipos if (vConsultorio.id_tipo != "TODOS") { vSQL = vSQL + "And CB.Id_Bus = '" + vConsultorio.id_tipo + "' "; } //agrega especialista al query de los 3 tipos if (vEspecialista.id_tipo != "TODOS") { vSQL = vSQL + "And CB.CMP = '" + vEspecialista.id_tipo + "' "; } //agrega turno al query de los 3 tipos if (vTurno.id_tipo != "TODOS") { vSQL = vSQL + "And CB.Turno = '" + vTurno.id_tipo + "' "; } //agrega ordenacion al query Parte de Atención Diaria if (cmbOpciones.SelectedIndex == 0) { vSQL = vSQL + "Order By C.Descripcion,B.Bus,CB.Fecha_Atencion,CB.Turno "; } //agrega agrupacion y ordenacion al query Consolidado de Atenciones y de Consolidado de Derivaciones if (cmbOpciones.SelectedIndex > 0) { vSQL = vSQL + "Group By C.Descripcion,B.Bus,X.Descripcion,Ape_Paterno,Ape_Materno,Nombres,P.Descripcion,D.Monto "; vSQL = vSQL + "Order By 1,2,3,4,5"; } //genera reporte y carga los datos object result = WaitWindow.Show(WorkerMethod, "Generando el reporte..."); if (result == null) { MessageBox.Show("No se pudo procesar el reporte."); return; } //llama al formulario que muestra el reporte frmCRViewer frg = new frmCRViewer(rpt); frg.ShowDialog(); } catch (Exception ex) { var st = new StackTrace(ex, true); var frame = st.GetFrame(0); var line = frame.GetFileLineNumber(); var col = frame.GetFileColumnNumber(); MessageBox.Show(ex.Message + (char)13 + "Linea: " + line + " Columna: " + col); } }
private void btnCons_Click(object sender, EventArgs e) { object result = null; if (cmbPerPago.SelectedIndex == -1) { MessageBox.Show("Seleccione periodo de pago o ingrese rango de fechas ...", "Aviso al usuario"); return; } string fi = dtpFecIni.Value.ToShortDateString(); string ff = dtpFecFin.Value.ToShortDateString(); string ic = cmbConsultorio.SelectedIndex == -1 ? "" : cmbConsultorio.SelectedValue.ToString(); string cm = cmbCMP.SelectedIndex == -1 ? "" : cmbCMP.SelectedValue.ToString(); string tr = cmbTurno.SelectedIndex == -1 ? "" : cmbTurno.SelectedValue.ToString(); this.subtitle = (cmbConsultorio.SelectedIndex != -1 ? "CONSULTORIO: " + cmbConsultorio.SelectedText : ""); this.periodo = "Periodo " + (cmbPerPago.SelectedIndex != -1 ? General.ProPer(cmbPerPago.SelectedText) : ("Del " + dtpFecIni.Value.ToLongDateString() + " al " + dtpFecFin.Value.ToLongDateString())); if (rbActual.Checked) { bool onlySelected = grdColegiatura.Enabled && !chkColegiaturas.Checked; List <Dictionary <string, string> > items = General.GetDictionaryList(grdColegiatura, onlySelected); string cl = "("; foreach (Dictionary <string, string> item in items) { cl += "'" + item["gIdTipo"] + "',"; } cl = cl.Substring(0, cl.Length - 1) + ")"; this.vSQL = "Select DatePart(Year,CB.Fecha_Atencion)Año,DateName(Month,CB.Fecha_Atencion)Mes,CB.Fecha_Atencion," + "M.Ape_Paterno+' '+M.Ape_Materno+', '+M.Nombres Medico,C.Descripcion Consultorio,P.Descripcion Producto," + "D.Monto Precio,Case When P.Tipo='C' And Left(M.TNCol,1) Not In('E','T') Then Sum(D.Cantidad) " + "When P.Tipo<>'C' And Left(M.TNCol,1) In('E','T') Then Sum(D.Cantidad) Else 0 End cCon," + "Case When P.Tipo<>'C' And B.Bus<>'SOP' And Left(M.TNCol,1) Not In('E','T') Then Sum(D.Cantidad) " + "Else 0 End cPrc,Case When P.Tipo<>'C' And B.Bus='SOP' Then Sum(D.Cantidad) Else 0 End cSOP," + "Case When P.Tipo='C' And Left(M.TNCol,1) Not In('E','T') Then Sum((D.Monto*D.Cantidad)-D.Dscto) " + "When P.Tipo<>'C' And Left(M.TNCol,1) In('E','T') Then Sum((D.Monto*D.Cantidad)-D.Dscto) Else 0.00 End tCon," + "Case When P.Tipo<>'C' And B.Bus<>'SOP' And Left(M.TNCol,1) Not In('E','T') " + "Then Sum((D.Monto*D.Cantidad)-D.Dscto) Else 0.00 End tPrc,Case When P.Tipo<>'C' And B.Bus='SOP' " + "Then Sum((D.Monto*D.Cantidad)-D.Dscto) Else 0.00 End tSOP,T.Descripcion Turno,T.Valor CTurno," + "T.Horas,TC.Descripcion Colegiatura,TC.Monto Sueldo " + "From Cab_Cie10 CB Inner Join Detalles D On CB.Nro_Historia=D.Nro_Historia Inner Join Productos P On " + "D.Id_Producto=P.Id_Producto Inner Join Personal M On CB.CMP=M.Id_Personal Inner Join Buses B On " + "CB.Id_Bus=B.Id_Bus Inner Join Consultorios C On B.Id_Esp=C.Id_Consultorio Inner Join " + "(Select Id_Tipo,Descripcion,Valor,Horas From TablaTipo TT Inner Join ValTurno V On TT.Id_Tipo=V.Id_Turno " + "Where Id_Tabla In(Select Id_Tipo From TablaTipo Where Descripcion='TURNOS' And Id_Tabla='0'))T On " + "CB.Turno=T.Id_Tipo Inner Join (Select Id_Tipo,Descripcion,Monto From TablaTipo TT Inner Join ValCol V On " + "TT.Id_Tipo=V.TCol Where Id_Tabla In(Select Id_Tipo From TablaTipo Where Descripcion='TIPO_COLEGIATURA' " + "And Id_Tabla='0'))TC On Left(M.TNCol,1)=TC.Id_Tipo " + "Where D.Pagado<>'' And CB.Id_Bus In(Select Id_Bus From Buses Where TBus='P' And Bus Not In('COMPUTO')) " + "And CB.Fecha_Atencion BetWeen '" + fi + "' And '" + ff + "' And Left(M.TNCol,1) In " + cl; if (!chkConsultorio.Checked && cmbConsultorio.SelectedIndex != -1) { this.vSQL += " And C.Id_Consultorio='" + ic + "' "; } if (!chkCMP.Checked && cmbCMP.SelectedIndex != -1) { this.vSQL += " And CB.CMP='" + cm + "' "; } if (!chkTurno.Checked && cmbTurno.SelectedIndex != -1) { this.vSQL += " And CB.Turno='" + tr + "' "; } this.vSQL += "Group By DatePart(Year,CB.Fecha_Atencion),DateName(Month,CB.Fecha_Atencion),CB.Fecha_Atencion,B.Bus," + "M.Ape_Paterno+' '+M.Ape_Materno+', '+M.Nombres,C.Descripcion,P.Descripcion,P.Tipo,D.Monto,T.Descripcion," + "T.Valor,T.Horas,TC.Descripcion,TC.Monto,M.TNCol Union All " + "Select DatePart(Year,PM.Fecha_Parte)Año,DateName(Month,PM.Fecha_Parte)Mes,PM.Fecha_Parte," + "M.Ape_Paterno+' '+M.Ape_Materno+', '+M.Nombres Medico,C.Descripcion Consultorio,P.Descripcion " + "Producto,PM.Precio,Sum(PM.Cantidad)cCon,0 cPrc,0 cSOP,Sum(PM.Monto)tCon,0.00 tPrc,0.00 tSOP," + "T.Descripcion Turno,T.Valor CTurno,T.Horas,TC.Descripcion Colegiatura,TC.Monto Sueldo " + "From ProdMedicos PM Inner Join Productos P On PM.Id_Producto=P.Id_Producto Inner Join Personal M On " + "PM.CMP=M.Id_Personal Inner Join Consultorios C On PM.Id_Consultorio=C.Id_Consultorio Inner Join " + "(Select Id_Tipo,Descripcion,Valor,Horas From TablaTipo TT Inner Join ValTurno V On TT.Id_Tipo=V.Id_TUrno " + "Where Id_Tabla In (Select Id_Tipo From TablaTipo Where Descripcion='TURNOS' And Id_Tabla='0'))T On " + "PM.Turno=T.Id_Tipo Inner Join (Select Id_Tipo,DescriMpcion,Monto From TablaTipo TT Inner Join ValCol V On " + "TT.Id_Tipo=V.TCol Where Id_Tabla In (Select Id_Tipo From TablaTipo Where Descripcion='TIPO_COLEGIATURA' And " + "Id_Tabla='0'))TC On Left(M.TNCol,1)=TC.Id_Tipo " + "Where PM.Fecha_Parte BetWeen '" + fi + "' And '" + ff + "' And Left(M.TNCol,1) In " + cl; if (!chkConsultorio.Checked && cmbConsultorio.SelectedIndex != -1) { this.vSQL += " And C.Id_Consultorio='" + ic + "' "; } if (!chkCMP.Checked && cmbCMP.SelectedIndex != -1) { this.vSQL += " And PM.CMP='" + cm + "' "; } if (!chkTurno.Checked && cmbTurno.SelectedIndex != -1) { this.vSQL += " And PM.Turno='" + tr + "' "; } this.vSQL += "Group By DatePart(Year,PM.Fecha_Parte),DateName(Month,PM.Fecha_Parte),PM.Fecha_Parte,M.Ape_Paterno" + "+' '+M.Ape_Materno+', '+M.Nombres,C.Descripcion,P.Descripcion,PM.Precio,T.Descripcion,T.Valor,T.Horas," + "TC.Descripcion,TC.Monto"; result = WaitWindow.Show(WorkerMethodRptProdMedCon, "Generando el reporte..."); int count = int.Parse(result.ToString()); General.setAll <Button, bool>(this, "Enabled", count > 0); btnCons.Enabled = true; } else { this.vSQL = "Exec ProdEspec '" + fi + "','" + ff + "','" + cm + "','" + ic + "','" + tr + "'"; result = WaitWindow.Show(WorkerMethodRptProdMedCon, "Generando el reporte..."); int count = int.Parse(result.ToString()); btnMarcar.Enabled = count > 0; } if (result == null) { MessageBox.Show("No se pudo procesar el reporte."); return; } frmCRViewer frg = new frmCRViewer(rpt); frg.ShowDialog(); }