private void Buscar() { try { //Borro todo las filas y columnas anteriores DG_Datos.Columns.Clear(); DG_Datos.Rows.Clear(); //Busco la lista de datos Datos.Factura F = Datos.Factura.GetFacturaRelacional(Txt_Id.Text, _TipoFactura.ToString(), "", "", "", razon_social_textBox1.Text); //Agrego las columnas de la regilla de datos. DG_Datos.Columns.Add("Clm_RSocial", "Razón social"); DG_Datos.Columns.Add("Clm_Dirección", "Dirección"); DG_Datos.Columns.Add("Clm_Teléfonos", "Teléfonos"); DG_Datos.Columns.Add("Clm_Fecha", "Fecha"); DG_Datos.Columns.Add("Clm_CPN", "Clase Puesto-Número"); DG_Datos.Columns.Add("Clm_Importe", "Importe"); DG_Datos.Columns.Add("Clm_ImporteInteres", "Interés"); DG_Datos.Font = new Font(Config.NombreFont, Config.TamañoFont); DG_Datos.Columns["Clm_RSocial"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; DG_Datos.Columns["Clm_Dirección"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; DG_Datos.Columns["Clm_Teléfonos"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; DG_Datos.Columns["Clm_Fecha"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; DG_Datos.Columns["Clm_CPN"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; DG_Datos.Columns["Clm_Importe"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; DG_Datos.Columns["Clm_ImporteInteres"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; //Agrego las filas foreach (Datos.Factura ItemFactura in F.ListaFactura) { bool Mostrar = true; if (Chk_Pendientes.Checked) { if (Datos.Couta.GetCouta("", ItemFactura.Id_Factura.ToString(), "0").ListaCouta.Count == 0) { Mostrar = false; } } if (Mostrar) { DG_Datos.Rows.Add(); DG_Datos.Rows[DG_Datos.Rows.Count - 1].Tag = ItemFactura.Id_Factura; if (_TipoFactura == 1) { if (ItemFactura.Pagado_Factura == false && ItemFactura.Id_Factura_Tipo != 3) { DG_Datos.Rows[DG_Datos.Rows.Count - 1].DefaultCellStyle.BackColor = Color.SkyBlue; } } else { if (ItemFactura.Facturado_Factura == false && ItemFactura.Id_Factura_Tipo != 3) { DG_Datos.Rows[DG_Datos.Rows.Count - 1].DefaultCellStyle.BackColor = Color.SkyBlue; } } if (ItemFactura.Anulado_Factura == true) { DG_Datos.Rows[DG_Datos.Rows.Count - 1].DefaultCellStyle.BackColor = Color.Red; } DG_Datos.Rows[DG_Datos.Rows.Count - 1].Cells["Clm_RSocial"].Value = ItemFactura.Tercero.Razon_Social_Tercero; DG_Datos.Rows[DG_Datos.Rows.Count - 1].Cells["Clm_Dirección"].Value = ItemFactura.Tercero.Direccion_Tercero; DG_Datos.Rows[DG_Datos.Rows.Count - 1].Cells["Clm_Teléfonos"].Value = ItemFactura.Tercero.Telefonos_Tercero; DG_Datos.Rows[DG_Datos.Rows.Count - 1].Cells["Clm_Fecha"].Value = ItemFactura.Fecha_Factura; DG_Datos.Rows[DG_Datos.Rows.Count - 1].Cells["Clm_CPN"].Value = ItemFactura.Clase_Factura + " " + ItemFactura.Puesto_Factura.ToString("0000") + "-" + ItemFactura.Numero_Factura.ToString("00000000"); if (_TipoFactura == 3) { DG_Datos.Rows[DG_Datos.Rows.Count - 1].Cells["Clm_Importe"].Value = "$ " + (ItemFactura.Total_Factura + ItemFactura.Otros_Factura).ToString(Config.NumeroDecimales); } else { DG_Datos.Rows[DG_Datos.Rows.Count - 1].Cells["Clm_Importe"].Value = "$ " + ItemFactura.Total_Factura.ToString(Config.NumeroDecimales); } DG_Datos.Rows[DG_Datos.Rows.Count - 1].Cells["Clm_ImporteInteres"].Value = "$ " + ItemFactura.Otros_Factura.ToString(Config.NumeroDecimales); } } Txt_CantidadRegistros.Text = F.ListaFactura.Count.ToString(); if (NumeroFilaUltimaSeleccion != 0 && DG_Datos.Rows.Count > NumeroFilaUltimaSeleccion) { DG_Datos.Rows[NumeroFilaUltimaSeleccion].Selected = true; } } catch (Exception Error) { MessageBox.Show(Error.Message); } }
private void FrmVolVentas_Load(object sender, EventArgs e) { //reportViewer1.LocalReport.ReportPath = Application.StartupPath + @"\RepBanlance.rdlc"; reportViewer1.LocalReport.DataSources.Clear(); //COMPRA-VENTA---------------------------------------------------------------------------- List <Datos.DatosReportes> DR = new List <Datos.DatosReportes>(); Datos.Factura FACTURAS = Datos.Factura.GetFactura("", "", "", "", "", "", DateTime.Now.Subtract(new TimeSpan(DateTime.Now.Day - 1, 0, 0, 0)).ToString()); Datos.DatosReportes VENTAS = new Datos.DatosReportes(); VENTAS.Descripcion = "VENTAS"; VENTAS.ValorDecimal = 0; Datos.DatosReportes COMPRAS = new Datos.DatosReportes(); COMPRAS.Descripcion = "COMPRAS"; COMPRAS.ValorDecimal = 0; int ArtComprados = 0; int ArtVendidos = 0; foreach (Datos.Factura itemListaFactura in FACTURAS.ListaFactura) { int CantidadTem = 0; Datos.Factura_detalle DF = Datos.Factura_detalle.GetFactura_detalle("", itemListaFactura.Id_Factura.ToString()); foreach (Datos.Factura_detalle itemFactura_detalle in DF.ListaFactura_detalle) { CantidadTem += itemFactura_detalle.Cantidad_Factura_Detalle; } if (itemListaFactura.Id_Factura_Tipo == 1) { COMPRAS.ValorDecimal += itemListaFactura.Total_Factura; ArtComprados += CantidadTem; } if (itemListaFactura.Id_Factura_Tipo == 2) { VENTAS.ValorDecimal += itemListaFactura.Total_Factura; ArtVendidos += CantidadTem; } } DR.Add(VENTAS); DR.Add(COMPRAS); Microsoft.Reporting.WinForms.ReportDataSource RDS = new Microsoft.Reporting.WinForms.ReportDataSource("DATOS1", DR); reportViewer1.LocalReport.DataSources.Add(RDS); //GRAFICO LINEAL---------------------------------------------------------------------------- List <Datos.DatosReportes> DR1 = new List <Datos.DatosReportes>(); for (int i = 7; i >= 0; i--) { //DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month - i, 1); int año = 0; int mes = 0; if (DateTime.Now.Month - (i + 1) < 0) { año = DateTime.Now.Year - 1; mes = (DateTime.Now.Month - (i + 1)) + 13; } else { año = DateTime.Now.Year; mes = DateTime.Now.Month - (i + 1) + 1; } DateTime dt = new DateTime(año, mes, 1); string Fecha = dt.ToString(); Datos.DatosReportes TEMP = new Datos.DatosReportes(); TEMP.Descripcion = Common.NombreMes(dt.Month).ToString(); TEMP.ValorDecimal = GananciaXmes(Fecha); DR1.Add(TEMP); } Microsoft.Reporting.WinForms.ReportDataSource RDS1 = new Microsoft.Reporting.WinForms.ReportDataSource("DATOS2", DR1); reportViewer1.LocalReport.DataSources.Add(RDS1); //10 MAS VENDIDOS---------------------------------------------------------------------------- List <Datos.DatosReportes> DR2 = new List <Datos.DatosReportes>(); //DateTime dt2 = new DateTime(DateTime.Now.Year, DateTime.Now.Month - 1, 1); int año2 = 0; int mes2 = 0; if (DateTime.Now.Month - 2 < 0) { año2 = DateTime.Now.Year - 1; mes2 = (DateTime.Now.Month - 2) + 13; } else { año2 = DateTime.Now.Year; mes2 = DateTime.Now.Month - 2 + 1; } DateTime dt2 = new DateTime(año2, mes2, 1); Datos.Articulo ART = Datos.Articulo.Los10MasVendidos(dt2.ToString()); foreach (Datos.Articulo itemArticulo in ART.ListaArticulo) { Datos.DatosReportes TEMP = new Datos.DatosReportes(); TEMP.Descripcion = itemArticulo.Descripcion_Articulo; TEMP.ValorDecimal = 0; DR2.Add(TEMP); } Microsoft.Reporting.WinForms.ReportDataSource RDS2 = new Microsoft.Reporting.WinForms.ReportDataSource("DATOS3", DR2); reportViewer1.LocalReport.DataSources.Add(RDS2); //PARAMETROS------------------------------------------------------------------------------- reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("VarVenta", "$ " + VENTAS.ValorDecimal.ToString(Config.NumeroDecimales))); reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("VarCompra", "$ " + COMPRAS.ValorDecimal.ToString(Config.NumeroDecimales))); reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("VarResultado", "$ " + (VENTAS.ValorDecimal - COMPRAS.ValorDecimal).ToString(Config.NumeroDecimales))); reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("CantidadVendidos", ArtVendidos.ToString())); reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("CantidadComprados", ArtComprados.ToString())); reportViewer1.LocalReport.Refresh(); this.reportViewer1.RefreshReport(); }
private void Btn_Aceptar_Click(object sender, EventArgs e) { try { ControlValores(); Datos.Factura F = new Datos.Factura(); Datos.Couta Cuotas = new Datos.Couta(); Cuotas.ListaCouta = new List <Datos.Couta>(); decimal TotalInteres = 0; foreach (DataGridViewRow Fila in DG_Facturas.Rows) { try { TotalInteres += Convert.ToDecimal(Fila.Cells["Clm_Interes"].Value); } catch { //none } } Datos.Caja ObjCaja = new Datos.Caja(); ObjCaja.ListaCaja = new List <Datos.Caja>(); F.Id_Factura = (Txt_Id.Text == "") ? 0 : Convert.ToInt32(Txt_Id.Text); F.Id_Factura_Tipo = 3; F.Id_Tercero = Convert.ToInt32(id_TerceroTextBox.Text); F.Fecha_Factura = DateTime.Now; F.Fecha_Vencimiento_Factura = DateTime.Now; F.Puesto_Factura = Convert.ToInt32(puesto_FacturaTextBox.Text); F.Numero_Factura = Convert.ToInt32(numero_Comprobante_FacturaTextBox.Text); F.Clase_Factura = "X"; F.Neto_Factura = 0; F.IVA_105_Factura = 0; F.IVA_21_Factura = 0; F.IVA_27_Factura = 0; F.Percepcion_Factura = 0; F.Exentos_Factura = 0; F.Otros_Factura = TotalInteres; F.Total_Factura = NUD_Total.Value - TotalInteres; F.Retencion_Factura = 0; F.Anulado_Factura = false; F.Observaciones_Factura = ""; F.Interes_Factura = 0; foreach (DataGridViewRow Fila in DG_Facturas.Rows) { Datos.Couta TEMP = Datos.Couta.GetCouta(Fila.Tag.ToString(), "", "0"); TEMP.ListaCouta[0].Pagado_Couta = ((TEMP.ListaCouta[0].Importe_Couta - TEMP.ListaCouta[0].Asignacion_Cuota) - Convert.ToDecimal(Fila.Cells["Clm_Importe1"].Value) <= 0) ? true : false; TEMP.ListaCouta[0].Fecha_Pago_Couta = DateTime.Now; TEMP.ListaCouta[0].Importe_Interes_Couta = Convert.ToDecimal(Fila.Cells["Clm_Interes"].Value); TEMP.ListaCouta[0].Asignacion_Cuota += Convert.ToDecimal(Fila.Cells["Clm_Importe1"].Value); TEMP.ListaCouta[0].Observaciones_Couta = Fila.Cells["Clm_Observaciones"].Value.ToString(); Cuotas.ListaCouta.Add(TEMP.ListaCouta[0]); } foreach (DataGridViewRow Fila in DG_Efectivo.Rows) { Datos.Caja TEMP = new Datos.Caja(); TEMP.Id_Caja_Tipo = 1; TEMP.Fecha_Caja = DateTime.Now; TEMP.Importe_Caja = Convert.ToDecimal(Fila.Cells["Clm_Importe"].Value); TEMP.Tag_Caja = Txt_NombreTercero.Text; if (TEMP.Importe_Caja != 0 || TEMP.Importe_Caja != 0) { ObjCaja.ListaCaja.Add(TEMP); } } if (Txt_Id.Text == "") { if (_TipoTercero == 1) { numero_Comprobante_FacturaTextBox.Text = Datos.Series.Bloquear("RECIBOS").ToString("00000000"); Datos.Series.Desbloquear("RECIBOS"); } else if (_TipoTercero == 2) { numero_Comprobante_FacturaTextBox.Text = Datos.Series.Bloquear("RECIBOS").ToString("00000000"); Datos.Series.Desbloquear("RECIBOS"); } string TipoComprobanteAnterior = ""; if (_TipoTercero == 1) { TipoComprobanteAnterior = "RECIBOS"; } else if (_TipoTercero == 2) { TipoComprobanteAnterior = "RECIBOS"; } MDI.FrmDialogoFactura FDF = new FrmDialogoFactura(TipoComprobanteAnterior, "X", puesto_FacturaTextBox.Text, numero_Comprobante_FacturaTextBox.Text); if (FDF.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (_TipoTercero == 1) { numero_Comprobante_FacturaTextBox.Text = Datos.Series.Bloquear("RECIBOS").ToString("00000000"); Datos.Series.Desbloquear("RECIBOS"); } else if (_TipoTercero == 2) { numero_Comprobante_FacturaTextBox.Text = Datos.Series.Bloquear("RECIBOS").ToString("00000000"); Datos.Series.Desbloquear("RECIBOS"); } if (Chk_ImprimirComprobante.Checked) { ImprimirDocumento.Print(); } Datos.Factura.AddRecibo_OrdenPago(F, Cuotas, CHECARTE, ObjCaja); if (_TipoTercero == 1) { Datos.Series.DesbloquearSumar("RECIBOS"); } else if (_TipoTercero == 2) { Datos.Series.DesbloquearSumar("RECIBOS"); } MessageBox.Show("Se ha agregado un nuevo registro."); } else { return; } } else { //Datos.Factura.SetRecibo_OrdenPago(F, Facturas, ObjChequePropio, ObjDeposito, ObjTransferencia, ObjCheque_Cartera, ObjCaja, ObjTarjeta); //MessageBox.Show("Se ha modificado correctamente el registro."); } CerrarVentana = true; Close(); } catch (Exception Error) { MessageBox.Show(Error.Message); } }