Example #1
0
        private void cargarDatosTabla()
        {
            List <DetalleLibroVentas> lista = DetalleLibroVentasBLL.GetDetalleLibroVentasByIdLibro(idLibro);

            foreach (DetalleLibroVentas venta in lista)
            {
                Object[] row = { venta.pkRegistro, venta.intNro, venta.dateFechaFactura, venta.txtNroFactura, venta.txtNroAutorizacion, venta.txtEstado, venta.txtNitCliente, venta.txtNombreRazon, venta.decImporteTotal, venta.decImporteImpuestos, venta.decExportacionesExentos, venta.decVentasTasaCero, venta.decSubTotal, venta.decDescuentos, venta.decImporteBaseDF, venta.decDebitoFiscal, venta.txtCodigoControl };
                gdDetalleLibroVentas.Rows.Add(row);
            }
            gdDetalleLibroVentas.Refresh();
        }
Example #2
0
 public void cargarTabla()
 {
     listaFacturas     = FacturaBLL.GetAllFacturas();
     listaDetalleLibro = DetalleLibroVentasBLL.SelectAll();
     foreach (Factura item in listaFacturas)
     {
         foreach (DetalleLibroVentas det in listaDetalleLibro)
         {
             if (item.txtNroFactura == det.txtNroFactura)
             {
                 dgvFacturas.Rows.Add(item.txtNroFactura, det.dateFechaFactura.ToShortDateString(), det.txtNitCliente, det.txtNombreRazon, item.decTotal);
             }
         }
     }
 }
Example #3
0
        private void frmReporteLibroVenta_Load(object sender, EventArgs e)
        {
            ;
            // TODO: This line of code loads data into the 'detalleLibroVentasDS.DetalleLibroVentas' table. You can move, or remove it, as needed.
            libro = LibroVentasBLL.GetLibroVentasById(idLibro);
            List <DetalleLibroVentas> detalles = DetalleLibroVentasBLL.GetDetalleLibroVentasByIdLibro(libro.pkLibro);
            ReportDataSource          dt       = new ReportDataSource("LV", detalles);
            ReportParameter           pYear    = new ReportParameter("Year", libro.txtAño);
            ReportParameter           pMonth   = new ReportParameter("Month", libro.txtMes);

            this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { pYear });
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { pMonth });
            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(dt);
            this.reportViewer1.RefreshReport();
        }
