private void btn_reporte_Click(object sender, EventArgs e) { int numero = 0; string condicion = ""; if (txt_numero_recibo.Text.Equals("")) { numero = 0; } else { numero = Convert.ToInt32(txt_numero_recibo.Text); } if (ch_incluir_fechas.Checked == true) { condicion = @"([ID_RECIBO] = " + numero + " OR 0 = " + numero + @") and ([ESTADO] = '" + cb_estado.Text + "' OR '' = '" + cb_estado.Text + @"') and ([NOMBRE] = '" + cb_cliente.Text + "' OR '' = '" + cb_cliente.Text + @"') and ([COBRADOR] = '" + cb_cobrador.Text + "' OR '' = '" + cb_cobrador.Text + @"') and ([FECHA_CREADO] Between('" + dt_desde.Value.Date + "', '" + dt_hasta.Value.Date + "'))"; } else { condicion = @"([ID_RECIBO] = " + numero + " OR 0 = " + numero + @") and ([ESTADO] = '" + cb_estado.Text + "' OR '' = '" + cb_estado.Text + @"') and ([NOMBRE] = '" + cb_cliente.Text + "' OR '' = '" + cb_cliente.Text + @"') and ([COBRADOR] = '" + cb_cobrador.Text + "' OR '' = '" + cb_cobrador.Text + @"')"; } Reportes.Rep_Recibo_Pago report = new Reportes.Rep_Recibo_Pago(); report.FilterString = condicion; ReportPrintTool tool = new ReportPrintTool(report); tool.ShowPreview(); }
private void btn_guardar_Click(object sender, EventArgs e) { if (txt_total.TextLength == 0) { S_Utilidades.Mensaje_Informacion("No hay Cuota(s) Seleccionada(s)"); return; } DETALLES_CUOTAS obj_detalle = new DETALLES_CUOTAS(); RECIBOS_COBRADOS obj_recibo = new RECIBOS_COBRADOS(); FACTURAS obj_factura = new FACTURAS(); try { foreach (DataGridViewRow row in dg_detalle_cuotas.Rows) { obj_detalle.ID_FACTURA = Convert.ToInt32(Txt_ID.Text); if (Convert.ToBoolean(row.Cells[3].Value) == true && Convert.ToDecimal(row.Cells[4].Value) > 0) { if (Convert.ToDecimal(row.Cells[4].Value) > Convert.ToDecimal(row.Cells[2].Value)) { //actualizar totales de cuotas obj_detalle.MONTO_PAGADO = Convert.ToDecimal(row.Cells[2].Value); obj_detalle.MONTO_PENDIENTE = 0; obj_detalle.NUMERO_CUOTA = Convert.ToInt32(row.Cells[0].Value); S_Factura.Cobrar_Cuota(obj_detalle); //actualizar totales de factura obj_factura.ID_FACTURA = Convert.ToInt32(Txt_ID.Text); obj_factura.MONTO_PAGADO = obj_detalle.MONTO_PAGADO; S_Factura.Actualizar_Montos_Factura(obj_factura); //asignar montos de recibos obj_recibo.VALOR_PAGADO = Convert.ToDecimal(row.Cells[2].Value); obj_recibo.VALOR_PENDIENTE = 0; } else { //actualizar totales de cuotas obj_detalle.MONTO_PAGADO = Convert.ToDecimal(row.Cells[4].Value); obj_detalle.MONTO_PENDIENTE = Convert.ToDecimal(row.Cells[2].Value) - Convert.ToDecimal(row.Cells[4].Value); obj_detalle.NUMERO_CUOTA = Convert.ToInt32(row.Cells[0].Value); S_Factura.Cobrar_Cuota(obj_detalle); //actualizar totales de factura obj_factura.ID_FACTURA = Convert.ToInt32(Txt_ID.Text); obj_factura.MONTO_PAGADO = obj_detalle.MONTO_PAGADO; S_Factura.Actualizar_Montos_Factura(obj_factura); //asignar montos de recibos obj_recibo.VALOR_PAGADO = Convert.ToDecimal(row.Cells[4].Value); obj_recibo.VALOR_PENDIENTE = obj_detalle.MONTO_PENDIENTE; } } else if (Convert.ToBoolean(row.Cells[3].Value) == true) { //actualizar totales de cuotas obj_detalle.MONTO_PAGADO = Convert.ToDecimal(row.Cells[2].Value); obj_detalle.MONTO_PENDIENTE = 0; obj_detalle.NUMERO_CUOTA = Convert.ToInt32(row.Cells[0].Value); S_Factura.Cobrar_Cuota(obj_detalle); //actualizar totales de factura obj_factura.ID_FACTURA = Convert.ToInt32(Txt_ID.Text); obj_factura.MONTO_PAGADO = obj_detalle.MONTO_PAGADO; S_Factura.Actualizar_Montos_Factura(obj_factura); //asignar montos de recibos obj_recibo.VALOR_PAGADO = Convert.ToDecimal(row.Cells[2].Value); obj_recibo.VALOR_PENDIENTE = 0; } if (Convert.ToBoolean(row.Cells[3].Value) == true) { //insertar recibos de cobros obj_recibo.ANULADO_POR = ""; obj_recibo.CREADO_POR = S_Utilidades.Datos_Usuario.USUARIO; int ID_FACTURA = Convert.ToInt32(Txt_ID.Text); var obj_encabezado = db.ENCABEZADO_CUOTAS.Where(a => a.ID_FACTURA == ID_FACTURA).Single(); obj_recibo.CANTIDAD_CUOTAS = obj_encabezado.CANTIADA_CUOTA; obj_recibo.CUOTA_COBRADA = Convert.ToInt32(row.Cells[0].Value); obj_recibo.ESTADO = "V"; obj_recibo.FECHA_ANULADO = ""; obj_recibo.FECHA_CREADO = DateTime.Now; obj_recibo.ID_FACTURA = Convert.ToInt32(Txt_ID.Text); var obj_fact = db.FACTURAS.Where(f => f.ID_FACTURA == ID_FACTURA).Single(); obj_recibo.NOTA_ANULACION = ""; obj_recibo.VALOR_CUOTA = Convert.ToDecimal(row.Cells[2].Value); S_Factura.Insertar_Recibo_Cobros(obj_recibo); } } String arry = ""; int id_factura = Convert.ToInt32(Txt_ID.Text); foreach (DataGridViewRow row in dg_detalle_cuotas.Rows) { int cuota = Convert.ToInt32(row.Cells[0].Value); if (Convert.ToBoolean(row.Cells[3].Value) == true) { var id_recibo = db.RECIBOS_COBRADOS.Where(s => s.ID_FACTURA == id_factura && s.CUOTA_COBRADA == cuota).Max(s => s.ID_RECIBO); arry += id_recibo.ToString() + ","; } } String recibos = arry.TrimEnd(','); S_Utilidades.Mensaje_Informacion("Cobros Realizados con Correctamente por un Monto Total de: " + txt_total.Text); Reportes.Rep_Recibo_Pago report = new Reportes.Rep_Recibo_Pago(); report.FilterString = "([ID_FACTURA] = " + Txt_ID.Text + " AND [ID_RECIBO] IN (" + recibos + "))"; ReportPrintTool tool = new ReportPrintTool(report); tool.ShowPreview(); Close(); } catch (Exception ex) { S_Utilidades.Mensaje_Informacion(ex.Message); } }