Example #4
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (idLibro != 0)
     {
         foreach (DataGridViewRow fila in gdDetalleLibroVentas.Rows)
         {
             double total        = Convert.ToDouble(fila.Cells["txtImporteTotal"].Value);
             double impuestos    = Convert.ToDouble(fila.Cells["txtImpuestos"].Value);
             double excentos     = Convert.ToDouble(fila.Cells["txtExcentos"].Value);
             double tasaCero     = Convert.ToDouble(fila.Cells["txtImporteVentasTasaCero;"].Value);
             double subtotal     = Convert.ToDouble(fila.Cells["txtSubTotal"].Value);
             double descuentos   = Convert.ToDouble(fila.Cells["txtDescuentos"].Value);
             double baseDF       = Convert.ToDouble(fila.Cells["txtImporteBaseDF"].Value);
             double debitoFiscal = Convert.ToDouble(fila.Cells["txtDebitoFiscal"].Value);
             if (fila.Cells["txtIdRegistro"].Value.ToString() != "-1")
             {
                 DetalleLibroVentasBLL.UpdateDetalle(Convert.ToInt32(fila.Cells["txtIdRegistro"].Value), Convert.ToInt32(fila.Cells["txtNro"].Value), Convert.ToDateTime(fila.Cells["dateFechaFactura"].Value), fila.Cells["txtNroFactura"].Value.ToString(), fila.Cells["txtNroAutorizacion"].Value.ToString(), fila.Cells["txtEstado"].Value.ToString(), fila.Cells["txtNitCliente"].Value.ToString(), fila.Cells["txtNombreRazon"].Value.ToString(), Convert.ToDecimal(total), Convert.ToDecimal(impuestos), Convert.ToDecimal(excentos), Convert.ToDecimal(tasaCero), Convert.ToDecimal(subtotal), Convert.ToDecimal(descuentos), Convert.ToDecimal(baseDF), Convert.ToDecimal(debitoFiscal), fila.Cells["txtCodigoControl"].Value.ToString(), idLibro, user);
             }
             else
             {
                 DetalleLibroVentasBLL.InsertDatosDetalleLibroVentas(Convert.ToInt32(fila.Cells["txtNro"].Value), Convert.ToDateTime(fila.Cells["dateFechaFactura"].Value), fila.Cells["txtNroFactura"].Value.ToString(), fila.Cells["txtNroAutorizacion"].Value.ToString(), fila.Cells["txtNitCliente"].Value.ToString(), fila.Cells["txtNombreRazon"].Value.ToString(), Convert.ToDecimal(total), Convert.ToDecimal(impuestos), Convert.ToDecimal(excentos), Convert.ToDecimal(tasaCero), Convert.ToDecimal(subtotal), Convert.ToDecimal(descuentos), Convert.ToDecimal(baseDF), Convert.ToDecimal(debitoFiscal), fila.Cells["txtCodigoControl"].Value.ToString(), idLibro, user);
             }
         }
     }
     else
     {
         idLibro = LibroVentasBLL.InsertDatosLibroVentas(txtMonth.Text, txtYear.Text);
         foreach (DataGridViewRow fila in gdDetalleLibroVentas.Rows)
         {
             double total        = Convert.ToDouble(fila.Cells["txtImporteTotal"].Value);
             double impuestos    = Convert.ToDouble(fila.Cells["txtImpuestos"].Value);
             double excentos     = Convert.ToDouble(fila.Cells["txtExcentos"].Value);
             double tasaCero     = Convert.ToDouble(fila.Cells["txtImporteVentasTasaCero;"].Value);
             double subtotal     = Convert.ToDouble(fila.Cells["txtSubTotal"].Value);
             double descuentos   = Convert.ToDouble(fila.Cells["txtDescuentos"].Value);
             double baseDF       = Convert.ToDouble(fila.Cells["txtImporteBaseDF"].Value);
             double debitoFiscal = Convert.ToDouble(fila.Cells["txtDebitoFiscal"].Value);
             DetalleLibroVentasBLL.InsertDatosDetalleLibroVentas(Convert.ToInt32(fila.Cells["txtNro"].Value), Convert.ToDateTime(fila.Cells["dateFechaFactura"].Value), fila.Cells["txtNroFactura"].Value.ToString(), fila.Cells["txtNroAutorizacion"].Value.ToString(), fila.Cells["txtNitCliente"].Value.ToString(), fila.Cells["txtNombreRazon"].Value.ToString(), Convert.ToDecimal(total), Convert.ToDecimal(impuestos), Convert.ToDecimal(excentos), Convert.ToDecimal(tasaCero), Convert.ToDecimal(subtotal), Convert.ToDecimal(descuentos), Convert.ToDecimal(baseDF), Convert.ToDecimal(debitoFiscal), fila.Cells["txtCodigoControl"].Value.ToString(), idLibro, user);
         }
     }
 }
Example #5
0
 private void gdLibrosVentas_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == btnEditar.Index)
     {
         frmInsertarLibroVentas frm = new frmInsertarLibroVentas(1, Convert.ToInt32(gdLibrosVentas.Rows[e.RowIndex].Cells[0].Value));
         frm.MdiParent   = this.MdiParent;
         frm.WindowState = FormWindowState.Maximized;
         frm.Show();
         this.Dispose();
     }
     if (e.ColumnIndex == btnExportar.Index)
     {
         FolderBrowserDialog sf = new FolderBrowserDialog();
         // Feed the dummy name to the save dialog
         DialogResult result = sf.ShowDialog();
         if (result == DialogResult.OK)
         {
             string savePath = sf.SelectedPath + "\\" + gdLibrosVentas.Rows[e.RowIndex].Cells[1].Value.ToString() + gdLibrosVentas.Rows[e.RowIndex].Cells[2].Value.ToString() + "LV.txt";
             using (StreamWriter writer = new StreamWriter(savePath, false))
             {
                 List <DetalleLibroVentas> detalles = DetalleLibroVentasBLL.GetDetalleLibroVentasByIdLibro(Convert.ToInt32(gdLibrosVentas.Rows[e.RowIndex].Cells[0].Value.ToString()));
                 foreach (DetalleLibroVentas detalle in detalles)
                 {
                     writer.WriteLine(detalle.intEspecificacion + "|" + detalle.intNro + "|" + detalle.dateFechaFactura.ToShortDateString() + "|" + detalle.txtNroFactura + "|" + detalle.txtNroAutorizacion + "|" + detalle.txtEstado + "|" +
                                      detalle.txtNitCliente + "|" + detalle.txtNombreRazon + "|" + detalle.decImporteTotal.ToString().Replace(',', '.') + "|" + detalle.decImporteImpuestos.ToString().Replace(',', '.') + "|" + detalle.decExportacionesExentos.ToString().Replace(',', '.') + "|" + detalle.decVentasTasaCero.ToString().Replace(',', '.') + "|" +
                                      detalle.decSubTotal.ToString().Replace(',', '.') + "|" + detalle.decDescuentos.ToString().Replace(',', '.') + "|" + detalle.decImporteBaseDF.ToString().Replace(',', '.') + "|" + detalle.decDebitoFiscal.ToString().Replace(',', '.') + "|" + detalle.txtCodigoControl + "\n");
                 }
             }
             MessageBox.Show("El archivo se guardó en la ruta " + savePath);
         }
     }
     if (e.ColumnIndex == btnImprimir.Index)
     {
         frmReporteLibroVenta frm = new frmReporteLibroVenta();
         frm.IdLibro     = Convert.ToInt32(gdLibrosVentas.Rows[e.RowIndex].Cells[0].Value);
         frm.MdiParent   = this.MdiParent;
         frm.WindowState = FormWindowState.Maximized;
         frm.Show();
         this.Dispose();
     }
 }
Example #6
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (validarStock() == true)
     {
         if (txtNitCliente.Text != "" && txtNombreCliente.Text != "" && tblDetalleVenta.RowCount > 0)
         {
             string nroFact = getNroFactura().ToString();
             int    idCliente;
             if (objCliente == null)
             {
                 int idPersona = PersonaBLL.InsertDatosPersona(txtNitCliente.Text, txtNombreCliente.Text, "", "", "", "", 1);
                 idCliente = ClienteBLL.InsertDatosCliente(idPersona, 1);
             }
             else
             {
                 idCliente = objCliente.pkCliente;
             }
             int idFactura = 0;
             if (llave != null && llave.txtLlave != "")
             {
                 idFactura = FacturaBLL.InsertarFactura(0, idCliente, 2, Convert.ToInt32(boxDescuentos.SelectedValue), 1, nroFact, llave.txtNroAutorizacion, llave.txtLlave, Convert.ToDecimal(sumarTotalVenta()), 1);
             }
             else
             {
                 MessageBox.Show("USTED NO HA INGRESADO LA LLAVE NI EL CODIGO DE AUTORIZACIÓN DE LA FACTURA");
                 return;
             }
             foreach (DataGridViewRow fila in tblDetalleVenta.Rows)
             {
                 if (Convert.ToInt32(fila.Cells["txtCantidad"].Value.ToString()) > 0)
                 {
                     if (fila.Cells["idProducto"] != null)
                     {
                         GananciasDTO ganancias = new GananciasDTO();
                         ganancias.fkProducto  = Convert.ToInt32(fila.Cells["idProducto"].Value.ToString());
                         ganancias.intCantidad = Convert.ToInt32(fila.Cells["txtCantidad"].Value.ToString());
                         Producto pro = ProductoBLL.GetProductById(ganancias.fkProducto);
                         ganancias.decValorVenta  = pro.decValorVenta;
                         ganancias.decValorCompra = pro.decValorCompra;
                         ganancias.decTotal       = Convert.ToDecimal(fila.Cells["txtSubTotal"].Value.ToString());
                         DetalleVentaBLL.InsertarDetalleVenta(0, Convert.ToInt32(fila.Cells["idProducto"].Value.ToString()), idFactura, Convert.ToInt32(fila.Cells["txtCantidad"].Value.ToString()), Convert.ToDecimal(fila.Cells["txtSubTotal"].Value.ToString()));
                         GananciasBLL.InsertObjetoGanancias(ganancias);
                         Producto auxProducto = getProductoOfList(fila.Cells["idProducto"].Value.ToString());
                         auxProducto.intCantidad -= Convert.ToInt32(fila.Cells["txtCantidad"].Value.ToString());
                         ProductoBLL.UpdateProducto(auxProducto);
                         sumaReal       += (double)auxProducto.decValorVenta * Convert.ToInt32(fila.Cells["txtCantidad"].Value.ToString());
                         sumaDescuentos += Convert.ToDouble(fila.Cells["txtSubTotal"].Value.ToString());
                     }
                 }
                 else
                 {
                     MessageBox.Show("Usted a ingresado una cantidad de 0");
                     return;
                 }
             }
             if (lastLibroVenta != null)
             {
                 if (lastLibroVenta.txtMes == DateTime.Now.Month.ToString() && lastLibroVenta.txtAño == DateTime.Now.Year.ToString())
                 {
                     List <DetalleLibroVentas> lista = DetalleLibroVentasBLL.GetDetalleLibroVentasByIdLibro(lastLibroVenta.pkLibro);
                     int lastNro = 0;
                     if (lista.Count != 0)
                     {
                         lastNro = lista[(lista.Count - 1)].intNro;
                     }
                     if (sumaReal == sumaDescuentos)
                     {
                         sumaDescuentos = 0;
                     }
                     double dif = sumaReal - sumaDescuentos;
                     double db  = 0;
                     if (dif == sumaReal)
                     {
                         db = sumaReal * 13 / 100;
                     }
                     else
                     {
                         db = (sumaReal - dif) * 13 / 100;
                     }
                     DetalleLibroVentasBLL.InsertDatosDetalleLibroVentas(lastNro + 1, DateTime.Now, nroFact, llave.txtNroAutorizacion, txtNitCliente.Text, txtNombreCliente.Text, Convert.ToDecimal(sumaReal), 0, 0, 0, Convert.ToDecimal(sumaReal), (dif == sumaReal) ? 0 : Convert.ToDecimal(dif), (dif == sumaReal) ? Convert.ToDecimal(sumaReal) : Convert.ToDecimal(sumaReal - dif), Convert.ToDecimal(db), getCodigoControl(), lastLibroVenta.pkLibro, 1);
                 }
                 else
                 {
                     int pkLibro = LibroVentasBLL.InsertDatosLibroVentas(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString());
                     int lastNro = 0;
                     if (sumaReal == sumaDescuentos)
                     {
                         sumaDescuentos = 0;
                     }
                     double dif = sumaReal - sumaDescuentos;
                     double db  = 0;
                     if (dif == sumaReal)
                     {
                         db = sumaReal * 13 / 100;
                     }
                     else
                     {
                         db = (sumaReal - dif) * 13 / 100;
                     }
                     DetalleLibroVentasBLL.InsertDatosDetalleLibroVentas(lastNro + 1, DateTime.Now, nroFact, llave.txtNroAutorizacion, txtNitCliente.Text, txtNombreCliente.Text, Convert.ToDecimal(sumaReal), 0, 0, 0, Convert.ToDecimal(sumaReal), (dif == sumaReal) ? 0 : Convert.ToDecimal(dif), (dif == sumaReal) ? Convert.ToDecimal(sumaReal) : Convert.ToDecimal(sumaReal - dif), Convert.ToDecimal(db), getCodigoControl(), pkLibro, 1);
                 }
             }
             else
             {
                 int pkLibro = LibroVentasBLL.InsertDatosLibroVentas(DateTime.Now.Month.ToString(), DateTime.Now.Year.ToString());
                 int lastNro = 0;
                 if (sumaReal == sumaDescuentos)
                 {
                     sumaDescuentos = 0;
                 }
                 double dif = sumaReal - sumaDescuentos;
                 double db  = 0;
                 if (dif == sumaReal)
                 {
                     db = sumaReal * 13 / 100;
                 }
                 else
                 {
                     db = (sumaReal - dif) * 13 / 100;
                 }
                 DetalleLibroVentasBLL.InsertDatosDetalleLibroVentas(lastNro + 1, DateTime.Now, nroFact, llave.txtNroAutorizacion, txtNitCliente.Text, txtNombreCliente.Text, Convert.ToDecimal(sumaReal), 0, 0, 0, Convert.ToDecimal(sumaReal), (dif == sumaReal) ? 0 : Convert.ToDecimal(dif), (dif == sumaReal) ? Convert.ToDecimal(sumaReal) : Convert.ToDecimal(sumaReal - dif), Convert.ToDecimal(db), getCodigoControl(), pkLibro, 1);
             }
             if (original == " COPIA")
             {
                 original = "ORIGINAL";
             }
             imprimirFactura();
             original = " COPIA";
             imprimirFactura();
             tblDetalleVenta.RowCount = 0;
             txtNitCliente.Text       = "";
             txtNombreCliente.Text    = "";
             sumaReal       = 0;
             sumaDescuentos = 0;
             lastFactura    = FacturaBLL.GetLastFactura();
             llave          = LlaveFacturaBLL.GetLastLlaveFactura();
             lastFactura    = FacturaBLL.GetLastFactura();
             lastLibroVenta = LibroVentasBLL.GetLastLibroVentas();
             listaProductos = new List <Producto>();
         }
         else
         {
             MessageBox.Show("Debe ingresar el nit, el nombre del cliente y al menos un producto");
         }
     }
 }